virtual void Stop(void);
inline virtual bool IsRunning(void) const { return m_ulId != 0L; }
+ inline ULONG GetTimerId(void) const { return m_ulId; }
protected:
void Init(void);
wxTimer m_vToolTimer;
wxTimer m_vToolExpTimer;
- ULONG m_ulToolTimer;
- ULONG m_ulToolExpTimer;
+ wxToolTip* m_pToolTip;
+ wxCoord m_vXMouse;
+ wxCoord m_vYMouse;
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxToolBar)
{
public:
// ctor & dtor
- wxToolTip(const wxString &tip);
+ wxToolTip(const wxString &rsTip);
virtual ~wxToolTip();
- // accessors
- // tip text
- void SetTip(const wxString& tip);
- const wxString& GetTip() const { return m_text; }
+ //
+ // Accessors
+ //
+ inline const wxString& GetTip(void) const { return m_sText; }
+ inline wxWindow* GetWindow(void) const { return m_pWindow; }
- // the window we're associated with
- void SetWindow(wxWindow *win);
- wxWindow *GetWindow() const { return m_window; }
+ void SetTip(const wxString& rsTip);
+ inline void SetWindow(wxWindow* pWin) { m_pWindow = pWin; }
- // controlling tooltip behaviour: globally change tooltip parameters
- // enable or disable the tooltips globally
- static void Enable(bool flag);
- // set the delay after which the tooltip appears
- static void SetDelay(long milliseconds);
-
- // implementation
- void RelayEvent(WXMSG *msg);
+ //
+ // Implementation
+ //
+ void DisplayToolTipWindow(const wxPoint& rPos);
+ void HideToolTipWindow(void);
private:
- static WXHWND hwndTT;
- // create the tooltip ctrl for our parent frame if it doesn't exist yet
- // and return its window handle
- WXHWND GetToolTipCtrl();
-
- // remove this tooltip from the tooltip control
- void Remove();
+ void Create(const wxString &rsTip);
- wxString m_text; // tooltip text
- wxWindow *m_window; // window we're associated with
-};
+ HWND m_hWnd;
+ wxString m_sText; // tooltip text
+ wxWindow* m_pWindow; // window we're associated with
+}; // end of CLASS wxToolTip
wxWindow* pWndThis = wxFindWinFromHandle((WXHWND)hWnd);
wxWindow* pWnd;
-#if wxUSE_TOOLTIPS
- //
- // We must relay WM_MOUSEMOVE events to the tooltip ctrl if we want it to
- // popup the tooltip bubbles
- //
- if (pWndThis && (pMsg->msg == WM_MOUSEMOVE))
- {
- wxToolTip* pToolTip = pWndThis->GetToolTip();
- if (pToolTip)
- {
- pToolTip->RelayEvent(pWxmsg);
- }
- }
-#endif // wxUSE_TOOLTIPS
-
//
// Pass non-system timer messages to the wxTimerProc
//
#include "wx/dcmemory.h"
#endif
+#include "wx/tooltip.h"
#include "wx/toolbar.h"
bool wxToolBar::m_bInitialized = FALSE;
m_defaultWidth = 16;
m_defaultHeight = 15;
+
+ m_pToolTip = NULL;
} // end of wxToolBar::Init
wxToolBarToolBase* wxToolBar::DoAddTool(
wxToolBar::~wxToolBar()
{
+ if (m_pToolTip)
+ {
+ delete m_pToolTip;
+ m_pToolTip = NULL;
+ }
} // end of wxToolBar::~wxToolBar
bool wxToolBar::Realize()
wxMouseEvent& rEvent
)
{
+ POINTL vPoint;
+ HWND hWnd;
wxCoord vX;
wxCoord vY;
HPOINTER hPtr = ::WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);
::WinSetPointer(HWND_DESKTOP, hPtr);
+ ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
+ hWnd = ::WinWindowFromPoint(HWND_DESKTOP, &vPoint, TRUE);
+ if (hWnd != (HWND)GetHwnd())
+ {
+ m_vToolTimer.Stop();
+ return;
+ }
+
rEvent.GetPosition(&vX, &vY);
wxToolBarTool* pTool = (wxToolBarTool *)FindToolForPosition( vX
ReleaseMouse();
}
- m_vToolTimer.Stop();
- m_vToolTimer.Start(3000L, FALSE);
if (!pTool)
{
+ m_vToolTimer.Stop();
+ if (m_pToolTip)
+ {
+ delete m_pToolTip;
+ m_pToolTip = NULL;
+ }
if (m_nCurrentTool > -1)
{
if (rEvent.LeftIsDown())
);
m_nCurrentTool = pTool->GetId();
OnMouseEnter(m_nCurrentTool);
+ if (!pTool->GetShortHelp().IsEmpty())
+ {
+ m_pToolTip = new wxToolTip(pTool->GetShortHelp());
+ m_vXMouse = (wxCoord)vPoint.x;
+ m_vYMouse = (wxCoord)vPoint.y;
+ m_vToolTimer.Start(3000L, TRUE);
+ }
if (!pTool->IsToggled())
RaiseTool(pTool);
}
wxTimerEvent& rEvent
)
{
- if (rEvent.GetId() == (int)m_ulToolTimer)
+ if (rEvent.GetId() == (int)m_vToolTimer.GetTimerId())
{
- (void)wxMessageBox("wxWindows toolbar timer", "ToolTimer");
+ wxPoint vPos( m_vXMouse
+ ,m_vYMouse
+ );
+
+ m_pToolTip->DisplayToolTipWindow(vPos);
+ m_vToolExpTimer.Start(3000L, TRUE);
}
- else if (rEvent.GetId() == (int)m_ulToolExpTimer)
+ else if (rEvent.GetId() == (int)m_vToolExpTimer.GetTimerId())
{
- (void)wxMessageBox("wxWindows toolbar timer", "ToolExpTimer");
+ m_pToolTip->HideToolTipWindow();
}
} // end of wxToolBar::OnTimer
// 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;
+ wxColour vColor;
+ 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");
+
+ vColor.InitFromName("YELLOW");
+ lColor = (LONG)vColor.GetPixel();
+ ::WinSetPresParam( m_hWnd
+ ,PP_BACKGROUNDCOLOR
+ ,sizeof(LONG)
+ ,(PVOID)&lColor
+ );
+ strcpy(zFont, "10.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() * 13;
+ 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() * 13;
+ 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
pMsg = pMsg; // just shut up the compiler
#endif // __WXUNIVERSAL__
-#if wxUSE_TOOLTIPS
- if ( m_tooltip )
- {
- // relay mouse move events to the tooltip control
- QMSG* pQMsg = (QMSG*)pMsg;
-
- if (pQMsg->msg == WM_MOUSEMOVE )
- m_tooltip->RelayEvent(pMsg);
- }
-#endif // wxUSE_TOOLTIPS
-
return FALSE;
} // end of wxWindowOS2::OS2ProcessMessage
CODE LOADONCALL
EXPORTS
-;From library: F:\DEV\WX2\WXWINDOWS\LIB\wx.lib
+;From library: H:\Dev\Wx2\WxWindows\Lib\wx.lib
;From object file: dummy.cpp
;PUBDEFs (Symbols available from object file):
wxDummyChar
wxEVT_NC_LEFT_DCLICK
wxEVT_INIT_DIALOG
wxEVT_COMMAND_SET_FOCUS
- ;From object file: F:\DEV\WX2\WXWINDOWS\src\common\extended.c
+ ;From object file: H:\DEV\WX2\WXWINDOWS\src\common\extended.c
;PUBDEFs (Symbols available from object file):
ConvertToIeeeExtended
ConvertFromIeeeExtended
Read32__17wxTextInputStreamFv
;wxTextInputStream::SkipIfEndOfLine(char)
SkipIfEndOfLine__17wxTextInputStreamFc
- ;From object file: F:\DEV\WX2\WXWINDOWS\src\common\unzip.c
+ ;From object file: H:\DEV\WX2\WXWINDOWS\src\common\unzip.c
;PUBDEFs (Symbols available from object file):
unzReadCurrentFile
unzGetCurrentFileInfo
;PUBDEFs (Symbols available from object file):
;wxToolTip::wxToolTip(const wxString&)
__ct__9wxToolTipFRC8wxString
- ;wxToolTip::SetWindow(wxWindow*)
- SetWindow__9wxToolTipFP8wxWindow
__vft9wxToolTip8wxObject
- ;wxToolTip::RelayEvent(void**)
- RelayEvent__9wxToolTipFPPv
;wxToolTip::~wxToolTip()
__dt__9wxToolTipFv
- ;wxToolTip::Enable(unsigned long)
- Enable__9wxToolTipFUl
- ;wxToolTip::SetDelay(long)
- SetDelay__9wxToolTipFl
+ ;wxToolTip::HideToolTipWindow()
+ HideToolTipWindow__9wxToolTipFv
;wxToolTip::SetTip(const wxString&)
SetTip__9wxToolTipFRC8wxString
- ;wxToolTip::GetToolTipCtrl()
- GetToolTipCtrl__9wxToolTipFv
- ;wxToolTip::Remove()
- Remove__9wxToolTipFv
- ;wxToolTip::hwndTT
- hwndTT__9wxToolTip
+ ;wxToolTip::DisplayToolTipWindow(const wxPoint&)
+ DisplayToolTipWindow__9wxToolTipFRC7wxPoint
+ ;wxToolTip::Create(const wxString&)
+ Create__9wxToolTipFRC8wxString
;From object file: ..\os2\toplevel.cpp
;PUBDEFs (Symbols available from object file):
;wxTopLevelWindowOS2::OS2GetStyle(long,unsigned long*) const