1. wxInputHandler now knows about wxRenderer and uses it
2. wxInputHandler::OnMouseMove() added 3. wxGTKRenderer (almost) draws scrollbars 4. scrollbar mouse handling starts to work git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8160 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -31,9 +31,6 @@ class WXDLLEXPORT wxInputHandler;
|
||||
// wxButton: a push button
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// class name
|
||||
#define wxCONTROL_BUTTON _T("button")
|
||||
|
||||
class WXDLLEXPORT wxButton : public wxButtonBase
|
||||
{
|
||||
public:
|
||||
@@ -75,7 +72,6 @@ public:
|
||||
void Click();
|
||||
|
||||
protected:
|
||||
virtual wxInputHandler *CreateInputHandler() const;
|
||||
virtual bool PerformAction(const wxControlAction& action,
|
||||
const wxEvent& event);
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
@@ -69,17 +69,13 @@ public:
|
||||
// the list of actions which apply to all controls (other actions are defined
|
||||
// in the controls headers)
|
||||
|
||||
#define wxACTION_NONE _T("") // no action to perform
|
||||
#define wxACTION_HIGHLIGHT _T("focus") // highlight the control
|
||||
#define wxACTION_UNHIGHLIGHT _T("unfocus") // remove highlight
|
||||
#define wxACTION_NONE _T("") // no action to perform
|
||||
#define wxACTION_FOCUS _T("focus") // make control focused
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxControl: the base class for all GUI controls
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// class name
|
||||
#define wxCONTROL_DEFAULT _T("")
|
||||
|
||||
class WXDLLEXPORT wxControl : public wxControlBase
|
||||
{
|
||||
public:
|
||||
@@ -140,6 +136,12 @@ public:
|
||||
return m_indexAccel == -1 ? _T('\0') : m_label[m_indexAccel];
|
||||
}
|
||||
|
||||
// perform the action which resulted from the translation of the event
|
||||
// (the exact event type depends on the action), return TRUE if the
|
||||
// control must be updated
|
||||
virtual bool PerformAction(const wxControlAction& action,
|
||||
const wxEvent& event);
|
||||
|
||||
protected:
|
||||
// create the event translator object for this control: the base class
|
||||
// action creates the default one which doesn't do anything
|
||||
@@ -151,12 +153,6 @@ protected:
|
||||
// draw the controls contents
|
||||
virtual void DoDraw(wxControlRenderer *renderer);
|
||||
|
||||
// perform the action which resulted from the translation of the event
|
||||
// (the exact event type depends on the action), return TRUE if the
|
||||
// control must be updated
|
||||
virtual bool PerformAction(const wxControlAction& action,
|
||||
const wxEvent& event);
|
||||
|
||||
// event handlers
|
||||
void OnMouse(wxMouseEvent& event);
|
||||
void OnKeyDown(wxKeyEvent& event);
|
||||
|
||||
@@ -28,10 +28,23 @@ class WXDLLEXPORT wxInputHandler
|
||||
public:
|
||||
// map a keyboard event to one or more actions (pressed == TRUE if the key
|
||||
// was pressed, FALSE if released)
|
||||
virtual wxControlActions Map(const wxKeyEvent& event, bool pressed) = 0;
|
||||
virtual wxControlActions Map(wxControl *control,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed) = 0;
|
||||
|
||||
// map a mouse event to one or more actions
|
||||
virtual wxControlActions Map(const wxMouseEvent& event) = 0;
|
||||
// map a mouse (click) event to one or more actions
|
||||
virtual wxControlActions Map(wxControl *control,
|
||||
const wxMouseEvent& event) = 0;
|
||||
|
||||
// do something with mouse move/enter/leave: unlike the Map() functions,
|
||||
// this doesn't translate the event into an action but, normally, uses the
|
||||
// renderer directly to change the controls appearance as needed
|
||||
//
|
||||
// this is faster than using Map() which is important for mouse move
|
||||
// events as they occur often and in a quick succession
|
||||
//
|
||||
// return TRUE to refresh the control, FALSE otherwise
|
||||
virtual bool OnMouseMove(wxControl *control, const wxMouseEvent& event);
|
||||
|
||||
// virtual dtor for any base class
|
||||
virtual ~wxInputHandler();
|
||||
|
||||
@@ -24,11 +24,33 @@
|
||||
|
||||
class WXDLLEXPORT wxControl;
|
||||
class WXDLLEXPORT wxDC;
|
||||
class WXDLLEXPORT wxScrollBar;
|
||||
class WXDLLEXPORT wxWindow;
|
||||
|
||||
#include "wx/string.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// hit test results
|
||||
enum wxHitTest
|
||||
{
|
||||
wxHT_NOWHERE,
|
||||
|
||||
// scrollbar
|
||||
wxHT_SCROLLBAR_ARROW_LINE_1, // left or upper arrow to scroll by line
|
||||
wxHT_SCROLLBAR_ARROW_LINE_2, // right or down
|
||||
wxHT_SCROLLBAR_ARROW_PAGE_1, // left or upper arrow to scroll by page
|
||||
wxHT_SCROLLBAR_ARROW_PAGE_2, // right or down
|
||||
wxHT_SCROLLBAR_THUMB, // on the thumb
|
||||
wxHT_SCROLLBAR_BAR_1, // bar to the left/above the thumb
|
||||
wxHT_SCROLLBAR_BAR_2, // bar to the right/below the thumb
|
||||
|
||||
wxHT_MAX
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxRenderer: abstract renderers interface
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -36,6 +58,9 @@ class WXDLLEXPORT wxWindow;
|
||||
class WXDLLEXPORT wxRenderer
|
||||
{
|
||||
public:
|
||||
// drawing functions
|
||||
// -----------------
|
||||
|
||||
// draw the controls background
|
||||
virtual void DrawBackground(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
@@ -79,14 +104,14 @@ public:
|
||||
int flags = 0) = 0;
|
||||
|
||||
// draw a scrollbar: thumb positions are in percent of the full scrollbar
|
||||
// length
|
||||
// length and the flags array contains the flags corresponding to each of
|
||||
// wxScrollBar::Elements
|
||||
virtual void DrawScrollbar(wxDC& dc,
|
||||
wxOrientation orient,
|
||||
int thumbPosStart,
|
||||
int thumbPosEnd,
|
||||
const wxRect& rect,
|
||||
int flags = 0,
|
||||
int extraFlags = 0) = 0;
|
||||
const int *flags = NULL) = 0;
|
||||
|
||||
// TODO: having this is ugly but I don't see how to solve GetBestSize()
|
||||
// problem without something like this
|
||||
@@ -97,6 +122,13 @@ public:
|
||||
// the control looks "nice" if it uses the adjusted rectangle
|
||||
virtual void AdjustSize(wxSize *size, const wxWindow *window) = 0;
|
||||
|
||||
// hit testing functions
|
||||
// ---------------------
|
||||
|
||||
// returns one of wxHT_SCROLLBAR_XXX constants
|
||||
virtual wxHitTest HitTestScrollbar(wxScrollBar *scrollbar,
|
||||
const wxPoint& pt) const = 0;
|
||||
|
||||
// virtual dtor for any base class
|
||||
virtual ~wxRenderer();
|
||||
};
|
||||
@@ -152,14 +184,17 @@ public:
|
||||
int thumbPosStart,
|
||||
int thumbPosEnd,
|
||||
const wxRect& rect,
|
||||
int flags = 0,
|
||||
int extraFlags = 0)
|
||||
const int *flags = NULL)
|
||||
{ m_renderer->DrawScrollbar(dc, orient, thumbPosStart,
|
||||
thumbPosEnd, rect, flags, extraFlags); }
|
||||
thumbPosEnd, rect, flags); }
|
||||
|
||||
virtual void AdjustSize(wxSize *size, const wxWindow *window)
|
||||
{ m_renderer->AdjustSize(size, window); }
|
||||
|
||||
virtual wxHitTest HitTestScrollbar(wxScrollBar *scrollbar,
|
||||
const wxPoint& pt) const
|
||||
{ return m_renderer->HitTestScrollbar(scrollbar, pt); }
|
||||
|
||||
protected:
|
||||
wxRenderer *m_renderer;
|
||||
};
|
||||
@@ -181,7 +216,7 @@ public:
|
||||
void DrawButtonBorder();
|
||||
void DrawFrame();
|
||||
void DrawBackgroundBitmap();
|
||||
void DrawScrollbar(int thumbStart, int thumbEnd, int extraFlags = 0);
|
||||
void DrawScrollbar(wxScrollBar *scrollbar);
|
||||
|
||||
// accessors
|
||||
wxRenderer *GetRenderer() const { return m_renderer; }
|
||||
|
||||
@@ -22,12 +22,6 @@ class WXDLLEXPORT wxInputHandler;
|
||||
// the actions supported by this control
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// various parts of scrollbar may be highlighted
|
||||
#define wxACTION_SCROLL_HIGHLIGHT_ARROW_UP _T("focusarrowup")
|
||||
#define wxACTION_SCROLL_HIGHLIGHT_ARROW_DOWN _T("focusarrowdown")
|
||||
#define wxACTION_SCROLL_HIGHLIGHT_THUMB _T("focusthumb")
|
||||
#define wxACTION_SCROLL_HIGHLIGHT_BAR _T("focusbar")
|
||||
|
||||
// scroll the bar
|
||||
#define wxACTION_SCROLL_START _T("start") // to the beginning
|
||||
#define wxACTION_SCROLL_END _T("end") // to the end
|
||||
@@ -45,19 +39,19 @@ class WXDLLEXPORT wxInputHandler;
|
||||
// wxScrollBar
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// class name
|
||||
#define wxCONTROL_SCROLLBAR _T("scrollbar")
|
||||
|
||||
class WXDLLEXPORT wxScrollBar : public wxScrollBarBase
|
||||
{
|
||||
public:
|
||||
enum
|
||||
// the parts of the scrollbar
|
||||
enum Element
|
||||
{
|
||||
// which part of scrollbar is currently highlighted?
|
||||
Highlight_Arrow1 = 0x0001,
|
||||
Highlight_Arrow2 = 0x0002,
|
||||
Highlight_Thumb = 0x0004,
|
||||
Highlight_Bar = 0x0008
|
||||
Element_Arrow_Line_1,
|
||||
Element_Arrow_Line_2,
|
||||
Element_Arrow_Page_1,
|
||||
Element_Arrow_Page_2,
|
||||
Element_Thumb,
|
||||
Element_Bar,
|
||||
Element_Max
|
||||
};
|
||||
|
||||
wxScrollBar() { Init(); }
|
||||
@@ -84,26 +78,39 @@ public:
|
||||
|
||||
virtual ~wxScrollBar();
|
||||
|
||||
// implementate base class pure virtuals
|
||||
// implement base class pure virtuals
|
||||
virtual int GetThumbPosition() const;
|
||||
virtual int GetThumbSize() const;
|
||||
virtual int GetPageSize() const;
|
||||
virtual int GetRange() const;
|
||||
|
||||
virtual void SetThumbPosition(int viewStart);
|
||||
virtual void SetThumbPosition(int thumbPos);
|
||||
virtual void SetScrollbar(int position, int thumbSize,
|
||||
int range, int pageSize,
|
||||
bool refresh = TRUE);
|
||||
|
||||
// wxScrollBar actions
|
||||
void ScrollToStart();
|
||||
void ScrollToEnd();
|
||||
void ScrollLines(int nLines);
|
||||
void ScrollPages(int nPages);
|
||||
|
||||
protected:
|
||||
virtual wxInputHandler *CreateInputHandler() const;
|
||||
virtual bool PerformAction(const wxControlAction& action,
|
||||
const wxEvent& event);
|
||||
|
||||
// wxScrollBar sub elements state (combination of wxCONTROL_XXX)
|
||||
void SetState(Element elem, int flags)
|
||||
{ m_elementsState[elem] = flags; }
|
||||
int GetState(Element elem) const
|
||||
{ return m_elementsState[elem]; }
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
virtual void DoDraw(wxControlRenderer *renderer);
|
||||
|
||||
// SetThumbPosition() helper
|
||||
void DoSetThumb(int thumbPos);
|
||||
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
@@ -120,6 +127,9 @@ private:
|
||||
// up/down action is performed
|
||||
int m_pageSize;
|
||||
|
||||
// the state of the sub elements
|
||||
int m_elementsState[Element_Max];
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxScrollBar)
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user