]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/window.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / univ / window.h
CommitLineData
1e6feb95
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/univ/window.h
3// Purpose: wxWindow class which is the base class for all
4// wxUniv port controls, it supports the customization of the
5// window drawing and input processing.
6// Author: Vadim Zeitlin
7// Modified by:
8// Created: 06.08.00
442b35b5 9// Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
65571936 10// Licence: wxWindows licence
1e6feb95
VZ
11///////////////////////////////////////////////////////////////////////////////
12
13#ifndef _WX_UNIV_WINDOW_H_
14#define _WX_UNIV_WINDOW_H_
15
1e6feb95
VZ
16#include "wx/bitmap.h" // for m_bitmapBg
17
b5dbe15d
VS
18class WXDLLIMPEXP_FWD_CORE wxControlRenderer;
19class WXDLLIMPEXP_FWD_CORE wxEventLoop;
9a6384ca
WS
20
21#if wxUSE_MENUS
b5dbe15d
VS
22 class WXDLLIMPEXP_FWD_CORE wxMenu;
23 class WXDLLIMPEXP_FWD_CORE wxMenuBar;
9a6384ca
WS
24#endif // wxUSE_MENUS
25
b5dbe15d 26class WXDLLIMPEXP_FWD_CORE wxRenderer;
9a6384ca
WS
27
28#if wxUSE_SCROLLBAR
b5dbe15d 29 class WXDLLIMPEXP_FWD_CORE wxScrollBar;
9a6384ca 30#endif // wxUSE_SCROLLBAR
1e6feb95 31
ab6b6b15
RR
32#ifdef __WXX11__
33#define wxUSE_TWO_WINDOWS 1
34#else
35#define wxUSE_TWO_WINDOWS 0
36#endif
37
1e6feb95
VZ
38// ----------------------------------------------------------------------------
39// wxWindow
40// ----------------------------------------------------------------------------
41
24ce4c18
JS
42#if defined(__WXMSW__)
43#define wxWindowNative wxWindowMSW
44#elif defined(__WXGTK__)
45#define wxWindowNative wxWindowGTK
1b0b798d
RR
46#elif defined(__WXX11__)
47#define wxWindowNative wxWindowX11
e766c8a9
SC
48#elif defined(__WXMAC__)
49#define wxWindowNative wxWindowMac
24ce4c18
JS
50#endif
51
53a2db12 52class WXDLLIMPEXP_CORE wxWindow : public wxWindowNative
1e6feb95
VZ
53{
54public:
1a77875b 55 // ctors and create functions
1e6feb95
VZ
56 // ---------------------------
57
6463b9f5 58 wxWindow() { Init(); }
1e6feb95
VZ
59
60 wxWindow(wxWindow *parent,
61 wxWindowID id,
62 const wxPoint& pos = wxDefaultPosition,
63 const wxSize& size = wxDefaultSize,
64 long style = 0,
6463b9f5
JS
65 const wxString& name = wxPanelNameStr)
66 : wxWindowNative(parent, id, pos, size, style | wxCLIP_CHILDREN, name)
67 { Init(); }
1e6feb95
VZ
68
69 bool Create(wxWindow *parent,
70 wxWindowID id,
71 const wxPoint& pos = wxDefaultPosition,
72 const wxSize& size = wxDefaultSize,
73 long style = 0,
74 const wxString& name = wxPanelNameStr);
75
8da1f9a9
VZ
76 virtual ~wxWindow();
77
1e6feb95
VZ
78 // background pixmap support
79 // -------------------------
80
81 virtual void SetBackground(const wxBitmap& bitmap,
82 int alignment = wxALIGN_CENTRE,
83 wxStretch stretch = wxSTRETCH_NOT);
84
85 const wxBitmap& GetBackgroundBitmap(int *alignment = NULL,
86 wxStretch *stretch = NULL) const;
87
88 // scrollbars: we (re)implement it ourselves using our own scrollbars
89 // instead of the native ones
90 // ------------------------------------------------------------------
91
92 virtual void SetScrollbar(int orient,
93 int pos,
94 int page,
95 int range,
a290fa5a
WS
96 bool refresh = true );
97 virtual void SetScrollPos(int orient, int pos, bool refresh = true);
1e6feb95
VZ
98 virtual int GetScrollPos(int orient) const;
99 virtual int GetScrollThumb(int orient) const;
100 virtual int GetScrollRange(int orient) const;
101 virtual void ScrollWindow(int dx, int dy,
d3b9f782 102 const wxRect* rect = NULL);
1e6feb95
VZ
103
104 // take into account the borders here
105 virtual wxPoint GetClientAreaOrigin() const;
106
107 // popup menu support
108 // ------------------
109
110 // NB: all menu related functions are implemented in menu.cpp
111
112#if wxUSE_MENUS
1e6feb95
VZ
113 // this is wxUniv-specific private method to be used only by wxMenu
114 void DismissPopupMenu();
115#endif // wxUSE_MENUS
116
117 // miscellaneous other methods
118 // ---------------------------
119
120 // get the state information
121 virtual bool IsFocused() const;
122 virtual bool IsCurrent() const;
123 virtual bool IsPressed() const;
124 virtual bool IsDefault() const;
125
126 // return all state flags at once (combination of wxCONTROL_XXX values)
127 int GetStateFlags() const;
128
a290fa5a
WS
129 // set the "highlighted" flag and return true if it changed
130 virtual bool SetCurrent(bool doit = true);
1e6feb95 131
9a6384ca 132#if wxUSE_SCROLLBAR
1e6feb95
VZ
133 // get the scrollbar (may be NULL) for the given orientation
134 wxScrollBar *GetScrollbar(int orient) const
135 {
136 return orient & wxVERTICAL ? m_scrollbarVert : m_scrollbarHorz;
137 }
9a6384ca 138#endif // wxUSE_SCROLLBAR
1e6feb95
VZ
139
140 // methods used by wxColourScheme to choose the colours for this window
141 // --------------------------------------------------------------------
142
a290fa5a 143 // return true if this is a panel/canvas window which contains other
1e6feb95 144 // controls only
a290fa5a 145 virtual bool IsCanvasWindow() const { return false; }
1e6feb95 146
a290fa5a 147 // return true if this control can be highlighted when the mouse is over
1e6feb95 148 // it (the theme decides itself whether it is really highlighted or not)
a290fa5a 149 virtual bool CanBeHighlighted() const { return false; }
1e6feb95 150
a290fa5a 151 // return true if we should use the colours/fonts returned by the
1e6feb95 152 // corresponding GetXXX() methods instead of the default ones
1e6feb95
VZ
153 bool UseFgCol() const { return m_hasFgCol; }
154 bool UseFont() const { return m_hasFont; }
155
a290fa5a 156 // return true if this window serves as a container for the other windows
30827629 157 // only and doesn't get any input itself
a290fa5a 158 virtual bool IsStaticBox() const { return false; }
30827629 159
1e6feb95
VZ
160 // returns the (low level) renderer to use for drawing the control by
161 // querying the current theme
162 wxRenderer *GetRenderer() const { return m_renderer; }
163
164 // scrolling helper: like ScrollWindow() except that it doesn't refresh the
165 // uncovered window areas but returns the rectangle to update (don't call
166 // this with both dx and dy non zero)
167 wxRect ScrollNoRefresh(int dx, int dy, const wxRect *rect = NULL);
168
169 // after scrollbars are added or removed they must be refreshed by calling
170 // this function
171 void RefreshScrollbars();
172
173 // erase part of the control
174 virtual void EraseBackground(wxDC& dc, const wxRect& rect);
4cc4e7b6 175
1e6feb95
VZ
176 // overridden base class methods
177 // -----------------------------
178
179 // the rect coordinates are, for us, in client coords, but if no rect is
180 // specified, the entire window is refreshed
a290fa5a 181 virtual void Refresh(bool eraseBackground = true,
1e6feb95
VZ
182 const wxRect *rect = (const wxRect *) NULL);
183
184 // we refresh the window when it is dis/enabled
a290fa5a 185 virtual bool Enable(bool enable = true);
1e6feb95 186
b2d22a3f
VZ
187 // should we use the standard control colours or not?
188 virtual bool ShouldInheritColours() const { return false; }
189
049908c5
VS
190 virtual bool IsClientAreaChild(const wxWindow *child) const
191 {
192#if wxUSE_SCROLLBAR
193 if ( child == (wxWindow*)m_scrollbarHorz ||
194 child == (wxWindow*)m_scrollbarVert )
195 return false;
196#endif
197 return wxWindowNative::IsClientAreaChild(child);
198 }
199
1e6feb95
VZ
200protected:
201 // common part of all ctors
202 void Init();
203
6f02a879
VZ
204#if wxUSE_MENUS
205 virtual bool DoPopupMenu(wxMenu *menu, int x, int y);
206#endif // wxUSE_MENUS
1e6feb95
VZ
207
208 // we deal with the scrollbars in these functions
209 virtual void DoSetClientSize(int width, int height);
210 virtual void DoGetClientSize(int *width, int *height) const;
211 virtual wxHitTest DoHitTest(wxCoord x, wxCoord y) const;
212
213 // event handlers
214 void OnSize(wxSizeEvent& event);
3795cdba 215 void OnNcPaint(wxNcPaintEvent& event);
1e6feb95
VZ
216 void OnPaint(wxPaintEvent& event);
217 void OnErase(wxEraseEvent& event);
218
219#if wxUSE_ACCEL || wxUSE_MENUS
220 void OnKeyDown(wxKeyEvent& event);
221#endif // wxUSE_ACCEL
222
223#if wxUSE_MENUS
224 void OnChar(wxKeyEvent& event);
225 void OnKeyUp(wxKeyEvent& event);
226#endif // wxUSE_MENUS
227
a290fa5a 228 // draw the control background, return true if done
1e6feb95
VZ
229 virtual bool DoDrawBackground(wxDC& dc);
230
231 // draw the controls border
232 virtual void DoDrawBorder(wxDC& dc, const wxRect& rect);
233
234 // draw the controls contents
235 virtual void DoDraw(wxControlRenderer *renderer);
236
2c1a1ed1
VZ
237 // override the base class method to return the size of the window borders
238 virtual wxSize DoGetBorderSize() const;
239
1e6feb95
VZ
240 // adjust the size of the window to take into account its borders
241 wxSize AdjustSize(const wxSize& size) const;
242
243 // put the scrollbars along the edges of the window
244 void PositionScrollbars();
245
246#if wxUSE_MENUS
247 // return the menubar of the parent frame or NULL
248 wxMenuBar *GetParentFrameMenuBar() const;
249#endif // wxUSE_MENUS
250
251 // the renderer we use
252 wxRenderer *m_renderer;
4cc4e7b6 253
1e6feb95
VZ
254 // background bitmap info
255 wxBitmap m_bitmapBg;
256 int m_alignBgBitmap;
257 wxStretch m_stretchBgBitmap;
4cc4e7b6 258
aae73669
RR
259 // old size
260 wxSize m_oldSize;
1e6feb95 261
23895080
VZ
262 // is the mouse currently inside the window?
263 bool m_isCurrent:1;
1e6feb95 264
30827629 265#ifdef __WXMSW__
e9efd3f5 266public:
30827629 267 // override MSWWindowProc() to process WM_NCHITTEST
c140b7e7 268 WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
30827629
VZ
269#endif // __WXMSW__
270
1e6feb95 271private:
9a6384ca
WS
272
273#if wxUSE_SCROLLBAR
1e6feb95
VZ
274 // the window scrollbars
275 wxScrollBar *m_scrollbarHorz,
276 *m_scrollbarVert;
9a6384ca 277#endif // wxUSE_SCROLLBAR
1e6feb95 278
1e6feb95
VZ
279#if wxUSE_MENUS
280 // the current modal event loop for the popup menu we show or NULL
281 static wxEventLoop *ms_evtLoopPopup;
282
283 // the last window over which Alt was pressed (used by OnKeyUp)
284 static wxWindow *ms_winLastAltPress;
285#endif // wxUSE_MENUS
286
287 DECLARE_DYNAMIC_CLASS(wxWindow)
288 DECLARE_EVENT_TABLE()
289};
290
291#endif // _WX_UNIV_WINDOW_H_