]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/scrolwin.h
Some C++Builder fixes
[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
VZ
28// default scrolled window style
29#define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL | wxTAB_TRAVERSAL)
30
31// ----------------------------------------------------------------------------
32// wxScrolledWindow
33// ----------------------------------------------------------------------------
34
a0bc2c1d 35class WXDLLEXPORT wxScrolledWindow : public wxPanel
c801d85f 36{
c801d85f 37public:
ecab4dba 38 wxScrolledWindow();
8614c467
VZ
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)
ecab4dba 45 {
8614c467 46 Create(parent, id, pos, size, style, name);
ecab4dba 47 }
c801d85f 48
ecab4dba 49 ~wxScrolledWindow();
c801d85f 50
8614c467
VZ
51 bool Create(wxWindow *parent,
52 wxWindowID id,
53 const wxPoint& pos = wxDefaultPosition,
54 const wxSize& size = wxDefaultSize,
55 long style = wxScrolledWindowStyle,
56 const wxString& name = wxPanelNameStr);
c801d85f 57
8614c467
VZ
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
ecab4dba 61 // the area between the scrollbars (spreadsheet: only cell area
8614c467 62 // will move).
ecab4dba
RR
63 virtual void SetTargetWindow( wxWindow *target );
64 virtual wxWindow *GetTargetWindow();
65
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,
debe6624
JS
70 int noUnitsX, int noUnitsY,
71 int xPos = 0, int yPos = 0,
8614c467 72 bool noRefresh = FALSE );
c801d85f 73
ecab4dba
RR
74 // Physically scroll the window
75 virtual void Scroll(int x_pos, int y_pos);
c801d85f
KB
76
77#if WXWIN_COMPATIBILITY
ecab4dba 78 virtual void GetScrollUnitsPerPage(int *x_page, int *y_page) const;
8614c467 79 virtual void CalcUnscrolledPosition(int x, int y, float *xx, float *yy) const;
c801d85f
KB
80#endif
81
8614c467 82 int GetScrollPageSize(int orient) const;
ecab4dba 83 void SetScrollPageSize(int orient, int pageSize);
c801d85f 84
ecab4dba 85 virtual void GetScrollPixelsPerUnit(int *x_unit, int *y_unit) const;
8614c467 86
ecab4dba
RR
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);
c801d85f 94
ecab4dba 95 // Get the view start
cf3da716
RR
96 virtual void GetViewStart(int *x, int *y) const;
97 // Compatibility
98 void ViewStart(int *x, int *y) const
99 { GetViewStart( x, y ); }
c801d85f 100
ecab4dba
RR
101 // Actual size in pixels when scrolling is taken into account
102 virtual void GetVirtualSize(int *x, int *y) const;
c801d85f 103
ecab4dba
RR
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; }
0d8d91a9 108
8614c467
VZ
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;
c801d85f 111
ecab4dba
RR
112 // Adjust the scrollbars
113 virtual void AdjustScrollbars(void);
c801d85f 114
ecab4dba
RR
115 // Override this function to draw the graphic (or just process EVT_PAINT)
116 virtual void OnDraw(wxDC& WXUNUSED(dc)) {};
c801d85f 117
ecab4dba
RR
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);
c801d85f 121
ecab4dba
RR
122 // implementation from now on
123 void OnScroll(wxScrollWinEvent& event);
124 void OnSize(wxSizeEvent& event);
125 void OnPaint(wxPaintEvent& event);
438e3558 126 void OnChar(wxKeyEvent& event);
a0bc2c1d 127
ecab4dba
RR
128 // Calculate scroll increment
129 virtual int CalcScrollInc(wxScrollWinEvent& event);
c801d85f 130
c801d85f 131protected:
ecab4dba
RR
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;
139 int m_xScrollLines;
140 int m_yScrollLines;
141 int m_xScrollLinesPerPage;
142 int m_yScrollLinesPerPage;
143 double m_scaleX;
144 double m_scaleY;
145
146private:
147 DECLARE_EVENT_TABLE()
148 DECLARE_ABSTRACT_CLASS(wxScrolledWindow)
c801d85f
KB
149};
150
c801d85f 151#endif
8614c467 152 // _WX_GENERIC_SCROLLWIN_H_