1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/scrolwin.h
3 // Purpose: wxScrolledWindow class
4 // Author: Robert Roebling
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GTK_SCROLLWIN_H_
13 #define _WX_GTK_SCROLLWIN_H_
16 #pragma interface "scrolwin.h"
19 // ----------------------------------------------------------------------------
20 // headers and constants
21 // ----------------------------------------------------------------------------
23 #include "wx/window.h"
26 WXDLLEXPORT_DATA(extern const wxChar
*) wxPanelNameStr
;
28 // default scrolled window style
29 #ifndef wxScrolledWindowStyle
30 #define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL)
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 class WXDLLEXPORT wxScrolledWindow
: public wxPanel
43 wxScrolledWindow(wxWindow
*parent
,
45 const wxPoint
& pos
= wxDefaultPosition
,
46 const wxSize
& size
= wxDefaultSize
,
47 long style
= wxScrolledWindowStyle
,
48 const wxString
& name
= wxPanelNameStr
)
49 { Create(parent
, id
, pos
, size
, style
, name
); }
53 bool Create(wxWindow
*parent
,
55 const wxPoint
& pos
= wxDefaultPosition
,
56 const wxSize
& size
= wxDefaultSize
,
57 long style
= wxScrolledWindowStyle
,
58 const wxString
& name
= wxPanelNameStr
);
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
65 virtual void SetTargetWindow( wxWindow
*target
, bool pushEventHandler
= FALSE
);
66 virtual wxWindow
*GetTargetWindow();
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
);
76 // Physically scroll the window
77 virtual void Scroll(int x_pos
, int y_pos
);
79 int GetScrollPageSize(int orient
) const;
80 void SetScrollPageSize(int orient
, int pageSize
);
82 virtual void GetScrollPixelsPerUnit(int *x_unit
, int *y_unit
) const;
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
);
93 virtual void GetViewStart(int *x
, int *y
) const;
95 void ViewStart(int *x
, int *y
) const
96 { GetViewStart( x
, y
); }
98 // Actual size in pixels when scrolling is taken into account
99 virtual void GetVirtualSize(int *x
, int *y
) const;
101 // translate between scrolled and unscrolled coordinates
102 void CalcScrolledPosition(int x
, int y
, int *xx
, int *yy
) const
103 { DoCalcScrolledPosition(x
, y
, xx
, yy
); }
104 wxPoint
CalcScrolledPosition(const wxPoint
& pt
) const
107 DoCalcScrolledPosition(pt
.x
, pt
.y
, &p2
.x
, &p2
.y
);
111 void CalcUnscrolledPosition(int x
, int y
, int *xx
, int *yy
) const
112 { DoCalcUnscrolledPosition(x
, y
, xx
, yy
); }
113 wxPoint
CalcUnscrolledPosition(const wxPoint
& pt
) const
116 DoCalcUnscrolledPosition(pt
.x
, pt
.y
, &p2
.x
, &p2
.y
);
120 virtual void DoCalcScrolledPosition(int x
, int y
, int *xx
, int *yy
) const;
121 virtual void DoCalcUnscrolledPosition(int x
, int y
, int *xx
, int *yy
) const;
123 // Override this function to draw the graphic (or just process EVT_PAINT)
124 virtual void OnDraw(wxDC
& WXUNUSED(dc
)) {}
126 // Override this function if you don't want to have wxScrolledWindow
127 // automatically change the origin according to the scroll position.
128 virtual void PrepareDC(wxDC
& dc
);
130 // lay out the window and its children
131 virtual bool Layout();
133 // Adjust the scrollbars
134 virtual void AdjustScrollbars();
136 // Set the scale factor, used in PrepareDC
137 void SetScale(double xs
, double ys
) { m_scaleX
= xs
; m_scaleY
= ys
; }
138 double GetScaleX() const { return m_scaleX
; }
139 double GetScaleY() const { return m_scaleY
; }
141 // implementation from now on
142 void OnScroll(wxScrollWinEvent
& event
);
143 void OnSize(wxSizeEvent
& event
);
144 void OnPaint(wxPaintEvent
& event
);
145 void OnChar(wxKeyEvent
& event
);
147 void GtkVScroll( float value
, unsigned int scroll_type
);
148 void GtkHScroll( float value
, unsigned int scroll_type
);
149 void GtkVConnectEvent();
150 void GtkHConnectEvent();
151 void GtkVDisconnectEvent();
152 void GtkHDisconnectEvent();
154 // Calculate scroll increment
155 virtual int CalcScrollInc(wxScrollWinEvent
& event
);
157 // Overridden from wxWindows due callback being static
158 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
161 wxWindow
*m_targetWindow
;
162 int m_xScrollPixelsPerLine
;
163 int m_yScrollPixelsPerLine
;
164 bool m_xScrollingEnabled
;
165 bool m_yScrollingEnabled
;
166 int m_xScrollPosition
;
167 int m_yScrollPosition
;
170 int m_xScrollLinesPerPage
;
171 int m_yScrollLinesPerPage
;
173 double m_scaleY
,m_scaleX
;
176 DECLARE_EVENT_TABLE()
177 DECLARE_ABSTRACT_CLASS(wxScrolledWindow
)
181 // _WX_GTK_SCROLLWIN_H_