]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/scrolwin.h
simplifications and corrections to background drawing:
[wxWidgets.git] / include / wx / gtk / scrolwin.h
CommitLineData
30954328 1/////////////////////////////////////////////////////////////////////////////
566d84a7 2// Name: wx/gtk/scrolwin.h
30954328
RR
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
65571936 9// Licence: wxWindows licence
30954328
RR
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_GTK_SCROLLWIN_H_
13#define _WX_GTK_SCROLLWIN_H_
14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
30954328
RR
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
26WXDLLEXPORT_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
37class WXDLLEXPORT wxScrolledWindow : public wxPanel
38{
39public:
830ed6d9
RR
40 wxScrolledWindow()
41 { Init(); }
29149a64 42
30954328
RR
43 wxScrolledWindow(wxWindow *parent,
44 wxWindowID id = -1,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize,
47 long style = wxScrolledWindowStyle,
48 const wxString& name = wxPanelNameStr)
830ed6d9 49 { Create(parent, id, pos, size, style, name); }
29149a64 50
830ed6d9 51 void Init();
30954328
RR
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).
13ff9344 65 virtual void SetTargetWindow( wxWindow *target, bool pushEventHandler = FALSE );
bfe35776 66 virtual wxWindow *GetTargetWindow() const;
30954328 67
566d84a7
RL
68 // Set the scrolled area of the window.
69 virtual void DoSetVirtualSize( int x, int y );
70
844adaa4
JS
71 // wxWindow's GetBestVirtualSize returns the actual window size,
72 // whereas we want to return the virtual size
73 virtual wxSize GetBestVirtualSize() const;
74
75 // Return the size best suited for the current window
76 // (this isn't a virtual size, this is a sensible size for the window)
77 virtual wxSize DoGetBestSize() const;
78
566d84a7
RL
79 // Set the x, y scrolling increments.
80 void SetScrollRate( int xstep, int ystep );
81
30954328
RR
82 // Number of pixels per user unit (0 or -1 for no scrollbar)
83 // Length of virtual canvas in user units
84 // Length of page in user units
566d84a7
RL
85 // Default action is to set the virtual size and alter scrollbars
86 // accordingly.
30954328
RR
87 virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
88 int noUnitsX, int noUnitsY,
89 int xPos = 0, int yPos = 0,
90 bool noRefresh = FALSE );
91
92 // Physically scroll the window
93 virtual void Scroll(int x_pos, int y_pos);
94
95 int GetScrollPageSize(int orient) const;
96 void SetScrollPageSize(int orient, int pageSize);
97
98 virtual void GetScrollPixelsPerUnit(int *x_unit, int *y_unit) const;
99
100 // Enable/disable Windows scrolling in either direction.
77ffb593 101 // If TRUE, wxWidgets scrolls the canvas and only a bit of
30954328
RR
102 // the canvas is invalidated; no Clear() is necessary.
103 // If FALSE, the whole canvas is invalidated and a Clear() is
104 // necessary. Disable for when the scroll increment is used
105 // to actually scroll a non-constant distance
106 virtual void EnableScrolling(bool x_scrolling, bool y_scrolling);
107
108 // Get the view start
109 virtual void GetViewStart(int *x, int *y) const;
30954328 110
8c2f3797
VS
111 // translate between scrolled and unscrolled coordinates
112 void CalcScrolledPosition(int x, int y, int *xx, int *yy) const
113 { DoCalcScrolledPosition(x, y, xx, yy); }
114 wxPoint CalcScrolledPosition(const wxPoint& pt) const
115 {
116 wxPoint p2;
117 DoCalcScrolledPosition(pt.x, pt.y, &p2.x, &p2.y);
118 return p2;
119 }
120
121 void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const
122 { DoCalcUnscrolledPosition(x, y, xx, yy); }
123 wxPoint CalcUnscrolledPosition(const wxPoint& pt) const
124 {
125 wxPoint p2;
126 DoCalcUnscrolledPosition(pt.x, pt.y, &p2.x, &p2.y);
127 return p2;
128 }
0d6d6051 129
8c2f3797
VS
130 virtual void DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const;
131 virtual void DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const;
30954328
RR
132
133 // Override this function to draw the graphic (or just process EVT_PAINT)
134 virtual void OnDraw(wxDC& WXUNUSED(dc)) {}
135
136 // Override this function if you don't want to have wxScrolledWindow
137 // automatically change the origin according to the scroll position.
fe5ddd92 138 void PrepareDC(wxDC& dc) { DoPrepareDC(dc); }
30954328 139
30486297
RD
140 // lay out the window and its children
141 virtual bool Layout();
142
30954328
RR
143 // Adjust the scrollbars
144 virtual void AdjustScrollbars();
29149a64 145
d9a4f620
RR
146 // Set the scale factor, used in PrepareDC
147 void SetScale(double xs, double ys) { m_scaleX = xs; m_scaleY = ys; }
148 double GetScaleX() const { return m_scaleX; }
149 double GetScaleY() const { return m_scaleY; }
150
30954328 151 // implementation from now on
d9a4f620 152 void OnScroll(wxScrollWinEvent& event);
30954328
RR
153 void OnSize(wxSizeEvent& event);
154 void OnPaint(wxPaintEvent& event);
155 void OnChar(wxKeyEvent& event);
29149a64 156
9e691f46
VZ
157 void GtkVScroll( float value, unsigned int scroll_type );
158 void GtkHScroll( float value, unsigned int scroll_type );
830ed6d9
RR
159 void GtkVConnectEvent();
160 void GtkHConnectEvent();
161 void GtkVDisconnectEvent();
162 void GtkHDisconnectEvent();
30954328 163
d9a4f620
RR
164 // Calculate scroll increment
165 virtual int CalcScrollInc(wxScrollWinEvent& event);
29149a64 166
77ffb593 167 // Overridden from wxWidgets due callback being static
0bc0cd5d 168 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
29149a64 169
0d6d6051
VZ
170#if WXWIN_COMPATIBILITY_2_2
171 // Compatibility
172 void ViewStart(int *x, int *y) const { GetViewStart( x, y ); }
173#endif // WXWIN_COMPATIBILITY_2_2
174
5de9f492
VZ
175 virtual void DoPrepareDC(wxDC& dc);
176
30954328
RR
177protected:
178 wxWindow *m_targetWindow;
179 int m_xScrollPixelsPerLine;
180 int m_yScrollPixelsPerLine;
181 bool m_xScrollingEnabled;
182 bool m_yScrollingEnabled;
566d84a7
RL
183
184 // FIXME: these next four members are duplicated in the GtkAdjustment
185 // members of wxWindow. Can they be safely removed from here?
186
30954328
RR
187 int m_xScrollPosition;
188 int m_yScrollPosition;
30954328
RR
189 int m_xScrollLinesPerPage;
190 int m_yScrollLinesPerPage;
29149a64 191
d9a4f620 192 double m_scaleY,m_scaleX;
30954328
RR
193
194private:
195 DECLARE_EVENT_TABLE()
8127b297 196 DECLARE_DYNAMIC_CLASS(wxScrolledWindow)
30954328
RR
197};
198
199#endif
200 // _WX_GTK_SCROLLWIN_H_
566d84a7
RL
201
202// vi:sts=4:sw=4:et