]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
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" | |
053f9cc1 | 20 | #include "wx/panel.h" |
c801d85f | 21 | |
908d4516 | 22 | WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr; |
c801d85f | 23 | |
a0bc2c1d | 24 | class WXDLLEXPORT wxScrolledWindow : public wxPanel |
c801d85f | 25 | { |
c801d85f | 26 | public: |
ecab4dba RR |
27 | wxScrolledWindow(); |
28 | inline wxScrolledWindow(wxWindow *parent, wxWindowID id = -1, | |
c801d85f KB |
29 | const wxPoint& pos = wxDefaultPosition, |
30 | const wxSize& size = wxDefaultSize, | |
debe6624 | 31 | long style = wxHSCROLL|wxVSCROLL, |
c801d85f | 32 | const wxString& name = wxPanelNameStr) |
ecab4dba | 33 | { |
c801d85f | 34 | Create(parent, id, pos, size, style, name); |
ecab4dba | 35 | } |
c801d85f | 36 | |
ecab4dba | 37 | ~wxScrolledWindow(); |
c801d85f | 38 | |
ecab4dba | 39 | bool Create(wxWindow *parent, wxWindowID id, |
c801d85f KB |
40 | const wxPoint& pos = wxDefaultPosition, |
41 | const wxSize& size = wxDefaultSize, | |
debe6624 | 42 | long style = wxHSCROLL|wxVSCROLL, |
c801d85f KB |
43 | const wxString& name = wxPanelNameStr); |
44 | ||
ecab4dba RR |
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, | |
debe6624 JS |
57 | int noUnitsX, int noUnitsY, |
58 | int xPos = 0, int yPos = 0, | |
59 | bool noRefresh = FALSE ); | |
c801d85f | 60 | |
ecab4dba RR |
61 | // Physically scroll the window |
62 | virtual void Scroll(int x_pos, int y_pos); | |
c801d85f KB |
63 | |
64 | #if WXWIN_COMPATIBILITY | |
ecab4dba RR |
65 | virtual void GetScrollUnitsPerPage(int *x_page, int *y_page) const; |
66 | virtual void CalcUnscrolledPosition(int x, int y, float *xx, float *yy) const ; | |
c801d85f KB |
67 | #endif |
68 | ||
ecab4dba RR |
69 | int GetScrollPageSize(int orient) const ; |
70 | void SetScrollPageSize(int orient, int pageSize); | |
c801d85f | 71 | |
ecab4dba RR |
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); | |
c801d85f | 81 | |
ecab4dba | 82 | // Get the view start |
cf3da716 RR |
83 | virtual void GetViewStart(int *x, int *y) const; |
84 | // Compatibility | |
85 | void ViewStart(int *x, int *y) const | |
86 | { GetViewStart( x, y ); } | |
c801d85f | 87 | |
ecab4dba RR |
88 | // Actual size in pixels when scrolling is taken into account |
89 | virtual void GetVirtualSize(int *x, int *y) const; | |
c801d85f | 90 | |
ecab4dba RR |
91 | // Set the scale factor, used in PrepareDC |
92 | void SetScale(double xs, double ys) { m_scaleX = xs; m_scaleY = ys; } | |
93 | double GetScaleX() const { return m_scaleX; } | |
94 | double GetScaleY() const { return m_scaleY; } | |
0d8d91a9 | 95 | |
ecab4dba RR |
96 | virtual void CalcScrolledPosition(int x, int y, int *xx, int *yy) const ; |
97 | virtual void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const ; | |
c801d85f | 98 | |
ecab4dba RR |
99 | // Adjust the scrollbars |
100 | virtual void AdjustScrollbars(void); | |
c801d85f | 101 | |
ecab4dba RR |
102 | // Override this function to draw the graphic (or just process EVT_PAINT) |
103 | virtual void OnDraw(wxDC& WXUNUSED(dc)) {}; | |
c801d85f | 104 | |
ecab4dba RR |
105 | // Override this function if you don't want to have wxScrolledWindow |
106 | // automatically change the origin according to the scroll position. | |
107 | virtual void PrepareDC(wxDC& dc); | |
c801d85f | 108 | |
ecab4dba RR |
109 | // implementation from now on |
110 | void OnScroll(wxScrollWinEvent& event); | |
111 | void OnSize(wxSizeEvent& event); | |
112 | void OnPaint(wxPaintEvent& event); | |
a0bc2c1d | 113 | |
ecab4dba RR |
114 | // Calculate scroll increment |
115 | virtual int CalcScrollInc(wxScrollWinEvent& event); | |
c801d85f | 116 | |
c801d85f | 117 | protected: |
ecab4dba RR |
118 | wxWindow *m_targetWindow; |
119 | int m_xScrollPixelsPerLine; | |
120 | int m_yScrollPixelsPerLine; | |
121 | bool m_xScrollingEnabled; | |
122 | bool m_yScrollingEnabled; | |
123 | int m_xScrollPosition; | |
124 | int m_yScrollPosition; | |
125 | int m_xScrollLines; | |
126 | int m_yScrollLines; | |
127 | int m_xScrollLinesPerPage; | |
128 | int m_yScrollLinesPerPage; | |
129 | double m_scaleX; | |
130 | double m_scaleY; | |
131 | ||
132 | private: | |
133 | DECLARE_EVENT_TABLE() | |
134 | DECLARE_ABSTRACT_CLASS(wxScrolledWindow) | |
c801d85f KB |
135 | }; |
136 | ||
c801d85f KB |
137 | #endif |
138 | // __SCROLWINH_G__ |