// Created: 10/17/99
// RCS-ID: $Id$
// Copyright: (c) David Webster
-// Licence: wxWindows license
+// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// global variables
// ----------------------------------------------------------------------------
-// the tooltip parent window
-WXHWND wxToolTip::hwndTT = (WXHWND)NULL;
-
-// ----------------------------------------------------------------------------
-// private classes
-// ----------------------------------------------------------------------------
-
-
-// a simple wrapper around TOOLINFO Win32 structure
-class wxToolInfo // define a TOOLINFO for OS/2 here : public TOOLINFO
-{
-public:
- wxToolInfo(wxWindow *win)
- {
- // initialize all members
-// ::ZeroMemory(this, sizeof(TOOLINFO));
-
- cbSize = sizeof(this);
- uFlags = 0; // TTF_IDISHWND;
- uId = (UINT)win->GetHWND();
- }
- size_t cbSize;
- ULONG uFlags;
- UINT uId;
- HWND hwnd;
- char* lpszText;
-};
-
-// ----------------------------------------------------------------------------
-// private functions
-// ----------------------------------------------------------------------------
-
-// send a message to the tooltip control
-inline MRESULT SendTooltipMessage(WXHWND hwnd,
- UINT msg,
- MPARAM wParam,
- MPARAM lParam)
-{
-// return hwnd ? ::SendMessage((HWND)hwnd, msg, wParam, (MPARAM)lParam)
-// : 0;
- return (MRESULT)0;
-}
-
-// send a message to all existing tooltip controls
-static void SendTooltipMessageToAll(WXHWND hwnd,
- UINT msg,
- MPARAM wParam,
- MPARAM lParam)
-{
- if ( hwnd )
- (void)SendTooltipMessage((WXHWND)hwnd, msg, wParam, lParam);
-}
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// static functions
-// ----------------------------------------------------------------------------
-
-void wxToolTip::Enable(bool flag)
-{
-// SendTooltipMessageToAll((WXHWND)hwndTT,TTM_ACTIVATE, flag, 0);
-}
-
-void wxToolTip::SetDelay(long milliseconds)
-{
-// SendTooltipMessageToAll((WXHWND)hwndTT,TTM_SETDELAYTIME, TTDT_INITIAL, milliseconds);
-}
-
-// ---------------------------------------------------------------------------
-// implementation helpers
-// ---------------------------------------------------------------------------
-
-// create the tooltip ctrl for our parent frame if it doesn't exist yet
-WXHWND wxToolTip::GetToolTipCtrl()
-{
-// TODO:
-/*
- if ( !hwndTT )
- {
- hwndTT = (WXHWND)::CreateWindow(TOOLTIPS_CLASS,
- (LPSTR)NULL,
- TTS_ALWAYSTIP,
- CW_USEDEFAULT, CW_USEDEFAULT,
- CW_USEDEFAULT, CW_USEDEFAULT,
- NULL, (HMENU)NULL,
- wxGetInstance(),
- NULL);
- if ( hwndTT )
- {
- SetWindowPos((HWND)hwndTT, HWND_TOPMOST, 0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- }
-
- }
- return (WXHWND)hwndTT;
-*/
- return (WXHWND)0;
-}
-
-void wxToolTip::RelayEvent(WXMSG *msg)
-{
-// (void)SendTooltipMessage(GetToolTipCtrl(), TTM_RELAYEVENT, 0, msg);
-}
-
// ----------------------------------------------------------------------------
// ctor & dtor
// ----------------------------------------------------------------------------
-wxToolTip::wxToolTip(const wxString &tip)
- : m_text(tip)
+wxToolTip::wxToolTip(
+ const wxString& rsTip
+)
+: m_sText(rsTip)
+, m_pWindow(NULL)
{
- m_window = NULL;
-}
+ Create(rsTip);
+} // end of wxToolTip::wxToolTip
wxToolTip::~wxToolTip()
{
- // there is no need to Remove() this tool - it will be done automatically
- // anyhow
-}
-
-// ----------------------------------------------------------------------------
-// others
-// ----------------------------------------------------------------------------
+ if (m_hWnd)
+ ::WinDestroyWindow(m_hWnd);
+} // end of wxToolTip::~wxToolTip
-void wxToolTip::Remove()
+void wxToolTip::Create(
+ const wxString& rsTip
+)
{
- // remove this tool from the tooltip control
- if ( m_window )
- {
- wxToolInfo ti(m_window);
-// (void)SendTooltipMessage(GetToolTipCtrl(), TTM_DELTOOL, 0, &ti);
- }
-}
-
-void wxToolTip::SetWindow(wxWindow *win)
+ ULONG lStyle = ES_READONLY | ES_MARGIN | ES_CENTER;
+ LONG lColor;
+ char zFont[128];
+
+ m_hWnd = ::WinCreateWindow( HWND_DESKTOP
+ ,WC_ENTRYFIELD
+ ,rsTip.c_str()
+ ,lStyle
+ ,0, 0, 0, 0
+ ,NULLHANDLE
+ ,HWND_TOP
+ ,1
+ ,NULL
+ ,NULL
+ );
+ if (!m_hWnd)
+ wxLogError("Unable to create tooltip window");
+
+ wxColour vColor( wxT("YELLOW") );
+ lColor = (LONG)vColor.GetPixel();
+ ::WinSetPresParam( m_hWnd
+ ,PP_BACKGROUNDCOLOR
+ ,sizeof(LONG)
+ ,(PVOID)&lColor
+ );
+ strcpy(zFont, "8.Helv");
+ ::WinSetPresParam( m_hWnd
+ ,PP_FONTNAMESIZE
+ ,strlen(zFont) + 1
+ ,(PVOID)zFont
+ );
+} // end of wxToolTip::Create
+
+void wxToolTip::DisplayToolTipWindow(
+ const wxPoint& rPoint
+)
{
- Remove();
-
- m_window = win;
-
- if ( m_window )
- {
- wxToolInfo ti(m_window);
-
- // as we store our text anyhow, it seems useless to waste system memory
- // by asking the tooltip ctrl to remember it too - instead it will send
- // us TTN_NEEDTEXT (via WM_NOTIFY) when it is about to be shown
- ti.hwnd = (HWND)m_window->GetHWND();
-// ti.lpszText = LPSTR_TEXTCALLBACK;
- // instead of: ti.lpszText = (char *)m_text.c_str();
-
-// TODO:
-/*
- if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, 0, &ti) )
- {
- wxLogSysError(_("Failed to create the tooltip '%s'"),
- m_text.c_str());
- }
-*/
- }
-}
-
-void wxToolTip::SetTip(const wxString& tip)
+ LONG lX = rPoint.x;
+ LONG lY = rPoint.y - 30;
+ LONG lWidth = 0L;
+ LONG lHeight = 0L;
+
+ lWidth = m_sText.Length() * 8;
+ lHeight = 15;
+ ::WinSetWindowPos( m_hWnd
+ ,HWND_TOP
+ ,lX
+ ,lY
+ ,lWidth
+ ,lHeight
+ ,SWP_MOVE | SWP_SIZE | SWP_SHOW
+ );
+} // end of wxToolTip::DisplayToolTipWindow
+
+void wxToolTip::HideToolTipWindow()
{
- m_text = tip;
+ ::WinShowWindow(m_hWnd, FALSE);
+} // end of wxToolTip::HideToolTipWindow
- if ( m_window )
- {
- // update it immediately
- wxToolInfo ti(m_window);
- ti.lpszText = (wxChar *)m_text.c_str();
-
-// (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti);
- }
-}
+void wxToolTip::SetTip(
+ const wxString& rsTip
+)
+{
+ SWP vSwp;
+ LONG lWidth = 0L;
+ LONG lHeight = 0L;
+
+ ::WinQueryWindowPos(m_hWnd, &vSwp);
+ m_sText = rsTip;
+ lWidth = rsTip.Length() * 8;
+ lHeight = 15;
+ ::WinSetWindowPos( m_hWnd
+ ,HWND_TOP
+ ,vSwp.cx
+ ,vSwp.cy
+ ,lWidth
+ ,lHeight
+ ,SWP_MOVE | SWP_SIZE | SWP_SHOW
+ );
+} // end of wxToolTip::SetTip
#endif // wxUSE_TOOLTIPS