1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/scrolwin.h
3 // Purpose: wxScrolledWindow class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GENERIC_SCROLLWIN_H_
13 #define _WX_GENERIC_SCROLLWIN_H_
16 #pragma interface "scrolwin.h"
19 // ----------------------------------------------------------------------------
20 // headers and constants
21 // ----------------------------------------------------------------------------
23 #include "wx/window.h"
26 WXDLLEXPORT_DATA(extern const wxChar
*) wxPanelNameStr
;
28 // default scrolled window style
29 #ifndef wxScrolledWindowStyle
30 #define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL)
33 // ----------------------------------------------------------------------------
34 // wxGenericScrolledWindow
35 // ----------------------------------------------------------------------------
37 class WXDLLEXPORT wxGenericScrolledWindow
: public wxPanel
40 wxGenericScrolledWindow();
41 wxGenericScrolledWindow(wxWindow
*parent
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
45 long style
= wxScrolledWindowStyle
,
46 const wxString
& name
= wxPanelNameStr
)
48 Create(parent
, id
, pos
, size
, style
, name
);
51 ~wxGenericScrolledWindow();
53 bool Create(wxWindow
*parent
,
55 const wxPoint
& pos
= wxDefaultPosition
,
56 const wxSize
& size
= wxDefaultSize
,
57 long style
= wxScrolledWindowStyle
,
58 const wxString
& name
= wxPanelNameStr
);
60 // Normally the wxGenericScrolledWindow will scroll itself, but in
61 // some rare occasions you might want it to scroll another
62 // window (e.g. a child of it in order to scroll only a portion
63 // the area between the scrollbars (spreadsheet: only cell area
65 virtual void SetTargetWindow( wxWindow
*target
);
66 virtual wxWindow
*GetTargetWindow();
68 // Number of pixels per user unit (0 or -1 for no scrollbar)
69 // Length of virtual canvas in user units
70 // Length of page in user units
71 virtual void SetScrollbars(int pixelsPerUnitX
, int pixelsPerUnitY
,
72 int noUnitsX
, int noUnitsY
,
73 int xPos
= 0, int yPos
= 0,
74 bool noRefresh
= FALSE
);
76 // Physically scroll the window
77 virtual void Scroll(int x_pos
, int y_pos
);
79 #if WXWIN_COMPATIBILITY
80 virtual void GetScrollUnitsPerPage(int *x_page
, int *y_page
) const;
81 virtual void CalcUnscrolledPosition(int x
, int y
, float *xx
, float *yy
) const;
84 int GetScrollPageSize(int orient
) const;
85 void SetScrollPageSize(int orient
, int pageSize
);
87 virtual void GetScrollPixelsPerUnit(int *x_unit
, int *y_unit
) const;
89 // Enable/disable Windows scrolling in either direction.
90 // If TRUE, wxWindows scrolls the canvas and only a bit of
91 // the canvas is invalidated; no Clear() is necessary.
92 // If FALSE, the whole canvas is invalidated and a Clear() is
93 // necessary. Disable for when the scroll increment is used
94 // to actually scroll a non-constant distance
95 virtual void EnableScrolling(bool x_scrolling
, bool y_scrolling
);
98 virtual void GetViewStart(int *x
, int *y
) const;
100 void ViewStart(int *x
, int *y
) const
101 { GetViewStart( x
, y
); }
103 // Actual size in pixels when scrolling is taken into account
104 virtual void GetVirtualSize(int *x
, int *y
) const;
106 // Set the scale factor, used in PrepareDC
107 void SetScale(double xs
, double ys
) { m_scaleX
= xs
; m_scaleY
= ys
; }
108 double GetScaleX() const { return m_scaleX
; }
109 double GetScaleY() const { return m_scaleY
; }
111 virtual void CalcScrolledPosition(int x
, int y
, int *xx
, int *yy
) const;
112 virtual void CalcUnscrolledPosition(int x
, int y
, int *xx
, int *yy
) const;
114 // Adjust the scrollbars
115 virtual void AdjustScrollbars(void);
117 // Override this function to draw the graphic (or just process EVT_PAINT)
118 virtual void OnDraw(wxDC
& WXUNUSED(dc
)) {};
120 // Override this function if you don't want to have wxGenericScrolledWindow
121 // automatically change the origin according to the scroll position.
122 virtual void PrepareDC(wxDC
& dc
);
124 // implementation from now on
125 void OnScroll(wxScrollWinEvent
& event
);
126 void OnSize(wxSizeEvent
& event
);
127 void OnPaint(wxPaintEvent
& event
);
128 void OnChar(wxKeyEvent
& event
);
129 void OnMouseWheel(wxMouseEvent
& event
);
131 // Calculate scroll increment
132 virtual int CalcScrollInc(wxScrollWinEvent
& event
);
135 wxWindow
*m_targetWindow
;
136 int m_xScrollPixelsPerLine
;
137 int m_yScrollPixelsPerLine
;
138 bool m_xScrollingEnabled
;
139 bool m_yScrollingEnabled
;
140 int m_xScrollPosition
;
141 int m_yScrollPosition
;
144 int m_xScrollLinesPerPage
;
145 int m_yScrollLinesPerPage
;
151 DECLARE_EVENT_TABLE()
152 DECLARE_ABSTRACT_CLASS(wxGenericScrolledWindow
)
156 // _WX_GENERIC_SCROLLWIN_H_