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"
22 WXDLLEXPORT_DATA(extern const wxChar
*) wxPanelNameStr
;
24 class WXDLLEXPORT wxScrolledWindow
: public wxPanel
26 DECLARE_ABSTRACT_CLASS(wxScrolledWindow
)
30 inline wxScrolledWindow(wxWindow
*parent
, wxWindowID id
= -1,
31 const wxPoint
& pos
= wxDefaultPosition
,
32 const wxSize
& size
= wxDefaultSize
,
33 long style
= wxHSCROLL
|wxVSCROLL
,
34 const wxString
& name
= wxPanelNameStr
)
36 Create(parent
, id
, pos
, size
, style
, name
);
39 ~wxScrolledWindow() { }
41 bool Create(wxWindow
*parent
, wxWindowID id
,
42 const wxPoint
& pos
= wxDefaultPosition
,
43 const wxSize
& size
= wxDefaultSize
,
44 long style
= wxHSCROLL
|wxVSCROLL
,
45 const wxString
& name
= wxPanelNameStr
);
48 // Should take account of scrollbars
49 // virtual void SetClientSize(int width, int size);
51 // Is the window retained?
52 // inline bool IsRetained(void) const;
54 // Number of pixels per user unit (0 or -1 for no scrollbar)
55 // Length of virtual canvas in user units
56 // Length of page in user units
57 virtual void SetScrollbars(int pixelsPerUnitX
, int pixelsPerUnitY
,
58 int noUnitsX
, int noUnitsY
,
59 int xPos
= 0, int yPos
= 0,
60 bool noRefresh
= FALSE
);
62 // Physically scroll the window
63 virtual void Scroll(int x_pos
, int y_pos
);
65 #if WXWIN_COMPATIBILITY
66 virtual void GetScrollUnitsPerPage(int *x_page
, int *y_page
) const;
67 virtual void CalcUnscrolledPosition(int x
, int y
, float *xx
, float *yy
) const ;
70 int GetScrollPageSize(int orient
) const ;
71 void SetScrollPageSize(int orient
, int pageSize
);
73 virtual void GetScrollPixelsPerUnit(int *x_unit
, int *y_unit
) const;
74 // Enable/disable Windows scrolling in either direction.
75 // If TRUE, wxWindows scrolls the canvas and only a bit of
76 // the canvas is invalidated; no Clear() is necessary.
77 // If FALSE, the whole canvas is invalidated and a Clear() is
78 // necessary. Disable for when the scroll increment is used
79 // to actually scroll a non-constant distance
80 virtual void EnableScrolling(bool x_scrolling
, bool y_scrolling
);
83 virtual void ViewStart(int *x
, int *y
) const;
85 // Actual size in pixels when scrolling is taken into account
86 virtual void GetVirtualSize(int *x
, int *y
) const;
88 // Set the scale factor, used in PrepareDC
89 void SetScale(double xs
, double ys
) { m_scaleX
= xs
; m_scaleY
= ys
; }
90 double GetScaleX() const { return m_scaleX
; }
91 double GetScaleY() const { return m_scaleY
; }
93 virtual void CalcScrolledPosition(int x
, int y
, int *xx
, int *yy
) const ;
94 virtual void CalcUnscrolledPosition(int x
, int y
, int *xx
, int *yy
) const ;
96 // Adjust the scrollbars
97 virtual void AdjustScrollbars(void);
99 // Override this function to draw the graphic (or just process EVT_PAINT)
100 virtual void OnDraw(wxDC
& WXUNUSED(dc
)) {};
102 // Override this function if you don't want to have wxScrolledWindow
103 // automatically change the origin according to the scroll position.
104 virtual void PrepareDC(wxDC
& dc
);
106 // implementation from now on
107 void OnScroll(wxScrollWinEvent
& event
);
108 void OnSize(wxSizeEvent
& event
);
109 void OnPaint(wxPaintEvent
& event
);
111 // Calculate scroll increment
112 virtual int CalcScrollInc(wxScrollWinEvent
& event
);
115 int m_xScrollPixelsPerLine
;
116 int m_yScrollPixelsPerLine
;
117 bool m_xScrollingEnabled
;
118 bool m_yScrollingEnabled
;
119 int m_xScrollPosition
;
120 int m_yScrollPosition
;
123 int m_xScrollLinesPerPage
;
124 int m_yScrollLinesPerPage
;
128 DECLARE_EVENT_TABLE()