]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/window.h
long long for DJGPP
[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)
1e6feb95
VZ
11// Licence: wxWindows license
12///////////////////////////////////////////////////////////////////////////////
13
14#ifndef _WX_UNIV_WINDOW_H_
15#define _WX_UNIV_WINDOW_H_
16
17#ifdef __GNUG__
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
30// ----------------------------------------------------------------------------
31// constants
32// ----------------------------------------------------------------------------
33
34// control state flags used in wxRenderer and wxColourScheme
35enum
36{
37 wxCONTROL_DISABLED = 0x00000001, // control is disabled
38 wxCONTROL_FOCUSED = 0x00000002, // currently has keyboard focus
39 wxCONTROL_PRESSED = 0x00000004, // (button) is pressed
40 wxCONTROL_ISDEFAULT = 0x00000008, // only applies to the buttons
41 wxCONTROL_ISSUBMENU = wxCONTROL_ISDEFAULT, // only for menu items
42 wxCONTROL_CURRENT = 0x00000010, // mouse is currently over the control
43 wxCONTROL_SELECTED = 0x00000020, // selected item in e.g. listbox
44 wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked
45 wxCONTROL_CHECKABLE = 0x00000080, // (menu) item can be checked
46
47 wxCONTROL_FLAGS_MASK = 0x000000ff,
48
49 // this is a pseudo flag not used directly by wxRenderer but rather by some
50 // controls internally
51 wxCONTROL_DIRTY = 0x80000000
52};
53
54// ----------------------------------------------------------------------------
55// wxWindow
56// ----------------------------------------------------------------------------
57
24ce4c18
JS
58#if defined(__WXMSW__)
59#define wxWindowNative wxWindowMSW
60#elif defined(__WXGTK__)
61#define wxWindowNative wxWindowGTK
62#elif defined(__WXMGL__)
63#define wxWindowNative wxWindowMGL
e766c8a9
SC
64#elif defined(__WXMAC__)
65#define wxWindowNative wxWindowMac
24ce4c18
JS
66#endif
67
1e6feb95
VZ
68class WXDLLEXPORT wxWindow : public wxWindowNative
69{
70public:
1a77875b 71 // ctors and create functions
1e6feb95
VZ
72 // ---------------------------
73
74 wxWindow() { Init(); }
75
76 wxWindow(wxWindow *parent,
77 wxWindowID id,
78 const wxPoint& pos = wxDefaultPosition,
79 const wxSize& size = wxDefaultSize,
80 long style = 0,
81 const wxString& name = wxPanelNameStr)
82 : wxWindowNative(parent, id, pos, size, style | wxCLIP_CHILDREN, name)
83 { Init(); }
84
85 bool Create(wxWindow *parent,
86 wxWindowID id,
87 const wxPoint& pos = wxDefaultPosition,
88 const wxSize& size = wxDefaultSize,
89 long style = 0,
90 const wxString& name = wxPanelNameStr);
91
92 // background pixmap support
93 // -------------------------
94
95 virtual void SetBackground(const wxBitmap& bitmap,
96 int alignment = wxALIGN_CENTRE,
97 wxStretch stretch = wxSTRETCH_NOT);
98
99 const wxBitmap& GetBackgroundBitmap(int *alignment = NULL,
100 wxStretch *stretch = NULL) const;
101
102 // scrollbars: we (re)implement it ourselves using our own scrollbars
103 // instead of the native ones
104 // ------------------------------------------------------------------
105
106 virtual void SetScrollbar(int orient,
107 int pos,
108 int page,
109 int range,
110 bool refresh = TRUE );
111 virtual void SetScrollPos(int orient, int pos, bool refresh = TRUE);
112 virtual int GetScrollPos(int orient) const;
113 virtual int GetScrollThumb(int orient) const;
114 virtual int GetScrollRange(int orient) const;
115 virtual void ScrollWindow(int dx, int dy,
116 const wxRect* rect = (wxRect *) NULL);
117
118 // take into account the borders here
119 virtual wxPoint GetClientAreaOrigin() const;
120
121 // popup menu support
122 // ------------------
123
124 // NB: all menu related functions are implemented in menu.cpp
125
126#if wxUSE_MENUS
127 virtual bool DoPopupMenu(wxMenu *menu, int x, int y);
128
129 // this is wxUniv-specific private method to be used only by wxMenu
130 void DismissPopupMenu();
131#endif // wxUSE_MENUS
132
133 // miscellaneous other methods
134 // ---------------------------
135
136 // get the state information
137 virtual bool IsFocused() const;
138 virtual bool IsCurrent() const;
139 virtual bool IsPressed() const;
140 virtual bool IsDefault() const;
141
142 // return all state flags at once (combination of wxCONTROL_XXX values)
143 int GetStateFlags() const;
144
145 // set the "highlighted" flag and return TRUE if it changed
146 virtual bool SetCurrent(bool doit = TRUE);
147
148 // get the scrollbar (may be NULL) for the given orientation
149 wxScrollBar *GetScrollbar(int orient) const
150 {
151 return orient & wxVERTICAL ? m_scrollbarVert : m_scrollbarHorz;
152 }
153
154 // methods used by wxColourScheme to choose the colours for this window
155 // --------------------------------------------------------------------
156
157 // return TRUE if this is a panel/canvas window which contains other
158 // controls only
159 virtual bool IsCanvasWindow() const { return FALSE; }
160
161 // return TRUE if this a container window which contains the other items:
162 // e.g, a listbox, listctrl, treectrl, ... and FALSE if it is a monolithic
163 // control (e.g. a button, checkbox, ...)
164 virtual bool IsContainerWindow() const { return FALSE; }
165
166 // return TRUE if this control can be highlighted when the mouse is over
167 // it (the theme decides itself whether it is really highlighted or not)
168 virtual bool CanBeHighlighted() const { return FALSE; }
169
170 // return TRUE if we should use the colours/fonts returned by the
171 // corresponding GetXXX() methods instead of the default ones
172 bool UseBgCol() const { return m_hasBgCol; }
173 bool UseFgCol() const { return m_hasFgCol; }
174 bool UseFont() const { return m_hasFont; }
175
176 // returns the (low level) renderer to use for drawing the control by
177 // querying the current theme
178 wxRenderer *GetRenderer() const { return m_renderer; }
179
180 // scrolling helper: like ScrollWindow() except that it doesn't refresh the
181 // uncovered window areas but returns the rectangle to update (don't call
182 // this with both dx and dy non zero)
183 wxRect ScrollNoRefresh(int dx, int dy, const wxRect *rect = NULL);
184
185 // after scrollbars are added or removed they must be refreshed by calling
186 // this function
187 void RefreshScrollbars();
188
189 // erase part of the control
190 virtual void EraseBackground(wxDC& dc, const wxRect& rect);
191
192 // overridden base class methods
193 // -----------------------------
194
195 // the rect coordinates are, for us, in client coords, but if no rect is
196 // specified, the entire window is refreshed
197 virtual void Refresh(bool eraseBackground = TRUE,
198 const wxRect *rect = (const wxRect *) NULL);
199
200 // we refresh the window when it is dis/enabled
201 virtual bool Enable(bool enable = TRUE);
202
1e6feb95
VZ
203 // our Capture/ReleaseMouse() maintains the stack of windows which had
204 // captured the mouse and when ReleaseMouse() is called, the mouse freed
205 // only if the stack is empty, otherwise it is captured back by the window
206 // on top of the stack
207 virtual void CaptureMouse();
208 virtual void ReleaseMouse();
209
210protected:
211 // common part of all ctors
212 void Init();
213
214 // overridden base class virtuals
215
216 // we deal with the scrollbars in these functions
217 virtual void DoSetClientSize(int width, int height);
218 virtual void DoGetClientSize(int *width, int *height) const;
219 virtual wxHitTest DoHitTest(wxCoord x, wxCoord y) const;
220
221 // event handlers
222 void OnSize(wxSizeEvent& event);
223 void OnNcPaint(wxPaintEvent& event);
224 void OnPaint(wxPaintEvent& event);
225 void OnErase(wxEraseEvent& event);
226
227#if wxUSE_ACCEL || wxUSE_MENUS
228 void OnKeyDown(wxKeyEvent& event);
229#endif // wxUSE_ACCEL
230
231#if wxUSE_MENUS
232 void OnChar(wxKeyEvent& event);
233 void OnKeyUp(wxKeyEvent& event);
234#endif // wxUSE_MENUS
235
236 // draw the control background, return TRUE if done
237 virtual bool DoDrawBackground(wxDC& dc);
238
239 // draw the controls border
240 virtual void DoDrawBorder(wxDC& dc, const wxRect& rect);
241
242 // draw the controls contents
243 virtual void DoDraw(wxControlRenderer *renderer);
244
245 // calculate the best size for the client area of the window: default
246 // implementation of DoGetBestSize() uses this method and adds the border
247 // width to the result
248 virtual wxSize DoGetBestClientSize() const;
249 virtual wxSize DoGetBestSize() const;
250
251 // adjust the size of the window to take into account its borders
252 wxSize AdjustSize(const wxSize& size) const;
253
254 // put the scrollbars along the edges of the window
255 void PositionScrollbars();
256
257#if wxUSE_MENUS
258 // return the menubar of the parent frame or NULL
259 wxMenuBar *GetParentFrameMenuBar() const;
260#endif // wxUSE_MENUS
261
262 // the renderer we use
263 wxRenderer *m_renderer;
264
265 // background bitmap info
266 wxBitmap m_bitmapBg;
267 int m_alignBgBitmap;
268 wxStretch m_stretchBgBitmap;
269
23895080
VZ
270 // is the mouse currently inside the window?
271 bool m_isCurrent:1;
1e6feb95
VZ
272
273private:
274 // the window scrollbars
275 wxScrollBar *m_scrollbarHorz,
276 *m_scrollbarVert;
277
278 // the stack of windows which have captured the mouse
279 static struct WXDLLEXPORT wxWindowNext *ms_winCaptureNext;
280
281#if wxUSE_MENUS
282 // the current modal event loop for the popup menu we show or NULL
283 static wxEventLoop *ms_evtLoopPopup;
284
285 // the last window over which Alt was pressed (used by OnKeyUp)
286 static wxWindow *ms_winLastAltPress;
287#endif // wxUSE_MENUS
288
289 DECLARE_DYNAMIC_CLASS(wxWindow)
290 DECLARE_EVENT_TABLE()
291};
292
293#endif // _WX_UNIV_WINDOW_H_
294