1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
///////////////////////////////////////////////////////////////////////////////
// Name: wx/univ/scrarrow.h
// Purpose: wxScrollArrows class
// Author: Vadim Zeitlin
// Modified by:
// Created: 22.01.01
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIV_SCRARROW_H_
#define _WX_UNIV_SCRARROW_H_
// ----------------------------------------------------------------------------
// wxScrollArrows is not a control but just a class containing the common
// functionality of scroll arrows, whether part of scrollbars, spin ctrls or
// anything else.
//
// To customize its behaviour, wxScrollArrows doesn't use any virtual methods
// but instead a callback pointer to a wxControlWithArrows object which is used
// for all control-dependent stuff. Thus, to use wxScrollArrows, you just need
// to derive from the wxControlWithArrows interface and implement its methods.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxControlWithArrows;
class WXDLLIMPEXP_FWD_CORE wxDC;
class WXDLLIMPEXP_FWD_CORE wxMouseEvent;
class WXDLLIMPEXP_FWD_CORE wxRect;
class WXDLLIMPEXP_FWD_CORE wxRenderer;
// ----------------------------------------------------------------------------
// wxScrollArrows: an abstraction of scrollbar arrow
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxScrollArrows
{
public:
enum Arrow
{
Arrow_None = -1,
Arrow_First, // left or top
Arrow_Second, // right or bottom
Arrow_Max
};
// ctor requires a back pointer to wxControlWithArrows
wxScrollArrows(wxControlWithArrows *control);
// draws the arrow on the given DC in the given rectangle, uses
// wxControlWithArrows::GetArrowState() to get its current state
void DrawArrow(Arrow arrow, wxDC& dc, const wxRect& rect,
bool scrollbarLike = false) const;
// process a mouse move, enter or leave event, possibly calling
// wxControlWithArrows::SetArrowState() if
// wxControlWithArrows::HitTestArrow() says that the mouse has left/entered
// an arrow
bool HandleMouseMove(const wxMouseEvent& event) const;
// process a mouse click event
bool HandleMouse(const wxMouseEvent& event) const;
// dtor
~wxScrollArrows();
private:
// set or clear the wxCONTROL_CURRENT flag for the arrow
void UpdateCurrentFlag(Arrow arrow, Arrow arrowCur) const;
// the main control
wxControlWithArrows *m_control;
// the data for the mouse capture
struct wxScrollArrowCaptureData *m_captureData;
};
// ----------------------------------------------------------------------------
// wxControlWithArrows: interface implemented by controls using wxScrollArrows
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxControlWithArrows
{
public:
virtual ~wxControlWithArrows() {}
// get the renderer to use for drawing the arrows
virtual wxRenderer *GetRenderer() const = 0;
// get the controls window (used for mouse capturing)
virtual wxWindow *GetWindow() = 0;
// get the orientation of the arrows (vertical or horizontal)
virtual bool IsVertical() const = 0;
// get the state of this arrow as combination of wxCONTROL_XXX flags
virtual int GetArrowState(wxScrollArrows::Arrow arrow) const = 0;
// set or clear the specified flag in the arrow state: this function is
// responsible for refreshing the control
virtual void SetArrowFlag(wxScrollArrows::Arrow arrow,
int flag, bool set = true) = 0;
// hit testing: return on which arrow the point is (or Arrow_None)
virtual wxScrollArrows::Arrow HitTestArrow(const wxPoint& pt) const = 0;
// called when the arrow is pressed, return true to continue scrolling and
// false to stop it
virtual bool OnArrow(wxScrollArrows::Arrow arrow) = 0;
};
#endif // _WX_UNIV_SCRARROW_H_
|