]> git.saurik.com Git - wxWidgets.git/blame - src/os2/tooltip.cpp
fixing and completing iPhone sound
[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
a8988cb3 64 ,rsTip.c_str()
05facebb
DW
65 ,lStyle
66 ,0, 0, 0, 0
67 ,NULLHANDLE
68 ,HWND_TOP
69 ,1
70 ,NULL
71 ,NULL
72 );
73 if (!m_hWnd)
43b2d5e7 74 {
9a83f860 75 wxLogError(wxT("Unable to create tooltip window"));
43b2d5e7 76 }
05facebb 77
aad6765c 78 wxColour vColor( wxT("YELLOW") );
05facebb
DW
79 lColor = (LONG)vColor.GetPixel();
80 ::WinSetPresParam( m_hWnd
81 ,PP_BACKGROUNDCOLOR
82 ,sizeof(LONG)
83 ,(PVOID)&lColor
84 );
ff5802f3 85 strcpy(zFont, "8.Helv");
05facebb
DW
86 ::WinSetPresParam( m_hWnd
87 ,PP_FONTNAMESIZE
88 ,strlen(zFont) + 1
89 ,(PVOID)zFont
90 );
91} // end of wxToolTip::Create
92
93void wxToolTip::DisplayToolTipWindow(
94 const wxPoint& rPoint
95)
d90895ac 96{
05facebb
DW
97 LONG lX = rPoint.x;
98 LONG lY = rPoint.y - 30;
99 LONG lWidth = 0L;
100 LONG lHeight = 0L;
101
5d644707 102 lWidth = m_sText.Length() * 8;
05facebb
DW
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
114void wxToolTip::HideToolTipWindow()
d90895ac 115{
05facebb
DW
116 ::WinShowWindow(m_hWnd, FALSE);
117} // end of wxToolTip::HideToolTipWindow
d90895ac 118
05facebb
DW
119void 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;
ff5802f3 129 lWidth = rsTip.Length() * 8;
05facebb
DW
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
d90895ac
DW
140
141#endif // wxUSE_TOOLTIPS