1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxScrolledWindow class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __SCROLWINH_G__
13 #define __SCROLWINH_G__
16 #pragma interface "scrolwin.h"
19 #include "wx/window.h"
21 WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr
;
23 class WXDLLEXPORT wxScrolledWindow
: public wxWindow
25 DECLARE_ABSTRACT_CLASS(wxScrolledWindow
)
28 wxScrolledWindow(void);
29 inline wxScrolledWindow(wxWindow
*parent
, const wxWindowID id
= -1,
30 const wxPoint
& pos
= wxDefaultPosition
,
31 const wxSize
& size
= wxDefaultSize
,
32 const long style
= wxHSCROLL
|wxVSCROLL
,
33 const wxString
& name
= wxPanelNameStr
)
35 Create(parent
, id
, pos
, size
, style
, name
);
38 inline ~wxScrolledWindow(void) {}
40 bool Create(wxWindow
*parent
, const wxWindowID id
,
41 const wxPoint
& pos
= wxDefaultPosition
,
42 const wxSize
& size
= wxDefaultSize
,
43 const long style
= wxHSCROLL
|wxVSCROLL
,
44 const wxString
& name
= wxPanelNameStr
);
47 // Should take account of scrollbars
48 // virtual void SetClientSize(const int width, const int size);
50 // Is the window retained?
51 // inline bool IsRetained(void) const;
53 // Number of pixels per user unit (0 or -1 for no scrollbar)
54 // Length of virtual canvas in user units
55 // Length of page in user units
56 virtual void SetScrollbars(const int pixelsPerUnitX
, const int pixelsPerUnitY
,
57 const int noUnitsX
, const int noUnitsY
,
58 const int xPos
= 0, const int yPos
= 0,
59 const bool noRefresh
= FALSE
);
61 // Physically scroll the window
62 virtual void Scroll(const int x_pos
, const int y_pos
);
64 #if WXWIN_COMPATIBILITY
65 virtual void GetScrollUnitsPerPage(int *x_page
, int *y_page
) const;
68 int GetScrollPageSize(int orient
) const ;
69 void SetScrollPageSize(int orient
, int pageSize
);
71 virtual void GetScrollPixelsPerUnit(int *x_unit
, int *y_unit
) const;
72 // Enable/disable Windows scrolling in either direction.
73 // If TRUE, wxWindows scrolls the canvas and only a bit of
74 // the canvas is invalidated; no Clear() is necessary.
75 // If FALSE, the whole canvas is invalidated and a Clear() is
76 // necessary. Disable for when the scroll increment is used
77 // to actually scroll a non-constant distance
78 virtual void EnableScrolling(const bool x_scrolling
, const bool y_scrolling
);
81 virtual void ViewStart(int *x
, int *y
) const;
83 // Actual size in pixels when scrolling is taken into account
84 virtual void GetVirtualSize(int *x
, int *y
) const;
86 virtual void CalcScrolledPosition(const int x
, const int y
, int *xx
, int *yy
) const ;
87 virtual void CalcUnscrolledPosition(const int x
, const int y
, float *xx
, float *yy
) const ;
89 // Adjust the scrollbars
90 virtual void AdjustScrollbars(void);
93 #if WXWIN_COMPATIBILITY
94 virtual void OldOnScroll(wxCommandEvent& WXUNUSED(event));
95 virtual void OldOnPaint(void); // Called when needs painting
96 virtual void OldOnSize(int width, int height); // Called on resize
97 virtual void OldOnMouseEvent(wxMouseEvent& event); // Called on mouse event
98 virtual void OldOnChar(wxKeyEvent& event); // Called on character event
102 void OnScroll(wxScrollEvent
& event
);
103 void OnSize(wxSizeEvent
& event
);
104 void OnPaint(wxPaintEvent
& event
);
106 // Override this function to draw the graphic.
107 virtual void OnDraw(wxDC
& WXUNUSED(dc
)) {};
109 // Override this function if you don't want to have wxScrolledWindow
110 // automatically change the origin according to the scroll position.
111 virtual void PrepareDC(wxDC
& dc
);
114 ////////////////////////////////////////////////////////////////////////
117 // Calculate scroll increment
118 virtual int CalcScrollInc(wxScrollEvent
& event
);
120 ////////////////////////////////////////////////////////////////////////
123 int m_xScrollPixelsPerLine
;
124 int m_yScrollPixelsPerLine
;
125 bool m_xScrollingEnabled
;
126 bool m_yScrollingEnabled
;
127 int m_xScrollPosition
;
128 int m_yScrollPosition
;
131 int m_xScrollLinesPerPage
;
132 int m_yScrollLinesPerPage
;
134 DECLARE_EVENT_TABLE()
137 ////////////////////////////////////////////////////////////////////////