Many changes for wxInputHandler creation mainly related to:
1. Allow the theme to create only the input handlers it customizes instead of forcing it to always create a handler even if the standard one is used: wxTheme::GetInputHandler() now takes wxInputConsumer to make this possible 2. Prefer delegation to inheritance when creating customized input handlers, almost all (except for wxStdScrollbarInputHandler) standard handler classes are now private, use wxClassName::GetStdInputHandler() to retrieve the standard handler for any class or polymorphic DoGetStdInputHandler() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41227 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
5eefe02976
commit
9467bdb7f5
@ -47,7 +47,7 @@ public:
|
||||
|
||||
Create(parent, id, bitmap, label, pos, size, style, validator, name);
|
||||
}
|
||||
|
||||
|
||||
wxButton(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& label = wxEmptyString,
|
||||
@ -74,7 +74,7 @@ public:
|
||||
return Create(parent, id, wxNullBitmap, label,
|
||||
pos, size, style, validator, name);
|
||||
}
|
||||
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxBitmap& bitmap,
|
||||
@ -106,9 +106,16 @@ public:
|
||||
|
||||
virtual bool CanBeHighlighted() const { return true; }
|
||||
|
||||
static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
|
||||
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
return GetStdInputHandler(handlerDef);
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestClientSize() const;
|
||||
|
||||
|
||||
virtual bool DoDrawBackground(wxDC& dc);
|
||||
virtual void DoDraw(wxControlRenderer *renderer);
|
||||
|
||||
@ -128,31 +135,5 @@ private:
|
||||
DECLARE_DYNAMIC_CLASS(wxButton)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdButtonInputHandler: translates SPACE and ENTER keys and the left mouse
|
||||
// click into button press/release actions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdButtonInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdButtonInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event);
|
||||
virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
|
||||
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
|
||||
|
||||
private:
|
||||
// the window (button) which has capture or NULL and the flag telling if
|
||||
// the mouse is inside the button which captured it or not
|
||||
wxWindow *m_winCapture;
|
||||
bool m_winHasMouse;
|
||||
};
|
||||
|
||||
#endif // _WX_UNIV_BUTTON_H_
|
||||
|
||||
|
@ -28,11 +28,6 @@
|
||||
// wxCheckBox
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// X11 headers may define this
|
||||
#ifdef Status
|
||||
#undef Status
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxCheckBox : public wxCheckBoxBase
|
||||
{
|
||||
public:
|
||||
@ -102,6 +97,11 @@ public:
|
||||
const wxString& strArg = wxEmptyString);
|
||||
|
||||
virtual bool CanBeHighlighted() const { return true; }
|
||||
virtual wxInputHandler *CreateStdInputHandler(wxInputHandler *handlerDef);
|
||||
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
return CreateStdInputHandler(handlerDef);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state));
|
||||
@ -147,20 +147,4 @@ private:
|
||||
DECLARE_DYNAMIC_CLASS(wxCheckBox)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdCheckboxInputHandler: handles the mouse events for the check and radio
|
||||
// boxes (handling the keyboard input is simple, but its handling differs a
|
||||
// lot between GTK and MSW, so a new class should be derived for this)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdCheckboxInputHandler : public wxStdButtonInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdCheckboxInputHandler(wxInputHandler *inphand);
|
||||
|
||||
// we have to override this one as wxStdButtonInputHandler version works
|
||||
// only with the buttons
|
||||
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
|
||||
};
|
||||
|
||||
#endif // _WX_UNIV_CHECKBOX_H_
|
||||
|
@ -78,6 +78,12 @@ public:
|
||||
long numArg = -1l,
|
||||
const wxString& strArg = wxEmptyString);
|
||||
|
||||
static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
|
||||
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
return GetStdInputHandler(handlerDef);
|
||||
}
|
||||
|
||||
// override all methods which add/delete items to update m_checks array as
|
||||
// well
|
||||
virtual void Delete(unsigned int n);
|
||||
@ -105,20 +111,4 @@ private:
|
||||
DECLARE_DYNAMIC_CLASS(wxCheckListBox)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdCheckListBoxInputHandler
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdCheckListboxInputHandler : public wxStdListboxInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdCheckListboxInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
};
|
||||
|
||||
#endif // _WX_UNIV_CHECKLST_H_
|
||||
|
@ -136,6 +136,12 @@ public:
|
||||
const wxString& strArg = wxEmptyString);
|
||||
*/
|
||||
|
||||
static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
|
||||
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
return GetStdInputHandler(handlerDef);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual int DoAppend(const wxString& item);
|
||||
virtual int DoInsert(const wxString& item, unsigned int pos);
|
||||
@ -158,20 +164,4 @@ private:
|
||||
DECLARE_DYNAMIC_CLASS(wxComboBox)
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdComboBoxInputHandler: allows the user to open/close the combo from kbd
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdComboBoxInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdComboBoxInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
};
|
||||
|
||||
|
||||
#endif // _WX_UNIV_COMBOBOX_H_
|
||||
|
@ -39,7 +39,7 @@ class WXDLLEXPORT wxInputConsumer
|
||||
{
|
||||
public:
|
||||
wxInputConsumer() { m_inputHandler = NULL; }
|
||||
virtual ~wxInputConsumer() {}
|
||||
virtual ~wxInputConsumer() { }
|
||||
|
||||
// get the input handler
|
||||
wxInputHandler *GetInputHandler() const { return m_inputHandler; }
|
||||
@ -60,6 +60,19 @@ public:
|
||||
// get the window to work with (usually the class wxInputConsumer was mixed into)
|
||||
virtual wxWindow *GetInputWindow() const = 0;
|
||||
|
||||
// this function must be implemented in any classes process input (i.e. not
|
||||
// static controls) to create the standard input handler for the concrete
|
||||
// class deriving from this mix-in
|
||||
//
|
||||
// the parameter is the default input handler which should receive all
|
||||
// unprocessed input (i.e. typically handlerDef is passed to
|
||||
// wxStdInputHandler ctor) or it may be NULL
|
||||
//
|
||||
// the returned pointer will not be deleted by caller so it must either
|
||||
// point to a static object or be deleted on program termination
|
||||
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef);
|
||||
|
||||
|
||||
protected:
|
||||
// event handlers
|
||||
void OnMouse(wxMouseEvent& event);
|
||||
@ -68,10 +81,12 @@ protected:
|
||||
void OnFocus(wxFocusEvent& event);
|
||||
void OnActivate(wxActivateEvent& event);
|
||||
|
||||
// create input handler by name
|
||||
// create input handler by name, fall back to GetStdInputHandler() if
|
||||
// the current theme doesn't define any specific handler of this type
|
||||
void CreateInputHandler(const wxString& inphandler);
|
||||
|
||||
// input processor (never deleted, the theme deletes it itself)
|
||||
private:
|
||||
// the input processor (we never delete it)
|
||||
wxInputHandler *m_inputHandler;
|
||||
};
|
||||
|
||||
|
@ -183,6 +183,12 @@ public:
|
||||
long numArg = 0l,
|
||||
const wxString& strArg = wxEmptyString);
|
||||
|
||||
static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
|
||||
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
return GetStdInputHandler(handlerDef);
|
||||
}
|
||||
|
||||
// idle processing
|
||||
virtual void OnInternalIdle();
|
||||
|
||||
@ -291,60 +297,4 @@ private:
|
||||
DECLARE_DYNAMIC_CLASS(wxListBox)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdListboxInputHandler: handles mouse and kbd in a single or multi
|
||||
// selection listbox
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdListboxInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
// if pressing the mouse button in a multiselection listbox should toggle
|
||||
// the item under mouse immediately, then specify true as the second
|
||||
// parameter (this is the standard behaviour, under GTK the item is toggled
|
||||
// only when the mouse is released in the multi selection listbox)
|
||||
wxStdListboxInputHandler(wxInputHandler *inphand,
|
||||
bool toggleOnPressAlways = true);
|
||||
|
||||
// base class methods
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
|
||||
protected:
|
||||
// return the item under mouse, 0 if the mouse is above the listbox or
|
||||
// GetCount() if it is below it
|
||||
int HitTest(const wxListBox *listbox, const wxMouseEvent& event);
|
||||
|
||||
// parts of HitTest(): first finds the pseudo (because not in range) index
|
||||
// of the item and the second one adjusts it if necessary - that is if the
|
||||
// third one returns false
|
||||
int HitTestUnsafe(const wxListBox *listbox, const wxMouseEvent& event);
|
||||
int FixItemIndex(const wxListBox *listbox, int item);
|
||||
bool IsValidIndex(const wxListBox *listbox, int item);
|
||||
|
||||
// init m_btnCapture and m_actionMouse
|
||||
wxControlAction SetupCapture(wxListBox *lbox,
|
||||
const wxMouseEvent& event,
|
||||
int item);
|
||||
|
||||
wxRenderer *m_renderer;
|
||||
|
||||
// the button which initiated the mouse capture (currently 0 or 1)
|
||||
int m_btnCapture;
|
||||
|
||||
// the action to perform when the mouse moves while we capture it
|
||||
wxControlAction m_actionMouse;
|
||||
|
||||
// the ctor parameter toggleOnPressAlways (see comments near it)
|
||||
bool m_toggleOnPressAlways;
|
||||
|
||||
// do we track the mouse outside the window when it is captured?
|
||||
bool m_trackMouseOutside;
|
||||
};
|
||||
|
||||
#endif // _WX_UNIV_LISTBOX_H_
|
||||
|
@ -111,6 +111,12 @@ public:
|
||||
long numArg = 0l,
|
||||
const wxString& strArg = wxEmptyString);
|
||||
|
||||
static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
|
||||
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
return GetStdInputHandler(handlerDef);
|
||||
}
|
||||
|
||||
// refresh the currently selected tab
|
||||
void RefreshCurrent();
|
||||
|
||||
@ -242,28 +248,5 @@ protected:
|
||||
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdNotebookInputHandler: translates SPACE and ENTER keys and the left mouse
|
||||
// click into button press/release actions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdNotebookInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdNotebookInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event);
|
||||
virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
|
||||
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
|
||||
|
||||
protected:
|
||||
void HandleFocusChange(wxInputConsumer *consumer);
|
||||
};
|
||||
|
||||
#endif // _WX_UNIV_NOTEBOOK_H_
|
||||
|
||||
|
@ -96,8 +96,13 @@ public:
|
||||
long numArg = 0,
|
||||
const wxString& strArg = wxEmptyString);
|
||||
|
||||
// The scrollbars around a normal window should not
|
||||
// receive the focus.
|
||||
static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
|
||||
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
return GetStdInputHandler(handlerDef);
|
||||
}
|
||||
|
||||
// scrollbars around a normal window should not receive the focus
|
||||
virtual bool AcceptsFocus() const;
|
||||
|
||||
// wxScrollBar sub elements state (combination of wxCONTROL_XXX)
|
||||
@ -165,8 +170,7 @@ private:
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// common scrollbar input handler: it manages clicks on the standard scrollbar
|
||||
// elements (line arrows, bar, thumb)
|
||||
// Standard scrollbar input handler which can be used as a base class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdScrollBarInputHandler : public wxStdInputHandler
|
||||
@ -193,12 +197,10 @@ public:
|
||||
const wxControlAction& action);
|
||||
|
||||
protected:
|
||||
// the methods which must be overridden in the derived class
|
||||
|
||||
// return true if the mouse button can be used to activate scrollbar, false
|
||||
// if not (only left mouse button can do it under Windows, any button under
|
||||
// GTK+)
|
||||
virtual bool IsAllowedButton(int button) = 0;
|
||||
// if not (any button under GTK+ unlike left button only which is default)
|
||||
virtual bool IsAllowedButton(int button) const
|
||||
{ return button == wxMOUSE_BTN_LEFT; }
|
||||
|
||||
// set or clear the specified flag on the scrollbar element corresponding
|
||||
// to m_htLast
|
||||
@ -222,6 +224,7 @@ protected:
|
||||
// generate a "thumb move" action for this mouse event
|
||||
void HandleThumbMove(wxScrollBar *scrollbar, const wxMouseEvent& event);
|
||||
|
||||
|
||||
// the window (scrollbar) which has capture or NULL and the flag telling if
|
||||
// the mouse is inside the element which captured it or not
|
||||
wxWindow *m_winCapture;
|
||||
|
@ -118,13 +118,19 @@ public:
|
||||
virtual void OnPageScrollStart();
|
||||
virtual bool OnPageScroll(int pageInc);
|
||||
|
||||
// for wxStdSliderButtonInputHandler
|
||||
// for wxStdSliderInputHandler
|
||||
wxScrollThumb& GetThumb() { return m_thumb; }
|
||||
|
||||
virtual bool PerformAction(const wxControlAction& action,
|
||||
long numArg = 0,
|
||||
const wxString& strArg = wxEmptyString);
|
||||
|
||||
static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
|
||||
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
return GetStdInputHandler(handlerDef);
|
||||
}
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
@ -217,29 +223,4 @@ private:
|
||||
DECLARE_DYNAMIC_CLASS(wxSlider)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdSliderButtonInputHandler: default slider input handling
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdSliderButtonInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
// default ctor
|
||||
wxStdSliderButtonInputHandler(wxInputHandler *inphand)
|
||||
: wxStdInputHandler(inphand)
|
||||
{
|
||||
}
|
||||
|
||||
// base class methods
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
|
||||
virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
|
||||
};
|
||||
|
||||
#endif // _WX_UNIV_SLIDER_H_
|
||||
|
@ -62,6 +62,12 @@ public:
|
||||
long numArg = 0,
|
||||
const wxString& strArg = wxEmptyString);
|
||||
|
||||
static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
|
||||
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
return GetStdInputHandler(handlerDef);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestClientSize() const;
|
||||
virtual void DoDraw(wxControlRenderer *renderer);
|
||||
|
@ -224,6 +224,12 @@ public:
|
||||
long numArg = -1,
|
||||
const wxString& strArg = wxEmptyString);
|
||||
|
||||
static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
|
||||
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
return GetStdInputHandler(handlerDef);
|
||||
}
|
||||
|
||||
// override these methods to handle the caret
|
||||
virtual bool SetFont(const wxFont &font);
|
||||
virtual bool Enable(bool enable = true);
|
||||
@ -522,32 +528,5 @@ private:
|
||||
friend class wxWrappedLineData;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdTextCtrlInputHandler: this control handles only the mouse/kbd actions
|
||||
// common to Win32 and GTK, platform-specific things are implemented elsewhere
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdTextCtrlInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdTextCtrlInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
|
||||
|
||||
protected:
|
||||
// get the position of the mouse click
|
||||
static wxTextPos HitTest(const wxTextCtrl *text, const wxPoint& pos);
|
||||
|
||||
// capture data
|
||||
wxTextCtrl *m_winCapture;
|
||||
};
|
||||
|
||||
#endif // _WX_UNIV_TEXTCTRL_H_
|
||||
|
||||
|
@ -18,10 +18,11 @@
|
||||
// wxTheme
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxRenderer;
|
||||
class WXDLLEXPORT wxColourScheme;
|
||||
class WXDLLEXPORT wxInputHandler;
|
||||
class WXDLLEXPORT wxArtProvider;
|
||||
class WXDLLEXPORT wxColourScheme;
|
||||
class WXDLLEXPORT wxInputConsumer;
|
||||
class WXDLLEXPORT wxInputHandler;
|
||||
class WXDLLEXPORT wxRenderer;
|
||||
struct WXDLLEXPORT wxThemeInfo;
|
||||
|
||||
class WXDLLEXPORT wxTheme
|
||||
@ -52,8 +53,9 @@ public:
|
||||
// get the art provider to be used together with this theme
|
||||
virtual wxArtProvider *GetArtProvider() = 0;
|
||||
|
||||
// get the input handler of the given type
|
||||
virtual wxInputHandler *GetInputHandler(const wxString& handlerType) = 0;
|
||||
// get the input handler of the given type, forward to the standard one
|
||||
virtual wxInputHandler *GetInputHandler(const wxString& handlerType,
|
||||
wxInputConsumer *consumer) = 0;
|
||||
|
||||
// get the colour scheme for the control with this name
|
||||
virtual wxColourScheme *GetColourScheme() = 0;
|
||||
|
@ -32,7 +32,7 @@ class WXDLLEXPORT wxToolBarTool;
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxToolBar : public wxToolBarBase
|
||||
{
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
wxToolBar() { Init(); }
|
||||
@ -54,7 +54,7 @@ public:
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxToolBarNameStr );
|
||||
|
||||
|
||||
virtual ~wxToolBar();
|
||||
|
||||
virtual bool Realize();
|
||||
@ -72,6 +72,12 @@ public:
|
||||
virtual bool PerformAction(const wxControlAction& action,
|
||||
long numArg = -1,
|
||||
const wxString& strArg = wxEmptyString);
|
||||
static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
|
||||
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
return GetStdInputHandler(handlerDef);
|
||||
}
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
@ -109,7 +115,7 @@ protected:
|
||||
// (re)calculate the tool positions, should only be called if it is
|
||||
// necessary to do it, i.e. m_needsLayout == true
|
||||
void DoLayout();
|
||||
|
||||
|
||||
// get the rect limits depending on the orientation: top/bottom for a
|
||||
// vertical toolbar, left/right for a horizontal one
|
||||
void GetRectLimits(const wxRect& rect, wxCoord *start, wxCoord *end) const;
|
||||
@ -129,29 +135,4 @@ private:
|
||||
DECLARE_DYNAMIC_CLASS(wxToolBar)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdToolbarInputHandler: translates SPACE and ENTER keys and the left mouse
|
||||
// click into button press/release actions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdToolbarInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdToolbarInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event);
|
||||
virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
|
||||
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
|
||||
|
||||
private:
|
||||
wxWindow *m_winCapture;
|
||||
wxToolBarToolBase *m_toolCapture;
|
||||
wxToolBarToolBase *m_toolLast;
|
||||
};
|
||||
|
||||
#endif // _WX_UNIV_TOOLBAR_H_
|
||||
|
@ -131,6 +131,12 @@ public:
|
||||
long numArg = -1,
|
||||
const wxString& strArg = wxEmptyString);
|
||||
|
||||
static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
|
||||
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
return GetStdInputHandler(handlerDef);
|
||||
}
|
||||
|
||||
// move/resize the frame interactively, i.e. let the user do it
|
||||
virtual void InteractiveMove(int flags = wxINTERACTIVE_MOVE);
|
||||
|
||||
@ -174,27 +180,4 @@ protected:
|
||||
WX_DECLARE_INPUT_CONSUMER()
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdFrameInputHandler: handles focus, resizing and titlebar buttons clicks
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdFrameInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdFrameInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event);
|
||||
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
|
||||
|
||||
private:
|
||||
// the window (button) which has capture or NULL and the last hittest result
|
||||
wxTopLevelWindow *m_winCapture;
|
||||
long m_winHitTest;
|
||||
long m_winPressed;
|
||||
bool m_borderCursorOn;
|
||||
wxCursor m_origCursor;
|
||||
};
|
||||
|
||||
#endif // __WX_UNIV_TOPLEVEL_H__
|
||||
|
@ -39,6 +39,34 @@
|
||||
#include "wx/univ/colschem.h"
|
||||
#include "wx/stockitem.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdButtonInputHandler: translates SPACE and ENTER keys and the left mouse
|
||||
// click into button press/release actions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdButtonInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdButtonInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleFocus(wxInputConsumer *consumer,
|
||||
const wxFocusEvent& event);
|
||||
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
|
||||
|
||||
private:
|
||||
// the window (button) which has capture or NULL and the flag telling if
|
||||
// the mouse is inside the button which captured it or not
|
||||
wxWindow *m_winCapture;
|
||||
bool m_winHasMouse;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -272,6 +300,14 @@ bool wxButton::PerformAction(const wxControlAction& action,
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxInputHandler *wxButton::GetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
static wxStdButtonInputHandler s_handlerBtn(handlerDef);
|
||||
|
||||
return &s_handlerBtn;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// misc
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -39,6 +39,22 @@
|
||||
#include "wx/univ/inphand.h"
|
||||
#include "wx/univ/colschem.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdCheckboxInputHandler: handles the mouse events for the check and radio
|
||||
// boxes (handling the keyboard input is simple, but its handling differs a
|
||||
// lot between GTK and MSW, so a new class should be derived for this)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdCheckboxInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdCheckboxInputHandler(wxInputHandler *inphand);
|
||||
|
||||
// we have to override this one as wxStdButtonInputHandler version works
|
||||
// only with the buttons
|
||||
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
@ -323,12 +339,20 @@ bool wxCheckBox::PerformAction(const wxControlAction& action,
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxInputHandler *wxCheckBox::CreateStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
static wxStdCheckboxInputHandler s_handler(handlerDef);
|
||||
|
||||
return &s_handler;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdCheckboxInputHandler
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxStdCheckboxInputHandler::wxStdCheckboxInputHandler(wxInputHandler *inphand)
|
||||
: wxStdButtonInputHandler(inphand)
|
||||
wxStdCheckboxInputHandler::wxStdCheckboxInputHandler(wxInputHandler *def)
|
||||
: wxStdInputHandler(wxButton::GetStdInputHandler(def))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,22 @@
|
||||
#include "wx/univ/inphand.h"
|
||||
#include "wx/univ/theme.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdCheckListBoxInputHandler
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdCheckListboxInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdCheckListboxInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// implementation of wxCheckListBox
|
||||
// ============================================================================
|
||||
@ -226,13 +242,21 @@ bool wxCheckListBox::PerformAction(const wxControlAction& action,
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxInputHandler *wxCheckListBox::GetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
static wxStdCheckListboxInputHandler s_handler(handlerDef);
|
||||
|
||||
return &s_handler;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdCheckListboxInputHandler
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxStdCheckListboxInputHandler::
|
||||
wxStdCheckListboxInputHandler(wxInputHandler *inphand)
|
||||
: wxStdListboxInputHandler(inphand)
|
||||
: wxStdInputHandler(wxListBox::GetStdInputHandler(inphand))
|
||||
{
|
||||
}
|
||||
|
||||
@ -243,7 +267,7 @@ bool wxStdCheckListboxInputHandler::HandleKey(wxInputConsumer *consumer,
|
||||
if ( pressed && (event.GetKeyCode() == WXK_SPACE) )
|
||||
consumer->PerformAction(wxACTION_CHECKLISTBOX_TOGGLE);
|
||||
|
||||
return wxStdListboxInputHandler::HandleKey(consumer, event, pressed);
|
||||
return wxStdInputHandler::HandleKey(consumer, event, pressed);
|
||||
}
|
||||
|
||||
bool wxStdCheckListboxInputHandler::HandleMouse(wxInputConsumer *consumer,
|
||||
@ -273,7 +297,7 @@ bool wxStdCheckListboxInputHandler::HandleMouse(wxInputConsumer *consumer,
|
||||
}
|
||||
}
|
||||
|
||||
return wxStdListboxInputHandler::HandleMouse(consumer, event);
|
||||
return wxStdInputHandler::HandleMouse(consumer, event);
|
||||
}
|
||||
|
||||
#endif // wxUSE_CHECKLISTBOX
|
||||
|
@ -44,6 +44,19 @@
|
||||
#include "wx/univ/inphand.h"
|
||||
#include "wx/univ/theme.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdComboBoxInputHandler: allows the user to open/close the combo from kbd
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdComboBoxInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdComboBoxInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxComboListBox is a listbox modified to be used as a popup window in a
|
||||
@ -530,5 +543,12 @@ bool wxStdComboBoxInputHandler::HandleKey(wxInputConsumer *consumer,
|
||||
return wxStdInputHandler::HandleKey(consumer, event, pressed);
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxInputHandler *wxComboBox::GetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
static wxStdComboBoxInputHandler s_handler(handlerDef);
|
||||
|
||||
return &s_handler;
|
||||
}
|
||||
|
||||
#endif // wxUSE_COMBOBOX
|
||||
|
@ -55,9 +55,15 @@ void wxInputConsumer::OnActivate(wxActivateEvent& event)
|
||||
// input processing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxInputHandler *
|
||||
wxInputConsumer::DoGetStdInputHandler(wxInputHandler * WXUNUSED(handlerDef))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void wxInputConsumer::CreateInputHandler(const wxString& inphandler)
|
||||
{
|
||||
m_inputHandler = wxTheme::Get()->GetInputHandler(inphandler);
|
||||
m_inputHandler = wxTheme::Get()->GetInputHandler(inphandler, this);
|
||||
}
|
||||
|
||||
void wxInputConsumer::OnKeyDown(wxKeyEvent& event)
|
||||
|
@ -37,6 +37,62 @@
|
||||
#include "wx/univ/inphand.h"
|
||||
#include "wx/univ/theme.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdListboxInputHandler: handles mouse and kbd in a single or multi
|
||||
// selection listbox
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdListboxInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
// if pressing the mouse button in a multiselection listbox should toggle
|
||||
// the item under mouse immediately, then specify true as the second
|
||||
// parameter (this is the standard behaviour, under GTK the item is toggled
|
||||
// only when the mouse is released in the multi selection listbox)
|
||||
wxStdListboxInputHandler(wxInputHandler *inphand,
|
||||
bool toggleOnPressAlways = true);
|
||||
|
||||
// base class methods
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
|
||||
protected:
|
||||
// return the item under mouse, 0 if the mouse is above the listbox or
|
||||
// GetCount() if it is below it
|
||||
int HitTest(const wxListBox *listbox, const wxMouseEvent& event);
|
||||
|
||||
// parts of HitTest(): first finds the pseudo (because not in range) index
|
||||
// of the item and the second one adjusts it if necessary - that is if the
|
||||
// third one returns false
|
||||
int HitTestUnsafe(const wxListBox *listbox, const wxMouseEvent& event);
|
||||
int FixItemIndex(const wxListBox *listbox, int item);
|
||||
bool IsValidIndex(const wxListBox *listbox, int item);
|
||||
|
||||
// init m_btnCapture and m_actionMouse
|
||||
wxControlAction SetupCapture(wxListBox *lbox,
|
||||
const wxMouseEvent& event,
|
||||
int item);
|
||||
|
||||
wxRenderer *m_renderer;
|
||||
|
||||
// the button which initiated the mouse capture (currently 0 or 1)
|
||||
int m_btnCapture;
|
||||
|
||||
// the action to perform when the mouse moves while we capture it
|
||||
wxControlAction m_actionMouse;
|
||||
|
||||
// the ctor parameter toggleOnPressAlways (see comments near it)
|
||||
bool m_toggleOnPressAlways;
|
||||
|
||||
// do we track the mouse outside the window when it is captured?
|
||||
bool m_trackMouseOutside;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// implementation of wxListBox
|
||||
// ============================================================================
|
||||
@ -1190,6 +1246,14 @@ bool wxListBox::PerformAction(const wxControlAction& action,
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxInputHandler *wxListBox::GetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
static wxStdListboxInputHandler s_handler(handlerDef);
|
||||
|
||||
return &s_handler;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// implementation of wxStdListboxInputHandler
|
||||
// ============================================================================
|
||||
|
@ -36,6 +36,29 @@
|
||||
|
||||
#include "wx/univ/renderer.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdNotebookInputHandler: translates SPACE and ENTER keys and the left mouse
|
||||
// click into button press/release actions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdNotebookInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdNotebookInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event);
|
||||
virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
|
||||
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
|
||||
|
||||
protected:
|
||||
void HandleFocusChange(wxInputConsumer *consumer);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -1319,6 +1342,14 @@ bool wxNotebook::PerformAction(const wxControlAction& action,
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxInputHandler *wxNotebook::GetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
static wxStdNotebookInputHandler s_handler(handlerDef);
|
||||
|
||||
return &s_handler;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdNotebookInputHandler
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -589,6 +589,15 @@ bool wxScrollBar::ScrollPages(int nPages)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxInputHandler *wxScrollBar::GetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
static wxStdScrollBarInputHandler
|
||||
s_handler(wxTheme::Get()->GetRenderer(), handlerDef);
|
||||
|
||||
return &s_handler;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// scroll bar input handler
|
||||
// ============================================================================
|
||||
@ -737,7 +746,7 @@ bool wxStdScrollBarInputHandler::HandleMouse(wxInputConsumer *consumer,
|
||||
{
|
||||
// is this a click event from an acceptable button?
|
||||
int btn = event.GetButton();
|
||||
if ( (btn != -1) && IsAllowedButton(btn) )
|
||||
if ( btn == wxMOUSE_BTN_LEFT )
|
||||
{
|
||||
// determine which part of the window mouse is in
|
||||
wxScrollBar *scrollbar = wxStaticCast(consumer->GetInputWindow(), wxScrollBar);
|
||||
|
@ -60,6 +60,31 @@
|
||||
#include "wx/univ/inphand.h"
|
||||
#include "wx/univ/theme.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdSliderInputHandler: default slider input handling
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdSliderInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
// default ctor
|
||||
wxStdSliderInputHandler(wxInputHandler *inphand)
|
||||
: wxStdInputHandler(inphand)
|
||||
{
|
||||
}
|
||||
|
||||
// base class methods
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
|
||||
virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -821,6 +846,14 @@ bool wxSlider::PerformAction(const wxControlAction& action,
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxInputHandler *wxSlider::GetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
static wxStdSliderInputHandler s_handler(handlerDef);
|
||||
|
||||
return &s_handler;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxSlider implementation of wxControlWithThumb interface
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -977,10 +1010,10 @@ bool wxSlider::OnPageScroll(int pageInc)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdSliderButtonInputHandler
|
||||
// wxStdSliderInputHandler
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxStdSliderButtonInputHandler::HandleKey(wxInputConsumer *consumer,
|
||||
bool wxStdSliderInputHandler::HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed)
|
||||
{
|
||||
@ -1029,7 +1062,7 @@ bool wxStdSliderButtonInputHandler::HandleKey(wxInputConsumer *consumer,
|
||||
return wxStdInputHandler::HandleKey(consumer, event, pressed);
|
||||
}
|
||||
|
||||
bool wxStdSliderButtonInputHandler::HandleMouse(wxInputConsumer *consumer,
|
||||
bool wxStdSliderInputHandler::HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event)
|
||||
{
|
||||
wxSlider *slider = wxStaticCast(consumer->GetInputWindow(), wxSlider);
|
||||
@ -1043,7 +1076,7 @@ bool wxStdSliderButtonInputHandler::HandleMouse(wxInputConsumer *consumer,
|
||||
return wxStdInputHandler::HandleMouse(consumer, event);
|
||||
}
|
||||
|
||||
bool wxStdSliderButtonInputHandler::HandleMouseMove(wxInputConsumer *consumer,
|
||||
bool wxStdSliderInputHandler::HandleMouseMove(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event)
|
||||
{
|
||||
wxSlider *slider = wxStaticCast(consumer->GetInputWindow(), wxSlider);
|
||||
@ -1058,10 +1091,10 @@ bool wxStdSliderButtonInputHandler::HandleMouseMove(wxInputConsumer *consumer,
|
||||
}
|
||||
|
||||
bool
|
||||
wxStdSliderButtonInputHandler::HandleFocus(wxInputConsumer * WXUNUSED(consumer),
|
||||
wxStdSliderInputHandler::HandleFocus(wxInputConsumer * WXUNUSED(consumer),
|
||||
const wxFocusEvent& WXUNUSED(event))
|
||||
{
|
||||
// slider's appearance changes when it gets/loses focus
|
||||
// slider appearance changes when it gets/loses focus
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -355,6 +355,14 @@ bool wxSpinButton::PerformAction(const wxControlAction& action,
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxInputHandler *wxSpinButton::GetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
static wxStdSpinButtonInputHandler s_handler(handlerDef);
|
||||
|
||||
return &s_handler;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdSpinButtonInputHandler
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -165,6 +165,33 @@
|
||||
#include "wx/tokenzr.h"
|
||||
#endif // WXDEBUG_TEXT_REPLACE
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdTextCtrlInputHandler: this control handles only the mouse/kbd actions
|
||||
// common to Win32 and GTK, platform-specific things are implemented elsewhere
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdTextCtrlInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdTextCtrlInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
|
||||
|
||||
protected:
|
||||
// get the position of the mouse click
|
||||
static wxTextPos HitTest(const wxTextCtrl *text, const wxPoint& pos);
|
||||
|
||||
// capture data
|
||||
wxTextCtrl *m_winCapture;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private functions
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -4722,6 +4749,14 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxInputHandler *wxTextCtrl::GetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
static wxStdTextCtrlInputHandler s_handler(handlerDef);
|
||||
|
||||
return &s_handler;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdTextCtrlInputHandler
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -57,6 +57,7 @@
|
||||
#endif // wxUSE_TOGGLEBTN
|
||||
|
||||
#include "wx/univ/renderer.h"
|
||||
#include "wx/univ/inpcons.h"
|
||||
#include "wx/univ/inphand.h"
|
||||
#include "wx/univ/colschem.h"
|
||||
#include "wx/univ/theme.h"
|
||||
@ -524,17 +525,15 @@ private:
|
||||
class wxGTKInputHandler : public wxInputHandler
|
||||
{
|
||||
public:
|
||||
wxGTKInputHandler(wxGTKRenderer *renderer);
|
||||
wxGTKInputHandler() { }
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *control,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *control,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *control, const wxMouseEvent& event);
|
||||
|
||||
protected:
|
||||
wxGTKRenderer *m_renderer;
|
||||
virtual bool HandleMouseMove(wxInputConsumer *control,
|
||||
const wxMouseEvent& event);
|
||||
};
|
||||
|
||||
#if wxUSE_SCROLLBAR
|
||||
@ -564,7 +563,8 @@ protected:
|
||||
wxStdScrollBarInputHandler::Press(scrollbar, doIt);
|
||||
}
|
||||
|
||||
virtual bool IsAllowedButton(int WXUNUSED(button)) { return true; }
|
||||
// any button can be used to drag the scrollbar under GTK+
|
||||
virtual bool IsAllowedButton(int WXUNUSED(button)) const { return true; }
|
||||
|
||||
bool IsArrow() const
|
||||
{
|
||||
@ -577,11 +577,11 @@ protected:
|
||||
|
||||
#if wxUSE_CHECKBOX
|
||||
|
||||
class wxGTKCheckboxInputHandler : public wxStdCheckboxInputHandler
|
||||
class wxGTKCheckboxInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxGTKCheckboxInputHandler(wxInputHandler *handler)
|
||||
: wxStdCheckboxInputHandler(handler) { }
|
||||
: wxStdInputHandler(handler) { }
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *control,
|
||||
const wxKeyEvent& event,
|
||||
@ -592,11 +592,11 @@ public:
|
||||
|
||||
#if wxUSE_TEXTCTRL
|
||||
|
||||
class wxGTKTextCtrlInputHandler : public wxStdTextCtrlInputHandler
|
||||
class wxGTKTextCtrlInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxGTKTextCtrlInputHandler(wxInputHandler *handler)
|
||||
: wxStdTextCtrlInputHandler(handler) { }
|
||||
: wxStdInputHandler(handler) { }
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *control,
|
||||
const wxKeyEvent& event,
|
||||
@ -642,13 +642,11 @@ public:
|
||||
|
||||
virtual wxRenderer *GetRenderer();
|
||||
virtual wxArtProvider *GetArtProvider();
|
||||
virtual wxInputHandler *GetInputHandler(const wxString& control);
|
||||
virtual wxInputHandler *GetInputHandler(const wxString& control,
|
||||
wxInputConsumer *consumer);
|
||||
virtual wxColourScheme *GetColourScheme();
|
||||
|
||||
private:
|
||||
// get the default input handler
|
||||
wxInputHandler *GetDefaultInputHandler();
|
||||
|
||||
wxGTKRenderer *m_renderer;
|
||||
|
||||
wxGTKArtProvider *m_artProvider;
|
||||
@ -727,75 +725,50 @@ wxColourScheme *wxGTKTheme::GetColourScheme()
|
||||
return m_scheme;
|
||||
}
|
||||
|
||||
wxInputHandler *wxGTKTheme::GetDefaultInputHandler()
|
||||
{
|
||||
if ( !m_handlerDefault )
|
||||
{
|
||||
m_handlerDefault = new wxGTKInputHandler(m_renderer);
|
||||
}
|
||||
|
||||
return m_handlerDefault;
|
||||
}
|
||||
|
||||
wxInputHandler *wxGTKTheme::GetInputHandler(const wxString& control)
|
||||
wxInputHandler *wxGTKTheme::GetInputHandler(const wxString& control,
|
||||
wxInputConsumer *consumer)
|
||||
{
|
||||
wxInputHandler *handler = NULL;
|
||||
int n = m_handlerNames.Index(control);
|
||||
if ( n == wxNOT_FOUND )
|
||||
{
|
||||
static wxGTKInputHandler s_handlerDef;
|
||||
|
||||
wxInputHandler * const
|
||||
handlerStd = consumer->DoGetStdInputHandler(&s_handlerDef);
|
||||
|
||||
// create a new handler
|
||||
#if wxUSE_CHECKBOX
|
||||
if ( control == wxINP_HANDLER_CHECKBOX )
|
||||
{
|
||||
static wxGTKCheckboxInputHandler s_handler(handlerStd);
|
||||
|
||||
handler = &s_handler;
|
||||
}
|
||||
else
|
||||
#endif // wxUSE_CHECKBOX
|
||||
#if wxUSE_SCROLLBAR
|
||||
if ( control == wxINP_HANDLER_SCROLLBAR )
|
||||
{
|
||||
#if wxUSE_SCROLLBAR
|
||||
handler = new wxGTKScrollBarInputHandler(m_renderer,
|
||||
GetDefaultInputHandler());
|
||||
#endif // wxUSE_SCROLLBAR
|
||||
}
|
||||
#if wxUSE_BUTTON
|
||||
else if ( control == wxINP_HANDLER_BUTTON )
|
||||
handler = new wxStdButtonInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_CHECKBOX
|
||||
#if wxUSE_CHECKBOX
|
||||
else if ( control == wxINP_HANDLER_CHECKBOX )
|
||||
handler = new wxGTKCheckboxInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_CHECKBOX
|
||||
#if wxUSE_COMBOBOX
|
||||
else if ( control == wxINP_HANDLER_COMBOBOX )
|
||||
handler = new wxStdComboBoxInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_COMBOBOX
|
||||
#if wxUSE_LISTBOX
|
||||
else if ( control == wxINP_HANDLER_LISTBOX )
|
||||
handler = new wxStdListboxInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_LISTBOX
|
||||
#if wxUSE_CHECKLISTBOX
|
||||
else if ( control == wxINP_HANDLER_CHECKLISTBOX )
|
||||
handler = new wxStdCheckListboxInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_CHECKLISTBOX
|
||||
#if wxUSE_TEXTCTRL
|
||||
else if ( control == wxINP_HANDLER_TEXTCTRL )
|
||||
handler = new wxGTKTextCtrlInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
#if wxUSE_SLIDER
|
||||
else if ( control == wxINP_HANDLER_SLIDER )
|
||||
handler = new wxStdSliderButtonInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_SLIDER
|
||||
#if wxUSE_SPINBTN
|
||||
else if ( control == wxINP_HANDLER_SPINBTN )
|
||||
handler = new wxStdSpinButtonInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_SPINBTN
|
||||
#if wxUSE_NOTEBOOK
|
||||
else if ( control == wxINP_HANDLER_NOTEBOOK )
|
||||
handler = new wxStdNotebookInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_NOTEBOOK
|
||||
#if wxUSE_TOOLBAR
|
||||
else if ( control == wxINP_HANDLER_TOOLBAR )
|
||||
handler = new wxStdToolbarInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_TOOLBAR
|
||||
else if ( control == wxINP_HANDLER_TOPLEVEL )
|
||||
handler = new wxStdFrameInputHandler(GetDefaultInputHandler());
|
||||
static wxGTKScrollBarInputHandler s_handler(m_renderer, handlerStd);
|
||||
|
||||
if(!handler)
|
||||
handler = GetDefaultInputHandler();
|
||||
handler = &s_handler;
|
||||
}
|
||||
else
|
||||
#endif // wxUSE_SCROLLBAR
|
||||
#if wxUSE_TEXTCTRL
|
||||
if ( control == wxINP_HANDLER_TEXTCTRL )
|
||||
{
|
||||
static wxGTKTextCtrlInputHandler s_handler(handlerStd);
|
||||
|
||||
handler = &s_handler;
|
||||
}
|
||||
else
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
{
|
||||
// no special handler for this control
|
||||
handler = handlerStd;
|
||||
}
|
||||
|
||||
n = m_handlerNames.Add(control);
|
||||
m_handlers.Insert(handler, n);
|
||||
@ -3331,11 +3304,6 @@ wxBitmap wxGTKArtProvider::CreateBitmap(const wxArtID& id,
|
||||
// wxGTKInputHandler
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxGTKInputHandler::wxGTKInputHandler(wxGTKRenderer *renderer)
|
||||
{
|
||||
m_renderer = renderer;
|
||||
}
|
||||
|
||||
bool wxGTKInputHandler::HandleKey(wxInputConsumer * WXUNUSED(control),
|
||||
const wxKeyEvent& WXUNUSED(event),
|
||||
bool WXUNUSED(pressed))
|
||||
@ -3495,7 +3463,7 @@ bool wxGTKTextCtrlInputHandler::HandleKey(wxInputConsumer *control,
|
||||
}
|
||||
}
|
||||
|
||||
return wxStdTextCtrlInputHandler::HandleKey(control, event, pressed);
|
||||
return wxStdInputHandler::HandleKey(control, event, pressed);
|
||||
}
|
||||
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
|
@ -41,10 +41,6 @@
|
||||
#include "wx/textctrl.h"
|
||||
#include "wx/toolbar.h"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
// for COLOR_* constants
|
||||
#include "wx/msw/private.h"
|
||||
#endif
|
||||
#include "wx/menu.h"
|
||||
#include "wx/settings.h"
|
||||
#include "wx/toplevel.h"
|
||||
@ -56,6 +52,7 @@
|
||||
|
||||
#include "wx/univ/scrtimer.h"
|
||||
#include "wx/univ/renderer.h"
|
||||
#include "wx/univ/inpcons.h"
|
||||
#include "wx/univ/inphand.h"
|
||||
#include "wx/univ/colschem.h"
|
||||
#include "wx/univ/theme.h"
|
||||
@ -152,8 +149,10 @@ public:
|
||||
|
||||
virtual wxRenderer *GetRenderer();
|
||||
virtual wxArtProvider *GetArtProvider();
|
||||
virtual wxInputHandler *GetInputHandler(const wxString& control);
|
||||
virtual wxInputHandler *GetInputHandler(const wxString& control,
|
||||
wxInputConsumer *consumer);
|
||||
virtual wxColourScheme *GetColourScheme();
|
||||
|
||||
private:
|
||||
bool GetOrCreateTheme()
|
||||
{
|
||||
@ -161,7 +160,7 @@ private:
|
||||
m_win32Theme = wxTheme::Create( wxT("win32") );
|
||||
return m_win32Theme != NULL;
|
||||
}
|
||||
private:
|
||||
|
||||
wxTheme *m_win32Theme;
|
||||
wxMetalRenderer *m_renderer;
|
||||
|
||||
@ -208,11 +207,12 @@ wxArtProvider *wxMetalTheme::GetArtProvider()
|
||||
return m_win32Theme->GetArtProvider();
|
||||
}
|
||||
|
||||
wxInputHandler *wxMetalTheme::GetInputHandler(const wxString& control)
|
||||
wxInputHandler *wxMetalTheme::GetInputHandler(const wxString& control,
|
||||
wxInputConsumer *consumer)
|
||||
{
|
||||
if ( !GetOrCreateTheme() )
|
||||
return 0;
|
||||
return m_win32Theme->GetInputHandler(control);
|
||||
return m_win32Theme->GetInputHandler(control, consumer);
|
||||
}
|
||||
|
||||
wxColourScheme *wxMetalTheme::GetColourScheme()
|
||||
@ -227,7 +227,7 @@ wxColourScheme *wxMetalTheme::GetColourScheme()
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxMetalRenderer::wxMetalRenderer(wxRenderer *renderer, wxColourScheme *scheme)
|
||||
: wxDelegateRenderer(renderer)
|
||||
: wxDelegateRenderer(renderer)
|
||||
{
|
||||
// init colours and pens
|
||||
m_penBlack = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_DARK), 0, wxSOLID);
|
||||
|
@ -62,6 +62,7 @@
|
||||
|
||||
#include "wx/univ/scrtimer.h"
|
||||
#include "wx/univ/renderer.h"
|
||||
#include "wx/univ/inpcons.h"
|
||||
#include "wx/univ/inphand.h"
|
||||
#include "wx/univ/colschem.h"
|
||||
#include "wx/univ/theme.h"
|
||||
@ -553,34 +554,31 @@ private:
|
||||
class wxWin32InputHandler : public wxInputHandler
|
||||
{
|
||||
public:
|
||||
wxWin32InputHandler(wxWin32Renderer *renderer);
|
||||
wxWin32InputHandler() { }
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *control,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *control,
|
||||
const wxMouseEvent& event);
|
||||
|
||||
protected:
|
||||
wxWin32Renderer *m_renderer;
|
||||
};
|
||||
|
||||
#if wxUSE_SCROLLBAR
|
||||
class wxWin32ScrollBarInputHandler : public wxStdScrollBarInputHandler
|
||||
{
|
||||
public:
|
||||
wxWin32ScrollBarInputHandler(wxWin32Renderer *renderer,
|
||||
wxWin32ScrollBarInputHandler(wxRenderer *renderer,
|
||||
wxInputHandler *handler);
|
||||
|
||||
virtual bool HandleMouse(wxInputConsumer *control, const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *control, const wxMouseEvent& event);
|
||||
virtual bool HandleMouse(wxInputConsumer *control,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *control,
|
||||
const wxMouseEvent& event);
|
||||
|
||||
virtual bool OnScrollTimer(wxScrollBar *scrollbar,
|
||||
const wxControlAction& action);
|
||||
|
||||
protected:
|
||||
virtual bool IsAllowedButton(int button) { return button == 1; }
|
||||
|
||||
virtual void Highlight(wxScrollBar * WXUNUSED(scrollbar),
|
||||
bool WXUNUSED(doIt))
|
||||
{
|
||||
@ -600,11 +598,11 @@ protected:
|
||||
#endif // wxUSE_SCROLLBAR
|
||||
|
||||
#if wxUSE_CHECKBOX
|
||||
class wxWin32CheckboxInputHandler : public wxStdCheckboxInputHandler
|
||||
class wxWin32CheckboxInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxWin32CheckboxInputHandler(wxInputHandler *handler)
|
||||
: wxStdCheckboxInputHandler(handler) { }
|
||||
: wxStdInputHandler(handler) { }
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *control,
|
||||
const wxKeyEvent& event,
|
||||
@ -613,11 +611,11 @@ public:
|
||||
#endif // wxUSE_CHECKBOX
|
||||
|
||||
#if wxUSE_TEXTCTRL
|
||||
class wxWin32TextCtrlInputHandler : public wxStdTextCtrlInputHandler
|
||||
class wxWin32TextCtrlInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxWin32TextCtrlInputHandler(wxInputHandler *handler)
|
||||
: wxStdTextCtrlInputHandler(handler) { }
|
||||
: wxStdInputHandler(handler) { }
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *control,
|
||||
const wxKeyEvent& event,
|
||||
@ -650,7 +648,7 @@ private:
|
||||
|
||||
class wxWin32SystemMenuEvtHandler;
|
||||
|
||||
class wxWin32FrameInputHandler : public wxStdFrameInputHandler
|
||||
class wxWin32FrameInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxWin32FrameInputHandler(wxInputHandler *handler);
|
||||
@ -707,13 +705,11 @@ public:
|
||||
|
||||
virtual wxRenderer *GetRenderer();
|
||||
virtual wxArtProvider *GetArtProvider();
|
||||
virtual wxInputHandler *GetInputHandler(const wxString& control);
|
||||
virtual wxInputHandler *GetInputHandler(const wxString& control,
|
||||
wxInputConsumer *consumer);
|
||||
virtual wxColourScheme *GetColourScheme();
|
||||
|
||||
private:
|
||||
// get the default input handler
|
||||
wxInputHandler *GetDefaultInputHandler();
|
||||
|
||||
wxWin32Renderer *m_renderer;
|
||||
|
||||
wxWin32ArtProvider *m_artProvider;
|
||||
@ -723,8 +719,6 @@ private:
|
||||
wxSortedArrayString m_handlerNames;
|
||||
wxArrayHandlers m_handlers;
|
||||
|
||||
wxWin32InputHandler *m_handlerDefault;
|
||||
|
||||
wxWin32ColourScheme *m_scheme;
|
||||
|
||||
WX_DECLARE_THEME(win32)
|
||||
@ -1275,21 +1269,11 @@ wxWin32Theme::wxWin32Theme()
|
||||
{
|
||||
m_scheme = NULL;
|
||||
m_renderer = NULL;
|
||||
m_handlerDefault = NULL;
|
||||
m_artProvider = NULL;
|
||||
}
|
||||
|
||||
wxWin32Theme::~wxWin32Theme()
|
||||
{
|
||||
size_t count = m_handlers.GetCount();
|
||||
for ( size_t n = 0; n < count; n++ )
|
||||
{
|
||||
if ( m_handlers[n] != m_handlerDefault )
|
||||
delete m_handlers[n];
|
||||
}
|
||||
|
||||
delete m_handlerDefault;
|
||||
|
||||
delete m_renderer;
|
||||
delete m_scheme;
|
||||
wxArtProvider::RemoveProvider(m_artProvider);
|
||||
@ -1315,79 +1299,63 @@ wxArtProvider *wxWin32Theme::GetArtProvider()
|
||||
return m_artProvider;
|
||||
}
|
||||
|
||||
wxInputHandler *wxWin32Theme::GetDefaultInputHandler()
|
||||
{
|
||||
if ( !m_handlerDefault )
|
||||
{
|
||||
m_handlerDefault = new wxWin32InputHandler(m_renderer);
|
||||
}
|
||||
|
||||
return m_handlerDefault;
|
||||
}
|
||||
|
||||
wxInputHandler *wxWin32Theme::GetInputHandler(const wxString& control)
|
||||
wxInputHandler *
|
||||
wxWin32Theme::GetInputHandler(const wxString& control,
|
||||
wxInputConsumer *consumer)
|
||||
{
|
||||
wxInputHandler *handler = NULL;
|
||||
int n = m_handlerNames.Index(control);
|
||||
if ( n == wxNOT_FOUND )
|
||||
{
|
||||
static wxWin32InputHandler s_handlerDef;
|
||||
|
||||
wxInputHandler * const
|
||||
handlerStd = consumer->DoGetStdInputHandler(&s_handlerDef);
|
||||
|
||||
// create a new handler
|
||||
if ( control == wxINP_HANDLER_SCROLLBAR )
|
||||
if ( control == wxINP_HANDLER_TOPLEVEL )
|
||||
{
|
||||
#if wxUSE_SCROLLBAR
|
||||
handler = new wxWin32ScrollBarInputHandler(m_renderer,
|
||||
GetDefaultInputHandler());
|
||||
#endif // wxUSE_SCROLLBAR
|
||||
static wxWin32FrameInputHandler s_handler(handlerStd);
|
||||
|
||||
handler = &s_handler;
|
||||
}
|
||||
#if wxUSE_BUTTON
|
||||
else if ( control == wxINP_HANDLER_BUTTON )
|
||||
handler = new wxStdButtonInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_BUTTON
|
||||
#if wxUSE_CHECKBOX
|
||||
else if ( control == wxINP_HANDLER_CHECKBOX )
|
||||
handler = new wxWin32CheckboxInputHandler(GetDefaultInputHandler());
|
||||
{
|
||||
static wxWin32CheckboxInputHandler s_handler(handlerStd);
|
||||
|
||||
handler = &s_handler;
|
||||
}
|
||||
#endif // wxUSE_CHECKBOX
|
||||
#if wxUSE_COMBOBOX
|
||||
else if ( control == wxINP_HANDLER_COMBOBOX )
|
||||
handler = new wxStdComboBoxInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_COMBOBOX
|
||||
#if wxUSE_LISTBOX
|
||||
else if ( control == wxINP_HANDLER_LISTBOX )
|
||||
handler = new wxStdListboxInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_LISTBOX
|
||||
#if wxUSE_CHECKLISTBOX
|
||||
else if ( control == wxINP_HANDLER_CHECKLISTBOX )
|
||||
handler = new wxStdCheckListboxInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_CHECKLISTBOX
|
||||
#if wxUSE_TEXTCTRL
|
||||
else if ( control == wxINP_HANDLER_TEXTCTRL )
|
||||
handler = new wxWin32TextCtrlInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
#if wxUSE_SLIDER
|
||||
else if ( control == wxINP_HANDLER_SLIDER )
|
||||
handler = new wxStdSliderButtonInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_SLIDER
|
||||
#if wxUSE_SPINBTN
|
||||
else if ( control == wxINP_HANDLER_SPINBTN )
|
||||
handler = new wxStdSpinButtonInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_SPINBTN
|
||||
#if wxUSE_NOTEBOOK
|
||||
else if ( control == wxINP_HANDLER_NOTEBOOK )
|
||||
handler = new wxStdNotebookInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_NOTEBOOK
|
||||
#if wxUSE_SCROLLBAR
|
||||
else if ( control == wxINP_HANDLER_SCROLLBAR )
|
||||
{
|
||||
static wxWin32ScrollBarInputHandler
|
||||
s_handler(GetRenderer(), handlerStd);
|
||||
|
||||
handler = &s_handler;
|
||||
}
|
||||
#endif // wxUSE_SCROLLBAR
|
||||
#if wxUSE_STATUSBAR
|
||||
else if ( control == wxINP_HANDLER_STATUSBAR )
|
||||
handler = new wxWin32StatusBarInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_STATUSBAR
|
||||
#if wxUSE_TOOLBAR
|
||||
else if ( control == wxINP_HANDLER_TOOLBAR )
|
||||
handler = new wxStdToolbarInputHandler(GetDefaultInputHandler());
|
||||
#endif // wxUSE_TOOLBAR
|
||||
else if ( control == wxINP_HANDLER_TOPLEVEL )
|
||||
handler = new wxWin32FrameInputHandler(GetDefaultInputHandler());
|
||||
{
|
||||
static wxWin32StatusBarInputHandler s_handler(handlerStd);
|
||||
|
||||
if(!handler)
|
||||
handler = GetDefaultInputHandler();
|
||||
handler = &s_handler;
|
||||
}
|
||||
#endif // wxUSE_STATUSBAR
|
||||
#if wxUSE_TEXTCTRL
|
||||
else if ( control == wxINP_HANDLER_TEXTCTRL )
|
||||
{
|
||||
static wxWin32TextCtrlInputHandler s_handler(handlerStd);
|
||||
|
||||
handler = &s_handler;
|
||||
}
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
else // no special handler for this control
|
||||
{
|
||||
handler = handlerStd;
|
||||
}
|
||||
|
||||
n = m_handlerNames.Add(control);
|
||||
m_handlers.Insert(handler, n);
|
||||
@ -4425,7 +4393,7 @@ void wxWin32Renderer::AdjustSize(wxSize *size, const wxWindow *window)
|
||||
// skip border width adjustments, they don't make sense for us
|
||||
return;
|
||||
}
|
||||
#endif // wxUSE_SCROLLBAR/!wxUSE_SCROLLBAR
|
||||
#endif // wxUSE_SCROLLBAR
|
||||
|
||||
#if wxUSE_BMPBUTTON
|
||||
if ( wxDynamicCast(window, wxBitmapButton) )
|
||||
@ -4486,11 +4454,6 @@ void wxWin32Renderer::AdjustSize(wxSize *size, const wxWindow *window)
|
||||
// wxWin32InputHandler
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxWin32InputHandler::wxWin32InputHandler(wxWin32Renderer *renderer)
|
||||
{
|
||||
m_renderer = renderer;
|
||||
}
|
||||
|
||||
bool wxWin32InputHandler::HandleKey(wxInputConsumer * WXUNUSED(control),
|
||||
const wxKeyEvent& WXUNUSED(event),
|
||||
bool WXUNUSED(pressed))
|
||||
@ -4506,8 +4469,8 @@ bool wxWin32InputHandler::HandleMouse(wxInputConsumer *control,
|
||||
{
|
||||
wxWindow *win = control->GetInputWindow();
|
||||
|
||||
if (( wxWindow::FindFocus() != control->GetInputWindow() ) &&
|
||||
( win->AcceptsFocus() ) )
|
||||
if ( (wxWindow::FindFocus() != control->GetInputWindow()) &&
|
||||
win->AcceptsFocus() )
|
||||
{
|
||||
win->SetFocus();
|
||||
|
||||
@ -4525,8 +4488,7 @@ bool wxWin32InputHandler::HandleMouse(wxInputConsumer *control,
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxWin32ScrollBarInputHandler::
|
||||
wxWin32ScrollBarInputHandler(wxWin32Renderer *renderer,
|
||||
wxInputHandler *handler)
|
||||
wxWin32ScrollBarInputHandler(wxRenderer *renderer, wxInputHandler *handler)
|
||||
: wxStdScrollBarInputHandler(renderer, handler)
|
||||
{
|
||||
m_scrollPaused = false;
|
||||
@ -4699,7 +4661,7 @@ bool wxWin32ScrollBarInputHandler::HandleMouseMove(wxInputConsumer *control,
|
||||
}
|
||||
}
|
||||
|
||||
return wxStdScrollBarInputHandler::HandleMouseMove(control, event);
|
||||
return wxStdInputHandler::HandleMouseMove(control, event);
|
||||
}
|
||||
|
||||
#endif // wxUSE_SCROLLBAR
|
||||
@ -4786,7 +4748,7 @@ bool wxWin32TextCtrlInputHandler::HandleKey(wxInputConsumer *control,
|
||||
}
|
||||
}
|
||||
|
||||
return wxStdTextCtrlInputHandler::HandleKey(control, event, pressed);
|
||||
return wxStdInputHandler::HandleKey(control, event, pressed);
|
||||
}
|
||||
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
@ -4913,8 +4875,8 @@ private:
|
||||
#endif
|
||||
};
|
||||
|
||||
wxWin32SystemMenuEvtHandler::wxWin32SystemMenuEvtHandler(
|
||||
wxWin32FrameInputHandler *handler)
|
||||
wxWin32SystemMenuEvtHandler::
|
||||
wxWin32SystemMenuEvtHandler(wxWin32FrameInputHandler *handler)
|
||||
{
|
||||
m_inputHnd = handler;
|
||||
m_wnd = NULL;
|
||||
@ -4994,7 +4956,7 @@ void wxWin32SystemMenuEvtHandler::OnClose(wxCloseEvent &event)
|
||||
|
||||
|
||||
wxWin32FrameInputHandler::wxWin32FrameInputHandler(wxInputHandler *handler)
|
||||
: wxStdFrameInputHandler(handler)
|
||||
: wxStdInputHandler(handler)
|
||||
{
|
||||
m_menuHandler = new wxWin32SystemMenuEvtHandler(this);
|
||||
}
|
||||
@ -5040,7 +5002,7 @@ bool wxWin32FrameInputHandler::HandleMouse(wxInputConsumer *consumer,
|
||||
}
|
||||
}
|
||||
|
||||
return wxStdFrameInputHandler::HandleMouse(consumer, event);
|
||||
return wxStdInputHandler::HandleMouse(consumer, event);
|
||||
}
|
||||
|
||||
#if wxUSE_MENUS
|
||||
@ -5095,5 +5057,5 @@ bool wxWin32FrameInputHandler::HandleActivation(wxInputConsumer *consumer,
|
||||
}
|
||||
}
|
||||
|
||||
return wxStdFrameInputHandler::HandleActivation(consumer, activated);
|
||||
return wxStdInputHandler::HandleActivation(consumer, activated);
|
||||
}
|
||||
|
@ -40,6 +40,31 @@
|
||||
|
||||
#include "wx/univ/renderer.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdToolbarInputHandler: translates SPACE and ENTER keys and the left mouse
|
||||
// click into button press/release actions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdToolbarInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdToolbarInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleKey(wxInputConsumer *consumer,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event);
|
||||
virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
|
||||
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
|
||||
|
||||
private:
|
||||
wxWindow *m_winCapture;
|
||||
wxToolBarToolBase *m_toolCapture;
|
||||
wxToolBarToolBase *m_toolLast;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -818,6 +843,14 @@ bool wxToolBar::PerformAction(const wxControlAction& action,
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxInputHandler *wxToolBar::GetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
static wxStdToolbarInputHandler s_handler(handlerDef);
|
||||
|
||||
return &s_handler;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// wxStdToolbarInputHandler implementation
|
||||
// ============================================================================
|
||||
|
@ -35,6 +35,29 @@
|
||||
#include "wx/cshelp.h"
|
||||
#include "wx/evtloop.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdTLWInputHandler: handles focus, resizing and titlebar buttons clicks
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdTLWInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdTLWInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event);
|
||||
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
|
||||
|
||||
private:
|
||||
// the window (button) which has capture or NULL and the last hittest result
|
||||
wxTopLevelWindow *m_winCapture;
|
||||
long m_winHitTest;
|
||||
long m_winPressed;
|
||||
bool m_borderCursorOn;
|
||||
wxCursor m_origCursor;
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event tables
|
||||
@ -780,13 +803,21 @@ void wxTopLevelWindow::OnSystemMenu(wxCommandEvent& event)
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxInputHandler *
|
||||
wxTopLevelWindow::GetStdInputHandler(wxInputHandler *handlerDef)
|
||||
{
|
||||
static wxStdTLWInputHandler s_handler(handlerDef);
|
||||
|
||||
return &s_handler;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// wxStdFrameInputHandler: handles focus, resizing and titlebar buttons clicks
|
||||
// wxStdTLWInputHandler: handles focus, resizing and titlebar buttons clicks
|
||||
// ============================================================================
|
||||
|
||||
wxStdFrameInputHandler::wxStdFrameInputHandler(wxInputHandler *inphand)
|
||||
: wxStdInputHandler(inphand)
|
||||
wxStdTLWInputHandler::wxStdTLWInputHandler(wxInputHandler *inphand)
|
||||
: wxStdInputHandler(inphand)
|
||||
{
|
||||
m_winCapture = NULL;
|
||||
m_winHitTest = 0;
|
||||
@ -794,8 +825,8 @@ wxStdFrameInputHandler::wxStdFrameInputHandler(wxInputHandler *inphand)
|
||||
m_borderCursorOn = false;
|
||||
}
|
||||
|
||||
bool wxStdFrameInputHandler::HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event)
|
||||
bool wxStdTLWInputHandler::HandleMouse(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event)
|
||||
{
|
||||
// the button has 2 states: pressed and normal with the following
|
||||
// transitions between them:
|
||||
@ -855,8 +886,8 @@ bool wxStdFrameInputHandler::HandleMouse(wxInputConsumer *consumer,
|
||||
return wxStdInputHandler::HandleMouse(consumer, event);
|
||||
}
|
||||
|
||||
bool wxStdFrameInputHandler::HandleMouseMove(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event)
|
||||
bool wxStdTLWInputHandler::HandleMouseMove(wxInputConsumer *consumer,
|
||||
const wxMouseEvent& event)
|
||||
{
|
||||
if ( event.GetEventObject() == m_winCapture )
|
||||
{
|
||||
@ -906,8 +937,8 @@ bool wxStdFrameInputHandler::HandleMouseMove(wxInputConsumer *consumer,
|
||||
return wxStdInputHandler::HandleMouseMove(consumer, event);
|
||||
}
|
||||
|
||||
bool wxStdFrameInputHandler::HandleActivation(wxInputConsumer *consumer,
|
||||
bool activated)
|
||||
bool wxStdTLWInputHandler::HandleActivation(wxInputConsumer *consumer,
|
||||
bool activated)
|
||||
{
|
||||
if ( m_borderCursorOn )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user