]> git.saurik.com Git - wxWidgets.git/blob - src/os2/tooltip.cpp
don't treat filenames starting with dot as having empty name and extension equal...
[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 wxLogError("Unable to create tooltip window");
75
76 wxColour vColor( wxT("YELLOW") );
77 lColor = (LONG)vColor.GetPixel();
78 ::WinSetPresParam( m_hWnd
79 ,PP_BACKGROUNDCOLOR
80 ,sizeof(LONG)
81 ,(PVOID)&lColor
82 );
83 strcpy(zFont, "8.Helv");
84 ::WinSetPresParam( m_hWnd
85 ,PP_FONTNAMESIZE
86 ,strlen(zFont) + 1
87 ,(PVOID)zFont
88 );
89 } // end of wxToolTip::Create
90
91 void wxToolTip::DisplayToolTipWindow(
92 const wxPoint& rPoint
93 )
94 {
95 LONG lX = rPoint.x;
96 LONG lY = rPoint.y - 30;
97 LONG lWidth = 0L;
98 LONG lHeight = 0L;
99
100 lWidth = m_sText.Length() * 8;
101 lHeight = 15;
102 ::WinSetWindowPos( m_hWnd
103 ,HWND_TOP
104 ,lX
105 ,lY
106 ,lWidth
107 ,lHeight
108 ,SWP_MOVE | SWP_SIZE | SWP_SHOW
109 );
110 } // end of wxToolTip::DisplayToolTipWindow
111
112 void wxToolTip::HideToolTipWindow()
113 {
114 ::WinShowWindow(m_hWnd, FALSE);
115 } // end of wxToolTip::HideToolTipWindow
116
117 void wxToolTip::SetTip(
118 const wxString& rsTip
119 )
120 {
121 SWP vSwp;
122 LONG lWidth = 0L;
123 LONG lHeight = 0L;
124
125 ::WinQueryWindowPos(m_hWnd, &vSwp);
126 m_sText = rsTip;
127 lWidth = rsTip.Length() * 8;
128 lHeight = 15;
129 ::WinSetWindowPos( m_hWnd
130 ,HWND_TOP
131 ,vSwp.cx
132 ,vSwp.cy
133 ,lWidth
134 ,lHeight
135 ,SWP_MOVE | SWP_SIZE | SWP_SHOW
136 );
137 } // end of wxToolTip::SetTip
138
139 #endif // wxUSE_TOOLTIPS