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