1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/scrolwin.h
3 // Purpose: wxScrolledWindow class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GENERIC_SCROLLWIN_H_
13 #define _WX_GENERIC_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 #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;
82 int GetScrollPageSize(int orient
) const;
83 void SetScrollPageSize(int orient
, int pageSize
);
85 virtual void GetScrollPixelsPerUnit(int *x_unit
, int *y_unit
) const;
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
);
96 virtual void GetViewStart(int *x
, int *y
) const;
98 void ViewStart(int *x
, int *y
) const
99 { GetViewStart( x
, y
); }
101 // Actual size in pixels when scrolling is taken into account
102 virtual void GetVirtualSize(int *x
, int *y
) const;
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
; }
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;
112 // Adjust the scrollbars
113 virtual void AdjustScrollbars(void);
115 // Override this function to draw the graphic (or just process EVT_PAINT)
116 virtual void OnDraw(wxDC
& WXUNUSED(dc
)) {};
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
);
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
);
128 // Calculate scroll increment
129 virtual int CalcScrollInc(wxScrollWinEvent
& event
);
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
;
141 int m_xScrollLinesPerPage
;
142 int m_yScrollLinesPerPage
;
147 DECLARE_EVENT_TABLE()
148 DECLARE_ABSTRACT_CLASS(wxScrolledWindow
)
152 // _WX_GENERIC_SCROLLWIN_H_