]> git.saurik.com Git - wxWidgets.git/blob - src/os2/tooltip.cpp
Fix wxHtmlHelpData::SetTempDir() to behave correctly without trailing slash.
[wxWidgets.git] / src / os2 / tooltip.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/tooltip.cpp
3 // Purpose: wxToolTip class implementation for MSW
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/17/99
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 #include "wx/wxprec.h"
20
21 #ifndef WX_PRECOMP
22 #include "wx/wx.h"
23 #endif
24
25 #if wxUSE_TOOLTIPS
26
27 #include "wx/tooltip.h"
28 #include "wx/os2/private.h"
29
30 // ----------------------------------------------------------------------------
31 // global variables
32 // ----------------------------------------------------------------------------
33
34 // ----------------------------------------------------------------------------
35 // ctor & dtor
36 // ----------------------------------------------------------------------------
37
38 wxToolTip::wxToolTip(
39 const wxString& rsTip
40 )
41 : m_sText(rsTip)
42 , m_pWindow(NULL)
43 {
44 Create(rsTip);
45 } // end of wxToolTip::wxToolTip
46
47 wxToolTip::~wxToolTip()
48 {
49 if (m_hWnd)
50 ::WinDestroyWindow(m_hWnd);
51 } // end of wxToolTip::~wxToolTip
52
53 void wxToolTip::Create(
54 const wxString& rsTip
55 )
56 {
57 ULONG lStyle = ES_READONLY | ES_MARGIN | ES_CENTER;
58 LONG lColor;
59 char zFont[128];
60
61 m_hWnd = ::WinCreateWindow( HWND_DESKTOP
62 ,WC_ENTRYFIELD
63 ,rsTip.c_str()
64 ,lStyle
65 ,0, 0, 0, 0
66 ,NULLHANDLE
67 ,HWND_TOP
68 ,1
69 ,NULL
70 ,NULL
71 );
72 if (!m_hWnd)
73 {
74 wxLogError(wxT("Unable to create tooltip window"));
75 }
76
77 wxColour vColor( wxT("YELLOW") );
78 lColor = (LONG)vColor.GetPixel();
79 ::WinSetPresParam( m_hWnd
80 ,PP_BACKGROUNDCOLOR
81 ,sizeof(LONG)
82 ,(PVOID)&lColor
83 );
84 strcpy(zFont, "8.Helv");
85 ::WinSetPresParam( m_hWnd
86 ,PP_FONTNAMESIZE
87 ,strlen(zFont) + 1
88 ,(PVOID)zFont
89 );
90 } // end of wxToolTip::Create
91
92 void wxToolTip::DisplayToolTipWindow(
93 const wxPoint& rPoint
94 )
95 {
96 LONG lX = rPoint.x;
97 LONG lY = rPoint.y - 30;
98 LONG lWidth = 0L;
99 LONG lHeight = 0L;
100
101 lWidth = m_sText.Length() * 8;
102 lHeight = 15;
103 ::WinSetWindowPos( m_hWnd
104 ,HWND_TOP
105 ,lX
106 ,lY
107 ,lWidth
108 ,lHeight
109 ,SWP_MOVE | SWP_SIZE | SWP_SHOW
110 );
111 } // end of wxToolTip::DisplayToolTipWindow
112
113 void wxToolTip::HideToolTipWindow()
114 {
115 ::WinShowWindow(m_hWnd, FALSE);
116 } // end of wxToolTip::HideToolTipWindow
117
118 void wxToolTip::SetTip(
119 const wxString& rsTip
120 )
121 {
122 SWP vSwp;
123 LONG lWidth = 0L;
124 LONG lHeight = 0L;
125
126 ::WinQueryWindowPos(m_hWnd, &vSwp);
127 m_sText = rsTip;
128 lWidth = rsTip.Length() * 8;
129 lHeight = 15;
130 ::WinSetWindowPos( m_hWnd
131 ,HWND_TOP
132 ,vSwp.cx
133 ,vSwp.cy
134 ,lWidth
135 ,lHeight
136 ,SWP_MOVE | SWP_SIZE | SWP_SHOW
137 );
138 } // end of wxToolTip::SetTip
139
140 #endif // wxUSE_TOOLTIPS