]>
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 | |
cc2b7472 VZ |
16 | // --------------------------------------------------------------------------- |
17 | // constants | |
18 | // --------------------------------------------------------------------------- | |
1e6d9499 | 19 | |
cc2b7472 VZ |
20 | // --------------------------------------------------------------------------- |
21 | // wxWindow declaration for MSW | |
22 | // --------------------------------------------------------------------------- | |
b782f2e0 | 23 | |
1e6feb95 | 24 | class WXDLLEXPORT wxWindowMSW : public wxWindowBase |
1e6d9499 | 25 | { |
8e44f3ca JS |
26 | friend class wxSpinCtrl; |
27 | friend class wxSlider; | |
28 | friend class wxRadioBox; | |
fa61fec5 MW |
29 | #if defined __VISUALC__ && __VISUALC__ <= 1200 |
30 | friend class wxWindowMSW; | |
31 | #endif | |
2bda0e17 | 32 | public: |
6463b9f5 | 33 | wxWindowMSW() { Init(); } |
1e6feb95 VZ |
34 | |
35 | wxWindowMSW(wxWindow *parent, | |
36 | wxWindowID id, | |
37 | const wxPoint& pos = wxDefaultPosition, | |
38 | const wxSize& size = wxDefaultSize, | |
39 | long style = 0, | |
6463b9f5 JS |
40 | const wxString& name = wxPanelNameStr) |
41 | { | |
42 | Init(); | |
43 | Create(parent, id, pos, size, style, name); | |
44 | } | |
2bda0e17 | 45 | |
1e6feb95 | 46 | virtual ~wxWindowMSW(); |
2bda0e17 | 47 | |
cc2b7472 VZ |
48 | bool Create(wxWindow *parent, |
49 | wxWindowID id, | |
50 | const wxPoint& pos = wxDefaultPosition, | |
51 | const wxSize& size = wxDefaultSize, | |
52 | long style = 0, | |
53 | const wxString& name = wxPanelNameStr); | |
bfc6fde4 | 54 | |
cc2b7472 | 55 | // implement base class pure virtuals |
faa49bfd WS |
56 | virtual void SetLabel(const wxString& label); |
57 | virtual wxString GetLabel() const; | |
42e69d6b | 58 | |
bfc6fde4 | 59 | virtual void Raise(); |
bfc6fde4 VZ |
60 | virtual void Lower(); |
61 | ||
376d7d97 VZ |
62 | virtual bool Show(bool show = true); |
63 | virtual bool ShowWithEffect(wxShowEffect effect, | |
64 | unsigned timeout = 0, | |
65 | wxDirection dir = wxBOTTOM) | |
66 | { | |
67 | return MSWShowWithEffect(true, effect, timeout, dir); | |
68 | } | |
69 | virtual bool HideWithEffect(wxShowEffect effect, | |
70 | unsigned timeout = 0, | |
71 | wxDirection dir = wxBOTTOM) | |
72 | { | |
73 | return MSWShowWithEffect(false, effect, timeout, dir); | |
74 | } | |
bfc6fde4 | 75 | |
cc2b7472 | 76 | virtual void SetFocus(); |
ddf9d04f | 77 | virtual void SetFocusFromKbd(); |
bfc6fde4 | 78 | |
1e6feb95 | 79 | virtual bool Reparent(wxWindowBase *newParent); |
bfc6fde4 | 80 | |
cc2b7472 | 81 | virtual void WarpPointer(int x, int y); |
bfc6fde4 | 82 | |
27d2dbbc | 83 | virtual void Refresh( bool eraseBackground = true, |
cc2b7472 | 84 | const wxRect *rect = (const wxRect *) NULL ); |
1e6feb95 | 85 | virtual void Update(); |
a0e449ff VZ |
86 | virtual void Freeze(); |
87 | virtual void Thaw(); | |
d4a1433f | 88 | virtual bool IsFrozen() const { return m_frozenness > 0; } |
bfc6fde4 | 89 | |
7bd6bf45 VZ |
90 | virtual void SetWindowStyleFlag(long style); |
91 | virtual void SetExtraStyle(long exStyle); | |
cc2b7472 VZ |
92 | virtual bool SetCursor( const wxCursor &cursor ); |
93 | virtual bool SetFont( const wxFont &font ); | |
bfc6fde4 | 94 | |
bfc6fde4 VZ |
95 | virtual int GetCharHeight() const; |
96 | virtual int GetCharWidth() const; | |
cc2b7472 VZ |
97 | virtual void GetTextExtent(const wxString& string, |
98 | int *x, int *y, | |
99 | int *descent = (int *) NULL, | |
100 | int *externalLeading = (int *) NULL, | |
101 | const wxFont *theFont = (const wxFont *) NULL) | |
102 | const; | |
103 | ||
cc2b7472 | 104 | virtual void SetScrollbar( int orient, int pos, int thumbVisible, |
27d2dbbc WS |
105 | int range, bool refresh = true ); |
106 | virtual void SetScrollPos( int orient, int pos, bool refresh = true ); | |
cc2b7472 VZ |
107 | virtual int GetScrollPos( int orient ) const; |
108 | virtual int GetScrollThumb( int orient ) const; | |
109 | virtual int GetScrollRange( int orient ) const; | |
110 | virtual void ScrollWindow( int dx, int dy, | |
111 | const wxRect* rect = (wxRect *) NULL ); | |
2bda0e17 | 112 | |
9cd6d737 VZ |
113 | virtual bool ScrollLines(int lines); |
114 | virtual bool ScrollPages(int pages); | |
b9b3393e | 115 | |
978af864 VZ |
116 | virtual void SetLayoutDirection(wxLayoutDirection dir); |
117 | virtual wxLayoutDirection GetLayoutDirection() const; | |
118 | virtual wxCoord AdjustForLayoutDirection(wxCoord x, | |
119 | wxCoord width, | |
120 | wxCoord widthTotal) const; | |
121 | ||
47d67540 | 122 | #if wxUSE_DRAG_AND_DROP |
cc2b7472 VZ |
123 | virtual void SetDropTarget( wxDropTarget *dropTarget ); |
124 | #endif // wxUSE_DRAG_AND_DROP | |
9f3362c4 | 125 | |
bfc6fde4 VZ |
126 | // Accept files for dragging |
127 | virtual void DragAcceptFiles(bool accept); | |
2bda0e17 | 128 | |
1e6feb95 | 129 | #ifndef __WXUNIVERSAL__ |
cc2b7472 VZ |
130 | // Native resource loading (implemented in src/msw/nativdlg.cpp) |
131 | // FIXME: should they really be all virtual? | |
bfc6fde4 VZ |
132 | virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id); |
133 | virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name); | |
42e69d6b VZ |
134 | wxWindow* GetWindowChild1(wxWindowID id); |
135 | wxWindow* GetWindowChild(wxWindowID id); | |
1e6feb95 | 136 | #endif // __WXUNIVERSAL__ |
2bda0e17 | 137 | |
540b6b09 | 138 | #if wxUSE_HOTKEY |
5048c832 | 139 | // install and deinstall a system wide hotkey |
540b6b09 | 140 | virtual bool RegisterHotKey(int hotkeyId, int modifiers, int keycode); |
5048c832 | 141 | virtual bool UnregisterHotKey(int hotkeyId); |
540b6b09 | 142 | #endif // wxUSE_HOTKEY |
5048c832 | 143 | |
7d4f65e3 JS |
144 | #ifdef __POCKETPC__ |
145 | bool IsContextMenuEnabled() const { return m_contextMenuEnabled; } | |
146 | void EnableContextMenu(bool enable = true) { m_contextMenuEnabled = enable; } | |
147 | #endif | |
148 | ||
ed4780ea VZ |
149 | // window handle stuff |
150 | // ------------------- | |
2bda0e17 | 151 | |
d7c24517 VZ |
152 | WXHWND GetHWND() const { return m_hWnd; } |
153 | void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; } | |
154 | virtual WXWidget GetHandle() const { return GetHWND(); } | |
2bda0e17 | 155 | |
ed4780ea VZ |
156 | void AssociateHandle(WXWidget handle); |
157 | void DissociateHandle(); | |
158 | ||
f7040b5f VZ |
159 | // does this window have deferred position and/or size? |
160 | bool IsSizeDeferred() const; | |
161 | ||
5acec112 VZ |
162 | // these functions allow to register a global handler for the given Windows |
163 | // message: it will be called from MSWWindowProc() of any window which gets | |
164 | // this event if it's not processed before (i.e. unlike a hook procedure it | |
165 | // does not override the normal processing) | |
166 | // | |
167 | // notice that if you want to process a message for a given window only you | |
168 | // should override its MSWWindowProc() instead | |
169 | ||
170 | // type of the handler: it is called with the message parameters (except | |
171 | // that the window object is passed instead of window handle) and should | |
172 | // return true if it handled the message or false if it should be passed to | |
173 | // DefWindowProc() | |
2035ad11 | 174 | typedef bool (*MSWMessageHandler)(wxWindowMSW *win, |
5acec112 VZ |
175 | WXUINT nMsg, |
176 | WXWPARAM wParam, | |
177 | WXLPARAM lParam); | |
178 | ||
179 | // install a handler, shouldn't be called more than one for the same message | |
180 | static bool MSWRegisterMessageHandler(int msg, MSWMessageHandler handler); | |
181 | ||
182 | // unregister a previously registered handler | |
183 | static void MSWUnregisterMessageHandler(int msg, MSWMessageHandler handler); | |
184 | ||
ed4780ea VZ |
185 | |
186 | // implementation from now on | |
187 | // ========================== | |
188 | ||
cc2b7472 VZ |
189 | // event handlers |
190 | // -------------- | |
00c4e897 | 191 | |
63da7df7 | 192 | void OnPaint(wxPaintEvent& event); |
8681b094 | 193 | void OnEraseBackground(wxEraseEvent& event); |
79099b80 | 194 | #ifdef __WXWINCE__ |
8681b094 | 195 | void OnInitDialog(wxInitDialogEvent& event); |
79099b80 | 196 | #endif |
2bda0e17 | 197 | |
2bda0e17 | 198 | public: |
bfc6fde4 VZ |
199 | // Windows subclassing |
200 | void SubclassWin(WXHWND hWnd); | |
201 | void UnsubclassWin(); | |
bfc6fde4 | 202 | |
a23fd0e1 VZ |
203 | WXFARPROC MSWGetOldWndProc() const { return m_oldWndProc; } |
204 | void MSWSetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; } | |
bfc6fde4 | 205 | |
27d2dbbc | 206 | // return true if the window is of a standard (i.e. not wxWidgets') class |
5a403e3f VZ |
207 | // |
208 | // to understand why does it work, look at SubclassWin() code and comments | |
209 | bool IsOfStandardClass() const { return m_oldWndProc != NULL; } | |
210 | ||
197dd9af | 211 | wxWindow *FindItem(long id) const; |
27d2dbbc | 212 | wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = false) const; |
bfc6fde4 | 213 | |
27d2dbbc | 214 | // MSW only: true if this control is part of the main control |
47b378bd | 215 | virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return false; } |
bfc6fde4 | 216 | |
c009bf3e VZ |
217 | #if wxUSE_TOOLTIPS |
218 | // MSW only: true if this window or any of its children have a tooltip | |
219 | virtual bool HasToolTips() const { return GetToolTip() != NULL; } | |
220 | #endif // wxUSE_TOOLTIPS | |
221 | ||
77ffb593 | 222 | // translate wxWidgets style flags for this control into the Windows style |
b2d5a7ee VZ |
223 | // and optional extended style for the corresponding native control |
224 | // | |
225 | // this is the function that should be overridden in the derived classes, | |
226 | // but you will mostly use MSWGetCreateWindowFlags() below | |
fe3d9123 | 227 | virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const ; |
b2d5a7ee | 228 | |
77ffb593 | 229 | // get the MSW window flags corresponding to wxWidgets ones |
b2d5a7ee VZ |
230 | // |
231 | // the functions returns the flags (WS_XXX) directly and puts the ext | |
232 | // (WS_EX_XXX) flags into the provided pointer if not NULL | |
233 | WXDWORD MSWGetCreateWindowFlags(WXDWORD *exflags = NULL) const | |
234 | { return MSWGetStyle(GetWindowStyle(), exflags); } | |
235 | ||
7bd6bf45 VZ |
236 | // update the real underlying window style flags to correspond to the |
237 | // current wxWindow object style (safe to call even if window isn't fully | |
238 | // created yet) | |
239 | void MSWUpdateStyle(long flagsOld, long exflagsOld); | |
240 | ||
77ffb593 | 241 | // translate wxWidgets coords into Windows ones suitable to be passed to |
b225f659 VZ |
242 | // ::CreateWindow() |
243 | // | |
27d2dbbc | 244 | // returns true if non default coords are returned, false otherwise |
b225f659 VZ |
245 | bool MSWGetCreateWindowCoords(const wxPoint& pos, |
246 | const wxSize& size, | |
247 | int& x, int& y, | |
248 | int& w, int& h) const; | |
249 | ||
9dfef5ac VZ |
250 | // get the HWND to be used as parent of this window with CreateWindow() |
251 | virtual WXHWND MSWGetParent() const; | |
252 | ||
b225f659 VZ |
253 | // creates the window of specified Windows class with given style, extended |
254 | // style, title and geometry (default values | |
255 | // | |
27d2dbbc | 256 | // returns true if the window has been created, false if creation failed |
b225f659 VZ |
257 | bool MSWCreate(const wxChar *wclass, |
258 | const wxChar *title = NULL, | |
259 | const wxPoint& pos = wxDefaultPosition, | |
260 | const wxSize& size = wxDefaultSize, | |
261 | WXDWORD style = 0, | |
a23fd0e1 | 262 | WXDWORD exendedStyle = 0); |
b225f659 | 263 | |
42e69d6b | 264 | virtual bool MSWCommand(WXUINT param, WXWORD id); |
bfc6fde4 | 265 | |
1e6feb95 | 266 | #ifndef __WXUNIVERSAL__ |
bfc6fde4 VZ |
267 | // Create an appropriate wxWindow from a HWND |
268 | virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd); | |
269 | ||
270 | // Make sure the window style reflects the HWND style (roughly) | |
271 | virtual void AdoptAttributesFromHWND(); | |
1e6feb95 | 272 | #endif // __WXUNIVERSAL__ |
bfc6fde4 VZ |
273 | |
274 | // Setup background and foreground colours correctly | |
275 | virtual void SetupColours(); | |
276 | ||
42e69d6b VZ |
277 | // ------------------------------------------------------------------------ |
278 | // helpers for message handlers: these perform the same function as the | |
279 | // message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into | |
280 | // the correct parameters | |
281 | // ------------------------------------------------------------------------ | |
282 | ||
283 | void UnpackCommand(WXWPARAM wParam, WXLPARAM lParam, | |
284 | WXWORD *id, WXHWND *hwnd, WXWORD *cmd); | |
285 | void UnpackActivate(WXWPARAM wParam, WXLPARAM lParam, | |
286 | WXWORD *state, WXWORD *minimized, WXHWND *hwnd); | |
287 | void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam, | |
288 | WXWORD *code, WXWORD *pos, WXHWND *hwnd); | |
289 | void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam, | |
01c500af | 290 | WXHDC *hdc, WXHWND *hwnd); |
42e69d6b VZ |
291 | void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam, |
292 | WXWORD *item, WXWORD *flags, WXHMENU *hmenu); | |
293 | ||
a23fd0e1 | 294 | // ------------------------------------------------------------------------ |
3cfcd50b | 295 | // internal handlers for MSW messages: all handlers return a boolean value: |
27d2dbbc | 296 | // true means that the handler processed the event and false that it didn't |
a23fd0e1 | 297 | // ------------------------------------------------------------------------ |
bfc6fde4 | 298 | |
42e69d6b VZ |
299 | // there are several cases where we have virtual functions for Windows |
300 | // message processing: this is because these messages often require to be | |
301 | // processed in a different manner in the derived classes. For all other | |
302 | // messages, however, we do *not* have corresponding MSWOnXXX() function | |
303 | // and if the derived class wants to process them, it should override | |
304 | // MSWWindowProc() directly. | |
a23fd0e1 | 305 | |
42e69d6b | 306 | // scroll event (both horizontal and vertical) |
a23fd0e1 VZ |
307 | virtual bool MSWOnScroll(int orientation, WXWORD nSBCode, |
308 | WXWORD pos, WXHWND control); | |
309 | ||
42e69d6b | 310 | // child control notifications |
a23fd0e1 | 311 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); |
a23fd0e1 | 312 | |
42e69d6b VZ |
313 | // owner-drawn controls need to process these messages |
314 | virtual bool MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *item); | |
315 | virtual bool MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *item); | |
316 | ||
317 | // the rest are not virtual | |
318 | bool HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate); | |
319 | bool HandleInitDialog(WXHWND hWndFocus); | |
320 | bool HandleDestroy(); | |
321 | ||
322 | bool HandlePaint(); | |
1a784dfc VZ |
323 | bool HandlePrintClient(WXHDC hDC); |
324 | bool HandleEraseBkgnd(WXHDC hDC); | |
42e69d6b VZ |
325 | |
326 | bool HandleMinimize(); | |
327 | bool HandleMaximize(); | |
328 | bool HandleSize(int x, int y, WXUINT flag); | |
5706de1c | 329 | bool HandleSizing(wxRect& rect); |
42e69d6b | 330 | bool HandleGetMinMaxInfo(void *mmInfo); |
aa767a45 JS |
331 | bool HandleEnterSizeMove(); |
332 | bool HandleExitSizeMove(); | |
42e69d6b VZ |
333 | |
334 | bool HandleShow(bool show, int status); | |
335 | bool HandleActivate(int flag, bool minimized, WXHWND activate); | |
336 | ||
337 | bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); | |
42e69d6b | 338 | |
48fa6bd3 | 339 | bool HandleCtlColor(WXHBRUSH *hBrush, WXHDC hdc, WXHWND hWnd); |
a23fd0e1 | 340 | |
42e69d6b VZ |
341 | bool HandlePaletteChanged(WXHWND hWndPalChange); |
342 | bool HandleQueryNewPalette(); | |
343 | bool HandleSysColorChange(); | |
574c939e | 344 | bool HandleDisplayChange(); |
a5e84126 | 345 | bool HandleCaptureChanged(WXHWND gainedCapture); |
1272e71b | 346 | virtual bool HandleSettingChange(WXWPARAM wParam, WXLPARAM lParam); |
a23fd0e1 | 347 | |
42e69d6b VZ |
348 | bool HandleQueryEndSession(long logOff, bool *mayEnd); |
349 | bool HandleEndSession(bool endSession, long logOff); | |
a23fd0e1 | 350 | |
42e69d6b VZ |
351 | bool HandleSetFocus(WXHWND wnd); |
352 | bool HandleKillFocus(WXHWND wnd); | |
bfc6fde4 | 353 | |
42e69d6b | 354 | bool HandleDropFiles(WXWPARAM wParam); |
bfc6fde4 | 355 | |
42e69d6b VZ |
356 | bool HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags); |
357 | bool HandleMouseMove(int x, int y, WXUINT flags); | |
d2c52078 | 358 | bool HandleMouseWheel(WXWPARAM wParam, WXLPARAM lParam); |
bfc6fde4 | 359 | |
27d2dbbc | 360 | bool HandleChar(WXWPARAM wParam, WXLPARAM lParam, bool isASCII = false); |
33ac7e6f KB |
361 | bool HandleKeyDown(WXWPARAM wParam, WXLPARAM lParam); |
362 | bool HandleKeyUp(WXWPARAM wParam, WXLPARAM lParam); | |
5048c832 JS |
363 | #if wxUSE_ACCEL |
364 | bool HandleHotKey(WXWPARAM wParam, WXLPARAM lParam); | |
365 | #endif | |
b74cce40 VZ |
366 | #ifdef __WIN32__ |
367 | int HandleMenuChar(int chAccel, WXLPARAM lParam); | |
368 | #endif | |
78c91815 VZ |
369 | // Create and process a clipboard event specified by type. |
370 | bool HandleClipboardEvent( WXUINT nMsg ); | |
bfc6fde4 | 371 | |
42e69d6b VZ |
372 | bool HandleQueryDragIcon(WXHICON *hIcon); |
373 | ||
374 | bool HandleSetCursor(WXHWND hWnd, short nHitTest, int mouseMsg); | |
bfc6fde4 | 375 | |
355debca VZ |
376 | bool HandlePower(WXWPARAM wParam, WXLPARAM lParam, bool *vetoed); |
377 | ||
378 | ||
bfc6fde4 | 379 | // Window procedure |
c140b7e7 | 380 | virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); |
bfc6fde4 VZ |
381 | |
382 | // Calls an appropriate default window procedure | |
c140b7e7 | 383 | virtual WXLRESULT MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); |
a37d422a VZ |
384 | |
385 | // message processing helpers | |
386 | ||
27d2dbbc | 387 | // return false if the message shouldn't be translated/preprocessed but |
a37d422a VZ |
388 | // dispatched normally |
389 | virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg); | |
390 | ||
27d2dbbc | 391 | // return true if the message was preprocessed and shouldn't be dispatched |
bfc6fde4 | 392 | virtual bool MSWProcessMessage(WXMSG* pMsg); |
a37d422a | 393 | |
27d2dbbc | 394 | // return true if the message was translated and shouldn't be dispatched |
bfc6fde4 | 395 | virtual bool MSWTranslateMessage(WXMSG* pMsg); |
a37d422a VZ |
396 | |
397 | // called when the window is about to be destroyed | |
bfc6fde4 VZ |
398 | virtual void MSWDestroyWindow(); |
399 | ||
01c500af | 400 | |
c5bd3c62 VZ |
401 | // this function should return the brush to paint the children controls |
402 | // background or 0 if this window doesn't impose any particular background | |
403 | // on its children | |
404 | // | |
c3732409 VZ |
405 | // the base class version returns a solid brush if we have a non default |
406 | // background colour or 0 otherwise | |
2bae4332 | 407 | virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, WXHWND hWnd); |
c5bd3c62 | 408 | |
c3732409 VZ |
409 | // return the background brush to use for painting the given window by |
410 | // quering the parent windows via their MSWGetBgBrushForChild() recursively | |
c5bd3c62 | 411 | // |
2bae4332 | 412 | // hWndToPaint is normally NULL meaning this window itself, but it can also |
c3732409 VZ |
413 | // be a child of this window which is used by the static box and could be |
414 | // potentially useful for other transparent controls | |
2bae4332 | 415 | WXHBRUSH MSWGetBgBrush(WXHDC hDC, WXHWND hWndToPaint = NULL); |
c3732409 VZ |
416 | |
417 | // gives the parent the possibility to draw its children background, e.g. | |
418 | // this is used by wxNotebook to do it using DrawThemeBackground() | |
07c19327 | 419 | // |
c3732409 VZ |
420 | // return true if background was drawn, false otherwise |
421 | virtual bool MSWPrintChild(WXHDC WXUNUSED(hDC), wxWindow * WXUNUSED(child)) | |
422 | { | |
423 | return false; | |
424 | } | |
07c19327 | 425 | |
ce0e1aac JS |
426 | // some controls (e.g. wxListBox) need to set the return value themselves |
427 | // | |
428 | // return true to let parent handle it if we don't, false otherwise | |
429 | virtual bool MSWShouldPropagatePrintChild() | |
430 | { | |
431 | return true; | |
432 | } | |
433 | ||
376d7d97 VZ |
434 | // common part of Show/HideWithEffect() |
435 | bool MSWShowWithEffect(bool show, | |
436 | wxShowEffect effect, | |
437 | unsigned timeout, | |
438 | wxDirection dir); | |
07c19327 | 439 | |
bfc6fde4 VZ |
440 | // Responds to colour changes: passes event on to children. |
441 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
442 | ||
a23fd0e1 VZ |
443 | // initialize various fields of wxMouseEvent (common part of MSWOnMouseXXX) |
444 | void InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags); | |
bfc6fde4 | 445 | |
1e6feb95 VZ |
446 | // check if mouse is in the window |
447 | bool IsMouseInWindow() const; | |
2e992e06 VZ |
448 | |
449 | // check if a native double-buffering applies for this window | |
450 | virtual bool IsDoubleBuffered() const; | |
1e6feb95 | 451 | |
51e4e266 VZ |
452 | // synthesize a wxEVT_LEAVE_WINDOW event and set m_mouseInWindow to false |
453 | void GenerateMouseLeave(); | |
454 | ||
e39af974 JS |
455 | // virtual function for implementing internal idle |
456 | // behaviour | |
c3732409 | 457 | virtual void OnInternalIdle(); |
e39af974 | 458 | |
2bda0e17 | 459 | protected: |
3c75d8ba PC |
460 | // this allows you to implement standard control borders without |
461 | // repeating the code in different classes that are not derived from | |
462 | // wxControl | |
463 | virtual wxBorder GetDefaultBorderForControl() const; | |
464 | ||
465 | // choose the default border for this window | |
466 | virtual wxBorder GetDefaultBorder() const; | |
6f02a879 | 467 | |
dc797d8e JS |
468 | // Translate wxBORDER_THEME (and other border styles if necessary to the value |
469 | // that makes most sense for this Windows environment | |
470 | virtual wxBorder TranslateBorder(wxBorder border) const; | |
471 | ||
6f02a879 VZ |
472 | #if wxUSE_MENUS_NATIVE |
473 | virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); | |
474 | #endif // wxUSE_MENUS_NATIVE | |
475 | ||
d7c24517 VZ |
476 | // the window handle |
477 | WXHWND m_hWnd; | |
478 | ||
cc2b7472 | 479 | // the old window proc (we subclass all windows) |
bfc6fde4 | 480 | WXFARPROC m_oldWndProc; |
2bda0e17 | 481 | |
cc2b7472 | 482 | // additional (MSW specific) flags |
cc2b7472 | 483 | bool m_mouseInWindow:1; |
68304caf | 484 | bool m_lastKeydownProcessed:1; |
bfc6fde4 | 485 | |
cc2b7472 | 486 | // the size of one page for scrolling |
bfc6fde4 VZ |
487 | int m_xThumbSize; |
488 | int m_yThumbSize; | |
2bda0e17 | 489 | |
cc2b7472 | 490 | // implement the base class pure virtuals |
dabc0cd5 VZ |
491 | virtual void DoClientToScreen( int *x, int *y ) const; |
492 | virtual void DoScreenToClient( int *x, int *y ) const; | |
cc2b7472 VZ |
493 | virtual void DoGetPosition( int *x, int *y ) const; |
494 | virtual void DoGetSize( int *width, int *height ) const; | |
495 | virtual void DoGetClientSize( int *width, int *height ) const; | |
496 | virtual void DoSetSize(int x, int y, | |
497 | int width, int height, | |
498 | int sizeFlags = wxSIZE_AUTO); | |
bfc6fde4 | 499 | virtual void DoSetClientSize(int width, int height); |
2bda0e17 | 500 | |
94633ad9 VZ |
501 | virtual void DoCaptureMouse(); |
502 | virtual void DoReleaseMouse(); | |
68304caf | 503 | |
3c75d8ba PC |
504 | virtual void DoEnable(bool enable); |
505 | ||
7d86a2d4 VZ |
506 | // this simply moves/resizes the given HWND which is supposed to be our |
507 | // sibling (this is useful for controls which are composite at MSW level | |
508 | // and for which DoMoveWindow() is not enough) | |
86e30911 VZ |
509 | // |
510 | // returns true if the window move was deferred, false if it was moved | |
511 | // immediately (no error return) | |
512 | bool DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height); | |
7d86a2d4 | 513 | |
b782f2e0 VZ |
514 | // move the window to the specified location and resize it: this is called |
515 | // from both DoSetSize() and DoSetClientSize() and would usually just call | |
516 | // ::MoveWindow() except for composite controls which will want to arrange | |
517 | // themselves inside the given rectangle | |
518 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
519 | ||
cc2b7472 VZ |
520 | #if wxUSE_TOOLTIPS |
521 | virtual void DoSetToolTip( wxToolTip *tip ); | |
bd9cd534 VZ |
522 | |
523 | // process TTN_NEEDTEXT message properly (i.e. fixing the bugs in | |
524 | // comctl32.dll in our code -- see the function body for more info) | |
525 | bool HandleTooltipNotify(WXUINT code, | |
526 | WXLPARAM lParam, | |
527 | const wxString& ttip); | |
cc2b7472 VZ |
528 | #endif // wxUSE_TOOLTIPS |
529 | ||
b09bda68 | 530 | // the helper functions used by HandleChar/KeyXXX methods |
9c7df356 VZ |
531 | wxKeyEvent CreateKeyEvent(wxEventType evType, int id, |
532 | WXLPARAM lParam = 0, WXWPARAM wParam = 0) const; | |
b09bda68 | 533 | |
3b72cd91 VZ |
534 | |
535 | // default OnEraseBackground() implementation, return true if we did erase | |
c3732409 VZ |
536 | // the background, false otherwise (i.e. the system should erase it) |
537 | bool DoEraseBackground(WXHDC hDC); | |
3b72cd91 | 538 | |
1ca78aa1 | 539 | // generate WM_CHANGEUISTATE if it's needed for the OS we're running under |
3ef092d6 | 540 | // |
1ca78aa1 JS |
541 | // action should be one of the UIS_XXX constants |
542 | // state should be one or more of the UISF_XXX constants | |
543 | // if action == UIS_INITIALIZE then it doesn't seem to matter what we use | |
544 | // for state as the system will decide for us what needs to be set | |
545 | void MSWUpdateUIState(int action, int state = 0); | |
d7e0024b | 546 | |
fd3f686c VZ |
547 | private: |
548 | // common part of all ctors | |
549 | void Init(); | |
550 | ||
a23fd0e1 VZ |
551 | // the (non-virtual) handlers for the events |
552 | bool HandleMove(int x, int y); | |
5706de1c | 553 | bool HandleMoving(wxRect& rect); |
a23fd0e1 | 554 | bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags); |
a23fd0e1 | 555 | bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); |
a23fd0e1 | 556 | |
d7cbabe0 | 557 | |
a1037371 VZ |
558 | // number of calls to Freeze() minus number of calls to Thaw() |
559 | unsigned int m_frozenness; | |
560 | ||
220f77b0 | 561 | // current defer window position operation handle (may be NULL) |
3b72cd91 | 562 | WXHANDLE m_hDWP; |
220f77b0 | 563 | |
5637cc35 | 564 | protected: |
67644c1d RD |
565 | // When deferred positioning is done these hold the pending changes, and |
566 | // are used for the default values if another size/pos changes is done on | |
567 | // this window before the group of deferred changes is completed. | |
568 | wxPoint m_pendingPosition; | |
569 | wxSize m_pendingSize; | |
220f77b0 | 570 | |
5637cc35 | 571 | private: |
7d4f65e3 JS |
572 | #ifdef __POCKETPC__ |
573 | bool m_contextMenuEnabled; | |
574 | #endif | |
575 | ||
e8e4fa12 GT |
576 | DECLARE_DYNAMIC_CLASS(wxWindowMSW) |
577 | DECLARE_NO_COPY_CLASS(wxWindowMSW) | |
fd3f686c | 578 | DECLARE_EVENT_TABLE() |
2bda0e17 KB |
579 | }; |
580 | ||
b0cb0158 VZ |
581 | // ---------------------------------------------------------------------------- |
582 | // inline functions | |
583 | // ---------------------------------------------------------------------------- | |
584 | ||
cc2b7472 VZ |
585 | // --------------------------------------------------------------------------- |
586 | // global functions | |
587 | // --------------------------------------------------------------------------- | |
2bda0e17 | 588 | |
cc2b7472 | 589 | // kbd code translation |
ff792344 | 590 | WXDLLEXPORT int wxCharCodeMSWToWX(int keySym, WXLPARAM lParam = 0); |
d5c21b02 | 591 | WXDLLEXPORT WXWORD wxCharCodeWXToMSW(int id, bool *IsVirtual = NULL); |
2bda0e17 | 592 | |
b225f659 VZ |
593 | // window creation helper class: before creating a new HWND, instantiate an |
594 | // object of this class on stack - this allows to process the messages sent to | |
595 | // the window even before CreateWindow() returns | |
596 | class wxWindowCreationHook | |
597 | { | |
598 | public: | |
599 | wxWindowCreationHook(wxWindowMSW *winBeingCreated); | |
600 | ~wxWindowCreationHook(); | |
601 | }; | |
602 | ||
cbc8c6ee VZ |
603 | // ---------------------------------------------------------------------------- |
604 | // global objects | |
605 | // ---------------------------------------------------------------------------- | |
606 | ||
607 | // notice that this hash must be defined after wxWindow declaration as it | |
608 | // needs to "see" its dtor and not just forward declaration | |
609 | #include "wx/hash.h" | |
610 | ||
611 | // pseudo-template HWND <-> wxWindow hash table | |
40ad3426 | 612 | WX_DECLARE_HASH(wxWindowMSW, wxWindowList, wxWinHashTable); |
cbc8c6ee VZ |
613 | |
614 | extern wxWinHashTable *wxWinHandleHash; | |
615 | ||
faa49bfd | 616 | #endif // _WX_WINDOW_H_ |