]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/window.h
use slashes instead of backslashes and quotes instead of angle brackets in all #includes
[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
9// RCS-ID: $Id$
442b35b5 10// Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
65571936 11// Licence: wxWindows licence
1e6feb95
VZ
12///////////////////////////////////////////////////////////////////////////////
13
14#ifndef _WX_UNIV_WINDOW_H_
15#define _WX_UNIV_WINDOW_H_
16
12028905 17#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
196cc38b 18 #pragma interface "univwindow.h"
1e6feb95
VZ
19#endif
20
21#include "wx/bitmap.h" // for m_bitmapBg
22
23class WXDLLEXPORT wxControlRenderer;
24class WXDLLEXPORT wxEventLoop;
25class WXDLLEXPORT wxMenu;
26class WXDLLEXPORT wxMenuBar;
27class WXDLLEXPORT wxRenderer;
28class WXDLLEXPORT wxScrollBar;
29
ab6b6b15
RR
30#ifdef __WXX11__
31#define wxUSE_TWO_WINDOWS 1
32#else
33#define wxUSE_TWO_WINDOWS 0
34#endif
35
1e6feb95
VZ
36// ----------------------------------------------------------------------------
37// wxWindow
38// ----------------------------------------------------------------------------
39
24ce4c18
JS
40#if defined(__WXMSW__)
41#define wxWindowNative wxWindowMSW
42#elif defined(__WXGTK__)
43#define wxWindowNative wxWindowGTK
44#elif defined(__WXMGL__)
45#define wxWindowNative wxWindowMGL
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
1e6feb95
VZ
52class WXDLLEXPORT wxWindow : public wxWindowNative
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
76 // background pixmap support
77 // -------------------------
78
79 virtual void SetBackground(const wxBitmap& bitmap,
80 int alignment = wxALIGN_CENTRE,
81 wxStretch stretch = wxSTRETCH_NOT);
82
83 const wxBitmap& GetBackgroundBitmap(int *alignment = NULL,
84 wxStretch *stretch = NULL) const;
85
86 // scrollbars: we (re)implement it ourselves using our own scrollbars
87 // instead of the native ones
88 // ------------------------------------------------------------------
89
90 virtual void SetScrollbar(int orient,
91 int pos,
92 int page,
93 int range,
a290fa5a
WS
94 bool refresh = true );
95 virtual void SetScrollPos(int orient, int pos, bool refresh = true);
1e6feb95
VZ
96 virtual int GetScrollPos(int orient) const;
97 virtual int GetScrollThumb(int orient) const;
98 virtual int GetScrollRange(int orient) const;
99 virtual void ScrollWindow(int dx, int dy,
100 const wxRect* rect = (wxRect *) NULL);
101
102 // take into account the borders here
103 virtual wxPoint GetClientAreaOrigin() const;
104
105 // popup menu support
106 // ------------------
107
108 // NB: all menu related functions are implemented in menu.cpp
109
110#if wxUSE_MENUS
111 virtual bool DoPopupMenu(wxMenu *menu, int x, int y);
112
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
VZ
131
132 // get the scrollbar (may be NULL) for the given orientation
133 wxScrollBar *GetScrollbar(int orient) const
134 {
135 return orient & wxVERTICAL ? m_scrollbarVert : m_scrollbarHorz;
136 }
137
138 // methods used by wxColourScheme to choose the colours for this window
139 // --------------------------------------------------------------------
140
a290fa5a 141 // return true if this is a panel/canvas window which contains other
1e6feb95 142 // controls only
a290fa5a 143 virtual bool IsCanvasWindow() const { return false; }
1e6feb95 144
a290fa5a 145 // returns true if the control has "transparent" areas such
193e19cf
RR
146 // as a wxStaticText and wxCheckBox and the background should
147 // be adapted from a parent window
a290fa5a 148 virtual bool HasTransparentBackground() { return false; }
193e19cf
RR
149
150 // to be used with function above: transparent windows get
a290fa5a 151 // their background from parents that return true here,
193e19cf 152 // so this is mostly for wxPanel, wxTopLevelWindow etc.
a290fa5a 153 virtual bool ProvidesBackground() const { return false; }
193e19cf 154
a290fa5a 155 // return true if this control can be highlighted when the mouse is over
1e6feb95 156 // it (the theme decides itself whether it is really highlighted or not)
a290fa5a 157 virtual bool CanBeHighlighted() const { return false; }
1e6feb95 158
a290fa5a 159 // return true if we should use the colours/fonts returned by the
1e6feb95
VZ
160 // corresponding GetXXX() methods instead of the default ones
161 bool UseBgCol() const { return m_hasBgCol; }
162 bool UseFgCol() const { return m_hasFgCol; }
163 bool UseFont() const { return m_hasFont; }
164
a290fa5a 165 // return true if this window serves as a container for the other windows
30827629 166 // only and doesn't get any input itself
a290fa5a 167 virtual bool IsStaticBox() const { return false; }
30827629 168
1e6feb95
VZ
169 // returns the (low level) renderer to use for drawing the control by
170 // querying the current theme
171 wxRenderer *GetRenderer() const { return m_renderer; }
172
173 // scrolling helper: like ScrollWindow() except that it doesn't refresh the
174 // uncovered window areas but returns the rectangle to update (don't call
175 // this with both dx and dy non zero)
176 wxRect ScrollNoRefresh(int dx, int dy, const wxRect *rect = NULL);
177
178 // after scrollbars are added or removed they must be refreshed by calling
179 // this function
180 void RefreshScrollbars();
181
182 // erase part of the control
183 virtual void EraseBackground(wxDC& dc, const wxRect& rect);
67d947ba 184
1e6feb95
VZ
185 // overridden base class methods
186 // -----------------------------
187
188 // the rect coordinates are, for us, in client coords, but if no rect is
189 // specified, the entire window is refreshed
a290fa5a 190 virtual void Refresh(bool eraseBackground = true,
1e6feb95
VZ
191 const wxRect *rect = (const wxRect *) NULL);
192
193 // we refresh the window when it is dis/enabled
a290fa5a 194 virtual bool Enable(bool enable = true);
1e6feb95 195
b2d22a3f
VZ
196 // should we use the standard control colours or not?
197 virtual bool ShouldInheritColours() const { return false; }
198
1e6feb95
VZ
199protected:
200 // common part of all ctors
201 void Init();
202
203 // overridden base class virtuals
204
205 // we deal with the scrollbars in these functions
206 virtual void DoSetClientSize(int width, int height);
207 virtual void DoGetClientSize(int *width, int *height) const;
208 virtual wxHitTest DoHitTest(wxCoord x, wxCoord y) const;
209
210 // event handlers
211 void OnSize(wxSizeEvent& event);
3795cdba 212 void OnNcPaint(wxNcPaintEvent& event);
1e6feb95
VZ
213 void OnPaint(wxPaintEvent& event);
214 void OnErase(wxEraseEvent& event);
215
216#if wxUSE_ACCEL || wxUSE_MENUS
217 void OnKeyDown(wxKeyEvent& event);
218#endif // wxUSE_ACCEL
219
220#if wxUSE_MENUS
221 void OnChar(wxKeyEvent& event);
222 void OnKeyUp(wxKeyEvent& event);
223#endif // wxUSE_MENUS
224
a290fa5a 225 // draw the control background, return true if done
1e6feb95
VZ
226 virtual bool DoDrawBackground(wxDC& dc);
227
228 // draw the controls border
229 virtual void DoDrawBorder(wxDC& dc, const wxRect& rect);
230
231 // draw the controls contents
232 virtual void DoDraw(wxControlRenderer *renderer);
233
234 // calculate the best size for the client area of the window: default
235 // implementation of DoGetBestSize() uses this method and adds the border
236 // width to the result
237 virtual wxSize DoGetBestClientSize() const;
238 virtual wxSize DoGetBestSize() const;
239
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;
67d947ba 253
1e6feb95
VZ
254 // background bitmap info
255 wxBitmap m_bitmapBg;
256 int m_alignBgBitmap;
257 wxStretch m_stretchBgBitmap;
aae73669
RR
258
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
VZ
265#ifdef __WXMSW__
266 // override MSWWindowProc() to process WM_NCHITTEST
c140b7e7 267 WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
30827629
VZ
268#endif // __WXMSW__
269
1e6feb95
VZ
270private:
271 // the window scrollbars
272 wxScrollBar *m_scrollbarHorz,
273 *m_scrollbarVert;
274
1e6feb95
VZ
275#if wxUSE_MENUS
276 // the current modal event loop for the popup menu we show or NULL
277 static wxEventLoop *ms_evtLoopPopup;
278
279 // the last window over which Alt was pressed (used by OnKeyUp)
280 static wxWindow *ms_winLastAltPress;
281#endif // wxUSE_MENUS
282
283 DECLARE_DYNAMIC_CLASS(wxWindow)
284 DECLARE_EVENT_TABLE()
285};
286
287#endif // _WX_UNIV_WINDOW_H_
288