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