wxToolTip for MSW implementation (it has several problems right now, but it
still works) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1541 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -27,13 +27,13 @@ WXDLLEXPORT_DATA(extern const char*) wxStatusLineNameStr;
|
|||||||
class WXDLLEXPORT wxMenuBar;
|
class WXDLLEXPORT wxMenuBar;
|
||||||
class WXDLLEXPORT wxStatusBar;
|
class WXDLLEXPORT wxStatusBar;
|
||||||
|
|
||||||
class WXDLLEXPORT wxFrame: public wxWindow {
|
class WXDLLEXPORT wxFrame : public wxWindow
|
||||||
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxFrame)
|
DECLARE_DYNAMIC_CLASS(wxFrame)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxFrame(void);
|
wxFrame();
|
||||||
inline wxFrame(wxWindow *parent,
|
wxFrame(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxString& title,
|
const wxString& title,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
Create(parent, id, title, pos, size, style, name);
|
Create(parent, id, title, pos, size, style, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
~wxFrame(void);
|
~wxFrame();
|
||||||
|
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
long style = wxDEFAULT_FRAME_STYLE,
|
long style = wxDEFAULT_FRAME_STYLE,
|
||||||
const wxString& name = wxFrameNameStr);
|
const wxString& name = wxFrameNameStr);
|
||||||
|
|
||||||
virtual bool Destroy(void);
|
virtual bool Destroy();
|
||||||
|
|
||||||
void SetClientSize(int width, int height);
|
void SetClientSize(int width, int height);
|
||||||
void SetClientSize(const wxSize& sz) { wxWindow::SetClientSize(sz); }
|
void SetClientSize(const wxSize& sz) { wxWindow::SetClientSize(sz); }
|
||||||
@@ -74,7 +74,7 @@ public:
|
|||||||
|
|
||||||
virtual void ScreenToClient(int *x, int *y) const;
|
virtual void ScreenToClient(int *x, int *y) const;
|
||||||
|
|
||||||
virtual bool OnClose(void);
|
virtual bool OnClose();
|
||||||
|
|
||||||
void OnSize(wxSizeEvent& event);
|
void OnSize(wxSizeEvent& event);
|
||||||
void OnMenuHighlight(wxMenuEvent& event);
|
void OnMenuHighlight(wxMenuEvent& event);
|
||||||
@@ -86,11 +86,11 @@ public:
|
|||||||
|
|
||||||
// Set menu bar
|
// Set menu bar
|
||||||
void SetMenuBar(wxMenuBar *menu_bar);
|
void SetMenuBar(wxMenuBar *menu_bar);
|
||||||
virtual wxMenuBar *GetMenuBar(void) const ;
|
virtual wxMenuBar *GetMenuBar() const ;
|
||||||
|
|
||||||
// Set title
|
// Set title
|
||||||
void SetTitle(const wxString& title);
|
void SetTitle(const wxString& title);
|
||||||
wxString GetTitle(void) const ;
|
wxString GetTitle() const ;
|
||||||
|
|
||||||
void Centre(int direction = wxBOTH);
|
void Centre(int direction = wxBOTH);
|
||||||
|
|
||||||
@@ -101,24 +101,32 @@ public:
|
|||||||
// Set icon
|
// Set icon
|
||||||
virtual void SetIcon(const wxIcon& icon);
|
virtual void SetIcon(const wxIcon& icon);
|
||||||
|
|
||||||
// Create status line
|
// Toolbar
|
||||||
virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0,
|
|
||||||
const wxString& name = wxStatusLineNameStr);
|
|
||||||
inline wxStatusBar *GetStatusBar() const { return m_frameStatusBar; }
|
|
||||||
inline void SetStatusBar(wxStatusBar *statusBar) { m_frameStatusBar = statusBar; }
|
|
||||||
virtual void PositionStatusBar(void);
|
|
||||||
virtual wxStatusBar *OnCreateStatusBar(int number, long style, wxWindowID id,
|
|
||||||
const wxString& name);
|
|
||||||
|
|
||||||
// Create toolbar
|
|
||||||
virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT,
|
virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT,
|
||||||
wxWindowID id = -1,
|
wxWindowID id = -1,
|
||||||
const wxString& name = wxToolBarNameStr);
|
const wxString& name = wxToolBarNameStr);
|
||||||
|
|
||||||
virtual wxToolBar *OnCreateToolBar(long style, wxWindowID id, const wxString& name);
|
virtual wxToolBar *OnCreateToolBar(long style, wxWindowID id, const wxString& name);
|
||||||
// If made known to the frame, the frame will manage it automatically.
|
|
||||||
virtual inline void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; }
|
virtual void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; }
|
||||||
virtual inline wxToolBar *GetToolBar(void) const { return m_frameToolBar; }
|
virtual wxToolBar *GetToolBar() const { return m_frameToolBar; }
|
||||||
virtual void PositionToolBar(void);
|
|
||||||
|
virtual void PositionToolBar();
|
||||||
|
|
||||||
|
// Status bar
|
||||||
|
virtual wxStatusBar* CreateStatusBar(int number = 1,
|
||||||
|
long style = wxST_SIZEGRIP,
|
||||||
|
wxWindowID id = 0,
|
||||||
|
const wxString& name = wxStatusLineNameStr);
|
||||||
|
|
||||||
|
wxStatusBar *GetStatusBar() const { return m_frameStatusBar; }
|
||||||
|
void SetStatusBar(wxStatusBar *statusBar) { m_frameStatusBar = statusBar; }
|
||||||
|
|
||||||
|
virtual void PositionStatusBar();
|
||||||
|
virtual wxStatusBar *OnCreateStatusBar(int number,
|
||||||
|
long style,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxString& name);
|
||||||
|
|
||||||
// Set status line text
|
// Set status line text
|
||||||
virtual void SetStatusText(const wxString& text, int number = 0);
|
virtual void SetStatusText(const wxString& text, int number = 0);
|
||||||
@@ -129,49 +137,58 @@ public:
|
|||||||
// Hint to tell framework which status bar to use
|
// Hint to tell framework which status bar to use
|
||||||
// TODO: should this go into a wxFrameworkSettings class perhaps?
|
// TODO: should this go into a wxFrameworkSettings class perhaps?
|
||||||
static void UseNativeStatusBar(bool useNative) { m_useNativeStatusBar = useNative; };
|
static void UseNativeStatusBar(bool useNative) { m_useNativeStatusBar = useNative; };
|
||||||
static bool UsesNativeStatusBar(void) { return m_useNativeStatusBar; };
|
static bool UsesNativeStatusBar() { return m_useNativeStatusBar; };
|
||||||
|
|
||||||
// Fit frame around subwindows
|
// Fit frame around subwindows
|
||||||
virtual void Fit(void);
|
virtual void Fit();
|
||||||
|
|
||||||
// Iconize
|
// Iconize
|
||||||
virtual void Iconize(bool iconize);
|
virtual void Iconize(bool iconize);
|
||||||
|
|
||||||
virtual bool IsIconized(void) const ;
|
virtual bool IsIconized() const ;
|
||||||
|
|
||||||
// Is it maximized?
|
// Is it maximized?
|
||||||
virtual bool IsMaximized(void) const ;
|
virtual bool IsMaximized() const ;
|
||||||
|
|
||||||
// Compatibility
|
// Compatibility
|
||||||
inline bool Iconized(void) const { return IsIconized(); }
|
bool Iconized() const { return IsIconized(); }
|
||||||
|
|
||||||
virtual void Maximize(bool maximize);
|
virtual void Maximize(bool maximize);
|
||||||
// virtual bool LoadAccelerators(const wxString& table);
|
// virtual bool LoadAccelerators(const wxString& table);
|
||||||
|
|
||||||
// Responds to colour changes
|
// Responds to colour changes
|
||||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||||
|
|
||||||
// Query app for menu item updates (called from OnIdle)
|
// Query app for menu item updates (called from OnIdle)
|
||||||
void DoMenuUpdates(void);
|
void DoMenuUpdates();
|
||||||
void DoMenuUpdates(wxMenu* menu);
|
void DoMenuUpdates(wxMenu* menu);
|
||||||
|
|
||||||
WXHMENU GetWinMenu(void) const ;
|
WXHMENU GetWinMenu() const ;
|
||||||
|
|
||||||
// Checks if there is a toolbar, and returns the first free client position
|
// Returns the origin of client area (may be different from (0,0) if the
|
||||||
|
// frame has a toolbar)
|
||||||
virtual wxPoint GetClientAreaOrigin() const;
|
virtual wxPoint GetClientAreaOrigin() const;
|
||||||
|
|
||||||
// Handlers
|
// Implementation only from here
|
||||||
bool MSWOnPaint(void);
|
// event handlers
|
||||||
WXHICON MSWOnQueryDragIcon(void);
|
bool MSWOnPaint();
|
||||||
|
WXHICON MSWOnQueryDragIcon();
|
||||||
void MSWOnSize(int x, int y, WXUINT flag);
|
void MSWOnSize(int x, int y, WXUINT flag);
|
||||||
bool MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control);
|
bool MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control);
|
||||||
bool MSWOnClose(void);
|
bool MSWOnClose();
|
||||||
void MSWOnMenuHighlight(WXWORD item, WXWORD flags, WXHMENU sysmenu);
|
void MSWOnMenuHighlight(WXWORD item, WXWORD flags, WXHMENU sysmenu);
|
||||||
bool MSWProcessMessage(WXMSG *msg);
|
bool MSWProcessMessage(WXMSG *msg);
|
||||||
bool MSWTranslateMessage(WXMSG *msg);
|
bool MSWTranslateMessage(WXMSG *msg);
|
||||||
void MSWCreate(int id, wxWindow *parent, const char *WXUNUSED(wclass), wxWindow *wx_win, const char *title,
|
void MSWCreate(int id, wxWindow *parent, const char *wclass,
|
||||||
|
wxWindow *wx_win, const char *title,
|
||||||
int x, int y, int width, int height, long style);
|
int x, int y, int width, int height, long style);
|
||||||
|
|
||||||
|
// tooltip management
|
||||||
|
#if wxUSE_TOOLTIPS
|
||||||
|
WXHWND GetToolTipCtrl() const { return m_hwndToolTip; }
|
||||||
|
void SetToolTipCtrl(WXHWND hwndTT) { m_hwndToolTip = hwndTT; }
|
||||||
|
#endif // tooltips
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// propagate our state change to all child frames
|
// propagate our state change to all child frames
|
||||||
void IconizeChildFrames(bool bIconize);
|
void IconizeChildFrames(bool bIconize);
|
||||||
@@ -181,9 +198,15 @@ protected:
|
|||||||
wxIcon m_icon;
|
wxIcon m_icon;
|
||||||
bool m_iconized;
|
bool m_iconized;
|
||||||
WXHICON m_defaultIcon;
|
WXHICON m_defaultIcon;
|
||||||
static bool m_useNativeStatusBar;
|
|
||||||
wxToolBar * m_frameToolBar ;
|
wxToolBar * m_frameToolBar ;
|
||||||
|
|
||||||
|
static bool m_useNativeStatusBar;
|
||||||
|
|
||||||
|
#if wxUSE_TOOLTIPS
|
||||||
|
WXHWND m_hwndToolTip;
|
||||||
|
#endif // tooltips
|
||||||
|
|
||||||
|
private:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
52
include/wx/msw/tooltip.h
Normal file
52
include/wx/msw/tooltip.h
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: msw/tooltip.h
|
||||||
|
// Purpose: wxToolTip class - tooltip control
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Modified by:
|
||||||
|
// Created: 31.01.99
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 1999 Robert Roebling, Vadim Zeitlin
|
||||||
|
// Licence: wxWindows license
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class wxToolTip : public wxObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// ctor & dtor
|
||||||
|
wxToolTip(const wxString &tip);
|
||||||
|
virtual ~wxToolTip();
|
||||||
|
|
||||||
|
// accessors
|
||||||
|
// tip text
|
||||||
|
void SetTip(const wxString& tip);
|
||||||
|
const wxString& GetTip() const { return m_text; }
|
||||||
|
|
||||||
|
// the window we're associated with
|
||||||
|
void SetWindow(wxWindow *win);
|
||||||
|
wxWindow *GetWindow() const { return m_window; }
|
||||||
|
|
||||||
|
// controlling tooltip behaviour: under MSW, these functions change the
|
||||||
|
// behaviour of the tooltips for all controls in the same frame as this
|
||||||
|
// one (it is an implementation limitation). Also, these functions won't
|
||||||
|
// do anything before the tooltip control is associated with a window, so
|
||||||
|
// SetWindow() should be called first
|
||||||
|
// enable or disable the tooltips globally
|
||||||
|
void Enable(bool flag);
|
||||||
|
// set the delay after which the tooltip appears
|
||||||
|
void SetDelay(long milliseconds);
|
||||||
|
|
||||||
|
// implementation
|
||||||
|
void RelayEvent(WXMSG *msg);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// 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();
|
||||||
|
|
||||||
|
wxString m_text; // tooltip text
|
||||||
|
wxWindow *m_window; // window we're associated with
|
||||||
|
};
|
||||||
|
|
196
src/msw/tooltip.cpp
Normal file
196
src/msw/tooltip.cpp
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: msw/tooltip.cpp
|
||||||
|
// Purpose: wxToolTip class implementation for MSW
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Modified by:
|
||||||
|
// Created: 31.01.99
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 1999 Vadim Zeitlin
|
||||||
|
// Licence: wxWindows license
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/wx.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/tooltip.h"
|
||||||
|
#include "wx/msw/private.h"
|
||||||
|
|
||||||
|
#include <commctrl.h>
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private classes
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// a simple wrapper around TOOLINFO Win32 structure
|
||||||
|
class wxToolInfo : public TOOLINFO
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxToolInfo(wxWindow *win)
|
||||||
|
{
|
||||||
|
// initialize all members
|
||||||
|
::ZeroMemory(this, sizeof(TOOLINFO));
|
||||||
|
|
||||||
|
cbSize = sizeof(TOOLINFO);
|
||||||
|
uFlags = TTF_IDISHWND;
|
||||||
|
uId = (UINT)win->GetHWND();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private functions
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// send a message to the tooltip control
|
||||||
|
inline LRESULT SendTooltipMessage(WXHWND hwnd,
|
||||||
|
UINT msg,
|
||||||
|
WPARAM wParam,
|
||||||
|
void *lParam)
|
||||||
|
{
|
||||||
|
return hwnd ? ::SendMessage((HWND)hwnd, msg, wParam, (LPARAM)lParam)
|
||||||
|
: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// "semiglobal" functions - these methods work with the tooltip control which
|
||||||
|
// is shared among all the wxToolTips of the same frame
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// create the tooltip ctrl for our parent frame if it doesn't exist yet
|
||||||
|
WXHWND wxToolTip::GetToolTipCtrl()
|
||||||
|
{
|
||||||
|
wxWindow *parent = m_window;
|
||||||
|
while ( parent && !parent->IsKindOf(CLASSINFO(wxFrame)) )
|
||||||
|
{
|
||||||
|
parent = parent->GetParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCHECK_MSG( parent, 0, "can't create tooltip control outside a frame" );
|
||||||
|
|
||||||
|
wxFrame *frame = (wxFrame *)parent;
|
||||||
|
HWND hwndTT = (HWND)frame->GetToolTipCtrl();
|
||||||
|
if ( !hwndTT )
|
||||||
|
{
|
||||||
|
hwndTT = ::CreateWindow(TOOLTIPS_CLASS,
|
||||||
|
(LPSTR)NULL,
|
||||||
|
TTS_ALWAYSTIP,
|
||||||
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
|
(HWND)frame->GetHWND(), (HMENU)NULL,
|
||||||
|
wxGetInstance(), NULL);
|
||||||
|
|
||||||
|
if ( hwndTT )
|
||||||
|
{
|
||||||
|
frame->SetToolTipCtrl((WXHWND)hwndTT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can not create tooltip control"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (WXHWND)hwndTT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxToolTip::Enable(bool flag)
|
||||||
|
{
|
||||||
|
(void)SendTooltipMessage(GetToolTipCtrl(), TTM_ACTIVATE, flag, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxToolTip::RelayEvent(WXMSG *msg)
|
||||||
|
{
|
||||||
|
(void)SendTooltipMessage(GetToolTipCtrl(), TTM_RELAYEVENT, 0, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxToolTip::SetDelay(long milliseconds)
|
||||||
|
{
|
||||||
|
(void)SendTooltipMessage(GetToolTipCtrl(), TTM_SETDELAYTIME,
|
||||||
|
TTDT_INITIAL, (void *)milliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// ctor & dtor
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxToolTip::wxToolTip(const wxString &tip)
|
||||||
|
: m_text(tip)
|
||||||
|
{
|
||||||
|
m_window = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxToolTip::~wxToolTip()
|
||||||
|
{
|
||||||
|
// there is no need to Remove() this tool - it will be done automatically
|
||||||
|
// anyhow
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// others
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxToolTip::Remove()
|
||||||
|
{
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
|
||||||
|
if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, 0, &ti) )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Failed to create the tooltip '%s'"),
|
||||||
|
m_text.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxToolTip::SetTip(const wxString& tip)
|
||||||
|
{
|
||||||
|
m_text = tip;
|
||||||
|
|
||||||
|
if ( m_window )
|
||||||
|
{
|
||||||
|
// update it immediately
|
||||||
|
wxToolInfo ti(m_window);
|
||||||
|
ti.lpszText = (char *)m_text.c_str();
|
||||||
|
|
||||||
|
(void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti);
|
||||||
|
}
|
||||||
|
}
|
@@ -21,21 +21,21 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "wx/setup.h"
|
#include "wx/setup.h"
|
||||||
#include "wx/menu.h"
|
#include "wx/menu.h"
|
||||||
#include "wx/dc.h"
|
#include "wx/dc.h"
|
||||||
#include "wx/dcclient.h"
|
#include "wx/dcclient.h"
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
#include "wx/panel.h"
|
#include "wx/panel.h"
|
||||||
#include "wx/layout.h"
|
#include "wx/layout.h"
|
||||||
#include "wx/dialog.h"
|
#include "wx/dialog.h"
|
||||||
#include "wx/frame.h"
|
#include "wx/frame.h"
|
||||||
#include "wx/listbox.h"
|
#include "wx/listbox.h"
|
||||||
#include "wx/button.h"
|
#include "wx/button.h"
|
||||||
#include "wx/settings.h"
|
#include "wx/settings.h"
|
||||||
#include "wx/msgdlg.h"
|
#include "wx/msgdlg.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_OWNER_DRAWN
|
#if wxUSE_OWNER_DRAWN
|
||||||
@@ -48,25 +48,30 @@
|
|||||||
|
|
||||||
#include "wx/menuitem.h"
|
#include "wx/menuitem.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
|
#include "wx/tooltip.h"
|
||||||
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef __GNUWIN32__
|
#ifndef __GNUWIN32__
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <commctrl.h>
|
||||||
|
|
||||||
#ifndef __TWIN32__
|
#ifndef __TWIN32__
|
||||||
#ifdef __GNUWIN32__
|
#ifdef __GNUWIN32__
|
||||||
#include <wx/msw/gnuwin32/extra.h>
|
#include <wx/msw/gnuwin32/extra.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// all these are defined in <windows.h>
|
||||||
#ifdef GetCharWidth
|
#ifdef GetCharWidth
|
||||||
#undef GetCharWidth
|
#undef GetCharWidth
|
||||||
#endif
|
#endif
|
||||||
@@ -97,13 +102,11 @@ void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win);
|
|||||||
wxWindow *wxFindWinFromHandle(WXHWND hWnd);
|
wxWindow *wxFindWinFromHandle(WXHWND hWnd);
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
#if !USE_SHARED_LIBRARY
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler)
|
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
|
BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
|
||||||
EVT_CHAR(wxWindow::OnChar)
|
EVT_CHAR(wxWindow::OnChar)
|
||||||
EVT_KEY_DOWN(wxWindow::OnKeyDown)
|
|
||||||
EVT_KEY_UP(wxWindow::OnKeyUp)
|
|
||||||
EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
|
EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
|
||||||
EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
|
EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
|
||||||
EVT_INIT_DIALOG(wxWindow::OnInitDialog)
|
EVT_INIT_DIALOG(wxWindow::OnInitDialog)
|
||||||
@@ -179,9 +182,19 @@ bool wxWindow::MSWCommand(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id))
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindow::MSWNotify(WXWPARAM WXUNUSED(wParam),
|
bool wxWindow::MSWNotify(WXWPARAM WXUNUSED(wParam),
|
||||||
WXLPARAM WXUNUSED(lParam),
|
WXLPARAM lParam,
|
||||||
WXLPARAM* WXUNUSED(result))
|
WXLPARAM* WXUNUSED(result))
|
||||||
{
|
{
|
||||||
|
NMHDR* hdr = (NMHDR *)lParam;
|
||||||
|
if ( hdr->code == TTN_NEEDTEXT && m_tooltip )
|
||||||
|
{
|
||||||
|
TOOLTIPTEXT *ttt = (TOOLTIPTEXT *)lParam;
|
||||||
|
ttt->lpszText = (char *)m_tooltip->GetTip().c_str();
|
||||||
|
|
||||||
|
// processed
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,6 +281,8 @@ void wxWindow::Init()
|
|||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
m_pDropTarget = NULL;
|
m_pDropTarget = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
m_tooltip = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindow::wxWindow()
|
wxWindow::wxWindow()
|
||||||
@@ -280,6 +295,10 @@ wxWindow::~wxWindow()
|
|||||||
{
|
{
|
||||||
m_isBeingDeleted = TRUE;
|
m_isBeingDeleted = TRUE;
|
||||||
|
|
||||||
|
// first of all, delete the things on which nothing else depends
|
||||||
|
|
||||||
|
wxDELETE(m_tooltip);
|
||||||
|
|
||||||
// JACS - if behaviour is odd, restore this
|
// JACS - if behaviour is odd, restore this
|
||||||
// to the start of ~wxWindow. Vadim has changed
|
// to the start of ~wxWindow. Vadim has changed
|
||||||
// it to nearer the end. Unsure of side-effects
|
// it to nearer the end. Unsure of side-effects
|
||||||
@@ -292,6 +311,7 @@ wxWindow::~wxWindow()
|
|||||||
// delete themselves.
|
// delete themselves.
|
||||||
#if wxUSE_CONSTRAINTS
|
#if wxUSE_CONSTRAINTS
|
||||||
DeleteRelatedConstraints();
|
DeleteRelatedConstraints();
|
||||||
|
|
||||||
if (m_constraints)
|
if (m_constraints)
|
||||||
{
|
{
|
||||||
// This removes any dangling pointers to this window
|
// This removes any dangling pointers to this window
|
||||||
@@ -300,11 +320,9 @@ wxWindow::~wxWindow()
|
|||||||
delete m_constraints;
|
delete m_constraints;
|
||||||
m_constraints = NULL;
|
m_constraints = NULL;
|
||||||
}
|
}
|
||||||
if (m_windowSizer)
|
|
||||||
{
|
wxDELETE(m_windowSizer);
|
||||||
delete m_windowSizer;
|
|
||||||
m_windowSizer = NULL;
|
|
||||||
}
|
|
||||||
// If this is a child of a sizer, remove self from parent
|
// If this is a child of a sizer, remove self from parent
|
||||||
if (m_sizerParent)
|
if (m_sizerParent)
|
||||||
m_sizerParent->RemoveChild((wxWindow *)this);
|
m_sizerParent->RemoveChild((wxWindow *)this);
|
||||||
@@ -501,7 +519,8 @@ void wxWindow::SetDropTarget(wxDropTarget *pDropTarget)
|
|||||||
m_pDropTarget->Register(m_hWnd);
|
m_pDropTarget->Register(m_hWnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
|
|
||||||
//old style file-manager drag&drop support
|
//old style file-manager drag&drop support
|
||||||
// I think we should retain the old-style
|
// I think we should retain the old-style
|
||||||
@@ -514,6 +533,24 @@ void wxWindow::DragAcceptFiles(bool accept)
|
|||||||
::DragAcceptFiles(hWnd, (BOOL)accept);
|
::DragAcceptFiles(hWnd, (BOOL)accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// tooltips
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxWindow::SetToolTip(const wxString &tip)
|
||||||
|
{
|
||||||
|
SetToolTip(new wxToolTip(tip));
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindow::SetToolTip(wxToolTip *tooltip)
|
||||||
|
{
|
||||||
|
if ( m_tooltip )
|
||||||
|
delete m_tooltip;
|
||||||
|
|
||||||
|
m_tooltip = tooltip;
|
||||||
|
m_tooltip->SetWindow(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Get total size
|
// Get total size
|
||||||
void wxWindow::GetSize(int *x, int *y) const
|
void wxWindow::GetSize(int *x, int *y) const
|
||||||
{
|
{
|
||||||
@@ -1164,10 +1201,10 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
{
|
{
|
||||||
MSWOnKeyDown((WORD) wParam, lParam);
|
MSWOnKeyDown((WORD) wParam, lParam);
|
||||||
#if 0
|
|
||||||
// we consider these message "not interesting"
|
// we consider these message "not interesting"
|
||||||
if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
|
if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
|
||||||
return Default();
|
return Default();
|
||||||
@@ -1185,9 +1222,9 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
|
|||||||
MSWOnChar((WORD)wParam, lParam);
|
MSWOnChar((WORD)wParam, lParam);
|
||||||
else
|
else
|
||||||
return Default();
|
return Default();
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
{
|
{
|
||||||
@@ -1902,14 +1939,19 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
|
|||||||
lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0);
|
lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bForward = TRUE;
|
bool bForward = TRUE,
|
||||||
|
bWindowChange = FALSE;
|
||||||
if ( bProcess ) {
|
if ( bProcess ) {
|
||||||
switch ( msg->wParam ) {
|
switch ( msg->wParam ) {
|
||||||
case VK_TAB:
|
case VK_TAB:
|
||||||
if ( lDlgCode & DLGC_WANTTAB ) // FALSE for Ctrl-Tab
|
if ( lDlgCode & DLGC_WANTTAB ) {
|
||||||
bProcess = FALSE;
|
bProcess = FALSE;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
|
// Ctrl-Tab cycles thru notebook pages
|
||||||
|
bWindowChange = bCtrlDown;
|
||||||
bForward = !(::GetKeyState(VK_SHIFT) & 0x100);
|
bForward = !(::GetKeyState(VK_SHIFT) & 0x100);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VK_UP:
|
case VK_UP:
|
||||||
@@ -1926,6 +1968,18 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
|
|||||||
bProcess = FALSE;
|
bProcess = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VK_RETURN:
|
||||||
|
// if there is a default button, Enter should press it
|
||||||
|
if ( !GetDefaultItem() ) {
|
||||||
|
// but if there is not it makes sense to make it work
|
||||||
|
// like a TAB
|
||||||
|
|
||||||
|
// nothing to do - all variables are already set
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//else: fall through and don't process the message
|
||||||
|
|
||||||
default:
|
default:
|
||||||
bProcess = FALSE;
|
bProcess = FALSE;
|
||||||
}
|
}
|
||||||
@@ -1934,7 +1988,7 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
|
|||||||
if ( bProcess ) {
|
if ( bProcess ) {
|
||||||
wxNavigationKeyEvent event;
|
wxNavigationKeyEvent event;
|
||||||
event.SetDirection(bForward);
|
event.SetDirection(bForward);
|
||||||
event.SetWindowChange(bCtrlDown);
|
event.SetWindowChange(bWindowChange);
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
|
|
||||||
if ( GetEventHandler()->ProcessEvent(event) )
|
if ( GetEventHandler()->ProcessEvent(event) )
|
||||||
@@ -1943,6 +1997,14 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
|
|||||||
|
|
||||||
return ::IsDialogMessage((HWND)GetHWND(), msg) != 0;
|
return ::IsDialogMessage((HWND)GetHWND(), msg) != 0;
|
||||||
}
|
}
|
||||||
|
#if wxUSE_TOOLTIPS
|
||||||
|
else if ( m_tooltip ) {
|
||||||
|
// relay mouse move events to the tooltip control
|
||||||
|
MSG *msg = (MSG *)pMsg;
|
||||||
|
if ( msg->message == WM_MOUSEMOVE )
|
||||||
|
m_tooltip->RelayEvent(pMsg);
|
||||||
|
}
|
||||||
|
#endif // wxUSE_TOOLTIPS
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -3049,13 +3111,6 @@ void wxWindow::Centre(int direction)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO (maybe)
|
|
||||||
void wxWindow::OnPaint()
|
|
||||||
{
|
|
||||||
PaintSelectionHandles();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void wxWindow::WarpPointer (int x_pos, int y_pos)
|
void wxWindow::WarpPointer (int x_pos, int y_pos)
|
||||||
{
|
{
|
||||||
// Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
|
// Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
|
||||||
@@ -3550,17 +3605,17 @@ WXDWORD wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D)
|
|||||||
|
|
||||||
void wxWindow::OnChar(wxKeyEvent& event)
|
void wxWindow::OnChar(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
/* I'm commenting this out because otherwise, we lose tabs in e.g. a text window (see MDI sample)
|
#if 0
|
||||||
* (JACS, 14/01/99)
|
|
||||||
if ( event.KeyCode() == WXK_TAB ) {
|
if ( event.KeyCode() == WXK_TAB ) {
|
||||||
// propagate the TABs to the parent - it's up to it to decide what
|
// propagate the TABs to the parent - it's up to it to decide what
|
||||||
// to do with it
|
// to do with it
|
||||||
if ( GetParent() ) {
|
wxWindow *parent = GetParent();
|
||||||
if ( GetParent()->GetEventHandler()->ProcessEvent(event) )
|
if ( parent ) {
|
||||||
|
if ( parent->GetEventHandler()->ProcessEvent(event) )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
#endif // 0
|
||||||
|
|
||||||
bool isVirtual;
|
bool isVirtual;
|
||||||
int id = wxCharCodeWXToMSW((int)event.KeyCode(), &isVirtual);
|
int id = wxCharCodeWXToMSW((int)event.KeyCode(), &isVirtual);
|
||||||
@@ -3572,21 +3627,6 @@ void wxWindow::OnChar(wxKeyEvent& event)
|
|||||||
(void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam);
|
(void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindow::OnKeyDown(wxKeyEvent& event)
|
|
||||||
{
|
|
||||||
Default();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxWindow::OnKeyUp(wxKeyEvent& event)
|
|
||||||
{
|
|
||||||
Default();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxWindow::OnPaint(wxPaintEvent& event)
|
|
||||||
{
|
|
||||||
Default();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxWindow::IsEnabled(void) const
|
bool wxWindow::IsEnabled(void) const
|
||||||
{
|
{
|
||||||
return (::IsWindowEnabled((HWND) GetHWND()) != 0);
|
return (::IsWindowEnabled((HWND) GetHWND()) != 0);
|
||||||
@@ -4427,6 +4467,7 @@ long wxWindow::MSWGetDlgCode()
|
|||||||
|
|
||||||
bool wxWindow::AcceptsFocus() const
|
bool wxWindow::AcceptsFocus() const
|
||||||
{
|
{
|
||||||
|
// invisible and disabled controls don't need focus
|
||||||
return IsShown() && IsEnabled();
|
return IsShown() && IsEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user