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