]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/scrolwin.h
tried to fix compilation for mingw32 and wxGTK/Motif in the same time
[wxWidgets.git] / include / wx / generic / scrolwin.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/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 _WX_GENERIC_SCROLLWIN_H_
13 #define _WX_GENERIC_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
29 #define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL | wxTAB_TRAVERSAL)
30
31 // ----------------------------------------------------------------------------
32 // wxScrolledWindow
33 // ----------------------------------------------------------------------------
34
35 class WXDLLEXPORT wxScrolledWindow : public wxPanel
36 {
37 public:
38 wxScrolledWindow();
39 wxScrolledWindow(wxWindow *parent,
40 wxWindowID id = -1,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 long style = wxScrolledWindowStyle,
44 const wxString& name = wxPanelNameStr)
45 {
46 Create(parent, id, pos, size, style, name);
47 }
48
49 ~wxScrolledWindow();
50
51 bool Create(wxWindow *parent,
52 wxWindowID id,
53 const wxPoint& pos = wxDefaultPosition,
54 const wxSize& size = wxDefaultSize,
55 long style = wxScrolledWindowStyle,
56 const wxString& name = wxPanelNameStr);
57
58 // Normally the wxScrolledWindow will scroll itself, but in
59 // some rare occasions you might want it to scroll another
60 // window (e.g. a child of it in order to scroll only a portion
61 // the area between the scrollbars (spreadsheet: only cell area
62 // will move).
63 virtual void SetTargetWindow( wxWindow *target );
64 virtual wxWindow *GetTargetWindow();
65
66 // Number of pixels per user unit (0 or -1 for no scrollbar)
67 // Length of virtual canvas in user units
68 // Length of page in user units
69 virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
70 int noUnitsX, int noUnitsY,
71 int xPos = 0, int yPos = 0,
72 bool noRefresh = FALSE );
73
74 // Physically scroll the window
75 virtual void Scroll(int x_pos, int y_pos);
76
77 #if WXWIN_COMPATIBILITY
78 virtual void GetScrollUnitsPerPage(int *x_page, int *y_page) const;
79 virtual void CalcUnscrolledPosition(int x, int y, float *xx, float *yy) const;
80 #endif
81
82 int GetScrollPageSize(int orient) const;
83 void SetScrollPageSize(int orient, int pageSize);
84
85 virtual void GetScrollPixelsPerUnit(int *x_unit, int *y_unit) const;
86
87 // Enable/disable Windows scrolling in either direction.
88 // If TRUE, wxWindows scrolls the canvas and only a bit of
89 // the canvas is invalidated; no Clear() is necessary.
90 // If FALSE, the whole canvas is invalidated and a Clear() is
91 // necessary. Disable for when the scroll increment is used
92 // to actually scroll a non-constant distance
93 virtual void EnableScrolling(bool x_scrolling, bool y_scrolling);
94
95 // Get the view start
96 virtual void GetViewStart(int *x, int *y) const;
97 // Compatibility
98 void ViewStart(int *x, int *y) const
99 { GetViewStart( x, y ); }
100
101 // Actual size in pixels when scrolling is taken into account
102 virtual void GetVirtualSize(int *x, int *y) const;
103
104 // Set the scale factor, used in PrepareDC
105 void SetScale(double xs, double ys) { m_scaleX = xs; m_scaleY = ys; }
106 double GetScaleX() const { return m_scaleX; }
107 double GetScaleY() const { return m_scaleY; }
108
109 virtual void CalcScrolledPosition(int x, int y, int *xx, int *yy) const;
110 virtual void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const;
111
112 // Adjust the scrollbars
113 virtual void AdjustScrollbars(void);
114
115 // Override this function to draw the graphic (or just process EVT_PAINT)
116 virtual void OnDraw(wxDC& WXUNUSED(dc)) {};
117
118 // Override this function if you don't want to have wxScrolledWindow
119 // automatically change the origin according to the scroll position.
120 virtual void PrepareDC(wxDC& dc);
121
122 // implementation from now on
123 void OnScroll(wxScrollWinEvent& event);
124 void OnSize(wxSizeEvent& event);
125 void OnPaint(wxPaintEvent& event);
126 void OnChar(wxKeyEvent& event);
127
128 // Calculate scroll increment
129 virtual int CalcScrollInc(wxScrollWinEvent& event);
130
131 protected:
132 wxWindow *m_targetWindow;
133 int m_xScrollPixelsPerLine;
134 int m_yScrollPixelsPerLine;
135 bool m_xScrollingEnabled;
136 bool m_yScrollingEnabled;
137 int m_xScrollPosition;
138 int m_yScrollPosition;
139 int m_xScrollLines;
140 int m_yScrollLines;
141 int m_xScrollLinesPerPage;
142 int m_yScrollLinesPerPage;
143 double m_scaleX;
144 double m_scaleY;
145
146 private:
147 DECLARE_EVENT_TABLE()
148 DECLARE_ABSTRACT_CLASS(wxScrolledWindow)
149 };
150
151 #endif
152 // _WX_GENERIC_SCROLLWIN_H_