root/trunk/GUIComponents/XHyperLink.h

Revision 5, 4.7 kB (checked in by qbert, 3 years ago)

Initial ( and last :( ) commit

Line 
1 // XHyperLink.h  Version 1.0
2 //
3 // XHyperLink static control. Will open the default browser with the given URL
4 // when the user clicks on the link.
5 //
6 // Copyright Chris Maunder, 1997-1999 (cmaunder@mail.com)
7 // Feel free to use and distribute. May not be sold for profit.
8 //
9 // 2/29/00 -- P. Shaffer standard font mod.
10 //
11 ///////////////////////////////////////////////////////////////////////////////
12 //
13 // Modified by:  Hans Dietrich
14 //               hdietrich2@hotmail.com
15 //
16 ///////////////////////////////////////////////////////////////////////////////
17
18
19 #ifndef XHYPERLINK_H
20 #define XHYPERLINK_H
21
22 extern UINT WM_XHYPERLINK_CLICKED;
23
24 /////////////////////////////////////////////////////////////////////////////
25 // CXHyperLink window
26
27 class CXHyperLink : public CStatic
28 {
29 // Construction/destruction
30 public:
31     CXHyperLink();
32     virtual ~CXHyperLink();
33
34 public:
35     enum UnderLineOptions { ulHover = -1, ulNone = 0, ulAlways = 1};
36
37 // Attributes
38 public:
39     void SetURL(CString strURL);
40     CString GetURL() const
41     {
42         return m_strURL;
43     }
44
45     void EnableURL(BOOL bFlag) { m_bIsURLEnabled = bFlag; }
46     BOOL IsURLEnabled() const { return m_bIsURLEnabled; }
47
48     void SetColours(COLORREF crLinkColour,
49                     COLORREF crVisitedColour,
50                     COLORREF crHoverColour = -1);
51
52     COLORREF GetLinkColour() const
53     {
54         return m_crLinkColour;
55     }
56
57     COLORREF GetVisitedColour() const
58     {
59         return m_crVisitedColour;
60     }
61
62     COLORREF GetHoverColour() const
63     {
64         return m_crHoverColour;
65     }
66
67     void SetBackgroundColour(COLORREF crBackground);
68     COLORREF GetBackgroundColour() const
69     {
70         return m_crBackground;
71     }
72
73     void SetVisited(BOOL bVisited = TRUE);
74     BOOL GetVisited() const
75     {
76         return m_bVisited;
77     }
78
79     void SetLinkCursor(HCURSOR hCursor);
80     HCURSOR CXHyperLink::GetLinkCursor() const
81     {
82         return m_hLinkCursor;
83     }
84
85     void SetUnderline(int nUnderline = ulHover);
86     int GetUnderline() const
87     {
88         return m_nUnderline;
89     }
90
91     void SetAutoSize(BOOL bAutoSize = TRUE);
92     BOOL GetAutoSize() const
93     {
94         return m_bAdjustToFit;
95     }
96
97     void SetNotifyParent(BOOL bFlag) { m_bNotifyParent = bFlag; }
98     BOOL GetNotifyParent() const { return m_bNotifyParent; }
99
100     void EnableTooltip(BOOL bFlag)
101     {
102         m_bToolTip = bFlag;
103         m_ToolTip.Activate(m_bToolTip);
104     }
105     BOOL IsTooltipEmabled() const
106     {
107         return m_bToolTip;
108     }
109
110     void SetAlwaysOpenNew(BOOL bFlag)
111     {
112         m_bAlwaysOpenNew = bFlag;
113     }
114     BOOL GetAlwaysOpenNew() const
115     {
116         return m_bAlwaysOpenNew;
117     }
118
119     void SetWindowText(LPCTSTR lpszString);
120
121
122 // Operations
123 public:
124     static HINSTANCE GotoURL(LPCTSTR url, int showcmd,  BOOL bAlwaysOpenNew = FALSE);
125
126
127 // Overrides
128     // ClassWizard generated virtual function overrides
129     //{{AFX_VIRTUAL(CXHyperLink)
130 public:
131     virtual BOOL PreTranslateMessage(MSG* pMsg);
132     virtual BOOL DestroyWindow();
133 protected:
134     virtual void PreSubclassWindow();
135     //}}AFX_VIRTUAL
136
137 // Implementation
138 protected:
139     static LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata);
140     void NotifyParent();
141     void PositionWindow();
142     void ReportError(int nError);
143     void SetDefaultCursor();
144
145 // Protected attributes
146 protected:
147     COLORREF        m_crLinkColour;     // Hyperlink colours
148     COLORREF        m_crVisitedColour;
149     COLORREF        m_crHoverColour;    // Hover colour
150     COLORREF        m_crBackground;     // background color
151     CBrush          m_Brush;            // background brush
152     BOOL            m_bOverControl;     // cursor over control?
153     BOOL            m_bVisited;         // Has it been visited?
154     int             m_nUnderline;       // underline hyperlink?
155     BOOL            m_bAdjustToFit;     // Adjust window size to fit text?
156     CString         m_strURL;           // hyperlink URL
157     CFont           m_UnderlineFont;    // Font for underline display
158     CFont           m_StdFont;          // Standard font
159     HCURSOR         m_hLinkCursor;      // Cursor for hyperlink
160     CToolTipCtrl    m_ToolTip;          // The tooltip
161     UINT            m_nTimerID;
162     BOOL            m_bIsURLEnabled;    // TRUE = navigate to url
163     BOOL            m_bNotifyParent;    // TRUE = notify parent
164     BOOL            m_bToolTip;         // TRUE = display tooltip
165     BOOL            m_bAlwaysOpenNew;   // TRUE = always open new browser window
166
167     // Generated message map functions
168 protected:
169     //{{AFX_MSG(CXHyperLink)
170     afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
171     afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
172     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
173     afx_msg BOOL OnEraseBkgnd(CDC* pDC);
174     //}}AFX_MSG
175     afx_msg void OnTimer(UINT nIDEvent);
176     afx_msg void OnClicked();
177     DECLARE_MESSAGE_MAP()
178 };
179
180 /////////////////////////////////////////////////////////////////////////////
181
182 //{{AFX_INSERT_LOCATION}}
183 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
184
185 #endif //XHYPERLINK_H
Note: See TracBrowser for help on using the browser.