]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/scrolwin.h
Added wxWindowBase::CentreOnParent to allow top level windows to be
[wxWidgets.git] / include / wx / generic / scrolwin.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: scrolwin.h
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
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __SCROLWINH_G__
13#define __SCROLWINH_G__
14
15#ifdef __GNUG__
16#pragma interface "scrolwin.h"
17#endif
18
19#include "wx/window.h"
053f9cc1 20#include "wx/panel.h"
c801d85f 21
908d4516 22WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
c801d85f 23
053f9cc1 24class WXDLLEXPORT wxScrolledWindow: public wxPanel
c801d85f
KB
25{
26 DECLARE_ABSTRACT_CLASS(wxScrolledWindow)
27
28public:
c5b42c87 29 wxScrolledWindow();
debe6624 30 inline wxScrolledWindow(wxWindow *parent, wxWindowID id = -1,
c801d85f
KB
31 const wxPoint& pos = wxDefaultPosition,
32 const wxSize& size = wxDefaultSize,
debe6624 33 long style = wxHSCROLL|wxVSCROLL,
c801d85f
KB
34 const wxString& name = wxPanelNameStr)
35 {
36 Create(parent, id, pos, size, style, name);
37 }
38
c5b42c87 39 ~wxScrolledWindow() {}
c801d85f 40
debe6624 41 bool Create(wxWindow *parent, wxWindowID id,
c801d85f
KB
42 const wxPoint& pos = wxDefaultPosition,
43 const wxSize& size = wxDefaultSize,
debe6624 44 long style = wxHSCROLL|wxVSCROLL,
c801d85f
KB
45 const wxString& name = wxPanelNameStr);
46
47 // Set client size
48 // Should take account of scrollbars
debe6624 49// virtual void SetClientSize(int width, int size);
c801d85f
KB
50
51 // Is the window retained?
52// inline bool IsRetained(void) const;
53
54 // Number of pixels per user unit (0 or -1 for no scrollbar)
55 // Length of virtual canvas in user units
56 // Length of page in user units
debe6624
JS
57 virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
58 int noUnitsX, int noUnitsY,
59 int xPos = 0, int yPos = 0,
60 bool noRefresh = FALSE );
c801d85f
KB
61
62 // Physically scroll the window
debe6624 63 virtual void Scroll(int x_pos, int y_pos);
c801d85f
KB
64
65#if WXWIN_COMPATIBILITY
66 virtual void GetScrollUnitsPerPage(int *x_page, int *y_page) const;
67#endif
68
69 int GetScrollPageSize(int orient) const ;
70 void SetScrollPageSize(int orient, int pageSize);
71
72 virtual void GetScrollPixelsPerUnit(int *x_unit, int *y_unit) const;
73 // Enable/disable Windows scrolling in either direction.
74 // If TRUE, wxWindows scrolls the canvas and only a bit of
75 // the canvas is invalidated; no Clear() is necessary.
76 // If FALSE, the whole canvas is invalidated and a Clear() is
77 // necessary. Disable for when the scroll increment is used
78 // to actually scroll a non-constant distance
debe6624 79 virtual void EnableScrolling(bool x_scrolling, bool y_scrolling);
c801d85f
KB
80
81 // Get the view start
82 virtual void ViewStart(int *x, int *y) const;
83
84 // Actual size in pixels when scrolling is taken into account
85 virtual void GetVirtualSize(int *x, int *y) const;
86
0d8d91a9
JS
87 // Set the scale factor, used in PrepareDC
88 inline void SetScale(double xs, double ys) { m_scaleX = xs; m_scaleY = ys; }
89 inline double GetScaleX() const { return m_scaleX; }
90 inline double GetScaleY() const { return m_scaleY; }
91
debe6624
JS
92 virtual void CalcScrolledPosition(int x, int y, int *xx, int *yy) const ;
93 virtual void CalcUnscrolledPosition(int x, int y, float *xx, float *yy) const ;
c801d85f
KB
94
95 // Adjust the scrollbars
96 virtual void AdjustScrollbars(void);
97
c5b42c87 98 void OnScroll(wxScrollWinEvent& event);
c801d85f
KB
99 void OnSize(wxSizeEvent& event);
100 void OnPaint(wxPaintEvent& event);
101
102 // Override this function to draw the graphic.
103 virtual void OnDraw(wxDC& WXUNUSED(dc)) {};
104
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);
108
109public:
c5b42c87 110 // IMPLEMENTATION
c801d85f
KB
111
112 // Calculate scroll increment
c5b42c87 113 virtual int CalcScrollInc(wxScrollWinEvent& event);
c801d85f 114
c801d85f
KB
115protected:
116 int m_xScrollPixelsPerLine;
117 int m_yScrollPixelsPerLine;
118 bool m_xScrollingEnabled;
119 bool m_yScrollingEnabled;
120 int m_xScrollPosition;
121 int m_yScrollPosition;
122 int m_xScrollLines;
123 int m_yScrollLines;
124 int m_xScrollLinesPerPage;
125 int m_yScrollLinesPerPage;
0d8d91a9
JS
126 double m_scaleX;
127 double m_scaleY;
c801d85f
KB
128
129DECLARE_EVENT_TABLE()
130};
131
c801d85f
KB
132#endif
133 // __SCROLWINH_G__