]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/scrolwin.h
Incremented the version number used in the DLL filename to match version.h
[wxWidgets.git] / include / wx / generic / scrolwin.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: scrolwin.h
3 // Purpose: wxScrolledWindow class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __SCROLWINH_G__
13 #define __SCROLWINH_G__
14
15 #ifdef __GNUG__
16 #pragma interface "scrolwin.h"
17 #endif
18
19 #include "wx/window.h"
20 #include "wx/panel.h"
21
22 WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
23
24 class WXDLLEXPORT wxScrolledWindow : public wxPanel
25 {
26 public:
27 wxScrolledWindow();
28 inline wxScrolledWindow(wxWindow *parent, wxWindowID id = -1,
29 const wxPoint& pos = wxDefaultPosition,
30 const wxSize& size = wxDefaultSize,
31 long style = wxHSCROLL|wxVSCROLL,
32 const wxString& name = wxPanelNameStr)
33 {
34 Create(parent, id, pos, size, style, name);
35 }
36
37 ~wxScrolledWindow();
38
39 bool Create(wxWindow *parent, wxWindowID id,
40 const wxPoint& pos = wxDefaultPosition,
41 const wxSize& size = wxDefaultSize,
42 long style = wxHSCROLL|wxVSCROLL,
43 const wxString& name = wxPanelNameStr);
44
45 // Normally the wxScrolledWindow will scroll itself, but in
46 // some rare occasions you might want it to scroll another
47 // window (e.g. a child of it in order to scroll only a portion
48 // the area between the scrollbars (spreadsheet: only cell area
49 // will move).
50 virtual void SetTargetWindow( wxWindow *target );
51 virtual wxWindow *GetTargetWindow();
52
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(int pixelsPerUnitX, int pixelsPerUnitY,
57 int noUnitsX, int noUnitsY,
58 int xPos = 0, int yPos = 0,
59 bool noRefresh = FALSE );
60
61 // Physically scroll the window
62 virtual void Scroll(int x_pos, int y_pos);
63
64 #if WXWIN_COMPATIBILITY
65 virtual void GetScrollUnitsPerPage(int *x_page, int *y_page) const;
66 virtual void CalcUnscrolledPosition(int x, int y, float *xx, float *yy) const ;
67 #endif
68
69 int GetScrollPageSize(int orient) const ;
70 void SetScrollPageSize(int orient, int pageSize);
71
72 virtual void GetScrollPixelsPerUnit(int *x_unit, int *y_unit) const;
73
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);
81
82 // Get the view start
83 virtual void ViewStart(int *x, int *y) const;
84
85 // Actual size in pixels when scrolling is taken into account
86 virtual void GetVirtualSize(int *x, int *y) const;
87
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; }
92
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 ;
95
96 // Adjust the scrollbars
97 virtual void AdjustScrollbars(void);
98
99 // Override this function to draw the graphic (or just process EVT_PAINT)
100 virtual void OnDraw(wxDC& WXUNUSED(dc)) {};
101
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);
105
106 // implementation from now on
107 void OnScroll(wxScrollWinEvent& event);
108 void OnSize(wxSizeEvent& event);
109 void OnPaint(wxPaintEvent& event);
110
111 // Calculate scroll increment
112 virtual int CalcScrollInc(wxScrollWinEvent& event);
113
114 protected:
115 wxWindow *m_targetWindow;
116 int m_xScrollPixelsPerLine;
117 int m_yScrollPixelsPerLine;
118 bool m_xScrollingEnabled;
119 bool m_yScrollingEnabled;
120 int m_xScrollPosition;
121 int m_yScrollPosition;
122 int m_xScrollLines;
123 int m_yScrollLines;
124 int m_xScrollLinesPerPage;
125 int m_yScrollLinesPerPage;
126 double m_scaleX;
127 double m_scaleY;
128
129 private:
130 DECLARE_EVENT_TABLE()
131 DECLARE_ABSTRACT_CLASS(wxScrolledWindow)
132 };
133
134 #endif
135 // __SCROLWINH_G__