]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/scrolwin.h
Implemented wxGetClientDisplayRect which returns the dimensions of the
[wxWidgets.git] / include / wx / generic / scrolwin.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
8614c467 2// Name: wx/generic/scrolwin.h
c801d85f
KB
3// Purpose: wxScrolledWindow class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
8614c467 9// Licence: wxWindows license
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
8614c467
VZ
12#ifndef _WX_GENERIC_SCROLLWIN_H_
13#define _WX_GENERIC_SCROLLWIN_H_
c801d85f
KB
14
15#ifdef __GNUG__
8614c467 16 #pragma interface "scrolwin.h"
c801d85f
KB
17#endif
18
8614c467
VZ
19// ----------------------------------------------------------------------------
20// headers and constants
21// ----------------------------------------------------------------------------
22
c801d85f 23#include "wx/window.h"
053f9cc1 24#include "wx/panel.h"
c801d85f 25
908d4516 26WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
c801d85f 27
8614c467 28// default scrolled window style
fa3541bd 29#ifndef wxScrolledWindowStyle
a99b3d76 30#define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL)
fa3541bd 31#endif
8614c467
VZ
32
33// ----------------------------------------------------------------------------
fa3541bd 34// wxGenericScrolledWindow
8614c467
VZ
35// ----------------------------------------------------------------------------
36
fa3541bd 37class WXDLLEXPORT wxGenericScrolledWindow : public wxPanel
c801d85f 38{
c801d85f 39public:
fa3541bd
JS
40 wxGenericScrolledWindow();
41 wxGenericScrolledWindow(wxWindow *parent,
8614c467
VZ
42 wxWindowID id = -1,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 long style = wxScrolledWindowStyle,
46 const wxString& name = wxPanelNameStr)
ecab4dba 47 {
8614c467 48 Create(parent, id, pos, size, style, name);
ecab4dba 49 }
c801d85f 50
fa3541bd 51 ~wxGenericScrolledWindow();
c801d85f 52
8614c467
VZ
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);
c801d85f 59
fa3541bd 60 // Normally the wxGenericScrolledWindow will scroll itself, but in
8614c467
VZ
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
ecab4dba 63 // the area between the scrollbars (spreadsheet: only cell area
8614c467 64 // will move).
ecab4dba
RR
65 virtual void SetTargetWindow( wxWindow *target );
66 virtual wxWindow *GetTargetWindow();
67
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,
debe6624
JS
72 int noUnitsX, int noUnitsY,
73 int xPos = 0, int yPos = 0,
8614c467 74 bool noRefresh = FALSE );
c801d85f 75
ecab4dba
RR
76 // Physically scroll the window
77 virtual void Scroll(int x_pos, int y_pos);
c801d85f
KB
78
79#if WXWIN_COMPATIBILITY
ecab4dba 80 virtual void GetScrollUnitsPerPage(int *x_page, int *y_page) const;
8614c467 81 virtual void CalcUnscrolledPosition(int x, int y, float *xx, float *yy) const;
c801d85f
KB
82#endif
83
8614c467 84 int GetScrollPageSize(int orient) const;
ecab4dba 85 void SetScrollPageSize(int orient, int pageSize);
c801d85f 86
ecab4dba 87 virtual void GetScrollPixelsPerUnit(int *x_unit, int *y_unit) const;
8614c467 88
ecab4dba
RR
89 // Enable/disable Windows scrolling in either direction.
90 // If TRUE, wxWindows scrolls the canvas and only a bit of
91 // the canvas is invalidated; no Clear() is necessary.
92 // If FALSE, the whole canvas is invalidated and a Clear() is
93 // necessary. Disable for when the scroll increment is used
94 // to actually scroll a non-constant distance
95 virtual void EnableScrolling(bool x_scrolling, bool y_scrolling);
c801d85f 96
ecab4dba 97 // Get the view start
cf3da716
RR
98 virtual void GetViewStart(int *x, int *y) const;
99 // Compatibility
100 void ViewStart(int *x, int *y) const
101 { GetViewStart( x, y ); }
c801d85f 102
ecab4dba
RR
103 // Actual size in pixels when scrolling is taken into account
104 virtual void GetVirtualSize(int *x, int *y) const;
c801d85f 105
ecab4dba
RR
106 // Set the scale factor, used in PrepareDC
107 void SetScale(double xs, double ys) { m_scaleX = xs; m_scaleY = ys; }
108 double GetScaleX() const { return m_scaleX; }
109 double GetScaleY() const { return m_scaleY; }
0d8d91a9 110
8614c467
VZ
111 virtual void CalcScrolledPosition(int x, int y, int *xx, int *yy) const;
112 virtual void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const;
c801d85f 113
ecab4dba
RR
114 // Adjust the scrollbars
115 virtual void AdjustScrollbars(void);
c801d85f 116
ecab4dba
RR
117 // Override this function to draw the graphic (or just process EVT_PAINT)
118 virtual void OnDraw(wxDC& WXUNUSED(dc)) {};
c801d85f 119
fa3541bd 120 // Override this function if you don't want to have wxGenericScrolledWindow
ecab4dba
RR
121 // automatically change the origin according to the scroll position.
122 virtual void PrepareDC(wxDC& dc);
c801d85f 123
ecab4dba
RR
124 // implementation from now on
125 void OnScroll(wxScrollWinEvent& event);
126 void OnSize(wxSizeEvent& event);
127 void OnPaint(wxPaintEvent& event);
438e3558 128 void OnChar(wxKeyEvent& event);
a0bc2c1d 129
ecab4dba
RR
130 // Calculate scroll increment
131 virtual int CalcScrollInc(wxScrollWinEvent& event);
c801d85f 132
c801d85f 133protected:
ecab4dba
RR
134 wxWindow *m_targetWindow;
135 int m_xScrollPixelsPerLine;
136 int m_yScrollPixelsPerLine;
137 bool m_xScrollingEnabled;
138 bool m_yScrollingEnabled;
139 int m_xScrollPosition;
140 int m_yScrollPosition;
141 int m_xScrollLines;
142 int m_yScrollLines;
143 int m_xScrollLinesPerPage;
144 int m_yScrollLinesPerPage;
145 double m_scaleX;
146 double m_scaleY;
147
148private:
149 DECLARE_EVENT_TABLE()
fa3541bd 150 DECLARE_ABSTRACT_CLASS(wxGenericScrolledWindow)
c801d85f
KB
151};
152
c801d85f 153#endif
8614c467 154 // _WX_GENERIC_SCROLLWIN_H_