]> git.saurik.com Git - wxWidgets.git/blame - src/os2/tooltip.cpp
wxGTK1 : wx/private/eventloopsourcesmanager.h was missing in evtloop.cpp
[wxWidgets.git] / src / os2 / tooltip.cpp
CommitLineData
d90895ac 1///////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/os2/tooltip.cpp
d90895ac
DW
3// Purpose: wxToolTip class implementation for MSW
4// Author: David Webster
5// Modified by:
6// Created: 10/17/99
d90895ac 7// Copyright: (c) David Webster
65571936 8// Licence: wxWindows licence
d90895ac
DW
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
d90895ac
DW
34// ----------------------------------------------------------------------------
35// ctor & dtor
36// ----------------------------------------------------------------------------
37
05facebb
DW
38wxToolTip::wxToolTip(
39 const wxString& rsTip
40)
41: m_sText(rsTip)
42, m_pWindow(NULL)
d90895ac 43{
05facebb
DW
44 Create(rsTip);
45} // end of wxToolTip::wxToolTip
d90895ac
DW
46
47wxToolTip::~wxToolTip()
48{
05facebb
DW
49 if (m_hWnd)
50 ::WinDestroyWindow(m_hWnd);
51} // end of wxToolTip::~wxToolTip
d90895ac 52
05facebb
DW
53void wxToolTip::Create(
54 const wxString& rsTip
55)
d90895ac 56{
05facebb 57 ULONG lStyle = ES_READONLY | ES_MARGIN | ES_CENTER;
05facebb
DW
58 LONG lColor;
59 char zFont[128];
60
61 m_hWnd = ::WinCreateWindow( HWND_DESKTOP
62 ,WC_ENTRYFIELD
a8988cb3 63 ,rsTip.c_str()
05facebb
DW
64 ,lStyle
65 ,0, 0, 0, 0
66 ,NULLHANDLE
67 ,HWND_TOP
68 ,1
69 ,NULL
70 ,NULL
71 );
72 if (!m_hWnd)
43b2d5e7 73 {
9a83f860 74 wxLogError(wxT("Unable to create tooltip window"));
43b2d5e7 75 }
05facebb 76
aad6765c 77 wxColour vColor( wxT("YELLOW") );
05facebb
DW
78 lColor = (LONG)vColor.GetPixel();
79 ::WinSetPresParam( m_hWnd
80 ,PP_BACKGROUNDCOLOR
81 ,sizeof(LONG)
82 ,(PVOID)&lColor
83 );
ff5802f3 84 strcpy(zFont, "8.Helv");
05facebb
DW
85 ::WinSetPresParam( m_hWnd
86 ,PP_FONTNAMESIZE
87 ,strlen(zFont) + 1
88 ,(PVOID)zFont
89 );
90} // end of wxToolTip::Create
91
92void wxToolTip::DisplayToolTipWindow(
93 const wxPoint& rPoint
94)
d90895ac 95{
05facebb
DW
96 LONG lX = rPoint.x;
97 LONG lY = rPoint.y - 30;
98 LONG lWidth = 0L;
99 LONG lHeight = 0L;
100
5d644707 101 lWidth = m_sText.Length() * 8;
05facebb
DW
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
113void wxToolTip::HideToolTipWindow()
d90895ac 114{
05facebb
DW
115 ::WinShowWindow(m_hWnd, FALSE);
116} // end of wxToolTip::HideToolTipWindow
d90895ac 117
05facebb
DW
118void 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;
ff5802f3 128 lWidth = rsTip.Length() * 8;
05facebb
DW
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
d90895ac
DW
139
140#endif // wxUSE_TOOLTIPS