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 #define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL)
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
35 class WXDLLEXPORT wxScrolledWindow
: public wxPanel
39 wxScrolledWindow(wxWindow
*parent
,
41 const wxPoint
& pos
= wxDefaultPosition
,
42 const wxSize
& size
= wxDefaultSize
,
43 long style
= wxScrolledWindowStyle
,
44 const wxString
& name
= wxPanelNameStr
)
46 Create(parent
, id
, pos
, size
, style
, name
);
51 bool Create(wxWindow
*parent
,
53 const wxPoint
& pos
= wxDefaultPosition
,
54 const wxSize
& size
= wxDefaultSize
,
55 long style
= wxScrolledWindowStyle
,
56 const wxString
& name
= wxPanelNameStr
);
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
63 virtual void SetTargetWindow( wxWindow
*target
);
64 virtual wxWindow
*GetTargetWindow();
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
);
74 // Physically scroll the window
75 virtual void Scroll(int x_pos
, int y_pos
);
77 int GetScrollPageSize(int orient
) const;
78 void SetScrollPageSize(int orient
, int pageSize
);
80 virtual void GetScrollPixelsPerUnit(int *x_unit
, int *y_unit
) const;
82 // Enable/disable Windows scrolling in either direction.
83 // If TRUE, wxWindows scrolls the canvas and only a bit of
84 // the canvas is invalidated; no Clear() is necessary.
85 // If FALSE, the whole canvas is invalidated and a Clear() is
86 // necessary. Disable for when the scroll increment is used
87 // to actually scroll a non-constant distance
88 virtual void EnableScrolling(bool x_scrolling
, bool y_scrolling
);
91 virtual void GetViewStart(int *x
, int *y
) const;
93 void ViewStart(int *x
, int *y
) const
94 { GetViewStart( x
, y
); }
96 // Actual size in pixels when scrolling is taken into account
97 virtual void GetVirtualSize(int *x
, int *y
) const;
99 virtual void CalcScrolledPosition(int x
, int y
, int *xx
, int *yy
) const;
100 virtual void CalcUnscrolledPosition(int x
, int y
, int *xx
, int *yy
) const;
102 // Override this function to draw the graphic (or just process EVT_PAINT)
103 virtual void OnDraw(wxDC
& WXUNUSED(dc
)) {}
105 // Override this function if you don't want to have wxScrolledWindow
106 // automatically change the origin according to the scroll position.
107 virtual void PrepareDC(wxDC
& dc
);
109 // Adjust the scrollbars
110 virtual void AdjustScrollbars();
112 // implementation from now on
113 void OnSize(wxSizeEvent
& event
);
114 void OnPaint(wxPaintEvent
& event
);
115 void OnChar(wxKeyEvent
& event
);
117 void GtkVScroll( float value
);
118 void GtkHScroll( float value
);
121 wxWindow
*m_targetWindow
;
122 int m_xScrollPixelsPerLine
;
123 int m_yScrollPixelsPerLine
;
124 bool m_xScrollingEnabled
;
125 bool m_yScrollingEnabled
;
126 int m_xScrollPosition
;
127 int m_yScrollPosition
;
130 int m_xScrollLinesPerPage
;
131 int m_yScrollLinesPerPage
;
134 DECLARE_EVENT_TABLE()
135 DECLARE_ABSTRACT_CLASS(wxScrolledWindow
)
139 // _WX_GTK_SCROLLWIN_H_