]> git.saurik.com Git - wxWidgets.git/blame - src/os2/tooltip.cpp
cleanup image after application
[wxWidgets.git] / src / os2 / tooltip.cpp
CommitLineData
d90895ac
DW
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
65571936 9// Licence: wxWindows licence
d90895ac
DW
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
d90895ac
DW
35// ----------------------------------------------------------------------------
36// ctor & dtor
37// ----------------------------------------------------------------------------
38
05facebb
DW
39wxToolTip::wxToolTip(
40 const wxString& rsTip
41)
42: m_sText(rsTip)
43, m_pWindow(NULL)
d90895ac 44{
05facebb
DW
45 Create(rsTip);
46} // end of wxToolTip::wxToolTip
d90895ac
DW
47
48wxToolTip::~wxToolTip()
49{
05facebb
DW
50 if (m_hWnd)
51 ::WinDestroyWindow(m_hWnd);
52} // end of wxToolTip::~wxToolTip
d90895ac 53
05facebb
DW
54void wxToolTip::Create(
55 const wxString& rsTip
56)
d90895ac 57{
05facebb 58 ULONG lStyle = ES_READONLY | ES_MARGIN | ES_CENTER;
05facebb
DW
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
aad6765c 76 wxColour vColor( wxT("YELLOW") );
05facebb
DW
77 lColor = (LONG)vColor.GetPixel();
78 ::WinSetPresParam( m_hWnd
79 ,PP_BACKGROUNDCOLOR
80 ,sizeof(LONG)
81 ,(PVOID)&lColor
82 );
ff5802f3 83 strcpy(zFont, "8.Helv");
05facebb
DW
84 ::WinSetPresParam( m_hWnd
85 ,PP_FONTNAMESIZE
86 ,strlen(zFont) + 1
87 ,(PVOID)zFont
88 );
89} // end of wxToolTip::Create
90
91void wxToolTip::DisplayToolTipWindow(
92 const wxPoint& rPoint
93)
d90895ac 94{
05facebb
DW
95 LONG lX = rPoint.x;
96 LONG lY = rPoint.y - 30;
97 LONG lWidth = 0L;
98 LONG lHeight = 0L;
99
5d644707 100 lWidth = m_sText.Length() * 8;
05facebb
DW
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
112void wxToolTip::HideToolTipWindow()
d90895ac 113{
05facebb
DW
114 ::WinShowWindow(m_hWnd, FALSE);
115} // end of wxToolTip::HideToolTipWindow
d90895ac 116
05facebb
DW
117void 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;
ff5802f3 127 lWidth = rsTip.Length() * 8;
05facebb
DW
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
d90895ac
DW
138
139#endif // wxUSE_TOOLTIPS