]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/tooltip.cpp
   1 /////////////////////////////////////////////////////////////////////////////// 
   2 // Name:        msw/tooltip.cpp 
   3 // Purpose:     wxToolTip class implementation for MSW 
   4 // Author:      David Webster 
   8 // Copyright:   (c) David Webster 
   9 // Licence:     wxWindows license 
  10 /////////////////////////////////////////////////////////////////////////////// 
  12 // ============================================================================ 
  14 // ============================================================================ 
  16 // ---------------------------------------------------------------------------- 
  18 // ---------------------------------------------------------------------------- 
  20 #include "wx/wxprec.h" 
  28 #include "wx/tooltip.h" 
  29 #include "wx/os2/private.h" 
  31 // ---------------------------------------------------------------------------- 
  33 // ---------------------------------------------------------------------------- 
  35 // the tooltip parent window 
  36 WXHWND 
wxToolTip::hwndTT 
= (WXHWND
)NULL
; 
  38 // ---------------------------------------------------------------------------- 
  40 // ---------------------------------------------------------------------------- 
  43 // a simple wrapper around TOOLINFO Win32 structure 
  44 class wxToolInfo 
// define a TOOLINFO for OS/2 here : public TOOLINFO 
  47     wxToolInfo(wxWindow 
*win
) 
  49         // initialize all members 
  50 //        ::ZeroMemory(this, sizeof(TOOLINFO)); 
  52         cbSize 
= sizeof(this); 
  53         uFlags 
= 0; // TTF_IDISHWND; 
  54         uId 
= (UINT
)win
->GetHWND(); 
  63 // ---------------------------------------------------------------------------- 
  65 // ---------------------------------------------------------------------------- 
  67 // send a message to the tooltip control 
  68 inline MRESULT 
SendTooltipMessage(WXHWND hwnd
, 
  73 //    return hwnd ? ::SendMessage((HWND)hwnd, msg, wParam, (MPARAM)lParam) 
  78 // send a message to all existing tooltip controls 
  79 static void SendTooltipMessageToAll(WXHWND hwnd
, 
  85      (void)SendTooltipMessage((WXHWND
)hwnd
, msg
, wParam
, lParam
); 
  88 // ============================================================================ 
  90 // ============================================================================ 
  92 // ---------------------------------------------------------------------------- 
  94 // ---------------------------------------------------------------------------- 
  96 void wxToolTip::Enable(bool flag
) 
  98 //    SendTooltipMessageToAll((WXHWND)hwndTT,TTM_ACTIVATE, flag, 0); 
 101 void wxToolTip::SetDelay(long milliseconds
) 
 103 //    SendTooltipMessageToAll((WXHWND)hwndTT,TTM_SETDELAYTIME, TTDT_INITIAL, milliseconds); 
 106 // --------------------------------------------------------------------------- 
 107 // implementation helpers 
 108 // --------------------------------------------------------------------------- 
 110 // create the tooltip ctrl for our parent frame if it doesn't exist yet 
 111 WXHWND 
wxToolTip::GetToolTipCtrl() 
 117         hwndTT = (WXHWND)::CreateWindow(TOOLTIPS_CLASS, 
 120                                 CW_USEDEFAULT, CW_USEDEFAULT, 
 121                                 CW_USEDEFAULT, CW_USEDEFAULT, 
 127            SetWindowPos((HWND)hwndTT, HWND_TOPMOST, 0, 0, 0, 0, 
 128                         SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); 
 132     return (WXHWND)hwndTT; 
 137 void wxToolTip::RelayEvent(WXMSG 
*msg
) 
 139 //  (void)SendTooltipMessage(GetToolTipCtrl(), TTM_RELAYEVENT, 0, msg); 
 142 // ---------------------------------------------------------------------------- 
 144 // ---------------------------------------------------------------------------- 
 146 wxToolTip::wxToolTip(const wxString 
&tip
) 
 152 wxToolTip::~wxToolTip() 
 154     // there is no need to Remove() this tool - it will be done automatically 
 158 // ---------------------------------------------------------------------------- 
 160 // ---------------------------------------------------------------------------- 
 162 void wxToolTip::Remove() 
 164     // remove this tool from the tooltip control 
 167         wxToolInfo 
ti(m_window
); 
 168 //      (void)SendTooltipMessage(GetToolTipCtrl(), TTM_DELTOOL, 0, &ti); 
 172 void wxToolTip::SetWindow(wxWindow 
*win
) 
 180         wxToolInfo 
ti(m_window
); 
 182         // as we store our text anyhow, it seems useless to waste system memory 
 183         // by asking the tooltip ctrl to remember it too - instead it will send 
 184         // us TTN_NEEDTEXT (via WM_NOTIFY) when it is about to be shown 
 185         ti
.hwnd 
= (HWND
)m_window
->GetHWND(); 
 186 //        ti.lpszText = LPSTR_TEXTCALLBACK; 
 187         // instead of: ti.lpszText = (char *)m_text.c_str(); 
 191         if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, 0, &ti) ) 
 193             wxLogSysError(_("Failed to create the tooltip '%s'"), 
 200 void wxToolTip::SetTip(const wxString
& tip
) 
 206         // update it immediately 
 207         wxToolInfo 
ti(m_window
); 
 208         ti
.lpszText 
= (wxChar 
*)m_text
.c_str(); 
 210 //      (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti); 
 214 #endif // wxUSE_TOOLTIPS