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