Create(parent, id, bitmap, label, pos, size, style, validator, name);
}
-
+
wxButton(wxWindow *parent,
wxWindowID id,
const wxString& label = wxEmptyString,
return Create(parent, id, wxNullBitmap, label,
pos, size, style, validator, name);
}
-
+
bool Create(wxWindow *parent,
wxWindowID id,
const wxBitmap& bitmap,
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);
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_
// wxCheckBox
// ----------------------------------------------------------------------------
-// X11 headers may define this
-#ifdef Status
-#undef Status
-#endif
-
class WXDLLEXPORT wxCheckBox : public wxCheckBoxBase
{
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));
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_
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);
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_
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);
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_
{
public:
wxInputConsumer() { m_inputHandler = NULL; }
- virtual ~wxInputConsumer() {}
+ virtual ~wxInputConsumer() { }
// get the input handler
wxInputHandler *GetInputHandler() const { return m_inputHandler; }
// 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);
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;
};
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();
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_
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();
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_
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)
};
// ----------------------------------------------------------------------------
-// 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
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
// 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;
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
{
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_
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);
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);
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_
// 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
// 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;
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxToolBar : public wxToolBarBase
-{
+{
public:
// construction/destruction
wxToolBar() { Init(); }
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxToolBarNameStr );
-
+
virtual ~wxToolBar();
virtual bool Realize();
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();
// (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;
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_
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);
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__
#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
// ----------------------------------------------------------------------------
return true;
}
+/* static */
+wxInputHandler *wxButton::GetStdInputHandler(wxInputHandler *handlerDef)
+{
+ static wxStdButtonInputHandler s_handlerBtn(handlerDef);
+
+ return &s_handlerBtn;
+}
+
// ----------------------------------------------------------------------------
// misc
// ----------------------------------------------------------------------------
#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
// ============================================================================
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))
{
}
#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
// ============================================================================
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))
{
}
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,
}
}
- return wxStdListboxInputHandler::HandleMouse(consumer, event);
+ return wxStdInputHandler::HandleMouse(consumer, event);
}
#endif // wxUSE_CHECKLISTBOX
#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
return wxStdInputHandler::HandleKey(consumer, event, pressed);
}
+/* static */
+wxInputHandler *wxComboBox::GetStdInputHandler(wxInputHandler *handlerDef)
+{
+ static wxStdComboBoxInputHandler s_handler(handlerDef);
+
+ return &s_handler;
+}
#endif // wxUSE_COMBOBOX
// 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)
#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
// ============================================================================
return true;
}
+/* static */
+wxInputHandler *wxListBox::GetStdInputHandler(wxInputHandler *handlerDef)
+{
+ static wxStdListboxInputHandler s_handler(handlerDef);
+
+ return &s_handler;
+}
+
// ============================================================================
// implementation of wxStdListboxInputHandler
// ============================================================================
#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
// ----------------------------------------------------------------------------
return true;
}
+/* static */
+wxInputHandler *wxNotebook::GetStdInputHandler(wxInputHandler *handlerDef)
+{
+ static wxStdNotebookInputHandler s_handler(handlerDef);
+
+ return &s_handler;
+}
+
// ----------------------------------------------------------------------------
// wxStdNotebookInputHandler
// ----------------------------------------------------------------------------
return true;
}
+/* static */
+wxInputHandler *wxScrollBar::GetStdInputHandler(wxInputHandler *handlerDef)
+{
+ static wxStdScrollBarInputHandler
+ s_handler(wxTheme::Get()->GetRenderer(), handlerDef);
+
+ return &s_handler;
+}
+
// ============================================================================
// scroll bar input handler
// ============================================================================
{
// 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);
#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
// ----------------------------------------------------------------------------
return true;
}
+/* static */
+wxInputHandler *wxSlider::GetStdInputHandler(wxInputHandler *handlerDef)
+{
+ static wxStdSliderInputHandler s_handler(handlerDef);
+
+ return &s_handler;
+}
+
// ----------------------------------------------------------------------------
// wxSlider implementation of wxControlWithThumb interface
// ----------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------
-// wxStdSliderButtonInputHandler
+// wxStdSliderInputHandler
// ----------------------------------------------------------------------------
-bool wxStdSliderButtonInputHandler::HandleKey(wxInputConsumer *consumer,
+bool wxStdSliderInputHandler::HandleKey(wxInputConsumer *consumer,
const wxKeyEvent& event,
bool pressed)
{
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);
return wxStdInputHandler::HandleMouse(consumer, event);
}
-bool wxStdSliderButtonInputHandler::HandleMouseMove(wxInputConsumer *consumer,
+bool wxStdSliderInputHandler::HandleMouseMove(wxInputConsumer *consumer,
const wxMouseEvent& event)
{
wxSlider *slider = wxStaticCast(consumer->GetInputWindow(), wxSlider);
}
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;
}
return true;
}
+/* static */
+wxInputHandler *wxSpinButton::GetStdInputHandler(wxInputHandler *handlerDef)
+{
+ static wxStdSpinButtonInputHandler s_handler(handlerDef);
+
+ return &s_handler;
+}
+
// ----------------------------------------------------------------------------
// wxStdSpinButtonInputHandler
// ----------------------------------------------------------------------------
#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
// ----------------------------------------------------------------------------
event.Skip();
}
+/* static */
+wxInputHandler *wxTextCtrl::GetStdInputHandler(wxInputHandler *handlerDef)
+{
+ static wxStdTextCtrlInputHandler s_handler(handlerDef);
+
+ return &s_handler;
+}
+
// ----------------------------------------------------------------------------
// wxStdTextCtrlInputHandler
// ----------------------------------------------------------------------------
#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"
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
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
{
#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,
#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,
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;
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);
// wxGTKInputHandler
// ----------------------------------------------------------------------------
-wxGTKInputHandler::wxGTKInputHandler(wxGTKRenderer *renderer)
-{
- m_renderer = renderer;
-}
-
bool wxGTKInputHandler::HandleKey(wxInputConsumer * WXUNUSED(control),
const wxKeyEvent& WXUNUSED(event),
bool WXUNUSED(pressed))
}
}
- return wxStdTextCtrlInputHandler::HandleKey(control, event, pressed);
+ return wxStdInputHandler::HandleKey(control, event, pressed);
}
#endif // wxUSE_TEXTCTRL
#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"
#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"
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()
{
m_win32Theme = wxTheme::Create( wxT("win32") );
return m_win32Theme != NULL;
}
-private:
+
wxTheme *m_win32Theme;
wxMetalRenderer *m_renderer;
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()
// ----------------------------------------------------------------------------
wxMetalRenderer::wxMetalRenderer(wxRenderer *renderer, wxColourScheme *scheme)
- : wxDelegateRenderer(renderer)
+ : wxDelegateRenderer(renderer)
{
// init colours and pens
m_penBlack = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_DARK), 0, wxSOLID);
#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"
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))
{
#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,
#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,
class wxWin32SystemMenuEvtHandler;
-class wxWin32FrameInputHandler : public wxStdFrameInputHandler
+class wxWin32FrameInputHandler : public wxStdInputHandler
{
public:
wxWin32FrameInputHandler(wxInputHandler *handler);
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;
wxSortedArrayString m_handlerNames;
wxArrayHandlers m_handlers;
- wxWin32InputHandler *m_handlerDefault;
-
wxWin32ColourScheme *m_scheme;
WX_DECLARE_THEME(win32)
{
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);
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);
// 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) )
// wxWin32InputHandler
// ----------------------------------------------------------------------------
-wxWin32InputHandler::wxWin32InputHandler(wxWin32Renderer *renderer)
-{
- m_renderer = renderer;
-}
-
bool wxWin32InputHandler::HandleKey(wxInputConsumer * WXUNUSED(control),
const wxKeyEvent& WXUNUSED(event),
bool WXUNUSED(pressed))
{
wxWindow *win = control->GetInputWindow();
- if (( wxWindow::FindFocus() != control->GetInputWindow() ) &&
- ( win->AcceptsFocus() ) )
+ if ( (wxWindow::FindFocus() != control->GetInputWindow()) &&
+ win->AcceptsFocus() )
{
win->SetFocus();
// ----------------------------------------------------------------------------
wxWin32ScrollBarInputHandler::
-wxWin32ScrollBarInputHandler(wxWin32Renderer *renderer,
- wxInputHandler *handler)
+wxWin32ScrollBarInputHandler(wxRenderer *renderer, wxInputHandler *handler)
: wxStdScrollBarInputHandler(renderer, handler)
{
m_scrollPaused = false;
}
}
- return wxStdScrollBarInputHandler::HandleMouseMove(control, event);
+ return wxStdInputHandler::HandleMouseMove(control, event);
}
#endif // wxUSE_SCROLLBAR
}
}
- return wxStdTextCtrlInputHandler::HandleKey(control, event, pressed);
+ return wxStdInputHandler::HandleKey(control, event, pressed);
}
#endif // wxUSE_TEXTCTRL
#endif
};
-wxWin32SystemMenuEvtHandler::wxWin32SystemMenuEvtHandler(
- wxWin32FrameInputHandler *handler)
+wxWin32SystemMenuEvtHandler::
+wxWin32SystemMenuEvtHandler(wxWin32FrameInputHandler *handler)
{
m_inputHnd = handler;
m_wnd = NULL;
wxWin32FrameInputHandler::wxWin32FrameInputHandler(wxInputHandler *handler)
- : wxStdFrameInputHandler(handler)
+ : wxStdInputHandler(handler)
{
m_menuHandler = new wxWin32SystemMenuEvtHandler(this);
}
}
}
- return wxStdFrameInputHandler::HandleMouse(consumer, event);
+ return wxStdInputHandler::HandleMouse(consumer, event);
}
#if wxUSE_MENUS
}
}
- return wxStdFrameInputHandler::HandleActivation(consumer, activated);
+ return wxStdInputHandler::HandleActivation(consumer, activated);
}
#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
// ----------------------------------------------------------------------------
return true;
}
+/* static */
+wxInputHandler *wxToolBar::GetStdInputHandler(wxInputHandler *handlerDef)
+{
+ static wxStdToolbarInputHandler s_handler(handlerDef);
+
+ return &s_handler;
+}
+
// ============================================================================
// wxStdToolbarInputHandler implementation
// ============================================================================
#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
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;
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:
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 )
{
return wxStdInputHandler::HandleMouseMove(consumer, event);
}
-bool wxStdFrameInputHandler::HandleActivation(wxInputConsumer *consumer,
- bool activated)
+bool wxStdTLWInputHandler::HandleActivation(wxInputConsumer *consumer,
+ bool activated)
{
if ( m_borderCursorOn )
{