]> git.saurik.com Git - wxWidgets.git/blob - src/os2/tooltip.cpp
force making stats
[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 license
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 wxColour vColor;
60 LONG lColor;
61 char zFont[128];
62
63 m_hWnd = ::WinCreateWindow( HWND_DESKTOP
64 ,WC_ENTRYFIELD
65 ,rsTip.c_str()
66 ,lStyle
67 ,0, 0, 0, 0
68 ,NULLHANDLE
69 ,HWND_TOP
70 ,1
71 ,NULL
72 ,NULL
73 );
74 if (!m_hWnd)
75 wxLogError("Unable to create tooltip window");
76
77 vColor.InitFromName("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