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