]>
Commit | Line | Data |
---|---|---|
30954328 RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/generic/scrolwin.h | |
3 | // Purpose: wxScrolledWindow class | |
4 | // Author: Robert Roebling | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Robert Roebling | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_GTK_SCROLLWIN_H_ | |
13 | #define _WX_GTK_SCROLLWIN_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "scrolwin.h" | |
17 | #endif | |
18 | ||
19 | // ---------------------------------------------------------------------------- | |
20 | // headers and constants | |
21 | // ---------------------------------------------------------------------------- | |
22 | ||
23 | #include "wx/window.h" | |
24 | #include "wx/panel.h" | |
25 | ||
26 | WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr; | |
27 | ||
28 | // default scrolled window style | |
fa3541bd | 29 | #ifndef wxScrolledWindowStyle |
30954328 | 30 | #define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL) |
fa3541bd | 31 | #endif |
30954328 RR |
32 | |
33 | // ---------------------------------------------------------------------------- | |
34 | // wxScrolledWindow | |
35 | // ---------------------------------------------------------------------------- | |
36 | ||
37 | class WXDLLEXPORT wxScrolledWindow : public wxPanel | |
38 | { | |
39 | public: | |
40 | wxScrolledWindow(); | |
41 | wxScrolledWindow(wxWindow *parent, | |
42 | wxWindowID id = -1, | |
43 | const wxPoint& pos = wxDefaultPosition, | |
44 | const wxSize& size = wxDefaultSize, | |
45 | long style = wxScrolledWindowStyle, | |
46 | const wxString& name = wxPanelNameStr) | |
47 | { | |
48 | Create(parent, id, pos, size, style, name); | |
49 | } | |
50 | ||
51 | ~wxScrolledWindow(); | |
52 | ||
53 | bool Create(wxWindow *parent, | |
54 | wxWindowID id, | |
55 | const wxPoint& pos = wxDefaultPosition, | |
56 | const wxSize& size = wxDefaultSize, | |
57 | long style = wxScrolledWindowStyle, | |
58 | const wxString& name = wxPanelNameStr); | |
59 | ||
60 | // Normally the wxScrolledWindow 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 | |
64 | // will move). | |
65 | virtual void SetTargetWindow( wxWindow *target ); | |
66 | virtual wxWindow *GetTargetWindow(); | |
67 | ||
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 ); | |
75 | ||
76 | // Physically scroll the window | |
77 | virtual void Scroll(int x_pos, int y_pos); | |
78 | ||
79 | int GetScrollPageSize(int orient) const; | |
80 | void SetScrollPageSize(int orient, int pageSize); | |
81 | ||
82 | virtual void GetScrollPixelsPerUnit(int *x_unit, int *y_unit) const; | |
83 | ||
84 | // Enable/disable Windows scrolling in either direction. | |
85 | // If TRUE, wxWindows scrolls the canvas and only a bit of | |
86 | // the canvas is invalidated; no Clear() is necessary. | |
87 | // If FALSE, the whole canvas is invalidated and a Clear() is | |
88 | // necessary. Disable for when the scroll increment is used | |
89 | // to actually scroll a non-constant distance | |
90 | virtual void EnableScrolling(bool x_scrolling, bool y_scrolling); | |
91 | ||
92 | // Get the view start | |
93 | virtual void GetViewStart(int *x, int *y) const; | |
94 | // Compatibility | |
95 | void ViewStart(int *x, int *y) const | |
96 | { GetViewStart( x, y ); } | |
97 | ||
98 | // Actual size in pixels when scrolling is taken into account | |
99 | virtual void GetVirtualSize(int *x, int *y) const; | |
100 | ||
101 | virtual void CalcScrolledPosition(int x, int y, int *xx, int *yy) const; | |
102 | virtual void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const; | |
103 | ||
104 | // Override this function to draw the graphic (or just process EVT_PAINT) | |
105 | virtual void OnDraw(wxDC& WXUNUSED(dc)) {} | |
106 | ||
107 | // Override this function if you don't want to have wxScrolledWindow | |
108 | // automatically change the origin according to the scroll position. | |
109 | virtual void PrepareDC(wxDC& dc); | |
110 | ||
111 | // Adjust the scrollbars | |
112 | virtual void AdjustScrollbars(); | |
113 | ||
114 | // implementation from now on | |
115 | void OnSize(wxSizeEvent& event); | |
116 | void OnPaint(wxPaintEvent& event); | |
117 | void OnChar(wxKeyEvent& event); | |
118 | ||
119 | void GtkVScroll( float value ); | |
120 | void GtkHScroll( float value ); | |
121 | ||
122 | protected: | |
123 | wxWindow *m_targetWindow; | |
124 | int m_xScrollPixelsPerLine; | |
125 | int m_yScrollPixelsPerLine; | |
126 | bool m_xScrollingEnabled; | |
127 | bool m_yScrollingEnabled; | |
128 | int m_xScrollPosition; | |
129 | int m_yScrollPosition; | |
130 | int m_xScrollLines; | |
131 | int m_yScrollLines; | |
132 | int m_xScrollLinesPerPage; | |
133 | int m_yScrollLinesPerPage; | |
134 | ||
135 | private: | |
136 | DECLARE_EVENT_TABLE() | |
137 | DECLARE_ABSTRACT_CLASS(wxScrolledWindow) | |
138 | }; | |
139 | ||
140 | #endif | |
141 | // _WX_GTK_SCROLLWIN_H_ |