refactoring/simplification of code dealing with scrollbars and their events

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40667 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-08-19 10:53:37 +00:00
parent 4e9be62bb3
commit 22c9b21132
2 changed files with 121 additions and 71 deletions

View File

@@ -211,11 +211,36 @@ public:
wxGtkIMData *m_imData;
// indices for the arrays below
enum ScrollDir { ScrollDir_Horz, ScrollDir_Vert, ScrollDir_Max };
// horizontal/vertical scroll bar
GtkRange* m_scrollBar[2];
GtkRange* m_scrollBar[ScrollDir_Max];
// horizontal/vertical scroll position
double m_scrollPos[2];
bool m_blockValueChanged[2];
double m_scrollPos[ScrollDir_Max];
// if true, don't notify about adjustment change (without resetting the
// flag, so this has to be done manually)
bool m_blockValueChanged[ScrollDir_Max];
// return the scroll direction index corresponding to the given orientation
// (which is wxVERTICAL or wxHORIZONTAL)
static ScrollDir ScrollDirFromOrient(int orient)
{
return orient == wxVERTICAL ? ScrollDir_Vert : ScrollDir_Horz;
}
// return the orientation for the given scrolling direction
static int OrientFromScrollDir(ScrollDir dir)
{
return dir == ScrollDir_Horz ? wxHORIZONTAL : wxVERTICAL;
}
// find the direction of the given scrollbar (must be one of ours)
ScrollDir ScrollDirFromRange(GtkRange *range) const;
// extra (wxGTK-specific) flags
bool m_needParent:1; // ! wxFrame, wxDialog, wxNotebookPage ?
@@ -291,6 +316,16 @@ protected:
static void GtkScrolledWindowSetBorder(GtkWidget* w, int style);
private:
enum ScrollUnit { ScrollUnit_Line, ScrollUnit_Page, ScrollUnit_Max };
// common part of ScrollLines() and ScrollPages() and could be used, in the
// future, for horizontal scrolling as well
//
// return true if we scrolled, false otherwise (on error or simply if we
// are already at the end)
bool DoScrollByUnits(ScrollDir dir, ScrollUnit unit, int units);
DECLARE_DYNAMIC_CLASS(wxWindowGTK)
DECLARE_NO_COPY_CLASS(wxWindowGTK)
};