]> git.saurik.com Git - wxWidgets.git/commitdiff
Many changes for wxInputHandler creation mainly related to:
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 14 Sep 2006 19:36:47 +0000 (19:36 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 14 Sep 2006 19:36:47 +0000 (19:36 +0000)
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

30 files changed:
include/wx/univ/button.h
include/wx/univ/checkbox.h
include/wx/univ/checklst.h
include/wx/univ/combobox.h
include/wx/univ/inpcons.h
include/wx/univ/listbox.h
include/wx/univ/notebook.h
include/wx/univ/scrolbar.h
include/wx/univ/slider.h
include/wx/univ/spinbutt.h
include/wx/univ/textctrl.h
include/wx/univ/theme.h
include/wx/univ/toolbar.h
include/wx/univ/toplevel.h
src/univ/button.cpp
src/univ/checkbox.cpp
src/univ/checklst.cpp
src/univ/combobox.cpp
src/univ/inpcons.cpp
src/univ/listbox.cpp
src/univ/notebook.cpp
src/univ/scrolbar.cpp
src/univ/slider.cpp
src/univ/spinbutt.cpp
src/univ/textctrl.cpp
src/univ/themes/gtk.cpp
src/univ/themes/metal.cpp
src/univ/themes/win32.cpp
src/univ/toolbar.cpp
src/univ/topluniv.cpp

index 44fe29ddbf2c336b1d5a536dc640d0830a341637..b9ce26f632f0ed5fd6b89ccad5c4c4cc18122100 100644 (file)
@@ -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_
 
index ba0abc8e7718a7a70c3eea09841f32d91ff5b5ed..c7ffee5be975317eac7bbc94bf5305809dbed739 100644 (file)
 // 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_
index 619ab94038f1adfea26f178ae4a522b0e9423223..e6afd10a16e3894176837433133f09ea767e01a2 100644 (file)
@@ -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_
index d3d8027426b0e8ddde68b6107545a65f79c022ee..383582c06fb6eedb7a64261bbf311d341061789a 100644 (file)
@@ -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_
index 28f6b7ee5261bf760a4ae441801a5cdbba78142e..0fbd1ba2da9504c35859381ddaaf9a4669a4b9e7 100644 (file)
@@ -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;
 };
 
index 837095cc864638f6fe8b8548cdf53add3e1800f8..2edbdc1003b630fbc96da02208f6c640840b739e 100644 (file)
@@ -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_
index 43e2d4ce9dfaa0efa563e8c3d9e40f5c2f765f4b..c87ad704fbe427636566c849741831167a0fe769 100644 (file)
@@ -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_
 
index 527455b40cb59ab8b9e88647f127aac70d46ba21..8580977eb13cd63bc6bfabafd11e997aaa1f7259 100644 (file)
@@ -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;
index ac92c6a8733152bbb06ad5808cb3a16ce90c2fd1..acb54538b60a758f952493527f1fe68f5b13e04f 100644 (file)
@@ -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_
index 9be652051401df03bc1813489d9411d47caa8cae..9f74d2b648c35c7e82435cd056a9420029c4f5e2 100644 (file)
@@ -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);
index 667ee48b9eed9d76d1e80ca40c956662109649d9..018454e8f9d7ed9d66e35b71e6eede2ed792900e 100644 (file)
@@ -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_
 
index 977ad08e966c1a77d5b90649e14fe2633cfe7b3b..64417f09001cd9e5780d5330520638201aa4f539 100644 (file)
 // wxTheme
 // ----------------------------------------------------------------------------
 
-class WXDLLEXPORT wxRenderer;
+class WXDLLEXPORT wxArtProvider;
 class WXDLLEXPORT wxColourScheme;
+class WXDLLEXPORT wxInputConsumer;
 class WXDLLEXPORT wxInputHandler;
-class WXDLLEXPORT wxArtProvider;
+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;
index feb9ae4bc3b26f87e3b7752b3be7d13104978219..1743a174fbaa7fa1c855e9e633e3e563cd84789e 100644 (file)
@@ -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_
index 4cb89dbf36057019dad5e3bc47583ea50a547280..7350e71e91b7f6df27ae718a037d6afc8b5548e2 100644 (file)
@@ -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__
index 995a3becaafc756434046b75cfed3584b6a4846f..39ac1eb1b84006aaa5ac22e51dd8f5cbbeb829d0 100644 (file)
 #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
 // ----------------------------------------------------------------------------
index d02c0c1d0b264124d938ac0ae03a7af1125547be..de5865cb8434be11577465f980c58346d54b4270 100644 (file)
 #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))
 {
 }
 
index 5633b9d24c4e38e1bb3e209b7c5acb5965848609..95e1af791dd924541be6a30fc46a796dff3dae66 100644 (file)
 #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
index 4c011c1a7e1d34af4d75b6cfaa4e097b89d93274..28ae78ee6d4f6d545a0af13498fc1be5da241cd9 100644 (file)
 #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
index e0b85433f0b9c3bad8cb59451bfe155d964068db..34743eff776efc0ae2830a2b3ccc2bf2cd66802b 100644 (file)
@@ -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)
index 45e5f77e870c4a1db674fdf1c29cd44bb250a3cf..a2697e5b41310e86e9afec18db5d42271a05d67c 100644 (file)
 #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
 // ============================================================================
index 237b4b73e25b1d687b823f0303faa0d1a5b50ba8..be60137093c8c447e18bf5325cf3c91447ee72b2 100644 (file)
 
 #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
 // ----------------------------------------------------------------------------
index f446c73f340bdb26b8656f0d271e60522253d7e9..c9f56e5c74c0d972dc8aa78a11d0b4b91f6db52d 100644 (file)
@@ -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);
index 01bd035af20a6fe5da4bc4b968f1acf9fcb03a3a..4df2aae29a84810976ef866ca7ce4adba8d2d65a 100644 (file)
 #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;
 }
 
index 93e674502a7de4a9c8ea3d547dc5046e74f28a61..5090c6329d5f751516b90bb4ac8a93ac5c522515 100644 (file)
@@ -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
 // ----------------------------------------------------------------------------
index 54c170b068581363b8e42ba026e42662b1b984cf..5dc742581b5f08660ede6e57ce4ecdce5f87e080 100644 (file)
     #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
 // ----------------------------------------------------------------------------
index e731e6b50e75abf80db271686488c1d04aa5bb1b..6a09c6f0d648a1cb917cce2c08ed54104959e6bc 100644 (file)
@@ -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 ( control == wxINP_HANDLER_SCROLLBAR )
+#if wxUSE_CHECKBOX
+        if ( control == wxINP_HANDLER_CHECKBOX )
         {
-#if wxUSE_SCROLLBAR
-            handler = new wxGTKScrollBarInputHandler(m_renderer,
-                                                     GetDefaultInputHandler());
-#endif // wxUSE_SCROLLBAR
+            static wxGTKCheckboxInputHandler s_handler(handlerStd);
+
+            handler = &s_handler;
         }
-#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());
+        else
 #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_SCROLLBAR
+        if ( control == wxINP_HANDLER_SCROLLBAR )
+        {
+            static wxGTKScrollBarInputHandler s_handler(m_renderer, handlerStd);
+
+            handler = &s_handler;
+        }
+        else
+#endif // wxUSE_SCROLLBAR
 #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());
+        if ( control == wxINP_HANDLER_TEXTCTRL )
+        {
+            static wxGTKTextCtrlInputHandler s_handler(handlerStd);
 
-        if(!handler)
-            handler = GetDefaultInputHandler();
+            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
index 39647e7eac7b202b9289ec18d67909d1ddae71b3..8c34633fa030f7a47356cbd717722eecfae3ff1c 100644 (file)
     #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);
index 6608ee824a5c71a5eb16287c002a0dc9b4766e95..0c89b814ae41a8e13009a7a7483934feddf82e78 100644 (file)
@@ -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());
+        {
+            static wxWin32StatusBarInputHandler s_handler(handlerStd);
+
+            handler = &s_handler;
+        }
 #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());
+#if wxUSE_TEXTCTRL
+        else if ( control == wxINP_HANDLER_TEXTCTRL )
+        {
+            static wxWin32TextCtrlInputHandler s_handler(handlerStd);
 
-        if(!handler)
-            handler = GetDefaultInputHandler();
+            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);
 }
index a6d53027834ae887af453e34206e5310f41c037a..0ab62234b0da33e48ff42078ab86250ad2fc496c 100644 (file)
 
 #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
 // ============================================================================
index ec7f1d665247f617b541a77743c22dae0f7665ec..3d0f437c5b7fd331c056b3b29771b49db6ad1aac 100644 (file)
 #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 )
     {