OSDN Git Service

RebaseDlg: Show Commit Info at tooltip for branch and upstream branch.
[tortoisegit/TortoiseGitJp.git] / src / Utils / MiscUI / hyperlink_base.h
1 /*\r
2  * Module ID: hyperlink.h\r
3  * Title    : CHyperLink Declaration.\r
4  *\r
5  * Author   : Olivier Langlois <olanglois@sympatico.ca>\r
6  * Date     : November 15, 2005\r
7  *\r
8  * To read the article describing this class, visit\r
9  * http://www3.sympatico.ca/olanglois/hyperlinkdemo.htm\r
10  *\r
11  * Note: Strongly inspired by Neal Stublen code\r
12  *       Minor ideas come from Chris Maunder and Paul DiLascia code\r
13  *\r
14  * Revision :\r
15  *\r
16  * 001        26-Nov-2005 - Olivier Langlois\r
17  *            - Added changes to make CHyperLink compatible with UNICODE\r
18  *            - Use dynamic memory allocation for the URL string\r
19  */\r
20 \r
21 #ifndef   _HYPERLINK_H_\r
22 #define   _HYPERLINK_H_\r
23 \r
24 #include "windows.h"\r
25 \r
26 class CHyperLink\r
27 {\r
28 public:\r
29     CHyperLink(void);\r
30     virtual ~CHyperLink(void);\r
31 \r
32     BOOL ConvertStaticToHyperlink(HWND hwndCtl, LPCTSTR strURL);\r
33     BOOL ConvertStaticToHyperlink(HWND hwndParent, UINT uiCtlId, LPCTSTR strURL);\r
34 \r
35         BOOL setURL( LPCTSTR strURL);\r
36         LPCTSTR getURL(void) const { return m_strURL; }\r
37 \r
38 protected:\r
39         /*\r
40          * Override if you want to perform some action when the link has the focus\r
41          * or when the cursor is over the link such as displaying the URL somewhere.\r
42          */\r
43         virtual void OnSelect(void)   {}\r
44         virtual void OnDeselect(void) {}\r
45 \r
46         LPTSTR   m_strURL;                              // hyperlink URL\r
47 \r
48 private:\r
49         static COLORREF g_crLinkColor, g_crVisitedColor;// Hyperlink colors\r
50         static HCURSOR  g_hLinkCursor;                  // Cursor for hyperlink\r
51         static HFONT    g_UnderlineFont;                // Font for underline display\r
52         static int      g_counter;                                              // Global resources user counter\r
53     BOOL     m_bOverControl;                        // cursor over control?\r
54     BOOL     m_bVisited;                            // Has it been visited?\r
55     HFONT    m_StdFont;                             // Standard font\r
56         WNDPROC  m_pfnOrigCtlProc;\r
57 \r
58         void createUnderlineFont(void);\r
59         static void createLinkCursor(void);\r
60     void createGlobalResources(void)\r
61         {\r
62                 createUnderlineFont();\r
63                 createLinkCursor();\r
64         }\r
65         static void destroyGlobalResources(void)\r
66         {\r
67                 /*\r
68                  * No need to call DestroyCursor() for cursors acquired through\r
69                  * LoadCursor().\r
70                  */\r
71                 g_hLinkCursor   = NULL;\r
72                 DeleteObject(g_UnderlineFont);\r
73                 g_UnderlineFont = NULL;\r
74         }\r
75 \r
76         void Navigate(void);\r
77 \r
78         static void DrawFocusRect(HWND hwnd);\r
79     static LRESULT CALLBACK _HyperlinkParentProc(HWND hwnd, UINT message,\r
80                                                          WPARAM wParam, LPARAM lParam);\r
81         static LRESULT CALLBACK _HyperlinkProc(HWND hwnd, UINT message,\r
82                                                    WPARAM wParam, LPARAM lParam);\r
83 };\r
84 \r
85 #endif /* _HYPERLINK_H_ */\r