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