]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
1e6feb95 | 2 | // Name: wx/msw/window.h |
faa49bfd | 3 | // Purpose: wxWindowMSW class |
2bda0e17 | 4 | // Author: Julian Smart |
1e6feb95 VZ |
5 | // Modified by: Vadim Zeitlin on 13.05.99: complete refont of message handling, |
6 | // elimination of Default(), ... | |
2bda0e17 KB |
7 | // Created: 01/02/97 |
8 | // RCS-ID: $Id$ | |
371a5b4e | 9 | // Copyright: (c) Julian Smart |
65571936 | 10 | // Licence: wxWindows licence |
2bda0e17 KB |
11 | ///////////////////////////////////////////////////////////////////////////// |
12 | ||
bbcdf8bc JS |
13 | #ifndef _WX_WINDOW_H_ |
14 | #define _WX_WINDOW_H_ | |
2bda0e17 | 15 | |
cf7715db | 16 | #include "wx/settings.h" // solely for wxSystemColour |
a5b1be33 | 17 | |
6bd9b9f2 VZ |
18 | // if this is set to 1, we use deferred window sizing to reduce flicker when |
19 | // resizing complicated window hierarchies, but this can in theory result in | |
20 | // different behaviour than the old code so we keep the possibility to use it | |
21 | // by setting this to 0 (in the future this should be removed completely) | |
22 | #ifdef __WXWINCE__ | |
23 | #define wxUSE_DEFERRED_SIZING 0 | |
24 | #else | |
25 | #define wxUSE_DEFERRED_SIZING 1 | |
26 | #endif | |
1e6d9499 | 27 | |
cc2b7472 VZ |
28 | // --------------------------------------------------------------------------- |
29 | // wxWindow declaration for MSW | |
30 | // --------------------------------------------------------------------------- | |
b782f2e0 | 31 | |
53a2db12 | 32 | class WXDLLIMPEXP_CORE wxWindowMSW : public wxWindowBase |
1e6d9499 | 33 | { |
8e44f3ca JS |
34 | friend class wxSpinCtrl; |
35 | friend class wxSlider; | |
36 | friend class wxRadioBox; | |
fa61fec5 MW |
37 | #if defined __VISUALC__ && __VISUALC__ <= 1200 |
38 | friend class wxWindowMSW; | |
39 | #endif | |
2bda0e17 | 40 | public: |
6463b9f5 | 41 | wxWindowMSW() { Init(); } |
1e6feb95 VZ |
42 | |
43 | wxWindowMSW(wxWindow *parent, | |
44 | wxWindowID id, | |
45 | const wxPoint& pos = wxDefaultPosition, | |
46 | const wxSize& size = wxDefaultSize, | |
47 | long style = 0, | |
6463b9f5 JS |
48 | const wxString& name = wxPanelNameStr) |
49 | { | |
50 | Init(); | |
51 | Create(parent, id, pos, size, style, name); | |
52 | } | |
2bda0e17 | 53 | |
1e6feb95 | 54 | virtual ~wxWindowMSW(); |
2bda0e17 | 55 | |
cc2b7472 VZ |
56 | bool Create(wxWindow *parent, |
57 | wxWindowID id, | |
58 | const wxPoint& pos = wxDefaultPosition, | |
59 | const wxSize& size = wxDefaultSize, | |
60 | long style = 0, | |
61 | const wxString& name = wxPanelNameStr); | |
bfc6fde4 | 62 | |
cc2b7472 | 63 | // implement base class pure virtuals |
faa49bfd WS |
64 | virtual void SetLabel(const wxString& label); |
65 | virtual wxString GetLabel() const; | |
42e69d6b | 66 | |
bfc6fde4 | 67 | virtual void Raise(); |
bfc6fde4 VZ |
68 | virtual void Lower(); |
69 | ||
376d7d97 VZ |
70 | virtual bool Show(bool show = true); |
71 | virtual bool ShowWithEffect(wxShowEffect effect, | |
eed04c99 | 72 | unsigned timeout = 0) |
376d7d97 | 73 | { |
eed04c99 | 74 | return MSWShowWithEffect(true, effect, timeout); |
376d7d97 VZ |
75 | } |
76 | virtual bool HideWithEffect(wxShowEffect effect, | |
eed04c99 | 77 | unsigned timeout = 0) |
376d7d97 | 78 | { |
eed04c99 | 79 | return MSWShowWithEffect(false, effect, timeout); |
376d7d97 | 80 | } |
bfc6fde4 | 81 | |
cc2b7472 | 82 | virtual void SetFocus(); |
ddf9d04f | 83 | virtual void SetFocusFromKbd(); |
bfc6fde4 | 84 | |
1e6feb95 | 85 | virtual bool Reparent(wxWindowBase *newParent); |
bfc6fde4 | 86 | |
cc2b7472 | 87 | virtual void WarpPointer(int x, int y); |
bfc6fde4 | 88 | |
27d2dbbc | 89 | virtual void Refresh( bool eraseBackground = true, |
cc2b7472 | 90 | const wxRect *rect = (const wxRect *) NULL ); |
1e6feb95 | 91 | virtual void Update(); |
bfc6fde4 | 92 | |
7bd6bf45 VZ |
93 | virtual void SetWindowStyleFlag(long style); |
94 | virtual void SetExtraStyle(long exStyle); | |
cc2b7472 VZ |
95 | virtual bool SetCursor( const wxCursor &cursor ); |
96 | virtual bool SetFont( const wxFont &font ); | |
bfc6fde4 | 97 | |
bfc6fde4 VZ |
98 | virtual int GetCharHeight() const; |
99 | virtual int GetCharWidth() const; | |
cc2b7472 | 100 | |
cc2b7472 | 101 | virtual void SetScrollbar( int orient, int pos, int thumbVisible, |
27d2dbbc WS |
102 | int range, bool refresh = true ); |
103 | virtual void SetScrollPos( int orient, int pos, bool refresh = true ); | |
cc2b7472 VZ |
104 | virtual int GetScrollPos( int orient ) const; |
105 | virtual int GetScrollThumb( int orient ) const; | |
106 | virtual int GetScrollRange( int orient ) const; | |
107 | virtual void ScrollWindow( int dx, int dy, | |
d3b9f782 | 108 | const wxRect* rect = NULL ); |
2bda0e17 | 109 | |
9cd6d737 VZ |
110 | virtual bool ScrollLines(int lines); |
111 | virtual bool ScrollPages(int pages); | |
b9b3393e | 112 | |
978af864 VZ |
113 | virtual void SetLayoutDirection(wxLayoutDirection dir); |
114 | virtual wxLayoutDirection GetLayoutDirection() const; | |
115 | virtual wxCoord AdjustForLayoutDirection(wxCoord x, | |
116 | wxCoord width, | |
117 | wxCoord widthTotal) const; | |
118 | ||
47d67540 | 119 | #if wxUSE_DRAG_AND_DROP |
cc2b7472 VZ |
120 | virtual void SetDropTarget( wxDropTarget *dropTarget ); |
121 | #endif // wxUSE_DRAG_AND_DROP | |
9f3362c4 | 122 | |
bfc6fde4 VZ |
123 | // Accept files for dragging |
124 | virtual void DragAcceptFiles(bool accept); | |
2bda0e17 | 125 | |
1e6feb95 | 126 | #ifndef __WXUNIVERSAL__ |
cc2b7472 VZ |
127 | // Native resource loading (implemented in src/msw/nativdlg.cpp) |
128 | // FIXME: should they really be all virtual? | |
bfc6fde4 VZ |
129 | virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id); |
130 | virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name); | |
42e69d6b VZ |
131 | wxWindow* GetWindowChild1(wxWindowID id); |
132 | wxWindow* GetWindowChild(wxWindowID id); | |
1e6feb95 | 133 | #endif // __WXUNIVERSAL__ |
2bda0e17 | 134 | |
540b6b09 | 135 | #if wxUSE_HOTKEY |
5048c832 | 136 | // install and deinstall a system wide hotkey |
540b6b09 | 137 | virtual bool RegisterHotKey(int hotkeyId, int modifiers, int keycode); |
5048c832 | 138 | virtual bool UnregisterHotKey(int hotkeyId); |
540b6b09 | 139 | #endif // wxUSE_HOTKEY |
5048c832 | 140 | |
7d4f65e3 JS |
141 | #ifdef __POCKETPC__ |
142 | bool IsContextMenuEnabled() const { return m_contextMenuEnabled; } | |
143 | void EnableContextMenu(bool enable = true) { m_contextMenuEnabled = enable; } | |
144 | #endif | |
145 | ||
ed4780ea VZ |
146 | // window handle stuff |
147 | // ------------------- | |
2bda0e17 | 148 | |
d7c24517 VZ |
149 | WXHWND GetHWND() const { return m_hWnd; } |
150 | void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; } | |
151 | virtual WXWidget GetHandle() const { return GetHWND(); } | |
2bda0e17 | 152 | |
ed4780ea VZ |
153 | void AssociateHandle(WXWidget handle); |
154 | void DissociateHandle(); | |
155 | ||
f7040b5f VZ |
156 | // does this window have deferred position and/or size? |
157 | bool IsSizeDeferred() const; | |
158 | ||
5acec112 VZ |
159 | // these functions allow to register a global handler for the given Windows |
160 | // message: it will be called from MSWWindowProc() of any window which gets | |
161 | // this event if it's not processed before (i.e. unlike a hook procedure it | |
162 | // does not override the normal processing) | |
163 | // | |
164 | // notice that if you want to process a message for a given window only you | |
165 | // should override its MSWWindowProc() instead | |
166 | ||
167 | // type of the handler: it is called with the message parameters (except | |
168 | // that the window object is passed instead of window handle) and should | |
169 | // return true if it handled the message or false if it should be passed to | |
170 | // DefWindowProc() | |
2035ad11 | 171 | typedef bool (*MSWMessageHandler)(wxWindowMSW *win, |
5acec112 VZ |
172 | WXUINT nMsg, |
173 | WXWPARAM wParam, | |
174 | WXLPARAM lParam); | |
175 | ||
176 | // install a handler, shouldn't be called more than one for the same message | |
177 | static bool MSWRegisterMessageHandler(int msg, MSWMessageHandler handler); | |
178 | ||
179 | // unregister a previously registered handler | |
180 | static void MSWUnregisterMessageHandler(int msg, MSWMessageHandler handler); | |
181 | ||
ed4780ea VZ |
182 | |
183 | // implementation from now on | |
184 | // ========================== | |
185 | ||
cc2b7472 VZ |
186 | // event handlers |
187 | // -------------- | |
00c4e897 | 188 | |
63da7df7 | 189 | void OnPaint(wxPaintEvent& event); |
79099b80 | 190 | #ifdef __WXWINCE__ |
8681b094 | 191 | void OnInitDialog(wxInitDialogEvent& event); |
79099b80 | 192 | #endif |
2bda0e17 | 193 | |
2bda0e17 | 194 | public: |
bfc6fde4 VZ |
195 | // Windows subclassing |
196 | void SubclassWin(WXHWND hWnd); | |
197 | void UnsubclassWin(); | |
bfc6fde4 | 198 | |
a23fd0e1 VZ |
199 | WXFARPROC MSWGetOldWndProc() const { return m_oldWndProc; } |
200 | void MSWSetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; } | |
bfc6fde4 | 201 | |
27d2dbbc | 202 | // return true if the window is of a standard (i.e. not wxWidgets') class |
5a403e3f VZ |
203 | // |
204 | // to understand why does it work, look at SubclassWin() code and comments | |
205 | bool IsOfStandardClass() const { return m_oldWndProc != NULL; } | |
206 | ||
197dd9af | 207 | wxWindow *FindItem(long id) const; |
27d2dbbc | 208 | wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = false) const; |
bfc6fde4 | 209 | |
27d2dbbc | 210 | // MSW only: true if this control is part of the main control |
47b378bd | 211 | virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return false; } |
bfc6fde4 | 212 | |
c009bf3e VZ |
213 | #if wxUSE_TOOLTIPS |
214 | // MSW only: true if this window or any of its children have a tooltip | |
215 | virtual bool HasToolTips() const { return GetToolTip() != NULL; } | |
216 | #endif // wxUSE_TOOLTIPS | |
217 | ||
77ffb593 | 218 | // translate wxWidgets style flags for this control into the Windows style |
b2d5a7ee VZ |
219 | // and optional extended style for the corresponding native control |
220 | // | |
221 | // this is the function that should be overridden in the derived classes, | |
222 | // but you will mostly use MSWGetCreateWindowFlags() below | |
fe3d9123 | 223 | virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const ; |
b2d5a7ee | 224 | |
77ffb593 | 225 | // get the MSW window flags corresponding to wxWidgets ones |
b2d5a7ee VZ |
226 | // |
227 | // the functions returns the flags (WS_XXX) directly and puts the ext | |
228 | // (WS_EX_XXX) flags into the provided pointer if not NULL | |
229 | WXDWORD MSWGetCreateWindowFlags(WXDWORD *exflags = NULL) const | |
230 | { return MSWGetStyle(GetWindowStyle(), exflags); } | |
231 | ||
7bd6bf45 VZ |
232 | // update the real underlying window style flags to correspond to the |
233 | // current wxWindow object style (safe to call even if window isn't fully | |
234 | // created yet) | |
235 | void MSWUpdateStyle(long flagsOld, long exflagsOld); | |
236 | ||
9dfef5ac VZ |
237 | // get the HWND to be used as parent of this window with CreateWindow() |
238 | virtual WXHWND MSWGetParent() const; | |
239 | ||
d9698bd4 VZ |
240 | // get the Win32 window class name used by all wxWindow objects by default |
241 | static const wxChar *MSWGetRegisteredClassName(); | |
242 | ||
b225f659 VZ |
243 | // creates the window of specified Windows class with given style, extended |
244 | // style, title and geometry (default values | |
245 | // | |
27d2dbbc | 246 | // returns true if the window has been created, false if creation failed |
b225f659 VZ |
247 | bool MSWCreate(const wxChar *wclass, |
248 | const wxChar *title = NULL, | |
249 | const wxPoint& pos = wxDefaultPosition, | |
250 | const wxSize& size = wxDefaultSize, | |
251 | WXDWORD style = 0, | |
a23fd0e1 | 252 | WXDWORD exendedStyle = 0); |
b225f659 | 253 | |
42e69d6b | 254 | virtual bool MSWCommand(WXUINT param, WXWORD id); |
bfc6fde4 | 255 | |
1e6feb95 | 256 | #ifndef __WXUNIVERSAL__ |
bfc6fde4 VZ |
257 | // Create an appropriate wxWindow from a HWND |
258 | virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd); | |
259 | ||
260 | // Make sure the window style reflects the HWND style (roughly) | |
261 | virtual void AdoptAttributesFromHWND(); | |
1e6feb95 | 262 | #endif // __WXUNIVERSAL__ |
bfc6fde4 VZ |
263 | |
264 | // Setup background and foreground colours correctly | |
265 | virtual void SetupColours(); | |
266 | ||
42e69d6b VZ |
267 | // ------------------------------------------------------------------------ |
268 | // helpers for message handlers: these perform the same function as the | |
269 | // message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into | |
270 | // the correct parameters | |
271 | // ------------------------------------------------------------------------ | |
272 | ||
273 | void UnpackCommand(WXWPARAM wParam, WXLPARAM lParam, | |
274 | WXWORD *id, WXHWND *hwnd, WXWORD *cmd); | |
275 | void UnpackActivate(WXWPARAM wParam, WXLPARAM lParam, | |
276 | WXWORD *state, WXWORD *minimized, WXHWND *hwnd); | |
277 | void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam, | |
278 | WXWORD *code, WXWORD *pos, WXHWND *hwnd); | |
279 | void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam, | |
01c500af | 280 | WXHDC *hdc, WXHWND *hwnd); |
42e69d6b VZ |
281 | void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam, |
282 | WXWORD *item, WXWORD *flags, WXHMENU *hmenu); | |
283 | ||
a23fd0e1 | 284 | // ------------------------------------------------------------------------ |
3cfcd50b | 285 | // internal handlers for MSW messages: all handlers return a boolean value: |
27d2dbbc | 286 | // true means that the handler processed the event and false that it didn't |
a23fd0e1 | 287 | // ------------------------------------------------------------------------ |
bfc6fde4 | 288 | |
42e69d6b VZ |
289 | // there are several cases where we have virtual functions for Windows |
290 | // message processing: this is because these messages often require to be | |
291 | // processed in a different manner in the derived classes. For all other | |
292 | // messages, however, we do *not* have corresponding MSWOnXXX() function | |
293 | // and if the derived class wants to process them, it should override | |
294 | // MSWWindowProc() directly. | |
a23fd0e1 | 295 | |
42e69d6b | 296 | // scroll event (both horizontal and vertical) |
a23fd0e1 VZ |
297 | virtual bool MSWOnScroll(int orientation, WXWORD nSBCode, |
298 | WXWORD pos, WXHWND control); | |
299 | ||
42e69d6b | 300 | // child control notifications |
a23fd0e1 | 301 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); |
a23fd0e1 | 302 | |
42e69d6b VZ |
303 | // owner-drawn controls need to process these messages |
304 | virtual bool MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *item); | |
305 | virtual bool MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *item); | |
306 | ||
307 | // the rest are not virtual | |
308 | bool HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate); | |
309 | bool HandleInitDialog(WXHWND hWndFocus); | |
310 | bool HandleDestroy(); | |
311 | ||
312 | bool HandlePaint(); | |
1a784dfc VZ |
313 | bool HandlePrintClient(WXHDC hDC); |
314 | bool HandleEraseBkgnd(WXHDC hDC); | |
42e69d6b VZ |
315 | |
316 | bool HandleMinimize(); | |
317 | bool HandleMaximize(); | |
318 | bool HandleSize(int x, int y, WXUINT flag); | |
5706de1c | 319 | bool HandleSizing(wxRect& rect); |
42e69d6b | 320 | bool HandleGetMinMaxInfo(void *mmInfo); |
aa767a45 JS |
321 | bool HandleEnterSizeMove(); |
322 | bool HandleExitSizeMove(); | |
42e69d6b VZ |
323 | |
324 | bool HandleShow(bool show, int status); | |
325 | bool HandleActivate(int flag, bool minimized, WXHWND activate); | |
326 | ||
327 | bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); | |
42e69d6b | 328 | |
48fa6bd3 | 329 | bool HandleCtlColor(WXHBRUSH *hBrush, WXHDC hdc, WXHWND hWnd); |
a23fd0e1 | 330 | |
42e69d6b VZ |
331 | bool HandlePaletteChanged(WXHWND hWndPalChange); |
332 | bool HandleQueryNewPalette(); | |
333 | bool HandleSysColorChange(); | |
574c939e | 334 | bool HandleDisplayChange(); |
a5e84126 | 335 | bool HandleCaptureChanged(WXHWND gainedCapture); |
1272e71b | 336 | virtual bool HandleSettingChange(WXWPARAM wParam, WXLPARAM lParam); |
a23fd0e1 | 337 | |
42e69d6b VZ |
338 | bool HandleQueryEndSession(long logOff, bool *mayEnd); |
339 | bool HandleEndSession(bool endSession, long logOff); | |
a23fd0e1 | 340 | |
42e69d6b VZ |
341 | bool HandleSetFocus(WXHWND wnd); |
342 | bool HandleKillFocus(WXHWND wnd); | |
bfc6fde4 | 343 | |
42e69d6b | 344 | bool HandleDropFiles(WXWPARAM wParam); |
bfc6fde4 | 345 | |
42e69d6b VZ |
346 | bool HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags); |
347 | bool HandleMouseMove(int x, int y, WXUINT flags); | |
b9e52a19 VZ |
348 | bool HandleMouseWheel(wxMouseWheelAxis axis, |
349 | WXWPARAM wParam, WXLPARAM lParam); | |
bfc6fde4 | 350 | |
b6885972 | 351 | bool HandleChar(WXWPARAM wParam, WXLPARAM lParam); |
33ac7e6f KB |
352 | bool HandleKeyDown(WXWPARAM wParam, WXLPARAM lParam); |
353 | bool HandleKeyUp(WXWPARAM wParam, WXLPARAM lParam); | |
5048c832 JS |
354 | #if wxUSE_ACCEL |
355 | bool HandleHotKey(WXWPARAM wParam, WXLPARAM lParam); | |
356 | #endif | |
b74cce40 VZ |
357 | #ifdef __WIN32__ |
358 | int HandleMenuChar(int chAccel, WXLPARAM lParam); | |
359 | #endif | |
78c91815 VZ |
360 | // Create and process a clipboard event specified by type. |
361 | bool HandleClipboardEvent( WXUINT nMsg ); | |
bfc6fde4 | 362 | |
42e69d6b VZ |
363 | bool HandleQueryDragIcon(WXHICON *hIcon); |
364 | ||
365 | bool HandleSetCursor(WXHWND hWnd, short nHitTest, int mouseMsg); | |
bfc6fde4 | 366 | |
355debca VZ |
367 | bool HandlePower(WXWPARAM wParam, WXLPARAM lParam, bool *vetoed); |
368 | ||
369 | ||
2e1cee23 VZ |
370 | // The main body of common window proc for all wxWindow objects. It tries |
371 | // to handle the given message and returns true if it was handled (the | |
372 | // appropriate return value is then put in result, which must be non-NULL) | |
373 | // or false if it wasn't. | |
374 | // | |
375 | // This function should be overridden in any new code instead of | |
376 | // MSWWindowProc() even if currently most of the code overrides | |
377 | // MSWWindowProc() as it had been written before this function was added. | |
378 | virtual bool MSWHandleMessage(WXLRESULT *result, | |
379 | WXUINT message, | |
380 | WXWPARAM wParam, | |
381 | WXLPARAM lParam); | |
382 | ||
383 | // Common Window procedure for all wxWindow objects: forwards to | |
384 | // MSWHandleMessage() and MSWDefWindowProc() if the message wasn't handled. | |
c140b7e7 | 385 | virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); |
bfc6fde4 VZ |
386 | |
387 | // Calls an appropriate default window procedure | |
c140b7e7 | 388 | virtual WXLRESULT MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); |
a37d422a VZ |
389 | |
390 | // message processing helpers | |
391 | ||
27d2dbbc | 392 | // return false if the message shouldn't be translated/preprocessed but |
a37d422a VZ |
393 | // dispatched normally |
394 | virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg); | |
395 | ||
27d2dbbc | 396 | // return true if the message was preprocessed and shouldn't be dispatched |
bfc6fde4 | 397 | virtual bool MSWProcessMessage(WXMSG* pMsg); |
a37d422a | 398 | |
27d2dbbc | 399 | // return true if the message was translated and shouldn't be dispatched |
bfc6fde4 | 400 | virtual bool MSWTranslateMessage(WXMSG* pMsg); |
a37d422a VZ |
401 | |
402 | // called when the window is about to be destroyed | |
bfc6fde4 VZ |
403 | virtual void MSWDestroyWindow(); |
404 | ||
01c500af | 405 | |
0a81f130 VZ |
406 | // Functions dealing with painting the window background. The derived |
407 | // classes should normally only need to reimplement MSWGetBgBrush() if they | |
408 | // need to use a non-solid brush for erasing their background. This | |
409 | // function is called by MSWGetBgBrushForChild() which only exists for the | |
410 | // weird wxToolBar case and MSWGetBgBrushForChild() itself is used by | |
411 | // MSWGetBgBrush() to actually find the right brush to use. | |
412 | ||
208717f6 VZ |
413 | // Adjust the origin for the brush returned by MSWGetBgBrushForChild(). |
414 | // | |
415 | // This needs to be overridden for scrolled windows to ensure that the | |
416 | // scrolling of their associated DC is taken into account. | |
417 | // | |
418 | // Both parameters must be non-NULL. | |
419 | virtual void MSWAdjustBrushOrg(int* WXUNUSED(xOrg), | |
420 | int* WXUNUSED(yOrg)) const | |
421 | { | |
422 | } | |
423 | ||
0a81f130 VZ |
424 | // The brush returned from here must remain valid at least until the next |
425 | // event loop iteration. Returning 0, as is done by default, indicates | |
426 | // there is no custom background brush. | |
427 | virtual WXHBRUSH MSWGetCustomBgBrush() { return 0; } | |
428 | ||
c5bd3c62 VZ |
429 | // this function should return the brush to paint the children controls |
430 | // background or 0 if this window doesn't impose any particular background | |
431 | // on its children | |
432 | // | |
b8797d96 VZ |
433 | // the hDC parameter is the DC background will be drawn on, it can be used |
434 | // to call SetBrushOrgEx() on it if the returned brush is a bitmap one | |
435 | // | |
ebfee179 VZ |
436 | // child parameter is never NULL, it can be this window itself or one of |
437 | // its (grand)children | |
b8797d96 | 438 | // |
c3732409 VZ |
439 | // the base class version returns a solid brush if we have a non default |
440 | // background colour or 0 otherwise | |
b8797d96 | 441 | virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child); |
c5bd3c62 | 442 | |
c3732409 | 443 | // return the background brush to use for painting the given window by |
ebfee179 VZ |
444 | // querying the parent windows via MSWGetBgBrushForChild() recursively |
445 | WXHBRUSH MSWGetBgBrush(WXHDC hDC); | |
c3732409 | 446 | |
a5b1be33 JS |
447 | enum MSWThemeColour |
448 | { | |
449 | ThemeColourText = 0, | |
450 | ThemeColourBackground, | |
451 | ThemeColourBorder | |
452 | }; | |
453 | ||
454 | // returns a specific theme colour, or if that is not possible then | |
455 | // wxSystemSettings::GetColour(fallback) | |
456 | wxColour MSWGetThemeColour(const wchar_t *themeName, | |
457 | int themePart, | |
458 | int themeState, | |
459 | MSWThemeColour themeColour, | |
108694fe | 460 | wxSystemColour fallback) const; |
a5b1be33 | 461 | |
c3732409 VZ |
462 | // gives the parent the possibility to draw its children background, e.g. |
463 | // this is used by wxNotebook to do it using DrawThemeBackground() | |
07c19327 | 464 | // |
c3732409 VZ |
465 | // return true if background was drawn, false otherwise |
466 | virtual bool MSWPrintChild(WXHDC WXUNUSED(hDC), wxWindow * WXUNUSED(child)) | |
467 | { | |
468 | return false; | |
469 | } | |
07c19327 | 470 | |
ce0e1aac JS |
471 | // some controls (e.g. wxListBox) need to set the return value themselves |
472 | // | |
473 | // return true to let parent handle it if we don't, false otherwise | |
474 | virtual bool MSWShouldPropagatePrintChild() | |
475 | { | |
476 | return true; | |
477 | } | |
478 | ||
d9317033 VZ |
479 | // This should be overridden to return true for the controls which have |
480 | // themed background that should through their children. Currently only | |
481 | // wxNotebook uses this. | |
4506b42c VZ |
482 | // |
483 | // The base class version already returns true if we have a solid | |
484 | // background colour that should be propagated to our children. | |
485 | virtual bool MSWHasInheritableBackground() const | |
486 | { | |
487 | return InheritsBackgroundColour(); | |
488 | } | |
d9317033 | 489 | |
bec9bf3e VZ |
490 | #if !defined(__WXWINCE__) && !defined(__WXUNIVERSAL__) |
491 | #define wxHAS_MSW_BACKGROUND_ERASE_HOOK | |
492 | #endif | |
493 | ||
494 | #ifdef wxHAS_MSW_BACKGROUND_ERASE_HOOK | |
495 | // allows the child to hook into its parent WM_ERASEBKGND processing: call | |
496 | // MSWSetEraseBgHook() with a non-NULL window to make parent call | |
497 | // MSWEraseBgHook() on this window (don't forget to reset it to NULL | |
498 | // afterwards) | |
499 | // | |
500 | // this hack is used by wxToolBar, see comments there | |
501 | void MSWSetEraseBgHook(wxWindow *child); | |
502 | ||
503 | // return true if WM_ERASEBKGND is currently hooked | |
504 | bool MSWHasEraseBgHook() const; | |
505 | ||
506 | // called when the window on which MSWSetEraseBgHook() had been called | |
507 | // receives WM_ERASEBKGND | |
508 | virtual bool MSWEraseBgHook(WXHDC WXUNUSED(hDC)) { return false; } | |
509 | #endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK | |
510 | ||
376d7d97 VZ |
511 | // common part of Show/HideWithEffect() |
512 | bool MSWShowWithEffect(bool show, | |
513 | wxShowEffect effect, | |
eed04c99 | 514 | unsigned timeout); |
07c19327 | 515 | |
bfc6fde4 VZ |
516 | // Responds to colour changes: passes event on to children. |
517 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
518 | ||
a23fd0e1 VZ |
519 | // initialize various fields of wxMouseEvent (common part of MSWOnMouseXXX) |
520 | void InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags); | |
bfc6fde4 | 521 | |
1e6feb95 VZ |
522 | // check if mouse is in the window |
523 | bool IsMouseInWindow() const; | |
2e992e06 VZ |
524 | |
525 | // check if a native double-buffering applies for this window | |
526 | virtual bool IsDoubleBuffered() const; | |
03647350 | 527 | |
f60ca3e2 | 528 | void SetDoubleBuffered(bool on); |
03647350 | 529 | |
51e4e266 VZ |
530 | // synthesize a wxEVT_LEAVE_WINDOW event and set m_mouseInWindow to false |
531 | void GenerateMouseLeave(); | |
532 | ||
e39af974 JS |
533 | // virtual function for implementing internal idle |
534 | // behaviour | |
c3732409 | 535 | virtual void OnInternalIdle(); |
e39af974 | 536 | |
2bda0e17 | 537 | protected: |
3c75d8ba PC |
538 | // this allows you to implement standard control borders without |
539 | // repeating the code in different classes that are not derived from | |
540 | // wxControl | |
541 | virtual wxBorder GetDefaultBorderForControl() const; | |
542 | ||
543 | // choose the default border for this window | |
544 | virtual wxBorder GetDefaultBorder() const; | |
6f02a879 | 545 | |
dc797d8e JS |
546 | // Translate wxBORDER_THEME (and other border styles if necessary to the value |
547 | // that makes most sense for this Windows environment | |
548 | virtual wxBorder TranslateBorder(wxBorder border) const; | |
549 | ||
6f02a879 VZ |
550 | #if wxUSE_MENUS_NATIVE |
551 | virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); | |
552 | #endif // wxUSE_MENUS_NATIVE | |
553 | ||
d7c24517 VZ |
554 | // the window handle |
555 | WXHWND m_hWnd; | |
556 | ||
cc2b7472 | 557 | // the old window proc (we subclass all windows) |
bfc6fde4 | 558 | WXFARPROC m_oldWndProc; |
2bda0e17 | 559 | |
cc2b7472 | 560 | // additional (MSW specific) flags |
cc2b7472 | 561 | bool m_mouseInWindow:1; |
68304caf | 562 | bool m_lastKeydownProcessed:1; |
bfc6fde4 | 563 | |
cc2b7472 | 564 | // the size of one page for scrolling |
bfc6fde4 VZ |
565 | int m_xThumbSize; |
566 | int m_yThumbSize; | |
2bda0e17 | 567 | |
cc2b7472 | 568 | // implement the base class pure virtuals |
6de70470 VZ |
569 | virtual void DoGetTextExtent(const wxString& string, |
570 | int *x, int *y, | |
571 | int *descent = NULL, | |
572 | int *externalLeading = NULL, | |
573 | const wxFont *font = NULL) const; | |
dabc0cd5 VZ |
574 | virtual void DoClientToScreen( int *x, int *y ) const; |
575 | virtual void DoScreenToClient( int *x, int *y ) const; | |
cc2b7472 VZ |
576 | virtual void DoGetPosition( int *x, int *y ) const; |
577 | virtual void DoGetSize( int *width, int *height ) const; | |
578 | virtual void DoGetClientSize( int *width, int *height ) const; | |
579 | virtual void DoSetSize(int x, int y, | |
580 | int width, int height, | |
581 | int sizeFlags = wxSIZE_AUTO); | |
bfc6fde4 | 582 | virtual void DoSetClientSize(int width, int height); |
2bda0e17 | 583 | |
743b4266 VZ |
584 | virtual wxSize DoGetBorderSize() const; |
585 | ||
94633ad9 VZ |
586 | virtual void DoCaptureMouse(); |
587 | virtual void DoReleaseMouse(); | |
68304caf | 588 | |
3c75d8ba PC |
589 | virtual void DoEnable(bool enable); |
590 | ||
17808a75 VZ |
591 | virtual void DoFreeze(); |
592 | virtual void DoThaw(); | |
593 | ||
7d86a2d4 VZ |
594 | // this simply moves/resizes the given HWND which is supposed to be our |
595 | // sibling (this is useful for controls which are composite at MSW level | |
596 | // and for which DoMoveWindow() is not enough) | |
86e30911 VZ |
597 | // |
598 | // returns true if the window move was deferred, false if it was moved | |
599 | // immediately (no error return) | |
600 | bool DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height); | |
7d86a2d4 | 601 | |
b782f2e0 VZ |
602 | // move the window to the specified location and resize it: this is called |
603 | // from both DoSetSize() and DoSetClientSize() and would usually just call | |
604 | // ::MoveWindow() except for composite controls which will want to arrange | |
605 | // themselves inside the given rectangle | |
606 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
607 | ||
cc2b7472 VZ |
608 | #if wxUSE_TOOLTIPS |
609 | virtual void DoSetToolTip( wxToolTip *tip ); | |
bd9cd534 VZ |
610 | |
611 | // process TTN_NEEDTEXT message properly (i.e. fixing the bugs in | |
612 | // comctl32.dll in our code -- see the function body for more info) | |
613 | bool HandleTooltipNotify(WXUINT code, | |
614 | WXLPARAM lParam, | |
615 | const wxString& ttip); | |
cc2b7472 VZ |
616 | #endif // wxUSE_TOOLTIPS |
617 | ||
b6885972 VZ |
618 | // This is used by CreateKeyEvent() and also for wxEVT_CHAR[_HOOK] event |
619 | // creation. Notice that this method doesn't initialize wxKeyEvent | |
620 | // m_keyCode and m_uniChar fields. | |
621 | void InitAnyKeyEvent(wxKeyEvent& event, | |
622 | WXWPARAM wParam, | |
623 | WXLPARAM lParam) const; | |
624 | ||
625 | // Helper functions used by HandleKeyXXX() methods and some derived | |
626 | // classes, wParam and lParam have the same meaning as in WM_KEY{DOWN,UP}. | |
627 | // | |
628 | // NB: evType here must be wxEVT_KEY_{DOWN,UP} as wParam here contains the | |
629 | // virtual key code, not character! | |
630 | wxKeyEvent CreateKeyEvent(wxEventType evType, | |
631 | WXWPARAM wParam, | |
632 | WXLPARAM lParam = 0) const; | |
b09bda68 | 633 | |
1afe4f9b VZ |
634 | // Another helper for creating wxKeyEvent for wxEVT_CHAR and related types. |
635 | // | |
636 | // The wParam and lParam here must come from WM_CHAR event parameters, i.e. | |
637 | // wParam must be a character and not a virtual code. | |
638 | wxKeyEvent CreateCharEvent(wxEventType evType, | |
639 | WXWPARAM wParam, | |
640 | WXLPARAM lParam) const; | |
641 | ||
3b72cd91 VZ |
642 | |
643 | // default OnEraseBackground() implementation, return true if we did erase | |
c3732409 VZ |
644 | // the background, false otherwise (i.e. the system should erase it) |
645 | bool DoEraseBackground(WXHDC hDC); | |
3b72cd91 | 646 | |
1ca78aa1 | 647 | // generate WM_CHANGEUISTATE if it's needed for the OS we're running under |
3ef092d6 | 648 | // |
1ca78aa1 JS |
649 | // action should be one of the UIS_XXX constants |
650 | // state should be one or more of the UISF_XXX constants | |
651 | // if action == UIS_INITIALIZE then it doesn't seem to matter what we use | |
652 | // for state as the system will decide for us what needs to be set | |
653 | void MSWUpdateUIState(int action, int state = 0); | |
d7e0024b | 654 | |
fa5f4858 VZ |
655 | // translate wxWidgets coords into Windows ones suitable to be passed to |
656 | // ::CreateWindow(), called from MSWCreate() | |
657 | virtual void MSWGetCreateWindowCoords(const wxPoint& pos, | |
658 | const wxSize& size, | |
659 | int& x, int& y, | |
660 | int& w, int& h) const; | |
661 | ||
0826c4d3 VS |
662 | bool MSWEnableHWND(WXHWND hWnd, bool enable); |
663 | ||
fd3f686c VZ |
664 | private: |
665 | // common part of all ctors | |
666 | void Init(); | |
667 | ||
a23fd0e1 VZ |
668 | // the (non-virtual) handlers for the events |
669 | bool HandleMove(int x, int y); | |
5706de1c | 670 | bool HandleMoving(wxRect& rect); |
a23fd0e1 | 671 | bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags); |
a23fd0e1 | 672 | bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); |
a23fd0e1 | 673 | |
6bd9b9f2 VZ |
674 | #if wxUSE_DEFERRED_SIZING |
675 | protected: | |
676 | // this function is called after the window was resized to its new size | |
677 | virtual void MSWEndDeferWindowPos() | |
678 | { | |
679 | m_pendingPosition = wxDefaultPosition; | |
680 | m_pendingSize = wxDefaultSize; | |
681 | } | |
d7cbabe0 | 682 | |
220f77b0 | 683 | // current defer window position operation handle (may be NULL) |
3b72cd91 | 684 | WXHANDLE m_hDWP; |
220f77b0 | 685 | |
67644c1d RD |
686 | // When deferred positioning is done these hold the pending changes, and |
687 | // are used for the default values if another size/pos changes is done on | |
688 | // this window before the group of deferred changes is completed. | |
689 | wxPoint m_pendingPosition; | |
690 | wxSize m_pendingSize; | |
6bd9b9f2 | 691 | #endif // wxUSE_DEFERRED_SIZING |
220f77b0 | 692 | |
5637cc35 | 693 | private: |
7d4f65e3 JS |
694 | #ifdef __POCKETPC__ |
695 | bool m_contextMenuEnabled; | |
696 | #endif | |
697 | ||
e8e4fa12 | 698 | DECLARE_DYNAMIC_CLASS(wxWindowMSW) |
c0c133e1 | 699 | wxDECLARE_NO_COPY_CLASS(wxWindowMSW); |
fd3f686c | 700 | DECLARE_EVENT_TABLE() |
2bda0e17 KB |
701 | }; |
702 | ||
b225f659 VZ |
703 | // window creation helper class: before creating a new HWND, instantiate an |
704 | // object of this class on stack - this allows to process the messages sent to | |
705 | // the window even before CreateWindow() returns | |
706 | class wxWindowCreationHook | |
707 | { | |
708 | public: | |
709 | wxWindowCreationHook(wxWindowMSW *winBeingCreated); | |
710 | ~wxWindowCreationHook(); | |
711 | }; | |
712 | ||
faa49bfd | 713 | #endif // _WX_WINDOW_H_ |