]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: windows.cpp | |
3 | // Purpose: wxWindow | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
a3622daa | 9 | // Licence: wxWindows license |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "window.h" | |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx.h". | |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #ifndef WX_PRECOMP | |
24 | #include <stdio.h> | |
25 | #include "wx/setup.h" | |
26 | #include "wx/menu.h" | |
27 | #include "wx/dc.h" | |
28 | #include "wx/dcclient.h" | |
29 | #include "wx/utils.h" | |
30 | #include "wx/app.h" | |
31 | #include "wx/panel.h" | |
32 | #include "wx/layout.h" | |
33 | #include "wx/dialog.h" | |
34 | #include "wx/listbox.h" | |
35 | #include "wx/button.h" | |
36 | #include "wx/settings.h" | |
37 | #include "wx/msgdlg.h" | |
38 | #endif | |
39 | ||
47d67540 | 40 | #if wxUSE_OWNER_DRAWN |
2bda0e17 KB |
41 | #include "wx/ownerdrw.h" |
42 | #endif | |
43 | ||
47d67540 | 44 | #if wxUSE_DRAG_AND_DROP |
2bda0e17 KB |
45 | #include "wx/msw/ole/droptgt.h" |
46 | #endif | |
47 | ||
48 | #include "wx/menuitem.h" | |
47cbd6da | 49 | #include "wx/log.h" |
2bda0e17 KB |
50 | #include "wx/msw/private.h" |
51 | ||
52 | #include <string.h> | |
53 | ||
54 | #ifndef __GNUWIN32__ | |
55 | #include <shellapi.h> | |
56 | #include <mmsystem.h> | |
57 | #endif | |
58 | ||
59 | #ifdef __WIN32__ | |
60 | #include <windowsx.h> | |
61 | #endif | |
62 | ||
63 | #ifdef __GNUWIN32__ | |
64 | #include <wx/msw/gnuwin32/extra.h> | |
65 | #endif | |
66 | ||
67 | #ifdef GetCharWidth | |
68 | #undef GetCharWidth | |
69 | #endif | |
70 | ||
71 | #ifdef FindWindow | |
72 | #undef FindWindow | |
73 | #endif | |
74 | ||
75 | #ifdef GetClassName | |
76 | #undef GetClassName | |
77 | #endif | |
78 | ||
79 | #ifdef GetClassInfo | |
80 | #undef GetClassInfo | |
81 | #endif | |
82 | ||
b2aef89b | 83 | #ifdef __WXDEBUG__ |
f449ef69 | 84 | const char *wxGetMessageName(int message); |
b2aef89b | 85 | #endif //WXDEBUG |
47cbd6da | 86 | |
f54f3bff | 87 | #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events |
2bda0e17 KB |
88 | |
89 | wxMenu *wxCurrentPopupMenu = NULL; | |
90 | extern wxList wxPendingDelete; | |
91 | ||
92 | void wxRemoveHandleAssociation(wxWindow *win); | |
93 | void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win); | |
94 | wxWindow *wxFindWinFromHandle(WXHWND hWnd); | |
95 | ||
96 | #if !USE_SHARED_LIBRARY | |
97 | IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler) | |
98 | ||
99 | BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler) | |
100 | EVT_CHAR(wxWindow::OnChar) | |
2bda0e17 KB |
101 | EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground) |
102 | EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged) | |
103 | EVT_INIT_DIALOG(wxWindow::OnInitDialog) | |
104 | EVT_IDLE(wxWindow::OnIdle) | |
105 | END_EVENT_TABLE() | |
106 | ||
107 | #endif | |
108 | ||
109 | // Find an item given the MS Windows id | |
debe6624 | 110 | wxWindow *wxWindow::FindItem(int id) const |
2bda0e17 KB |
111 | { |
112 | if (!GetChildren()) | |
113 | return NULL; | |
114 | wxNode *current = GetChildren()->First(); | |
115 | while (current) | |
116 | { | |
117 | wxWindow *childWin = (wxWindow *)current->Data(); | |
118 | ||
119 | wxWindow *wnd = childWin->FindItem(id) ; | |
120 | if (wnd) | |
121 | return wnd ; | |
122 | ||
123 | if (childWin->IsKindOf(CLASSINFO(wxControl))) | |
124 | { | |
125 | wxControl *item = (wxControl *)childWin; | |
126 | if (item->m_windowId == id) | |
127 | return item; | |
128 | else | |
129 | { | |
130 | // In case it's a 'virtual' control (e.g. radiobox) | |
131 | if (item->GetSubcontrols().Member((wxObject *)id)) | |
132 | return item; | |
133 | } | |
134 | } | |
135 | current = current->Next(); | |
136 | } | |
137 | return NULL; | |
138 | } | |
139 | ||
140 | // Find an item given the MS Windows handle | |
debe6624 | 141 | wxWindow *wxWindow::FindItemByHWND(WXHWND hWnd, bool controlOnly) const |
2bda0e17 KB |
142 | { |
143 | if (!GetChildren()) | |
144 | return NULL; | |
145 | wxNode *current = GetChildren()->First(); | |
146 | while (current) | |
147 | { | |
148 | wxObject *obj = (wxObject *)current->Data() ; | |
149 | // Do a recursive search. | |
150 | wxWindow *parent = (wxWindow *)obj ; | |
151 | wxWindow *wnd = parent->FindItemByHWND(hWnd) ; | |
152 | if (wnd) | |
153 | return wnd ; | |
154 | ||
155 | if ((!controlOnly) || obj->IsKindOf(CLASSINFO(wxControl))) | |
156 | { | |
157 | wxWindow *item = (wxWindow *)current->Data(); | |
158 | if ((HWND)(item->GetHWND()) == (HWND) hWnd) | |
159 | return item; | |
160 | else | |
161 | { | |
564b2609 VZ |
162 | if ( item->ContainsHWND(hWnd) ) |
163 | return item; | |
2bda0e17 KB |
164 | } |
165 | } | |
166 | current = current->Next(); | |
167 | } | |
168 | return NULL; | |
169 | } | |
170 | ||
171 | // Default command handler | |
debe6624 | 172 | bool wxWindow::MSWCommand(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id)) |
2bda0e17 KB |
173 | { |
174 | return FALSE; | |
175 | } | |
176 | ||
debe6624 | 177 | bool wxWindow::MSWNotify(WXWPARAM WXUNUSED(wParam), WXLPARAM WXUNUSED(lParam)) |
2bda0e17 KB |
178 | { |
179 | return FALSE; | |
180 | } | |
181 | ||
debe6624 | 182 | void wxWindow::PreDelete(WXHDC WXUNUSED(dc)) |
2bda0e17 KB |
183 | { |
184 | } | |
185 | ||
186 | WXHWND wxWindow::GetHWND(void) const | |
187 | { | |
188 | return (WXHWND) m_hWnd; | |
189 | } | |
190 | ||
191 | void wxWindow::SetHWND(WXHWND hWnd) | |
192 | { | |
564b2609 | 193 | m_hWnd = hWnd; |
2bda0e17 KB |
194 | } |
195 | ||
196 | // Constructor | |
197 | wxWindow::wxWindow(void) | |
198 | { | |
199 | // Generic | |
200 | m_windowId = 0; | |
201 | m_isShown = TRUE; | |
202 | m_windowStyle = 0; | |
203 | m_windowParent = NULL; | |
204 | m_windowEventHandler = this; | |
205 | m_windowName = ""; | |
206 | m_windowCursor = *wxSTANDARD_CURSOR; | |
207 | m_children = new wxList; | |
208 | m_doubleClickAllowed = 0 ; | |
209 | m_winCaptured = FALSE; | |
210 | m_constraints = NULL; | |
211 | m_constraintsInvolvedIn = NULL; | |
212 | m_windowSizer = NULL; | |
213 | m_sizerParent = NULL; | |
214 | m_autoLayout = FALSE; | |
215 | m_windowValidator = NULL; | |
216 | ||
217 | // MSW-specific | |
218 | m_hWnd = 0; | |
219 | m_winEnabled = TRUE; | |
220 | m_caretWidth = 0; m_caretHeight = 0; | |
221 | m_caretEnabled = FALSE; | |
222 | m_caretShown = FALSE; | |
223 | m_inOnSize = FALSE; | |
224 | m_minSizeX = -1; | |
225 | m_minSizeY = -1; | |
226 | m_maxSizeX = -1; | |
227 | m_maxSizeY = -1; | |
228 | // m_paintHDC = 0; | |
229 | // m_tempHDC = 0; | |
230 | m_isBeingDeleted = FALSE; | |
231 | m_oldWndProc = 0; | |
232 | #ifndef __WIN32__ | |
233 | m_globalHandle = 0; | |
234 | #endif | |
235 | m_useCtl3D = FALSE; | |
236 | ||
237 | m_defaultItem = NULL; | |
238 | ||
239 | wxSystemSettings settings; | |
240 | ||
241 | m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; | |
242 | m_foregroundColour = *wxBLACK; | |
243 | m_defaultForegroundColour = *wxBLACK ; | |
244 | m_defaultBackgroundColour = settings.GetSystemColour(wxSYS_COLOUR_3DFACE) ; | |
245 | ||
246 | /* | |
247 | wxColour(GetRValue(GetSysColor(COLOR_WINDOW)), | |
564b2609 | 248 | GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE))); |
2bda0e17 KB |
249 | */ |
250 | ||
251 | // wxWnd | |
252 | m_lastMsg = 0; | |
253 | m_lastWParam = 0; | |
254 | m_lastLParam = 0; | |
57a7b7c1 | 255 | // m_acceleratorTable = 0; |
2bda0e17 KB |
256 | m_hMenu = 0; |
257 | ||
258 | m_xThumbSize = 0; | |
259 | m_yThumbSize = 0; | |
260 | m_backgroundTransparent = FALSE; | |
261 | ||
262 | m_lastXPos = (float)-1.0; | |
263 | m_lastYPos = (float)-1.0; | |
264 | m_lastEvent = -1; | |
265 | m_returnCode = 0; | |
266 | ||
47d67540 | 267 | #if wxUSE_DRAG_AND_DROP |
2bda0e17 KB |
268 | m_pDropTarget = NULL; |
269 | #endif | |
270 | } | |
271 | ||
272 | // Destructor | |
273 | wxWindow::~wxWindow(void) | |
274 | { | |
275 | m_isBeingDeleted = TRUE; | |
276 | ||
277 | // JACS - if behaviour is odd, restore this | |
278 | // to the start of ~wxWindow. Vadim has changed | |
279 | // it to nearer the end. Unsure of side-effects | |
280 | // e.g. when deleting associated global data. | |
281 | // Restore old Window proc, if required | |
282 | // UnsubclassWin(); | |
283 | ||
564b2609 VZ |
284 | // Have to delete constraints/sizer FIRST otherwise |
285 | // sizers may try to look at deleted windows as they | |
286 | // delete themselves. | |
47d67540 | 287 | #if wxUSE_CONSTRAINTS |
2bda0e17 KB |
288 | DeleteRelatedConstraints(); |
289 | if (m_constraints) | |
290 | { | |
291 | // This removes any dangling pointers to this window | |
292 | // in other windows' constraintsInvolvedIn lists. | |
293 | UnsetConstraints(m_constraints); | |
294 | delete m_constraints; | |
295 | m_constraints = NULL; | |
296 | } | |
297 | if (m_windowSizer) | |
298 | { | |
299 | delete m_windowSizer; | |
300 | m_windowSizer = NULL; | |
301 | } | |
302 | // If this is a child of a sizer, remove self from parent | |
303 | if (m_sizerParent) | |
304 | m_sizerParent->RemoveChild((wxWindow *)this); | |
305 | #endif | |
306 | ||
307 | // wxWnd | |
308 | MSWDetachWindowMenu(); | |
309 | ||
2bda0e17 KB |
310 | if (m_windowParent) |
311 | m_windowParent->RemoveChild(this); | |
312 | ||
313 | DestroyChildren(); | |
314 | ||
315 | if (m_hWnd) | |
316 | ::DestroyWindow((HWND)m_hWnd); | |
195896c7 VZ |
317 | |
318 | wxRemoveHandleAssociation(this); | |
2bda0e17 KB |
319 | m_hWnd = 0; |
320 | #ifndef __WIN32__ | |
321 | if (m_globalHandle) | |
322 | { | |
323 | GlobalFree((HGLOBAL) m_globalHandle); | |
324 | m_globalHandle = 0; | |
325 | } | |
326 | #endif | |
327 | ||
328 | delete m_children; | |
329 | m_children = NULL; | |
330 | ||
331 | // Just in case the window has been Closed, but | |
332 | // we're then deleting immediately: don't leave | |
333 | // dangling pointers. | |
334 | wxPendingDelete.DeleteObject(this); | |
335 | ||
336 | // Just in case we've loaded a top-level window via | |
337 | // wxWindow::LoadNativeDialog but we weren't a dialog | |
338 | // class | |
339 | wxTopLevelWindows.DeleteObject(this); | |
340 | ||
2bda0e17 | 341 | if ( m_windowValidator ) |
564b2609 | 342 | delete m_windowValidator; |
2bda0e17 KB |
343 | |
344 | // Restore old Window proc, if required | |
345 | // and remove hWnd <-> wxWindow association | |
346 | UnsubclassWin(); | |
347 | } | |
348 | ||
349 | // Destroy the window (delayed, if a managed window) | |
350 | bool wxWindow::Destroy(void) | |
351 | { | |
352 | delete this; | |
353 | return TRUE; | |
354 | } | |
355 | ||
356 | extern char wxCanvasClassName[]; | |
357 | ||
358 | // Constructor | |
debe6624 | 359 | bool wxWindow::Create(wxWindow *parent, wxWindowID id, |
2bda0e17 KB |
360 | const wxPoint& pos, |
361 | const wxSize& size, | |
debe6624 | 362 | long style, |
2bda0e17 KB |
363 | const wxString& name) |
364 | { | |
365 | // Generic | |
366 | m_isBeingDeleted = FALSE; | |
367 | m_windowId = 0; | |
368 | m_isShown = TRUE; | |
369 | m_windowStyle = 0; | |
370 | m_windowParent = NULL; | |
371 | m_windowEventHandler = this; | |
2bda0e17 KB |
372 | m_windowName = ""; |
373 | m_windowCursor = *wxSTANDARD_CURSOR; | |
374 | m_doubleClickAllowed = 0 ; | |
375 | m_winCaptured = FALSE; | |
376 | m_constraints = NULL; | |
377 | m_constraintsInvolvedIn = NULL; | |
378 | m_windowSizer = NULL; | |
379 | m_sizerParent = NULL; | |
380 | m_autoLayout = FALSE; | |
381 | m_windowValidator = NULL; | |
47d67540 | 382 | #if wxUSE_DRAG_AND_DROP |
2bda0e17 KB |
383 | m_pDropTarget = NULL; |
384 | #endif | |
385 | ||
386 | // MSW-specific | |
387 | m_hWnd = 0; | |
388 | m_winEnabled = TRUE; | |
389 | m_caretWidth = 0; m_caretHeight = 0; | |
390 | m_caretEnabled = FALSE; | |
391 | m_caretShown = FALSE; | |
392 | m_inOnSize = FALSE; | |
393 | m_minSizeX = -1; | |
394 | m_minSizeY = -1; | |
395 | m_maxSizeX = -1; | |
396 | m_maxSizeY = -1; | |
2bda0e17 KB |
397 | m_oldWndProc = 0; |
398 | #ifndef __WIN32__ | |
399 | m_globalHandle = 0; | |
400 | #endif | |
401 | m_useCtl3D = FALSE; | |
402 | m_defaultItem = NULL; | |
403 | m_windowParent = NULL; | |
2bda0e17 KB |
404 | m_mouseInWindow = FALSE; |
405 | if (!parent) | |
406 | return FALSE; | |
407 | ||
408 | if (parent) parent->AddChild(this); | |
409 | ||
410 | // wxWnd | |
411 | m_lastMsg = 0; | |
412 | m_lastWParam = 0; | |
413 | m_lastLParam = 0; | |
2bda0e17 KB |
414 | m_hMenu = 0; |
415 | ||
416 | m_xThumbSize = 0; | |
417 | m_yThumbSize = 0; | |
418 | m_backgroundTransparent = FALSE; | |
419 | ||
420 | m_lastXPos = (float)-1.0; | |
421 | m_lastYPos = (float)-1.0; | |
422 | m_lastEvent = -1; | |
423 | m_returnCode = 0; | |
424 | ||
425 | SetName(name); | |
426 | ||
427 | if ( id == -1 ) | |
564b2609 | 428 | m_windowId = (int)NewControlId(); |
2bda0e17 | 429 | else |
564b2609 | 430 | m_windowId = id; |
2bda0e17 KB |
431 | |
432 | int x = pos.x; | |
433 | int y = pos.y; | |
434 | int width = size.x; | |
435 | int height = size.y; | |
436 | ||
437 | wxSystemSettings settings; | |
438 | ||
439 | m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; | |
440 | m_foregroundColour = *wxBLACK; | |
441 | m_defaultForegroundColour = *wxBLACK ; | |
442 | m_defaultBackgroundColour = settings.GetSystemColour(wxSYS_COLOUR_3DFACE) ; | |
2bda0e17 KB |
443 | |
444 | m_windowStyle = style; | |
445 | ||
446 | DWORD msflags = 0; | |
447 | if (style & wxBORDER) | |
448 | msflags |= WS_BORDER; | |
449 | if (style & wxTHICK_FRAME) | |
450 | msflags |= WS_THICKFRAME; | |
1c089c47 JS |
451 | |
452 | msflags |= WS_CHILD | WS_VISIBLE; | |
453 | if (style & wxCLIP_CHILDREN) | |
454 | msflags |= WS_CLIPCHILDREN; | |
2bda0e17 KB |
455 | |
456 | bool want3D; | |
457 | WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ; | |
458 | ||
459 | // Even with extended styles, need to combine with WS_BORDER | |
460 | // for them to look right. | |
461 | if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || | |
462 | (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)) | |
463 | msflags |= WS_BORDER; | |
464 | ||
465 | m_mouseInWindow = FALSE ; | |
466 | ||
a02eb1d2 VZ |
467 | MSWCreate(m_windowId, parent, wxCanvasClassName, this, NULL, |
468 | x, y, width, height, msflags, NULL, exStyle); | |
2bda0e17 KB |
469 | |
470 | return TRUE; | |
471 | } | |
472 | ||
473 | void wxWindow::SetFocus(void) | |
474 | { | |
475 | HWND hWnd = (HWND) GetHWND(); | |
476 | if (hWnd) | |
477 | ::SetFocus(hWnd); | |
478 | } | |
479 | ||
debe6624 | 480 | void wxWindow::Enable(bool enable) |
2bda0e17 KB |
481 | { |
482 | m_winEnabled = enable; | |
483 | HWND hWnd = (HWND) GetHWND(); | |
484 | if (hWnd) | |
485 | ::EnableWindow(hWnd, (BOOL)enable); | |
486 | } | |
487 | ||
488 | void wxWindow::CaptureMouse(void) | |
489 | { | |
490 | HWND hWnd = (HWND) GetHWND(); | |
491 | if (hWnd && !m_winCaptured) | |
492 | { | |
493 | SetCapture(hWnd); | |
494 | m_winCaptured = TRUE; | |
495 | } | |
496 | } | |
497 | ||
498 | void wxWindow::ReleaseMouse(void) | |
499 | { | |
500 | if (m_winCaptured) | |
501 | { | |
502 | ReleaseCapture(); | |
503 | m_winCaptured = FALSE; | |
504 | } | |
505 | } | |
506 | ||
088a95f5 JS |
507 | void wxWindow::SetAcceleratorTable(const wxAcceleratorTable& accel) |
508 | { | |
509 | m_acceleratorTable = accel; | |
510 | } | |
511 | ||
512 | ||
2bda0e17 KB |
513 | // Push/pop event handler (i.e. allow a chain of event handlers |
514 | // be searched) | |
515 | void wxWindow::PushEventHandler(wxEvtHandler *handler) | |
516 | { | |
564b2609 VZ |
517 | handler->SetNextHandler(GetEventHandler()); |
518 | SetEventHandler(handler); | |
2bda0e17 KB |
519 | } |
520 | ||
521 | wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler) | |
522 | { | |
564b2609 VZ |
523 | if ( GetEventHandler() ) |
524 | { | |
525 | wxEvtHandler *handlerA = GetEventHandler(); | |
526 | wxEvtHandler *handlerB = handlerA->GetNextHandler(); | |
527 | handlerA->SetNextHandler(NULL); | |
528 | SetEventHandler(handlerB); | |
529 | if ( deleteHandler ) | |
530 | { | |
531 | delete handlerA; | |
532 | return NULL; | |
533 | } | |
534 | else | |
535 | return handlerA; | |
536 | } | |
537 | else | |
538 | return NULL; | |
2bda0e17 KB |
539 | } |
540 | ||
47d67540 | 541 | #if wxUSE_DRAG_AND_DROP |
2bda0e17 KB |
542 | |
543 | void wxWindow::SetDropTarget(wxDropTarget *pDropTarget) | |
544 | { | |
195896c7 VZ |
545 | if ( m_pDropTarget != 0 ) { |
546 | m_pDropTarget->Revoke(m_hWnd); | |
547 | delete m_pDropTarget; | |
548 | } | |
549 | ||
2bda0e17 KB |
550 | m_pDropTarget = pDropTarget; |
551 | if ( m_pDropTarget != 0 ) | |
552 | m_pDropTarget->Register(m_hWnd); | |
553 | } | |
554 | ||
555 | #endif | |
556 | ||
557 | //old style file-manager drag&drop support | |
558 | // I think we should retain the old-style | |
559 | // DragAcceptFiles in parallel with SetDropTarget. | |
560 | // JACS | |
debe6624 | 561 | void wxWindow::DragAcceptFiles(bool accept) |
2bda0e17 KB |
562 | { |
563 | HWND hWnd = (HWND) GetHWND(); | |
564 | if (hWnd) | |
565 | ::DragAcceptFiles(hWnd, (BOOL)accept); | |
566 | } | |
567 | ||
568 | // Get total size | |
569 | void wxWindow::GetSize(int *x, int *y) const | |
570 | { | |
571 | HWND hWnd = (HWND) GetHWND(); | |
572 | RECT rect; | |
573 | GetWindowRect(hWnd, &rect); | |
574 | *x = rect.right - rect.left; | |
575 | *y = rect.bottom - rect.top; | |
576 | } | |
577 | ||
578 | void wxWindow::GetPosition(int *x, int *y) const | |
579 | { | |
580 | HWND hWnd = (HWND) GetHWND(); | |
581 | HWND hParentWnd = 0; | |
582 | if (GetParent()) | |
583 | hParentWnd = (HWND) GetParent()->GetHWND(); | |
584 | ||
585 | RECT rect; | |
586 | GetWindowRect(hWnd, &rect); | |
587 | ||
588 | // Since we now have the absolute screen coords, | |
589 | // if there's a parent we must subtract its top left corner | |
590 | POINT point; | |
591 | point.x = rect.left; | |
592 | point.y = rect.top; | |
593 | if (hParentWnd) | |
594 | { | |
595 | ::ScreenToClient(hParentWnd, &point); | |
596 | } | |
81d66cf3 JS |
597 | |
598 | // We may be faking the client origin. | |
599 | // So a window that's really at (0, 30) may appear | |
600 | // (to wxWin apps) to be at (0, 0). | |
601 | if (GetParent()) | |
602 | { | |
603 | wxPoint pt(GetParent()->GetClientAreaOrigin()); | |
604 | point.x -= pt.x; | |
605 | point.y -= pt.y; | |
606 | } | |
2bda0e17 KB |
607 | *x = point.x; |
608 | *y = point.y; | |
609 | } | |
610 | ||
611 | void wxWindow::ScreenToClient(int *x, int *y) const | |
612 | { | |
613 | HWND hWnd = (HWND) GetHWND(); | |
614 | POINT pt; | |
615 | pt.x = *x; | |
616 | pt.y = *y; | |
617 | ::ScreenToClient(hWnd, &pt); | |
618 | ||
0757d27c | 619 | /* |
81d66cf3 JS |
620 | // We may be faking the client origin. |
621 | // So a window that's really at (0, 30) may appear | |
622 | // (to wxWin apps) to be at (0, 0). | |
623 | if (GetParent()) | |
624 | { | |
625 | wxPoint pt1(GetParent()->GetClientAreaOrigin()); | |
626 | pt.x -= pt1.x; | |
627 | pt.y -= pt1.y; | |
628 | } | |
0757d27c JS |
629 | */ |
630 | ||
2bda0e17 KB |
631 | *x = pt.x; |
632 | *y = pt.y; | |
633 | } | |
634 | ||
635 | void wxWindow::ClientToScreen(int *x, int *y) const | |
636 | { | |
637 | HWND hWnd = (HWND) GetHWND(); | |
638 | POINT pt; | |
639 | pt.x = *x; | |
640 | pt.y = *y; | |
81d66cf3 | 641 | |
0757d27c | 642 | /* |
81d66cf3 JS |
643 | // We may be faking the client origin. |
644 | // So a window that's really at (0, 30) may appear | |
645 | // (to wxWin apps) to be at (0, 0). | |
646 | if (GetParent()) | |
647 | { | |
648 | wxPoint pt1(GetParent()->GetClientAreaOrigin()); | |
649 | pt.x += pt1.x; | |
650 | pt.y += pt1.y; | |
651 | } | |
0757d27c | 652 | */ |
81d66cf3 | 653 | |
2bda0e17 KB |
654 | ::ClientToScreen(hWnd, &pt); |
655 | ||
656 | *x = pt.x; | |
657 | *y = pt.y; | |
658 | } | |
659 | ||
660 | void wxWindow::SetCursor(const wxCursor& cursor) | |
661 | { | |
662 | m_windowCursor = cursor; | |
663 | if (m_windowCursor.Ok()) | |
664 | { | |
665 | HWND hWnd = (HWND) GetHWND(); | |
666 | ||
667 | // Change the cursor NOW if we're within the correct window | |
668 | POINT point; | |
669 | ::GetCursorPos(&point); | |
670 | ||
671 | RECT rect; | |
672 | ::GetWindowRect(hWnd, &rect); | |
673 | ||
674 | if (::PtInRect(&rect, point) && !wxIsBusy()) | |
675 | ::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR()); | |
676 | } | |
677 | ||
678 | // This will cause big reentrancy problems if wxFlushEvents is implemented. | |
679 | // wxFlushEvents(); | |
680 | // return old_cursor; | |
681 | } | |
682 | ||
683 | ||
684 | // Get size *available for subwindows* i.e. excluding menu bar etc. | |
2bda0e17 KB |
685 | void wxWindow::GetClientSize(int *x, int *y) const |
686 | { | |
687 | HWND hWnd = (HWND) GetHWND(); | |
688 | RECT rect; | |
689 | GetClientRect(hWnd, &rect); | |
690 | *x = rect.right; | |
691 | *y = rect.bottom; | |
692 | } | |
693 | ||
debe6624 | 694 | void wxWindow::SetSize(int x, int y, int width, int height, int sizeFlags) |
2bda0e17 KB |
695 | { |
696 | int currentX, currentY; | |
697 | GetPosition(¤tX, ¤tY); | |
698 | int actualWidth = width; | |
699 | int actualHeight = height; | |
700 | int actualX = x; | |
701 | int actualY = y; | |
702 | if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
703 | actualX = currentX; | |
704 | if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
705 | actualY = currentY; | |
706 | ||
81d66cf3 JS |
707 | AdjustForParentClientOrigin(actualX, actualY, sizeFlags); |
708 | ||
2bda0e17 KB |
709 | int currentW,currentH; |
710 | GetSize(¤tW, ¤tH); | |
711 | if (width == -1) | |
712 | actualWidth = currentW ; | |
713 | if (height == -1) | |
714 | actualHeight = currentH ; | |
715 | ||
716 | HWND hWnd = (HWND) GetHWND(); | |
717 | if (hWnd) | |
718 | MoveWindow(hWnd, actualX, actualY, actualWidth, actualHeight, (BOOL)TRUE); | |
2bda0e17 KB |
719 | } |
720 | ||
debe6624 | 721 | void wxWindow::SetClientSize(int width, int height) |
2bda0e17 KB |
722 | { |
723 | wxWindow *parent = GetParent(); | |
724 | HWND hWnd = (HWND) GetHWND(); | |
725 | HWND hParentWnd = (HWND) (HWND) parent->GetHWND(); | |
726 | ||
727 | RECT rect; | |
728 | GetClientRect(hWnd, &rect); | |
729 | ||
730 | RECT rect2; | |
731 | GetWindowRect(hWnd, &rect2); | |
732 | ||
733 | // Find the difference between the entire window (title bar and all) | |
734 | // and the client area; add this to the new client size to move the | |
735 | // window | |
736 | int actual_width = rect2.right - rect2.left - rect.right + width; | |
737 | int actual_height = rect2.bottom - rect2.top - rect.bottom + height; | |
738 | ||
739 | // If there's a parent, must subtract the parent's top left corner | |
740 | // since MoveWindow moves relative to the parent | |
741 | ||
742 | POINT point; | |
743 | point.x = rect2.left; | |
744 | point.y = rect2.top; | |
745 | if (parent) | |
746 | { | |
747 | ::ScreenToClient(hParentWnd, &point); | |
748 | } | |
749 | ||
750 | MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)TRUE); | |
debe6624 | 751 | |
2bda0e17 | 752 | wxSizeEvent event(wxSize(width, height), m_windowId); |
debe6624 | 753 | event.SetEventObject(this); |
2bda0e17 | 754 | GetEventHandler()->ProcessEvent(event); |
2bda0e17 KB |
755 | } |
756 | ||
81d66cf3 JS |
757 | // For implementation purposes - sometimes decorations make the client area |
758 | // smaller | |
759 | wxPoint wxWindow::GetClientAreaOrigin() const | |
760 | { | |
761 | return wxPoint(0, 0); | |
762 | } | |
763 | ||
764 | // Makes an adjustment to the window position (for example, a frame that has | |
765 | // a toolbar that it manages itself). | |
766 | void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) | |
767 | { | |
768 | if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent()) | |
769 | { | |
770 | wxPoint pt(GetParent()->GetClientAreaOrigin()); | |
771 | x += pt.x; y += pt.y; | |
772 | } | |
773 | } | |
774 | ||
debe6624 | 775 | bool wxWindow::Show(bool show) |
2bda0e17 KB |
776 | { |
777 | HWND hWnd = (HWND) GetHWND(); | |
778 | int cshow; | |
779 | if (show) | |
780 | cshow = SW_SHOW; | |
781 | else | |
782 | cshow = SW_HIDE; | |
783 | ShowWindow(hWnd, (BOOL)cshow); | |
784 | if (show) | |
785 | { | |
786 | BringWindowToTop(hWnd); | |
787 | // Next line causes a crash on NT, apparently. | |
788 | // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency? | |
789 | } | |
790 | return TRUE; | |
791 | } | |
792 | ||
793 | bool wxWindow::IsShown(void) const | |
794 | { | |
795 | return (::IsWindowVisible((HWND) GetHWND()) != 0); | |
796 | } | |
797 | ||
798 | int wxWindow::GetCharHeight(void) const | |
799 | { | |
800 | TEXTMETRIC lpTextMetric; | |
801 | HWND hWnd = (HWND) GetHWND(); | |
802 | HDC dc = ::GetDC(hWnd); | |
803 | ||
804 | GetTextMetrics(dc, &lpTextMetric); | |
805 | ::ReleaseDC(hWnd, dc); | |
806 | ||
807 | return lpTextMetric.tmHeight; | |
808 | } | |
809 | ||
810 | int wxWindow::GetCharWidth(void) const | |
811 | { | |
812 | TEXTMETRIC lpTextMetric; | |
813 | HWND hWnd = (HWND) GetHWND(); | |
814 | HDC dc = ::GetDC(hWnd); | |
815 | ||
816 | GetTextMetrics(dc, &lpTextMetric); | |
817 | ::ReleaseDC(hWnd, dc); | |
818 | ||
819 | return lpTextMetric.tmAveCharWidth; | |
820 | } | |
821 | ||
822 | void wxWindow::GetTextExtent(const wxString& string, int *x, int *y, | |
debe6624 | 823 | int *descent, int *externalLeading, const wxFont *theFont, bool) const |
2bda0e17 KB |
824 | { |
825 | wxFont *fontToUse = (wxFont *)theFont; | |
826 | if (!fontToUse) | |
827 | fontToUse = (wxFont *) & m_windowFont; | |
828 | ||
829 | HWND hWnd = (HWND) GetHWND(); | |
830 | HDC dc = ::GetDC(hWnd); | |
831 | ||
832 | HFONT fnt = 0; | |
833 | HFONT was = 0; | |
834 | if (fontToUse && fontToUse->Ok()) | |
835 | { | |
2bda0e17 | 836 | if ((fnt=(HFONT) fontToUse->GetResourceHandle())) |
c4e7c2aa | 837 | was = (HFONT) SelectObject(dc,fnt) ; |
2bda0e17 KB |
838 | } |
839 | ||
840 | SIZE sizeRect; | |
841 | TEXTMETRIC tm; | |
842 | GetTextExtentPoint(dc, (const char *)string, (int)string.Length(), &sizeRect); | |
843 | GetTextMetrics(dc, &tm); | |
844 | ||
845 | if (fontToUse && fnt && was) | |
846 | SelectObject(dc,was) ; | |
847 | ||
848 | ReleaseDC(hWnd, dc); | |
849 | ||
850 | *x = sizeRect.cx; | |
851 | *y = sizeRect.cy; | |
852 | if (descent) *descent = tm.tmDescent; | |
853 | if (externalLeading) *externalLeading = tm.tmExternalLeading; | |
854 | ||
855 | // if (fontToUse) | |
856 | // fontToUse->ReleaseResource(); | |
857 | } | |
858 | ||
debe6624 | 859 | void wxWindow::Refresh(bool eraseBack, const wxRectangle *rect) |
2bda0e17 KB |
860 | { |
861 | HWND hWnd = (HWND) GetHWND(); | |
862 | if (hWnd) | |
863 | { | |
864 | if (rect) | |
865 | { | |
866 | RECT mswRect; | |
867 | mswRect.left = rect->x; | |
868 | mswRect.top = rect->y; | |
869 | mswRect.right = rect->x + rect->width; | |
870 | mswRect.bottom = rect->y + rect->height; | |
871 | ||
872 | ::InvalidateRect(hWnd, &mswRect, eraseBack); | |
873 | } | |
874 | else | |
875 | ::InvalidateRect(hWnd, NULL, eraseBack); | |
876 | } | |
877 | } | |
878 | ||
a02eb1d2 VZ |
879 | bool wxWindow::ProcessEvent(wxEvent& event) |
880 | { | |
881 | // we save here the information about the last message because it might be | |
882 | // overwritten if the event handler sends any messages to our window (case | |
883 | // in point: wxNotebook::OnSize) - and then if we call Default() later | |
884 | // (which is done quite often if the message is not processed) it will use | |
885 | // incorrect values for m_lastXXX variables | |
886 | WXUINT lastMsg = m_lastMsg; | |
887 | WXWPARAM lastWParam = m_lastWParam; | |
888 | WXLPARAM lastLParam = m_lastLParam; | |
889 | ||
890 | // call the base version | |
891 | bool bProcessed = wxEvtHandler::ProcessEvent(event); | |
892 | ||
893 | // restore | |
894 | m_lastMsg = lastMsg; | |
895 | m_lastWParam = lastWParam; | |
896 | m_lastLParam = lastLParam; | |
897 | ||
898 | return bProcessed; | |
899 | } | |
900 | ||
2bda0e17 KB |
901 | // Hook for new window just as it's being created, |
902 | // when the window isn't yet associated with the handle | |
903 | wxWindow *wxWndHook = NULL; | |
904 | ||
1c089c47 | 905 | // Main window proc |
2bda0e17 KB |
906 | LRESULT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
907 | { | |
908 | wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd); | |
909 | ||
910 | if (!wnd && wxWndHook) | |
911 | { | |
564b2609 | 912 | wxAssociateWinWithHandle(hWnd, wxWndHook); |
2bda0e17 | 913 | wnd = wxWndHook; |
564b2609 | 914 | wxWndHook = NULL; |
2bda0e17 KB |
915 | wnd->m_hWnd = (WXHWND) hWnd; |
916 | } | |
b2aef89b | 917 | #if (WXDEBUG > 1) |
2bda0e17 KB |
918 | wxDebugMsg("hWnd = %d, m_hWnd = %d, msg = %d\n", hWnd, m_hWnd, message); |
919 | #endif | |
920 | // Stop right here if we don't have a valid handle | |
921 | // in our wxWnd object. | |
922 | if (wnd && !wnd->m_hWnd) { | |
923 | // wxDebugMsg("Warning: could not find a valid handle, wx_win.cc/wxWndProc.\n"); | |
924 | wnd->m_hWnd = (WXHWND) hWnd; | |
925 | long res = wnd->MSWDefWindowProc(message, wParam, lParam ); | |
926 | wnd->m_hWnd = 0; | |
927 | return res; | |
928 | } | |
929 | ||
930 | if (wnd) { | |
931 | wnd->m_lastMsg = message; | |
932 | wnd->m_lastWParam = wParam; | |
933 | wnd->m_lastLParam = lParam; | |
2bda0e17 KB |
934 | } |
935 | if (wnd) | |
936 | return wnd->MSWWindowProc(message, wParam, lParam); | |
937 | else | |
938 | return DefWindowProc( hWnd, message, wParam, lParam ); | |
939 | } | |
940 | ||
941 | // Should probably have a test for 'genuine' NT | |
942 | #if defined(__WIN32__) | |
943 | #define DIMENSION_TYPE short | |
944 | #else | |
945 | #define DIMENSION_TYPE int | |
946 | #endif | |
947 | ||
948 | // Main Windows 3 window proc | |
949 | long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) | |
950 | { | |
a02eb1d2 VZ |
951 | wxASSERT( m_lastMsg == message && |
952 | m_lastWParam == wParam && | |
953 | m_lastLParam == lParam ); | |
5de76427 | 954 | |
b2aef89b | 955 | #ifdef __WXDEBUG__ |
a02eb1d2 VZ |
956 | wxLogTrace(wxTraceMessages, "Processing %s(%lx, %lx)", |
957 | wxGetMessageName(message), wParam, lParam); | |
b2aef89b | 958 | #endif // WXDEBUG |
2bda0e17 KB |
959 | |
960 | HWND hWnd = (HWND)m_hWnd; | |
961 | ||
962 | switch (message) | |
963 | { | |
2bda0e17 KB |
964 | case WM_ACTIVATE: |
965 | { | |
966 | #ifdef __WIN32__ | |
967 | WORD state = LOWORD(wParam); | |
968 | WORD minimized = HIWORD(wParam); | |
969 | HWND hwnd = (HWND)lParam; | |
970 | #else | |
971 | WORD state = (WORD)wParam; | |
972 | WORD minimized = LOWORD(lParam); | |
973 | HWND hwnd = (HWND)HIWORD(lParam); | |
974 | #endif | |
975 | MSWOnActivate(state, (minimized != 0), (WXHWND) hwnd); | |
976 | return 0; | |
977 | break; | |
978 | } | |
979 | case WM_SETFOCUS: | |
980 | { | |
981 | HWND hwnd = (HWND)wParam; | |
982 | // return OnSetFocus(hwnd); | |
983 | ||
984 | if (MSWOnSetFocus((WXHWND) hwnd)) | |
985 | return 0; | |
986 | else return MSWDefWindowProc(message, wParam, lParam ); | |
987 | break; | |
988 | } | |
989 | case WM_KILLFOCUS: | |
990 | { | |
991 | HWND hwnd = (HWND)lParam; | |
992 | // return OnKillFocus(hwnd); | |
993 | if (MSWOnKillFocus((WXHWND) hwnd)) | |
994 | return 0; | |
995 | else | |
996 | return MSWDefWindowProc(message, wParam, lParam ); | |
997 | break; | |
998 | } | |
47cbd6da VZ |
999 | case WM_CREATE: |
1000 | { | |
1001 | MSWOnCreate((WXLPCREATESTRUCT) (LPCREATESTRUCT)lParam); | |
1002 | return 0; | |
1003 | break; | |
1004 | } | |
1005 | case WM_SHOWWINDOW: | |
1006 | { | |
1007 | MSWOnShow((wParam != 0), (int) lParam); | |
1008 | break; | |
1009 | } | |
1010 | case WM_PAINT: | |
1011 | { | |
2bda0e17 KB |
1012 | if (MSWOnPaint()) |
1013 | return 0; | |
1014 | else return MSWDefWindowProc(message, wParam, lParam ); | |
1015 | break; | |
1016 | } | |
47cbd6da VZ |
1017 | case WM_QUERYDRAGICON: |
1018 | { | |
1019 | HICON hIcon = 0; | |
2bda0e17 KB |
1020 | if ((hIcon = (HICON) MSWOnQueryDragIcon())) |
1021 | return (long)hIcon; | |
1022 | else return MSWDefWindowProc(message, wParam, lParam ); | |
1023 | break; | |
1024 | } | |
1025 | ||
1026 | case WM_SIZE: | |
1027 | { | |
1028 | int width = LOWORD(lParam); | |
1029 | int height = HIWORD(lParam); | |
1030 | MSWOnSize(width, height, wParam); | |
1031 | break; | |
1032 | } | |
1033 | ||
568cb543 VZ |
1034 | case WM_MOVE: |
1035 | { | |
1036 | wxMoveEvent event(wxPoint(LOWORD(lParam), HIWORD(lParam)), | |
1037 | m_windowId); | |
1038 | event.SetEventObject(this); | |
1039 | if ( !GetEventHandler()->ProcessEvent(event) ) | |
1040 | Default(); | |
1041 | } | |
1042 | break; | |
1043 | ||
2bda0e17 KB |
1044 | case WM_WINDOWPOSCHANGING: |
1045 | { | |
568cb543 | 1046 | MSWOnWindowPosChanging((void *)lParam); |
2bda0e17 KB |
1047 | break; |
1048 | } | |
1049 | ||
1050 | case WM_RBUTTONDOWN: | |
1051 | { | |
1052 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1053 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1054 | MSWOnRButtonDown(x, y, wParam); | |
1055 | break; | |
1056 | } | |
1057 | case WM_RBUTTONUP: | |
1058 | { | |
1059 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1060 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1061 | MSWOnRButtonUp(x, y, wParam); | |
1062 | break; | |
1063 | } | |
1064 | case WM_RBUTTONDBLCLK: | |
1065 | { | |
1066 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1067 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1068 | MSWOnRButtonDClick(x, y, wParam); | |
1069 | break; | |
1070 | } | |
1071 | case WM_MBUTTONDOWN: | |
1072 | { | |
1073 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1074 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1075 | MSWOnMButtonDown(x, y, wParam); | |
1076 | break; | |
1077 | } | |
1078 | case WM_MBUTTONUP: | |
1079 | { | |
1080 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1081 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1082 | MSWOnMButtonUp(x, y, wParam); | |
1083 | break; | |
1084 | } | |
1085 | case WM_MBUTTONDBLCLK: | |
1086 | { | |
1087 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1088 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1089 | MSWOnMButtonDClick(x, y, wParam); | |
1090 | break; | |
1091 | } | |
1092 | case WM_LBUTTONDOWN: | |
1093 | { | |
1094 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1095 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1096 | MSWOnLButtonDown(x, y, wParam); | |
1097 | break; | |
1098 | } | |
1099 | case WM_LBUTTONUP: | |
1100 | { | |
1101 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1102 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1103 | MSWOnLButtonUp(x, y, wParam); | |
1104 | break; | |
1105 | } | |
1106 | case WM_LBUTTONDBLCLK: | |
1107 | { | |
1108 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1109 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1110 | MSWOnLButtonDClick(x, y, wParam); | |
1111 | break; | |
1112 | } | |
1113 | case WM_MOUSEMOVE: | |
1114 | { | |
1115 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1116 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1117 | MSWOnMouseMove(x, y, wParam); | |
1118 | break; | |
1119 | } | |
1120 | case MM_JOY1BUTTONDOWN: | |
1121 | { | |
1122 | int x = LOWORD(lParam); | |
1123 | int y = HIWORD(lParam); | |
1124 | MSWOnJoyDown(wxJOYSTICK1, x, y, wParam); | |
1125 | break; | |
1126 | } | |
1127 | case MM_JOY2BUTTONDOWN: | |
1128 | { | |
1129 | int x = LOWORD(lParam); | |
1130 | int y = HIWORD(lParam); | |
1131 | MSWOnJoyDown(wxJOYSTICK2, x, y, wParam); | |
1132 | break; | |
1133 | } | |
1134 | case MM_JOY1BUTTONUP: | |
1135 | { | |
1136 | int x = LOWORD(lParam); | |
1137 | int y = HIWORD(lParam); | |
1138 | MSWOnJoyUp(wxJOYSTICK1, x, y, wParam); | |
1139 | break; | |
1140 | } | |
1141 | case MM_JOY2BUTTONUP: | |
1142 | { | |
1143 | int x = LOWORD(lParam); | |
1144 | int y = HIWORD(lParam); | |
1145 | MSWOnJoyUp(wxJOYSTICK2, x, y, wParam); | |
1146 | break; | |
1147 | } | |
1148 | case MM_JOY1MOVE: | |
1149 | { | |
1150 | int x = LOWORD(lParam); | |
1151 | int y = HIWORD(lParam); | |
1152 | MSWOnJoyMove(wxJOYSTICK1, x, y, wParam); | |
1153 | break; | |
1154 | } | |
1155 | case MM_JOY2MOVE: | |
1156 | { | |
1157 | int x = LOWORD(lParam); | |
1158 | int y = HIWORD(lParam); | |
1159 | MSWOnJoyMove(wxJOYSTICK2, x, y, wParam); | |
1160 | break; | |
1161 | } | |
1162 | case MM_JOY1ZMOVE: | |
1163 | { | |
1164 | int z = LOWORD(lParam); | |
1165 | MSWOnJoyZMove(wxJOYSTICK1, z, wParam); | |
1166 | break; | |
1167 | } | |
1168 | case MM_JOY2ZMOVE: | |
1169 | { | |
1170 | int z = LOWORD(lParam); | |
1171 | MSWOnJoyZMove(wxJOYSTICK2, z, wParam); | |
1172 | break; | |
1173 | } | |
1174 | case WM_DESTROY: | |
1175 | { | |
1176 | if (MSWOnDestroy()) | |
1177 | return 0; | |
1178 | else return MSWDefWindowProc(message, wParam, lParam ); | |
1179 | break; | |
1180 | } | |
1181 | case WM_SYSCOMMAND: | |
1182 | { | |
1183 | return MSWOnSysCommand(wParam, lParam); | |
1184 | break; | |
1185 | } | |
1186 | case WM_COMMAND: | |
47cbd6da | 1187 | { |
2bda0e17 KB |
1188 | #ifdef __WIN32__ |
1189 | WORD id = LOWORD(wParam); | |
1190 | HWND hwnd = (HWND)lParam; | |
1191 | WORD cmd = HIWORD(wParam); | |
1192 | #else | |
1193 | WORD id = (WORD)wParam; | |
1194 | HWND hwnd = (HWND)LOWORD(lParam) ; | |
1195 | WORD cmd = HIWORD(lParam); | |
1196 | #endif | |
1197 | if (!MSWOnCommand(id, cmd, (WXHWND) hwnd)) | |
1198 | return MSWDefWindowProc(message, wParam, lParam ); | |
1199 | break; | |
47cbd6da | 1200 | } |
2bda0e17 KB |
1201 | #if defined(__WIN95__) |
1202 | case WM_NOTIFY: | |
47cbd6da | 1203 | { |
2bda0e17 KB |
1204 | if (!MSWOnNotify(wParam, lParam)) |
1205 | return MSWDefWindowProc(message, wParam, lParam ); | |
1206 | break; | |
1207 | } | |
1208 | #endif | |
1209 | case WM_MENUSELECT: | |
1210 | { | |
1211 | #ifdef __WIN32__ | |
1212 | WORD flags = HIWORD(wParam); | |
1213 | HMENU sysmenu = (HMENU)lParam; | |
1214 | #else | |
1215 | WORD flags = LOWORD(lParam); | |
1216 | HMENU sysmenu = (HMENU)HIWORD(lParam); | |
1217 | #endif | |
1218 | MSWOnMenuHighlight((WORD)wParam, flags, (WXHMENU) sysmenu); | |
1219 | break; | |
1220 | } | |
1221 | case WM_INITMENUPOPUP: | |
1222 | { | |
1223 | MSWOnInitMenuPopup((WXHMENU) (HMENU)wParam, (int)LOWORD(lParam), (HIWORD(lParam) != 0)); | |
1224 | break; | |
1225 | } | |
1226 | case WM_DRAWITEM: | |
1227 | { | |
1228 | return MSWOnDrawItem((int)wParam, (WXDRAWITEMSTRUCT *)lParam); | |
1229 | break; | |
1230 | } | |
1231 | case WM_MEASUREITEM: | |
1232 | { | |
1233 | return MSWOnMeasureItem((int)wParam, (WXMEASUREITEMSTRUCT *)lParam); | |
1234 | break; | |
1235 | } | |
f54f3bff | 1236 | |
2bda0e17 | 1237 | case WM_KEYDOWN: |
47cbd6da VZ |
1238 | // we consider these message "not interesting" |
1239 | if ( wParam == VK_SHIFT || wParam == VK_CONTROL ) | |
1240 | return Default(); | |
1241 | ||
2bda0e17 | 1242 | // Avoid duplicate messages to OnChar |
47cbd6da VZ |
1243 | if ( (wParam != VK_ESCAPE) && (wParam != VK_SPACE) && |
1244 | (wParam != VK_RETURN) && (wParam != VK_BACK) && | |
1245 | (wParam != VK_TAB) ) | |
1246 | { | |
1c089c47 | 1247 | MSWOnChar((WORD)wParam, lParam); |
47cbd6da VZ |
1248 | if ( ::GetKeyState(VK_CONTROL) & 0x100 ) |
1249 | return Default(); | |
1250 | } | |
1251 | else if ( ::GetKeyState(VK_CONTROL) & 0x100 ) | |
1252 | MSWOnChar((WORD)wParam, lParam); | |
1253 | else | |
1254 | return Default(); | |
1255 | break; | |
1256 | ||
2bda0e17 | 1257 | case WM_CHAR: // Always an ASCII character |
47cbd6da VZ |
1258 | { |
1259 | MSWOnChar((WORD)wParam, lParam, TRUE); | |
1260 | break; | |
1261 | } | |
f54f3bff | 1262 | |
2bda0e17 KB |
1263 | case WM_HSCROLL: |
1264 | { | |
1265 | #ifdef __WIN32__ | |
1266 | WORD code = LOWORD(wParam); | |
1267 | WORD pos = HIWORD(wParam); | |
1268 | HWND control = (HWND)lParam; | |
1269 | #else | |
1270 | WORD code = (WORD)wParam; | |
1271 | WORD pos = LOWORD(lParam); | |
1272 | HWND control = (HWND)HIWORD(lParam); | |
1273 | #endif | |
1274 | MSWOnHScroll(code, pos, (WXHWND) control); | |
1275 | break; | |
1276 | } | |
1277 | case WM_VSCROLL: | |
1278 | { | |
1279 | #ifdef __WIN32__ | |
1280 | WORD code = LOWORD(wParam); | |
1281 | WORD pos = HIWORD(wParam); | |
1282 | HWND control = (HWND)lParam; | |
1283 | #else | |
1284 | WORD code = (WORD)wParam; | |
1285 | WORD pos = LOWORD(lParam); | |
1286 | HWND control = (HWND)HIWORD(lParam); | |
1287 | #endif | |
1288 | MSWOnVScroll(code, pos, (WXHWND) control); | |
1289 | break; | |
1290 | } | |
1291 | #ifdef __WIN32__ | |
1292 | case WM_CTLCOLORBTN: | |
47cbd6da | 1293 | { |
2bda0e17 KB |
1294 | int nCtlColor = CTLCOLOR_BTN; |
1295 | HWND control = (HWND)lParam; | |
1296 | HDC pDC = (HDC)wParam; | |
1297 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1298 | message, wParam, lParam); | |
1299 | break; | |
47cbd6da | 1300 | } |
2bda0e17 | 1301 | case WM_CTLCOLORDLG: |
47cbd6da | 1302 | { |
2bda0e17 KB |
1303 | int nCtlColor = CTLCOLOR_DLG; |
1304 | HWND control = (HWND)lParam; | |
1305 | HDC pDC = (HDC)wParam; | |
1306 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1307 | message, wParam, lParam);\ | |
1308 | break; | |
47cbd6da | 1309 | } |
2bda0e17 | 1310 | case WM_CTLCOLORLISTBOX: |
47cbd6da | 1311 | { |
2bda0e17 KB |
1312 | int nCtlColor = CTLCOLOR_LISTBOX; |
1313 | HWND control = (HWND)lParam; | |
1314 | HDC pDC = (HDC)wParam; | |
1315 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1316 | message, wParam, lParam); | |
1317 | break; | |
47cbd6da | 1318 | } |
2bda0e17 | 1319 | case WM_CTLCOLORMSGBOX: |
47cbd6da | 1320 | { |
2bda0e17 KB |
1321 | int nCtlColor = CTLCOLOR_MSGBOX; |
1322 | HWND control = (HWND)lParam; | |
1323 | HDC pDC = (HDC)wParam; | |
1324 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1325 | message, wParam, lParam); | |
1326 | break; | |
47cbd6da | 1327 | } |
2bda0e17 | 1328 | case WM_CTLCOLORSCROLLBAR: |
47cbd6da | 1329 | { |
2bda0e17 KB |
1330 | int nCtlColor = CTLCOLOR_SCROLLBAR; |
1331 | HWND control = (HWND)lParam; | |
1332 | HDC pDC = (HDC)wParam; | |
1333 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1334 | message, wParam, lParam); | |
1335 | break; | |
47cbd6da | 1336 | } |
2bda0e17 | 1337 | case WM_CTLCOLORSTATIC: |
47cbd6da | 1338 | { |
2bda0e17 KB |
1339 | int nCtlColor = CTLCOLOR_STATIC; |
1340 | HWND control = (HWND)lParam; | |
1341 | HDC pDC = (HDC)wParam; | |
1342 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1343 | message, wParam, lParam); | |
1344 | break; | |
47cbd6da | 1345 | } |
2bda0e17 | 1346 | case WM_CTLCOLOREDIT: |
47cbd6da | 1347 | { |
2bda0e17 KB |
1348 | int nCtlColor = CTLCOLOR_EDIT; |
1349 | HWND control = (HWND)lParam; | |
1350 | HDC pDC = (HDC)wParam; | |
1351 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1352 | message, wParam, lParam); | |
1353 | break; | |
47cbd6da | 1354 | } |
2bda0e17 KB |
1355 | #else |
1356 | case WM_CTLCOLOR: | |
1357 | { | |
1358 | HWND control = (HWND)LOWORD(lParam); | |
1359 | int nCtlColor = (int)HIWORD(lParam); | |
1360 | HDC pDC = (HDC)wParam; | |
1361 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1362 | message, wParam, lParam); | |
1363 | break; | |
1364 | } | |
1365 | #endif | |
1366 | case WM_SYSCOLORCHANGE: | |
1367 | { | |
1368 | // Return value of 0 means, we processed it. | |
1369 | if (MSWOnColorChange((WXHWND) hWnd, message, wParam, lParam) == 0) | |
1370 | return 0; | |
1371 | else | |
1372 | return MSWDefWindowProc(message, wParam, lParam ); | |
1373 | break; | |
1374 | } | |
f7bd2698 JS |
1375 | case WM_PALETTECHANGED: |
1376 | { | |
1377 | return MSWOnPaletteChanged((WXHWND) (HWND) wParam); | |
1378 | break; | |
1379 | } | |
1380 | case WM_QUERYNEWPALETTE: | |
1381 | { | |
1382 | return MSWOnQueryNewPalette(); | |
1383 | break; | |
1384 | } | |
2bda0e17 KB |
1385 | case WM_ERASEBKGND: |
1386 | { | |
1387 | // Prevents flicker when dragging | |
1388 | if (IsIconic(hWnd)) return 1; | |
1389 | ||
2bda0e17 KB |
1390 | if (!MSWOnEraseBkgnd((WXHDC) (HDC)wParam)) |
1391 | return 0; // Default(); MSWDefWindowProc(message, wParam, lParam ); | |
1392 | else return 1; | |
1393 | break; | |
1394 | } | |
1395 | case WM_MDIACTIVATE: | |
1396 | { | |
1397 | #ifdef __WIN32__ | |
1398 | HWND hWndActivate = GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam,lParam); | |
1399 | HWND hWndDeactivate = GET_WM_MDIACTIVATE_HWNDDEACT(wParam,lParam); | |
1400 | BOOL activate = GET_WM_MDIACTIVATE_FACTIVATE(hWnd,wParam,lParam); | |
1401 | return MSWOnMDIActivate((long) activate, (WXHWND) hWndActivate, (WXHWND) hWndDeactivate); | |
1402 | #else | |
1403 | return MSWOnMDIActivate((BOOL)wParam, (HWND)LOWORD(lParam), | |
1404 | (HWND)HIWORD(lParam)); | |
1405 | #endif | |
1406 | } | |
1407 | case WM_DROPFILES: | |
1408 | { | |
1409 | MSWOnDropFiles(wParam); | |
1410 | break; | |
47cbd6da | 1411 | } |
2bda0e17 KB |
1412 | case WM_INITDIALOG: |
1413 | { | |
1414 | return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam); | |
1415 | break; | |
47cbd6da | 1416 | } |
2bda0e17 KB |
1417 | case WM_QUERYENDSESSION: |
1418 | { | |
47cbd6da | 1419 | // Same as WM_CLOSE, but inverted results. Thx Microsoft :-) |
2bda0e17 KB |
1420 | return MSWOnClose(); |
1421 | break; | |
1422 | } | |
1423 | case WM_CLOSE: | |
1424 | { | |
1425 | if (MSWOnClose()) | |
1426 | return 0L; | |
1427 | else | |
1428 | return 1L; | |
1429 | break; | |
1430 | } | |
1431 | ||
1432 | case WM_GETMINMAXINFO: | |
1433 | { | |
1434 | MINMAXINFO *info = (MINMAXINFO *)lParam; | |
1435 | if (m_minSizeX != -1) | |
1436 | info->ptMinTrackSize.x = (int)m_minSizeX; | |
1437 | if (m_minSizeY != -1) | |
1438 | info->ptMinTrackSize.y = (int)m_minSizeY; | |
1439 | if (m_maxSizeX != -1) | |
1440 | info->ptMaxTrackSize.x = (int)m_maxSizeX; | |
1441 | if (m_maxSizeY != -1) | |
1442 | info->ptMaxTrackSize.y = (int)m_maxSizeY; | |
1443 | return MSWDefWindowProc(message, wParam, lParam ); | |
1444 | break; | |
1445 | } | |
1446 | ||
47cbd6da VZ |
1447 | case WM_GETDLGCODE: |
1448 | return MSWGetDlgCode(); | |
1449 | ||
2bda0e17 KB |
1450 | default: |
1451 | return MSWDefWindowProc(message, wParam, lParam ); | |
1452 | } | |
1453 | return 0; // Success: we processed this command. | |
1454 | } | |
1455 | ||
1456 | // Dialog window proc | |
1457 | LONG APIENTRY _EXPORT | |
1458 | wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | |
1459 | { | |
1460 | return 0; | |
1461 | } | |
1462 | ||
1463 | wxList *wxWinHandleList = NULL; | |
1464 | wxWindow *wxFindWinFromHandle(WXHWND hWnd) | |
1465 | { | |
1466 | wxNode *node = wxWinHandleList->Find((long)hWnd); | |
1467 | if (!node) | |
1468 | return NULL; | |
1469 | return (wxWindow *)node->Data(); | |
1470 | } | |
1471 | ||
1472 | void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win) | |
1473 | { | |
195896c7 VZ |
1474 | // adding NULL hWnd is (first) surely a result of an error and |
1475 | // (secondly) breaks menu command processing | |
f54f3bff | 1476 | wxCHECK_RET( hWnd != NULL, "attempt to add a NULL hWnd to window list" ); |
195896c7 | 1477 | |
2bda0e17 KB |
1478 | if ( !wxWinHandleList->Find((long)hWnd) ) |
1479 | wxWinHandleList->Append((long)hWnd, win); | |
1480 | } | |
1481 | ||
1482 | void wxRemoveHandleAssociation(wxWindow *win) | |
1483 | { | |
1484 | wxWinHandleList->DeleteObject(win); | |
1485 | } | |
1486 | ||
1487 | // Default destroyer - override if you destroy it in some other way | |
1488 | // (e.g. with MDI child windows) | |
1489 | void wxWindow::MSWDestroyWindow(void) | |
1490 | { | |
2bda0e17 KB |
1491 | } |
1492 | ||
debe6624 JS |
1493 | void wxWindow::MSWCreate(int id, wxWindow *parent, const char *wclass, wxWindow *wx_win, const char *title, |
1494 | int x, int y, int width, int height, | |
1495 | WXDWORD style, const char *dialog_template, WXDWORD extendedStyle) | |
2bda0e17 KB |
1496 | { |
1497 | bool is_dialog = (dialog_template != NULL); | |
1498 | int x1 = CW_USEDEFAULT; | |
1499 | int y1 = 0; | |
1500 | int width1 = CW_USEDEFAULT; | |
1501 | int height1 = 100; | |
1502 | ||
1503 | // Find parent's size, if it exists, to set up a possible default | |
1504 | // panel size the size of the parent window | |
1505 | RECT parent_rect; | |
1506 | if (parent) | |
1507 | { | |
1508 | // Was GetWindowRect: JACS 5/5/95 | |
1509 | ::GetClientRect((HWND) parent->GetHWND(), &parent_rect); | |
1510 | ||
1511 | width1 = parent_rect.right - parent_rect.left; | |
1512 | height1 = parent_rect.bottom - parent_rect.top; | |
1513 | } | |
1514 | ||
1515 | if (x > -1) x1 = x; | |
1516 | if (y > -1) y1 = y; | |
1517 | if (width > -1) width1 = width; | |
1518 | if (height > -1) height1 = height; | |
1519 | ||
1520 | HWND hParent = NULL; | |
1521 | if (parent) | |
1522 | hParent = (HWND) parent->GetHWND(); | |
1523 | ||
1524 | wxWndHook = this; | |
1525 | ||
1526 | if (is_dialog) | |
1527 | { | |
1528 | // MakeProcInstance doesn't seem to be needed in C7. Is it needed for | |
1529 | // other compilers??? | |
1530 | // VZ: it's always needed for Win16 and never for Win32 | |
1531 | #ifdef __WIN32__ | |
1532 | m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent, | |
1533 | (DLGPROC)wxDlgProc); | |
1534 | #else | |
1535 | DLGPROC dlgproc = (DLGPROC)MakeProcInstance((DLGPROC)wxWndProc, wxGetInstance()); | |
1536 | ||
1537 | m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent, | |
1538 | (DLGPROC)dlgproc); | |
1539 | #endif | |
1540 | ||
1541 | if (m_hWnd == 0) | |
1542 | MessageBox(NULL, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.", | |
1543 | "wxWindows Error", MB_ICONEXCLAMATION | MB_OK); | |
1544 | else MoveWindow((HWND) m_hWnd, x1, y1, width1, height1, FALSE); | |
1545 | } | |
1546 | else | |
1547 | { | |
1548 | int controlId = 0; | |
1549 | if (style & WS_CHILD) | |
1550 | controlId = id; | |
1551 | if (!title) | |
1552 | title = ""; | |
1553 | ||
a02eb1d2 | 1554 | m_hWnd = (WXHWND)CreateWindowEx(extendedStyle, wclass, |
2bda0e17 KB |
1555 | title, |
1556 | style, | |
1557 | x1, y1, | |
1558 | width1, height1, | |
2bda0e17 KB |
1559 | hParent, (HMENU)controlId, wxGetInstance(), |
1560 | NULL); | |
1561 | ||
a02eb1d2 VZ |
1562 | if ( !m_hWnd ) { |
1563 | wxLogError("Can't create window of class %s!\n" | |
1564 | "Possible Windows 3.x compatibility problem?", wclass); | |
2bda0e17 KB |
1565 | } |
1566 | } | |
a02eb1d2 | 1567 | |
2bda0e17 KB |
1568 | wxWndHook = NULL; |
1569 | wxWinHandleList->Append((long)m_hWnd, this); | |
1570 | ||
b2aef89b | 1571 | #if WXDEBUG > 1 |
2bda0e17 KB |
1572 | wxDebugMsg("wxWindow::MSWCreate %d\n", m_hWnd); |
1573 | #endif | |
1574 | } | |
1575 | ||
1576 | void wxWindow::MSWOnCreate(WXLPCREATESTRUCT WXUNUSED(cs)) | |
1577 | { | |
1578 | } | |
1579 | ||
1580 | bool wxWindow::MSWOnClose(void) | |
1581 | { | |
b2aef89b | 1582 | #if WXDEBUG > 1 |
2bda0e17 KB |
1583 | wxDebugMsg("wxWindow::MSWOnClose %d\n", handle); |
1584 | #endif | |
1585 | return FALSE; | |
1586 | } | |
1587 | ||
1588 | bool wxWindow::MSWOnDestroy(void) | |
1589 | { | |
b2aef89b | 1590 | #if WXDEBUG > 1 |
2bda0e17 KB |
1591 | wxDebugMsg("wxWindow::MSWOnDestroy %d\n", handle); |
1592 | #endif | |
195896c7 | 1593 | // delete our drop target if we've got one |
47d67540 | 1594 | #if wxUSE_DRAG_AND_DROP |
195896c7 | 1595 | if ( m_pDropTarget != NULL ) { |
2bda0e17 KB |
1596 | m_pDropTarget->Revoke(m_hWnd); |
1597 | ||
1598 | delete m_pDropTarget; | |
1599 | m_pDropTarget = NULL; | |
1600 | } | |
195896c7 | 1601 | #endif |
2bda0e17 KB |
1602 | |
1603 | return TRUE; | |
1604 | } | |
1605 | ||
1606 | // Deal with child commands from buttons etc. | |
1607 | ||
debe6624 | 1608 | bool wxWindow::MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam) |
2bda0e17 KB |
1609 | { |
1610 | #if defined(__WIN95__) | |
1611 | // Find a child window to send the notification to, e.g. a toolbar. | |
1612 | // There's a problem here. NMHDR::hwndFrom doesn't give us the | |
1613 | // handle of the toolbar; it's probably the handle of the tooltip | |
1614 | // window (anyway, it's parent is also the toolbar's parent). | |
1615 | // So, since we don't know which hWnd or wxWindow originated the | |
1616 | // WM_NOTIFY, we'll need to go through all the children of this window | |
1617 | // trying out MSWNotify. | |
564b2609 VZ |
1618 | // This won't work now, though, because any number of controls |
1619 | // could respond to the same generic messages :-( | |
2bda0e17 KB |
1620 | |
1621 | /* This doesn't work for toolbars, but try for other controls first. | |
1622 | */ | |
1623 | NMHDR *hdr = (NMHDR *)lParam; | |
1624 | HWND hWnd = (HWND)hdr->hwndFrom; | |
1625 | wxWindow *win = wxFindWinFromHandle((WXHWND) hWnd); | |
1626 | ||
564b2609 VZ |
1627 | if ( win ) |
1628 | return win->MSWNotify(wParam, lParam); | |
1629 | else | |
1630 | { | |
1631 | // Rely on MSWNotify to check whether the message | |
1632 | // belongs to the window or not | |
1633 | wxNode *node = GetChildren()->First(); | |
1634 | while (node) | |
1635 | { | |
1636 | wxWindow *child = (wxWindow *)node->Data(); | |
1637 | if ( child->MSWNotify(wParam, lParam) ) | |
1638 | return TRUE; | |
1639 | node = node->Next(); | |
1640 | } | |
1641 | } | |
2bda0e17 KB |
1642 | |
1643 | return FALSE; | |
1644 | ||
1645 | #endif | |
1646 | return FALSE; | |
1647 | } | |
1648 | ||
debe6624 | 1649 | void wxWindow::MSWOnMenuHighlight(WXWORD WXUNUSED(item), WXWORD WXUNUSED(flags), WXHMENU WXUNUSED(sysmenu)) |
2bda0e17 | 1650 | { |
b2aef89b | 1651 | #if WXDEBUG > 1 |
2bda0e17 KB |
1652 | wxDebugMsg("wxWindow::MSWOnMenuHighlight %d\n", handle); |
1653 | #endif | |
1654 | } | |
1655 | ||
debe6624 | 1656 | void wxWindow::MSWOnInitMenuPopup(WXHMENU menu, int pos, bool isSystem) |
2bda0e17 | 1657 | { |
2bda0e17 KB |
1658 | } |
1659 | ||
debe6624 | 1660 | bool wxWindow::MSWOnActivate(int state, bool WXUNUSED(minimized), WXHWND WXUNUSED(activate)) |
2bda0e17 | 1661 | { |
b2aef89b | 1662 | #if WXDEBUG > 1 |
2bda0e17 KB |
1663 | wxDebugMsg("wxWindow::MSWOnActivate %d\n", handle); |
1664 | #endif | |
1665 | ||
2bda0e17 | 1666 | wxActivateEvent event(wxEVT_ACTIVATE, ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)), |
564b2609 | 1667 | m_windowId); |
debe6624 | 1668 | event.SetEventObject(this); |
2bda0e17 | 1669 | GetEventHandler()->ProcessEvent(event); |
2bda0e17 KB |
1670 | return 0; |
1671 | } | |
1672 | ||
debe6624 | 1673 | bool wxWindow::MSWOnSetFocus(WXHWND WXUNUSED(hwnd)) |
2bda0e17 | 1674 | { |
b2aef89b | 1675 | #if WXDEBUG > 1 |
2bda0e17 KB |
1676 | wxDebugMsg("wxWindow::MSWOnSetFocus %d\n", m_hWnd); |
1677 | #endif | |
1678 | // Deal with caret | |
1679 | if (m_caretEnabled && (m_caretWidth > 0) && (m_caretHeight > 0)) | |
1680 | { | |
1681 | ::CreateCaret((HWND) GetHWND(), NULL, m_caretWidth, m_caretHeight); | |
1682 | if (m_caretShown) | |
1683 | ::ShowCaret((HWND) GetHWND()); | |
1684 | } | |
1685 | ||
2bda0e17 | 1686 | wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId); |
debe6624 JS |
1687 | event.SetEventObject(this); |
1688 | if (!GetEventHandler()->ProcessEvent(event)) | |
1689 | Default(); | |
1690 | return TRUE; | |
2bda0e17 KB |
1691 | } |
1692 | ||
debe6624 | 1693 | bool wxWindow::MSWOnKillFocus(WXHWND WXUNUSED(hwnd)) |
2bda0e17 | 1694 | { |
b2aef89b | 1695 | #if WXDEBUG > 1 |
2bda0e17 KB |
1696 | wxDebugMsg("wxWindow::MSWOnKillFocus %d\n", m_hWnd); |
1697 | #endif | |
1698 | // Deal with caret | |
1699 | if (m_caretEnabled) | |
1700 | { | |
1701 | ::DestroyCaret(); | |
1702 | } | |
1703 | ||
2bda0e17 | 1704 | wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId); |
debe6624 JS |
1705 | event.SetEventObject(this); |
1706 | if (!GetEventHandler()->ProcessEvent(event)) | |
1707 | Default(); | |
2bda0e17 KB |
1708 | return TRUE; |
1709 | } | |
1710 | ||
debe6624 | 1711 | void wxWindow::MSWOnDropFiles(WXWPARAM wParam) |
2bda0e17 | 1712 | { |
b2aef89b | 1713 | #if WXDEBUG > 1 |
2bda0e17 KB |
1714 | wxDebugMsg("wxWindow::MSWOnDropFiles %d\n", m_hWnd); |
1715 | #endif | |
1716 | ||
c4e7c2aa | 1717 | HDROP hFilesInfo = (HDROP) wParam; |
2bda0e17 KB |
1718 | POINT dropPoint; |
1719 | DragQueryPoint(hFilesInfo, (LPPOINT) &dropPoint); | |
1720 | ||
1721 | // Get the total number of files dropped | |
1722 | WORD gwFilesDropped = (WORD)DragQueryFile ((HDROP)hFilesInfo, | |
564b2609 | 1723 | (UINT)-1, |
2bda0e17 KB |
1724 | (LPSTR)0, |
1725 | (UINT)0); | |
1726 | ||
1727 | wxString *files = new wxString[gwFilesDropped]; | |
1728 | int wIndex; | |
1729 | for (wIndex=0; wIndex < (int)gwFilesDropped; wIndex++) | |
1730 | { | |
1731 | DragQueryFile (hFilesInfo, wIndex, (LPSTR) wxBuffer, 1000); | |
1732 | files[wIndex] = wxBuffer; | |
1733 | } | |
1734 | DragFinish (hFilesInfo); | |
1735 | ||
1736 | wxDropFilesEvent event(wxEVT_DROP_FILES, gwFilesDropped, files); | |
1737 | event.m_eventObject = this; | |
1738 | event.m_pos.x = dropPoint.x; event.m_pos.x = dropPoint.y; | |
1739 | ||
debe6624 JS |
1740 | if (!GetEventHandler()->ProcessEvent(event)) |
1741 | Default(); | |
2bda0e17 KB |
1742 | |
1743 | delete[] files; | |
1744 | } | |
1745 | ||
debe6624 | 1746 | bool wxWindow::MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct) |
2bda0e17 | 1747 | { |
47d67540 | 1748 | #if wxUSE_OWNER_DRAWN |
2bda0e17 KB |
1749 | if ( id == 0 ) { // is it a menu item? |
1750 | DRAWITEMSTRUCT *pDrawStruct = (DRAWITEMSTRUCT *)itemStruct; | |
1751 | wxMenuItem *pMenuItem = (wxMenuItem *)(pDrawStruct->itemData); | |
f54f3bff | 1752 | wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); |
2bda0e17 KB |
1753 | |
1754 | // prepare to call OnDrawItem() | |
1755 | wxDC dc; | |
1756 | dc.SetHDC((WXHDC)pDrawStruct->hDC, FALSE); | |
1757 | wxRect rect(pDrawStruct->rcItem.left, pDrawStruct->rcItem.top, | |
1758 | pDrawStruct->rcItem.right - pDrawStruct->rcItem.left, | |
1759 | pDrawStruct->rcItem.bottom - pDrawStruct->rcItem.top); | |
1760 | return pMenuItem->OnDrawItem( | |
1761 | dc, rect, | |
1762 | (wxOwnerDrawn::wxODAction)pDrawStruct->itemAction, | |
1763 | (wxOwnerDrawn::wxODStatus)pDrawStruct->itemState | |
1764 | ); | |
1765 | } | |
1766 | #endif // owner-drawn menus | |
1767 | ||
1768 | wxWindow *item = FindItem(id); | |
47d67540 | 1769 | #if wxUSE_DYNAMIC_CLASSES |
2bda0e17 KB |
1770 | if (item && item->IsKindOf(CLASSINFO(wxControl))) |
1771 | { | |
1772 | return ((wxControl *)item)->MSWOnDraw(itemStruct); | |
1773 | } | |
1774 | else | |
1775 | #endif | |
1776 | return FALSE; | |
1777 | } | |
1778 | ||
debe6624 | 1779 | bool wxWindow::MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct) |
2bda0e17 | 1780 | { |
47d67540 | 1781 | #if wxUSE_OWNER_DRAWN |
2bda0e17 KB |
1782 | if ( id == 0 ) { // is it a menu item? |
1783 | MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct; | |
1784 | wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData); | |
f54f3bff | 1785 | wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); |
2bda0e17 KB |
1786 | |
1787 | return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth, | |
1788 | &pMeasureStruct->itemHeight); | |
1789 | } | |
1790 | #endif // owner-drawn menus | |
1791 | ||
1792 | wxWindow *item = FindItem(id); | |
47d67540 | 1793 | #if wxUSE_DYNAMIC_CLASSES |
2bda0e17 KB |
1794 | if (item && item->IsKindOf(CLASSINFO(wxControl))) |
1795 | { | |
1796 | return ((wxControl *)item)->MSWOnMeasure(itemStruct); | |
1797 | } | |
1798 | else | |
1799 | #endif | |
1800 | return FALSE; | |
1801 | } | |
1802 | ||
debe6624 JS |
1803 | WXHBRUSH wxWindow::MSWOnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, |
1804 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam) | |
2bda0e17 | 1805 | { |
b2aef89b | 1806 | #if WXDEBUG > 1 |
2bda0e17 KB |
1807 | wxDebugMsg("wxWindow::MSWOnCtlColour %d\n", m_hWnd); |
1808 | #endif | |
1809 | if (nCtlColor == CTLCOLOR_DLG) | |
1810 | { | |
564b2609 | 1811 | return OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam); |
2bda0e17 KB |
1812 | } |
1813 | ||
1814 | wxControl *item = (wxControl *)FindItemByHWND(pWnd, TRUE); | |
1815 | ||
1816 | WXHBRUSH hBrush = 0; | |
1817 | ||
1818 | if ( item ) | |
564b2609 | 1819 | hBrush = item->OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam); |
2bda0e17 KB |
1820 | |
1821 | // I think that even for dialogs, we may need to call DefWindowProc (?) | |
1822 | // Or maybe just rely on the usual default behaviour. | |
1823 | if ( !hBrush ) | |
1824 | hBrush = (WXHBRUSH) MSWDefWindowProc(message, wParam, lParam); | |
1825 | ||
1826 | return hBrush ; | |
1827 | } | |
1828 | ||
1829 | // Define for each class of dialog and control | |
debe6624 | 1830 | WXHBRUSH wxWindow::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, |
564b2609 | 1831 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam) |
2bda0e17 KB |
1832 | { |
1833 | return (WXHBRUSH) MSWDefWindowProc(message, wParam, lParam); | |
1834 | } | |
1835 | ||
debe6624 | 1836 | bool wxWindow::MSWOnColorChange(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam) |
2bda0e17 KB |
1837 | { |
1838 | wxSysColourChangedEvent event; | |
f7bd2698 | 1839 | event.SetEventObject(this); |
2bda0e17 KB |
1840 | |
1841 | // Check if app handles this. | |
1842 | if (GetEventHandler()->ProcessEvent(event)) | |
1843 | return 0; | |
1844 | ||
2bda0e17 KB |
1845 | // We didn't process it |
1846 | return 1; | |
1847 | } | |
1848 | ||
f7bd2698 JS |
1849 | long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange) |
1850 | { | |
1851 | wxPaletteChangedEvent event(GetId()); | |
1852 | event.SetEventObject(this); | |
1853 | event.SetChangedWindow(wxFindWinFromHandle(hWndPalChange)); | |
1854 | GetEventHandler()->ProcessEvent(event); | |
1855 | return 0; | |
1856 | } | |
1857 | ||
1858 | long wxWindow::MSWOnQueryNewPalette() | |
1859 | { | |
1860 | wxQueryNewPaletteEvent event(GetId()); | |
1861 | event.SetEventObject(this); | |
1862 | if (!GetEventHandler()->ProcessEvent(event) || !event.GetPaletteRealized()) | |
1863 | { | |
1864 | return (long) FALSE; | |
1865 | } | |
1866 | else | |
1867 | return (long) TRUE; | |
1868 | } | |
1869 | ||
2bda0e17 KB |
1870 | // Responds to colour changes: passes event on to children. |
1871 | void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event) | |
1872 | { | |
1873 | wxNode *node = GetChildren()->First(); | |
1874 | while ( node ) | |
1875 | { | |
1876 | // Only propagate to non-top-level windows | |
1877 | wxWindow *win = (wxWindow *)node->Data(); | |
1878 | if ( win->GetParent() ) | |
1879 | { | |
1880 | wxSysColourChangedEvent event2; | |
1881 | event.m_eventObject = win; | |
1882 | win->GetEventHandler()->ProcessEvent(event2); | |
1883 | } | |
1884 | ||
1885 | node = node->Next(); | |
1886 | } | |
1887 | } | |
1888 | ||
1889 | long wxWindow::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) | |
1890 | { | |
1891 | if ( m_oldWndProc ) | |
564b2609 | 1892 | return ::CallWindowProc(CASTWNDPROC m_oldWndProc, (HWND) GetHWND(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam); |
2bda0e17 | 1893 | else |
564b2609 | 1894 | return ::DefWindowProc((HWND) GetHWND(), nMsg, wParam, lParam); |
2bda0e17 KB |
1895 | } |
1896 | ||
1897 | long wxWindow::Default() | |
1898 | { | |
46851318 JS |
1899 | // Ignore 'fake' events (perhaps generated as a result of a separate real event) |
1900 | if (m_lastMsg == 0) | |
1c089c47 | 1901 | return 0; |
46851318 | 1902 | |
b2aef89b | 1903 | #ifdef __WXDEBUG__ |
47cbd6da | 1904 | wxLogTrace(wxTraceMessages, "Forwarding %s to DefWindowProc.", |
f449ef69 | 1905 | wxGetMessageName(m_lastMsg)); |
b2aef89b | 1906 | #endif // WXDEBUG |
47cbd6da | 1907 | |
46851318 | 1908 | return this->MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam); |
2bda0e17 KB |
1909 | } |
1910 | ||
1911 | bool wxWindow::MSWProcessMessage(WXMSG* pMsg) | |
1912 | { | |
47cbd6da VZ |
1913 | if ( m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL) ) { |
1914 | // intercept dialog navigation keys | |
1915 | MSG *msg = (MSG *)pMsg; | |
1916 | bool bProcess = TRUE; | |
1917 | if ( msg->message != WM_KEYDOWN ) | |
1918 | bProcess = FALSE; | |
1919 | ||
1920 | if ( (HIWORD(msg->lParam) & KF_ALTDOWN) == KF_ALTDOWN ) | |
1921 | bProcess = FALSE; | |
1922 | ||
1923 | bool bCtrlDown = (::GetKeyState(VK_CONTROL) & 0x100) != 0; | |
1924 | ||
1925 | // WM_GETDLGCODE: if the control wants it for itself, don't process it | |
1926 | // (except for Ctrl-Tab combination which is always processed) | |
88db66e3 | 1927 | LONG lDlgCode = 0; |
47cbd6da VZ |
1928 | if ( bProcess && !bCtrlDown ) { |
1929 | lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0); | |
1930 | } | |
1931 | ||
1932 | bool bForward; | |
1933 | if ( bProcess ) { | |
1934 | switch ( msg->wParam ) { | |
1935 | case VK_TAB: | |
88db66e3 | 1936 | if ( lDlgCode & DLGC_WANTTAB ) // this is FALSE for Ctrl-Tab |
47cbd6da VZ |
1937 | bProcess = FALSE; |
1938 | else | |
1939 | bForward = !(::GetKeyState(VK_SHIFT) & 0x100); | |
1940 | break; | |
1941 | ||
1942 | case VK_UP: | |
1943 | case VK_LEFT: | |
a02eb1d2 | 1944 | if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown ) |
47cbd6da VZ |
1945 | bProcess = FALSE; |
1946 | else | |
1947 | bForward = FALSE; | |
1948 | break; | |
1949 | ||
1950 | case VK_DOWN: | |
1951 | case VK_RIGHT: | |
a02eb1d2 | 1952 | if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown ) |
47cbd6da VZ |
1953 | bProcess = FALSE; |
1954 | else | |
1955 | bForward = TRUE; | |
1956 | break; | |
1957 | ||
1958 | default: | |
1959 | bProcess = FALSE; | |
1960 | } | |
1961 | } | |
1962 | ||
1963 | if ( bProcess ) { | |
1964 | wxNavigationKeyEvent event; | |
1965 | event.SetDirection(bForward); | |
1966 | event.SetWindowChange(bCtrlDown); | |
1967 | event.SetEventObject(this); | |
1968 | ||
1969 | if ( GetEventHandler()->ProcessEvent(event) ) | |
1970 | return TRUE; | |
1971 | } | |
1972 | ||
1973 | return ::IsDialogMessage((HWND)GetHWND(), msg) != 0; | |
2bda0e17 | 1974 | } |
47cbd6da VZ |
1975 | |
1976 | return FALSE; | |
2bda0e17 KB |
1977 | } |
1978 | ||
088a95f5 | 1979 | bool wxWindow::MSWTranslateMessage(WXMSG* pMsg) |
57a7b7c1 | 1980 | { |
088a95f5 JS |
1981 | if (m_acceleratorTable.Ok() && |
1982 | ::TranslateAccelerator((HWND) GetHWND(), (HACCEL) m_acceleratorTable.GetHACCEL(), (MSG *)pMsg)) | |
1983 | return TRUE; | |
1984 | else | |
1985 | return FALSE; | |
57a7b7c1 JS |
1986 | } |
1987 | ||
debe6624 | 1988 | long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag), WXHWND WXUNUSED(activate), WXHWND WXUNUSED(deactivate)) |
2bda0e17 | 1989 | { |
b2aef89b | 1990 | #if WXDEBUG > 1 |
2bda0e17 KB |
1991 | wxDebugMsg("wxWindow::MSWOnMDIActivate %d\n", m_hWnd); |
1992 | #endif | |
1993 | return 1; | |
1994 | } | |
1995 | ||
1996 | void wxWindow::MSWDetachWindowMenu(void) | |
1997 | { | |
1998 | if (m_hMenu) | |
1999 | { | |
2000 | int N = GetMenuItemCount((HMENU) m_hMenu); | |
2001 | int i; | |
2002 | for (i = 0; i < N; i++) | |
2003 | { | |
2004 | char buf[100]; | |
2005 | int chars = GetMenuString((HMENU) m_hMenu, i, buf, 100, MF_BYPOSITION); | |
2006 | if ((chars > 0) && (strcmp(buf, "&Window") == 0)) | |
2007 | { | |
2008 | RemoveMenu((HMENU) m_hMenu, i, MF_BYPOSITION); | |
2009 | break; | |
2010 | } | |
2011 | } | |
2012 | } | |
2013 | } | |
2014 | ||
2015 | bool wxWindow::MSWOnPaint(void) | |
2016 | { | |
81d66cf3 JS |
2017 | #ifdef __WIN32__ |
2018 | HRGN hRegion = ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle | |
2019 | ::GetUpdateRgn((HWND) GetHWND(), hRegion, FALSE); | |
2020 | ||
2021 | m_updateRegion = wxRegion((WXHRGN) hRegion); | |
2022 | #else | |
2023 | RECT updateRect; | |
2024 | ::GetUpdateRect((HWND) GetHWND(), & updateRect, FALSE); | |
2025 | ||
2026 | m_updateRegion = wxRegion(updateRect.left, updateRect.top, | |
2027 | updateRect.right - updateRect.left, updateRect.bottom - updateRect.top); | |
2028 | #endif | |
2029 | ||
2bda0e17 | 2030 | wxPaintEvent event(m_windowId); |
debe6624 JS |
2031 | event.SetEventObject(this); |
2032 | if (!GetEventHandler()->ProcessEvent(event)) | |
2033 | Default(); | |
2bda0e17 | 2034 | return TRUE; |
2bda0e17 KB |
2035 | } |
2036 | ||
debe6624 | 2037 | void wxWindow::MSWOnSize(int w, int h, WXUINT WXUNUSED(flag)) |
2bda0e17 KB |
2038 | { |
2039 | if (m_inOnSize) | |
2040 | return; | |
2041 | ||
b2aef89b | 2042 | #if WXDEBUG > 1 |
2bda0e17 KB |
2043 | wxDebugMsg("wxWindow::MSWOnSize %d\n", m_hWnd); |
2044 | #endif | |
2045 | if (!m_hWnd) | |
2046 | return; | |
2047 | ||
2048 | m_inOnSize = TRUE; | |
2049 | ||
2bda0e17 | 2050 | wxSizeEvent event(wxSize(w, h), m_windowId); |
debe6624 JS |
2051 | event.SetEventObject(this); |
2052 | if (!GetEventHandler()->ProcessEvent(event)) | |
2053 | Default(); | |
2bda0e17 KB |
2054 | |
2055 | m_inOnSize = FALSE; | |
2056 | } | |
2057 | ||
2058 | void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos)) | |
2059 | { | |
2060 | Default(); | |
2061 | } | |
2062 | ||
2063 | // Deal with child commands from buttons etc. | |
34138703 | 2064 | bool wxWindow::MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control) |
2bda0e17 | 2065 | { |
b2aef89b | 2066 | #if WXDEBUG > 1 |
2bda0e17 KB |
2067 | wxDebugMsg("wxWindow::MSWOnCommand\n"); |
2068 | #endif | |
2069 | if (wxCurrentPopupMenu) | |
2070 | { | |
2071 | wxMenu *popupMenu = wxCurrentPopupMenu; | |
2072 | wxCurrentPopupMenu = NULL; | |
2073 | bool succ = popupMenu->MSWCommand(cmd, id); | |
2074 | return succ; | |
2075 | } | |
b2aef89b | 2076 | #if WXDEBUG > 1 |
2bda0e17 KB |
2077 | char buf[80]; |
2078 | sprintf(buf, "Looking for item %d...\n", id); | |
2079 | wxDebugMsg(buf); | |
2080 | #endif | |
2081 | ||
2082 | wxWindow *item = FindItem(id); | |
2083 | if (item) | |
2084 | { | |
2085 | bool value = item->MSWCommand(cmd, id); | |
b2aef89b | 2086 | #if WXDEBUG > 1 |
2bda0e17 KB |
2087 | if (value) |
2088 | wxDebugMsg("MSWCommand succeeded\n"); | |
2089 | else | |
2090 | wxDebugMsg("MSWCommand failed\n"); | |
2091 | #endif | |
2092 | return value; | |
2093 | } | |
2094 | else | |
2095 | { | |
34138703 JS |
2096 | wxWindow *win = wxFindWinFromHandle(control); |
2097 | if (win) | |
2098 | return win->MSWCommand(cmd, id); | |
2bda0e17 | 2099 | } |
34138703 | 2100 | return FALSE; |
2bda0e17 KB |
2101 | } |
2102 | ||
2103 | long wxWindow::MSWOnSysCommand(WXWPARAM wParam, WXLPARAM lParam) | |
2104 | { | |
2105 | switch (wParam) | |
2106 | { | |
2107 | case SC_MAXIMIZE: | |
2108 | { | |
2109 | wxMaximizeEvent event(m_windowId); | |
2110 | event.SetEventObject(this); | |
2111 | if (!GetEventHandler()->ProcessEvent(event)) | |
2112 | return Default(); | |
2113 | else | |
2114 | return 0; | |
2115 | break; | |
2116 | } | |
2117 | case SC_MINIMIZE: | |
2118 | { | |
2119 | wxIconizeEvent event(m_windowId); | |
2120 | event.SetEventObject(this); | |
2121 | if (!GetEventHandler()->ProcessEvent(event)) | |
2122 | return Default(); | |
2123 | else | |
2124 | return 0; | |
2125 | break; | |
2126 | } | |
2127 | default: | |
2128 | return Default(); | |
2129 | } | |
2130 | return 0; | |
2131 | } | |
2132 | ||
debe6624 | 2133 | void wxWindow::MSWOnLButtonDown(int x, int y, WXUINT flags) |
2bda0e17 | 2134 | { |
7798a18e | 2135 | wxMouseEvent event(wxEVT_LEFT_DOWN); |
2bda0e17 | 2136 | |
2bda0e17 KB |
2137 | event.m_x = x; event.m_y = y; |
2138 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2139 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2140 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2141 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2142 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2143 | event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ | |
2144 | event.m_eventObject = this; | |
2145 | ||
2146 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_LEFT_DOWN; | |
debe6624 JS |
2147 | |
2148 | if (!GetEventHandler()->ProcessEvent(event)) | |
2149 | Default(); | |
2bda0e17 KB |
2150 | } |
2151 | ||
debe6624 | 2152 | void wxWindow::MSWOnLButtonUp(int x, int y, WXUINT flags) |
2bda0e17 | 2153 | { |
7798a18e | 2154 | wxMouseEvent event(wxEVT_LEFT_UP); |
2bda0e17 | 2155 | |
2bda0e17 KB |
2156 | event.m_x = x; event.m_y = y; |
2157 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2158 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2159 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2160 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2161 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2162 | event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ | |
2163 | event.m_eventObject = this; | |
2164 | ||
7798a18e | 2165 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_LEFT_UP; |
2bda0e17 | 2166 | |
debe6624 JS |
2167 | if (!GetEventHandler()->ProcessEvent(event)) |
2168 | Default(); | |
2bda0e17 KB |
2169 | } |
2170 | ||
debe6624 | 2171 | void wxWindow::MSWOnLButtonDClick(int x, int y, WXUINT flags) |
2bda0e17 | 2172 | { |
7798a18e | 2173 | wxMouseEvent event(wxEVT_LEFT_DCLICK); |
2bda0e17 | 2174 | |
2bda0e17 KB |
2175 | event.m_x = x; event.m_y = y; |
2176 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2177 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2178 | event.m_leftDown = ((flags & MK_LBUTTON != 0)); | |
2179 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2180 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2181 | event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ | |
2182 | event.m_eventObject = this; | |
2183 | ||
7798a18e | 2184 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_LEFT_DCLICK; |
2bda0e17 | 2185 | |
debe6624 JS |
2186 | if (!GetEventHandler()->ProcessEvent(event)) |
2187 | Default(); | |
2bda0e17 KB |
2188 | } |
2189 | ||
debe6624 | 2190 | void wxWindow::MSWOnMButtonDown(int x, int y, WXUINT flags) |
2bda0e17 | 2191 | { |
7798a18e | 2192 | wxMouseEvent event(wxEVT_MIDDLE_DOWN); |
2bda0e17 | 2193 | |
2bda0e17 KB |
2194 | event.m_x = x; event.m_y = y; |
2195 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2196 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2197 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2198 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2199 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2200 | event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ | |
2201 | event.m_eventObject = this; | |
2202 | ||
7798a18e | 2203 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_DOWN; |
debe6624 JS |
2204 | |
2205 | if (!GetEventHandler()->ProcessEvent(event)) | |
2206 | Default(); | |
2bda0e17 KB |
2207 | } |
2208 | ||
debe6624 | 2209 | void wxWindow::MSWOnMButtonUp(int x, int y, WXUINT flags) |
2bda0e17 KB |
2210 | { |
2211 | //wxDebugMsg("MButtonUp\n") ; | |
7798a18e | 2212 | wxMouseEvent event(wxEVT_MIDDLE_UP); |
2bda0e17 | 2213 | |
2bda0e17 KB |
2214 | event.m_x = x; event.m_y = y; |
2215 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2216 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2217 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2218 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2219 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2220 | event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ | |
2221 | event.m_eventObject = this; | |
2222 | ||
7798a18e | 2223 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_UP; |
debe6624 JS |
2224 | |
2225 | if (!GetEventHandler()->ProcessEvent(event)) | |
2226 | Default(); | |
2bda0e17 KB |
2227 | } |
2228 | ||
debe6624 | 2229 | void wxWindow::MSWOnMButtonDClick(int x, int y, WXUINT flags) |
2bda0e17 | 2230 | { |
7798a18e | 2231 | wxMouseEvent event(wxEVT_MIDDLE_DCLICK); |
2bda0e17 | 2232 | |
2bda0e17 KB |
2233 | event.m_x = x; event.m_y = y; |
2234 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2235 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2236 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2237 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2238 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2239 | event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ | |
2240 | event.m_eventObject = this; | |
2241 | ||
7798a18e | 2242 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_DCLICK; |
debe6624 JS |
2243 | |
2244 | if (!GetEventHandler()->ProcessEvent(event)) | |
2245 | Default(); | |
2bda0e17 KB |
2246 | } |
2247 | ||
debe6624 | 2248 | void wxWindow::MSWOnRButtonDown(int x, int y, WXUINT flags) |
2bda0e17 | 2249 | { |
7798a18e | 2250 | wxMouseEvent event(wxEVT_RIGHT_DOWN); |
2bda0e17 | 2251 | |
2bda0e17 KB |
2252 | event.m_x = x; event.m_y = y; |
2253 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2254 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2255 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2256 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2257 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2258 | event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ | |
2259 | event.m_eventObject = this; | |
2260 | ||
7798a18e | 2261 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_DOWN; |
debe6624 JS |
2262 | |
2263 | if (!GetEventHandler()->ProcessEvent(event)) | |
2264 | Default(); | |
2bda0e17 KB |
2265 | } |
2266 | ||
debe6624 | 2267 | void wxWindow::MSWOnRButtonUp(int x, int y, WXUINT flags) |
2bda0e17 | 2268 | { |
7798a18e | 2269 | wxMouseEvent event(wxEVT_RIGHT_UP); |
2bda0e17 | 2270 | |
2bda0e17 KB |
2271 | event.m_x = x; event.m_y = y; |
2272 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2273 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2274 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2275 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2276 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2277 | event.m_eventObject = this; | |
2278 | event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ | |
2279 | ||
7798a18e | 2280 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_UP; |
debe6624 JS |
2281 | |
2282 | if (!GetEventHandler()->ProcessEvent(event)) | |
2283 | Default(); | |
2bda0e17 KB |
2284 | } |
2285 | ||
debe6624 | 2286 | void wxWindow::MSWOnRButtonDClick(int x, int y, WXUINT flags) |
2bda0e17 | 2287 | { |
7798a18e | 2288 | wxMouseEvent event(wxEVT_RIGHT_DCLICK); |
2bda0e17 | 2289 | |
2bda0e17 KB |
2290 | event.m_x = x; event.m_y = y; |
2291 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2292 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2293 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2294 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2295 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2296 | event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ | |
2297 | event.m_eventObject = this; | |
2298 | ||
7798a18e | 2299 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_DCLICK; |
debe6624 JS |
2300 | |
2301 | if (!GetEventHandler()->ProcessEvent(event)) | |
2302 | Default(); | |
2bda0e17 KB |
2303 | } |
2304 | ||
debe6624 | 2305 | void wxWindow::MSWOnMouseMove(int x, int y, WXUINT flags) |
2bda0e17 KB |
2306 | { |
2307 | // 'normal' move event... | |
2308 | // Set cursor, but only if we're not in 'busy' mode | |
2309 | ||
2310 | // Trouble with this is that it sets the cursor for controls too :-( | |
2311 | if (m_windowCursor.Ok() && !wxIsBusy()) | |
2312 | ::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR()); | |
2313 | ||
f54f3bff | 2314 | if (!m_mouseInWindow) |
2bda0e17 | 2315 | { |
43d811ea JS |
2316 | // Generate an ENTER event |
2317 | m_mouseInWindow = TRUE; | |
2318 | MSWOnMouseEnter(x, y, flags); | |
2bda0e17 | 2319 | } |
2bda0e17 | 2320 | |
7798a18e | 2321 | wxMouseEvent event(wxEVT_MOTION); |
2bda0e17 | 2322 | |
2bda0e17 KB |
2323 | event.m_x = x; event.m_y = y; |
2324 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2325 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2326 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2327 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2328 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2329 | event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ | |
2330 | event.m_eventObject = this; | |
2331 | ||
2332 | // Window gets a click down message followed by a mouse move | |
2333 | // message even if position isn't changed! We want to discard | |
2334 | // the trailing move event if x and y are the same. | |
7798a18e JS |
2335 | if ((m_lastEvent == wxEVT_RIGHT_DOWN || m_lastEvent == wxEVT_LEFT_DOWN || |
2336 | m_lastEvent == wxEVT_MIDDLE_DOWN) && | |
2bda0e17 KB |
2337 | (m_lastXPos == event.m_x && m_lastYPos == event.m_y)) |
2338 | { | |
2339 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; | |
7798a18e | 2340 | m_lastEvent = wxEVT_MOTION; |
2bda0e17 KB |
2341 | return; |
2342 | } | |
2343 | ||
7798a18e | 2344 | m_lastEvent = wxEVT_MOTION; |
2bda0e17 | 2345 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; |
debe6624 JS |
2346 | |
2347 | if (!GetEventHandler()->ProcessEvent(event)) | |
2348 | Default(); | |
2bda0e17 | 2349 | } |
2bda0e17 | 2350 | |
debe6624 | 2351 | void wxWindow::MSWOnMouseEnter(int x, int y, WXUINT flags) |
2bda0e17 | 2352 | { |
43d811ea | 2353 | wxMouseEvent event(wxEVT_ENTER_WINDOW); |
2bda0e17 KB |
2354 | |
2355 | event.m_x = x; event.m_y = y; | |
2356 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2357 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2358 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2359 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2360 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2361 | event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ | |
2362 | event.m_eventObject = this; | |
2363 | ||
43d811ea | 2364 | m_lastEvent = wxEVT_ENTER_WINDOW; |
2bda0e17 | 2365 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; |
46851318 JS |
2366 | // No message - ensure we don't try to call the default behaviour accidentally. |
2367 | m_lastMsg = 0; | |
1c089c47 | 2368 | GetEventHandler()->ProcessEvent(event); |
2bda0e17 KB |
2369 | } |
2370 | ||
debe6624 | 2371 | void wxWindow::MSWOnMouseLeave(int x, int y, WXUINT flags) |
2bda0e17 | 2372 | { |
43d811ea | 2373 | wxMouseEvent event(wxEVT_LEAVE_WINDOW); |
2bda0e17 KB |
2374 | |
2375 | event.m_x = x; event.m_y = y; | |
2376 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2377 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2378 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2379 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2380 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2381 | event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ | |
2382 | event.m_eventObject = this; | |
2383 | ||
43d811ea | 2384 | m_lastEvent = wxEVT_LEAVE_WINDOW; |
2bda0e17 | 2385 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; |
46851318 JS |
2386 | // No message - ensure we don't try to call the default behaviour accidentally. |
2387 | m_lastMsg = 0; | |
1c089c47 | 2388 | GetEventHandler()->ProcessEvent(event); |
2bda0e17 KB |
2389 | } |
2390 | ||
debe6624 | 2391 | void wxWindow::MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII) |
2bda0e17 KB |
2392 | { |
2393 | int id; | |
2394 | bool tempControlDown = FALSE; | |
2395 | if (isASCII) | |
2396 | { | |
2397 | // If 1 -> 26, translate to CTRL plus a letter. | |
2398 | id = wParam; | |
2399 | if ((id > 0) && (id < 27)) | |
2400 | { | |
2401 | switch (id) | |
2402 | { | |
2403 | case 13: | |
2404 | { | |
2405 | id = WXK_RETURN; | |
2406 | break; | |
2407 | } | |
2408 | case 8: | |
2409 | { | |
2410 | id = WXK_BACK; | |
2411 | break; | |
2412 | } | |
2413 | case 9: | |
2414 | { | |
2415 | id = WXK_TAB; | |
2416 | break; | |
2417 | } | |
2418 | default: | |
2419 | { | |
2420 | tempControlDown = TRUE; | |
2421 | id = id + 96; | |
2422 | } | |
2423 | } | |
2424 | } | |
2425 | } | |
f54f3bff VZ |
2426 | else if ((id = wxCharCodeMSWToWX(wParam)) == 0) { |
2427 | // it's ASCII and will be processed here only when called from | |
2428 | // WM_CHAR (i.e. when isASCII = TRUE) | |
2bda0e17 | 2429 | id = -1; |
f54f3bff | 2430 | } |
2bda0e17 | 2431 | |
f54f3bff | 2432 | if (id != -1) |
2bda0e17 KB |
2433 | { |
2434 | wxKeyEvent event(wxEVT_CHAR); | |
2435 | event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE); | |
2436 | event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE); | |
2437 | if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN) | |
2438 | event.m_altDown = TRUE; | |
2439 | ||
2440 | event.m_eventObject = this; | |
2441 | event.m_keyCode = id; | |
2442 | event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ | |
2443 | ||
2444 | POINT pt ; | |
2445 | GetCursorPos(&pt) ; | |
2446 | RECT rect ; | |
2447 | GetWindowRect((HWND) GetHWND(),&rect) ; | |
2448 | pt.x -= rect.left ; | |
2449 | pt.y -= rect.top ; | |
2450 | ||
2bda0e17 KB |
2451 | event.m_x = pt.x; event.m_y = pt.y; |
2452 | ||
2bda0e17 | 2453 | if (!GetEventHandler()->ProcessEvent(event)) |
564b2609 | 2454 | Default(); |
2bda0e17 KB |
2455 | } |
2456 | } | |
2457 | ||
debe6624 | 2458 | void wxWindow::MSWOnJoyDown(int joystick, int x, int y, WXUINT flags) |
2bda0e17 KB |
2459 | { |
2460 | int buttons = 0; | |
2461 | int change = 0; | |
2462 | if (flags & JOY_BUTTON1CHG) | |
2463 | change = wxJOY_BUTTON1; | |
2464 | if (flags & JOY_BUTTON2CHG) | |
2465 | change = wxJOY_BUTTON2; | |
2466 | if (flags & JOY_BUTTON3CHG) | |
2467 | change = wxJOY_BUTTON3; | |
2468 | if (flags & JOY_BUTTON4CHG) | |
2469 | change = wxJOY_BUTTON4; | |
2470 | ||
2471 | if (flags & JOY_BUTTON1) | |
2472 | buttons |= wxJOY_BUTTON1; | |
2473 | if (flags & JOY_BUTTON2) | |
2474 | buttons |= wxJOY_BUTTON2; | |
2475 | if (flags & JOY_BUTTON3) | |
2476 | buttons |= wxJOY_BUTTON3; | |
2477 | if (flags & JOY_BUTTON4) | |
2478 | buttons |= wxJOY_BUTTON4; | |
2479 | ||
2480 | wxJoystickEvent event(wxEVT_JOY_BUTTON_DOWN, buttons, joystick, change); | |
2481 | event.SetPosition(wxPoint(x, y)); | |
2482 | event.SetEventObject(this); | |
2483 | ||
2484 | GetEventHandler()->ProcessEvent(event); | |
2485 | } | |
2486 | ||
debe6624 | 2487 | void wxWindow::MSWOnJoyUp(int joystick, int x, int y, WXUINT flags) |
2bda0e17 KB |
2488 | { |
2489 | int buttons = 0; | |
2490 | int change = 0; | |
2491 | if (flags & JOY_BUTTON1CHG) | |
2492 | change = wxJOY_BUTTON1; | |
2493 | if (flags & JOY_BUTTON2CHG) | |
2494 | change = wxJOY_BUTTON2; | |
2495 | if (flags & JOY_BUTTON3CHG) | |
2496 | change = wxJOY_BUTTON3; | |
2497 | if (flags & JOY_BUTTON4CHG) | |
2498 | change = wxJOY_BUTTON4; | |
2499 | ||
2500 | if (flags & JOY_BUTTON1) | |
2501 | buttons |= wxJOY_BUTTON1; | |
2502 | if (flags & JOY_BUTTON2) | |
2503 | buttons |= wxJOY_BUTTON2; | |
2504 | if (flags & JOY_BUTTON3) | |
2505 | buttons |= wxJOY_BUTTON3; | |
2506 | if (flags & JOY_BUTTON4) | |
2507 | buttons |= wxJOY_BUTTON4; | |
2508 | ||
2509 | wxJoystickEvent event(wxEVT_JOY_BUTTON_UP, buttons, joystick, change); | |
2510 | event.SetPosition(wxPoint(x, y)); | |
2511 | event.SetEventObject(this); | |
2512 | ||
2513 | GetEventHandler()->ProcessEvent(event); | |
2514 | } | |
2515 | ||
debe6624 | 2516 | void wxWindow::MSWOnJoyMove(int joystick, int x, int y, WXUINT flags) |
2bda0e17 KB |
2517 | { |
2518 | int buttons = 0; | |
2519 | if (flags & JOY_BUTTON1) | |
2520 | buttons |= wxJOY_BUTTON1; | |
2521 | if (flags & JOY_BUTTON2) | |
2522 | buttons |= wxJOY_BUTTON2; | |
2523 | if (flags & JOY_BUTTON3) | |
2524 | buttons |= wxJOY_BUTTON3; | |
2525 | if (flags & JOY_BUTTON4) | |
2526 | buttons |= wxJOY_BUTTON4; | |
2527 | ||
2528 | wxJoystickEvent event(wxEVT_JOY_MOVE, buttons, joystick, 0); | |
2529 | event.SetPosition(wxPoint(x, y)); | |
2530 | event.SetEventObject(this); | |
2531 | ||
2532 | GetEventHandler()->ProcessEvent(event); | |
2533 | } | |
2534 | ||
debe6624 | 2535 | void wxWindow::MSWOnJoyZMove(int joystick, int z, WXUINT flags) |
2bda0e17 KB |
2536 | { |
2537 | int buttons = 0; | |
2538 | if (flags & JOY_BUTTON1) | |
2539 | buttons |= wxJOY_BUTTON1; | |
2540 | if (flags & JOY_BUTTON2) | |
2541 | buttons |= wxJOY_BUTTON2; | |
2542 | if (flags & JOY_BUTTON3) | |
2543 | buttons |= wxJOY_BUTTON3; | |
2544 | if (flags & JOY_BUTTON4) | |
2545 | buttons |= wxJOY_BUTTON4; | |
2546 | ||
2547 | wxJoystickEvent event(wxEVT_JOY_ZMOVE, buttons, joystick, 0); | |
2548 | event.SetZPosition(z); | |
2549 | event.SetEventObject(this); | |
2550 | ||
2551 | GetEventHandler()->ProcessEvent(event); | |
2552 | } | |
2553 | ||
debe6624 | 2554 | void wxWindow::MSWOnVScroll(WXWORD wParam, WXWORD pos, WXHWND control) |
2bda0e17 KB |
2555 | { |
2556 | if (control) | |
2557 | { | |
2558 | wxWindow *child = wxFindWinFromHandle(control); | |
47cbd6da VZ |
2559 | if ( child ) |
2560 | child->MSWOnVScroll(wParam, pos, control); | |
2bda0e17 KB |
2561 | return; |
2562 | } | |
2563 | ||
47cbd6da VZ |
2564 | wxScrollEvent event; |
2565 | event.SetPosition(pos); | |
2566 | event.SetOrientation(wxVERTICAL); | |
2567 | event.m_eventObject = this; | |
2bda0e17 | 2568 | |
564b2609 VZ |
2569 | switch ( wParam ) |
2570 | { | |
2571 | case SB_TOP: | |
2572 | event.m_eventType = wxEVT_SCROLL_TOP; | |
2573 | break; | |
2bda0e17 | 2574 | |
564b2609 VZ |
2575 | case SB_BOTTOM: |
2576 | event.m_eventType = wxEVT_SCROLL_BOTTOM; | |
2577 | break; | |
2bda0e17 | 2578 | |
564b2609 VZ |
2579 | case SB_LINEUP: |
2580 | event.m_eventType = wxEVT_SCROLL_LINEUP; | |
2581 | break; | |
2bda0e17 | 2582 | |
564b2609 VZ |
2583 | case SB_LINEDOWN: |
2584 | event.m_eventType = wxEVT_SCROLL_LINEDOWN; | |
2585 | break; | |
2bda0e17 | 2586 | |
564b2609 | 2587 | case SB_PAGEUP: |
7798a18e | 2588 | event.m_eventType = wxEVT_SCROLL_PAGEUP; |
564b2609 | 2589 | break; |
2bda0e17 | 2590 | |
564b2609 | 2591 | case SB_PAGEDOWN: |
7798a18e | 2592 | event.m_eventType = wxEVT_SCROLL_PAGEDOWN; |
564b2609 | 2593 | break; |
2bda0e17 KB |
2594 | |
2595 | case SB_THUMBTRACK: | |
2596 | case SB_THUMBPOSITION: | |
7798a18e | 2597 | event.m_eventType = wxEVT_SCROLL_THUMBTRACK; |
564b2609 | 2598 | break; |
2bda0e17 | 2599 | |
564b2609 | 2600 | default: |
2bda0e17 KB |
2601 | return; |
2602 | break; | |
564b2609 | 2603 | } |
2bda0e17 KB |
2604 | |
2605 | if (!GetEventHandler()->ProcessEvent(event)) | |
2bda0e17 | 2606 | Default(); |
2bda0e17 KB |
2607 | } |
2608 | ||
debe6624 | 2609 | void wxWindow::MSWOnHScroll( WXWORD wParam, WXWORD pos, WXHWND control) |
2bda0e17 KB |
2610 | { |
2611 | if (control) | |
2612 | { | |
2613 | wxWindow *child = wxFindWinFromHandle(control); | |
564b2609 | 2614 | if ( child ) { |
47cbd6da | 2615 | child->MSWOnHScroll(wParam, pos, control); |
564b2609 VZ |
2616 | |
2617 | return; | |
2618 | } | |
2bda0e17 | 2619 | } |
564b2609 VZ |
2620 | else { |
2621 | wxScrollEvent event; | |
2622 | event.SetPosition(pos); | |
2623 | event.SetOrientation(wxHORIZONTAL); | |
2624 | event.m_eventObject = this; | |
47cbd6da | 2625 | |
564b2609 VZ |
2626 | switch ( wParam ) |
2627 | { | |
2628 | case SB_TOP: | |
2629 | event.m_eventType = wxEVT_SCROLL_TOP; | |
2630 | break; | |
2631 | ||
2632 | case SB_BOTTOM: | |
2633 | event.m_eventType = wxEVT_SCROLL_BOTTOM; | |
2634 | break; | |
2635 | ||
2636 | case SB_LINEUP: | |
2637 | event.m_eventType = wxEVT_SCROLL_LINEUP; | |
2638 | break; | |
2639 | ||
2640 | case SB_LINEDOWN: | |
2641 | event.m_eventType = wxEVT_SCROLL_LINEDOWN; | |
2642 | break; | |
2643 | ||
2644 | case SB_PAGEUP: | |
2645 | event.m_eventType = wxEVT_SCROLL_PAGEUP; | |
2646 | break; | |
2647 | ||
2648 | case SB_PAGEDOWN: | |
2649 | event.m_eventType = wxEVT_SCROLL_PAGEDOWN; | |
2650 | break; | |
2651 | ||
2652 | case SB_THUMBTRACK: | |
2653 | case SB_THUMBPOSITION: | |
2654 | event.m_eventType = wxEVT_SCROLL_THUMBTRACK; | |
2655 | break; | |
2656 | ||
2657 | default: | |
2658 | return; | |
2659 | } | |
2bda0e17 | 2660 | |
564b2609 VZ |
2661 | if ( GetEventHandler()->ProcessEvent(event) ) |
2662 | return; | |
2663 | } | |
2bda0e17 | 2664 | |
564b2609 VZ |
2665 | // call the default WM_HSCROLL handler: it's non trivial in some common |
2666 | // controls (up-down control for example) | |
2667 | Default(); | |
2bda0e17 KB |
2668 | } |
2669 | ||
2670 | void wxWindow::MSWOnShow(bool show, int status) | |
2671 | { | |
47cbd6da VZ |
2672 | wxShowEvent event(GetId(), show); |
2673 | event.m_eventObject = this; | |
2674 | GetEventHandler()->ProcessEvent(event); | |
2bda0e17 KB |
2675 | } |
2676 | ||
2677 | bool wxWindow::MSWOnInitDialog(WXHWND WXUNUSED(hWndFocus)) | |
2678 | { | |
47cbd6da VZ |
2679 | wxInitDialogEvent event(GetId()); |
2680 | event.m_eventObject = this; | |
2681 | GetEventHandler()->ProcessEvent(event); | |
2682 | return TRUE; | |
2bda0e17 KB |
2683 | } |
2684 | ||
2685 | void wxWindow::InitDialog(void) | |
2686 | { | |
47cbd6da VZ |
2687 | wxInitDialogEvent event(GetId()); |
2688 | event.SetEventObject( this ); | |
2689 | GetEventHandler()->ProcessEvent(event); | |
2bda0e17 KB |
2690 | } |
2691 | ||
2692 | // Default init dialog behaviour is to transfer data to window | |
2693 | void wxWindow::OnInitDialog(wxInitDialogEvent& event) | |
2694 | { | |
47cbd6da | 2695 | TransferDataToWindow(); |
2bda0e17 KB |
2696 | } |
2697 | ||
2698 | void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font) | |
2699 | { | |
2700 | TEXTMETRIC tm; | |
2701 | HDC dc = ::GetDC((HWND) wnd); | |
2702 | HFONT fnt =0; | |
2703 | HFONT was = 0; | |
2704 | if (the_font) | |
2705 | { | |
b2aef89b | 2706 | #if WXDEBUG > 1 |
2bda0e17 KB |
2707 | wxDebugMsg("wxGetCharSize: Selecting HFONT %X\n", fnt); |
2708 | #endif | |
2709 | // the_font->UseResource(); | |
2710 | // the_font->RealizeResource(); | |
2711 | if ((fnt=(HFONT) the_font->GetResourceHandle())) | |
c4e7c2aa | 2712 | was = (HFONT) SelectObject(dc,fnt) ; |
2bda0e17 KB |
2713 | } |
2714 | GetTextMetrics(dc, &tm); | |
2715 | if (the_font && fnt && was) | |
2716 | { | |
b2aef89b | 2717 | #if WXDEBUG > 1 |
2bda0e17 KB |
2718 | wxDebugMsg("wxGetCharSize: Selecting old HFONT %X\n", was); |
2719 | #endif | |
2720 | SelectObject(dc,was) ; | |
2721 | } | |
2722 | ReleaseDC((HWND)wnd, dc); | |
2723 | *x = tm.tmAveCharWidth; | |
2724 | *y = tm.tmHeight + tm.tmExternalLeading; | |
2725 | ||
2726 | // if (the_font) | |
2727 | // the_font->ReleaseResource(); | |
2728 | } | |
2729 | ||
2730 | // Returns 0 if was a normal ASCII value, not a special key. This indicates that | |
2731 | // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead. | |
2732 | int wxCharCodeMSWToWX(int keySym) | |
2733 | { | |
2734 | int id = 0; | |
2735 | switch (keySym) | |
2736 | { | |
2737 | case VK_CANCEL: id = WXK_CANCEL; break; | |
2738 | case VK_BACK: id = WXK_BACK; break; | |
564b2609 VZ |
2739 | case VK_TAB: id = WXK_TAB; break; |
2740 | case VK_CLEAR: id = WXK_CLEAR; break; | |
2741 | case VK_RETURN: id = WXK_RETURN; break; | |
2742 | case VK_SHIFT: id = WXK_SHIFT; break; | |
2743 | case VK_CONTROL: id = WXK_CONTROL; break; | |
2744 | case VK_MENU : id = WXK_MENU; break; | |
2745 | case VK_PAUSE: id = WXK_PAUSE; break; | |
2746 | case VK_SPACE: id = WXK_SPACE; break; | |
2747 | case VK_ESCAPE: id = WXK_ESCAPE; break; | |
2748 | case VK_PRIOR: id = WXK_PRIOR; break; | |
2749 | case VK_NEXT : id = WXK_NEXT; break; | |
2750 | case VK_END: id = WXK_END; break; | |
2751 | case VK_HOME : id = WXK_HOME; break; | |
2752 | case VK_LEFT : id = WXK_LEFT; break; | |
2753 | case VK_UP: id = WXK_UP; break; | |
2754 | case VK_RIGHT: id = WXK_RIGHT; break; | |
2755 | case VK_DOWN : id = WXK_DOWN; break; | |
2756 | case VK_SELECT: id = WXK_SELECT; break; | |
2757 | case VK_PRINT: id = WXK_PRINT; break; | |
2758 | case VK_EXECUTE: id = WXK_EXECUTE; break; | |
2759 | case VK_INSERT: id = WXK_INSERT; break; | |
2760 | case VK_DELETE: id = WXK_DELETE; break; | |
2761 | case VK_HELP : id = WXK_HELP; break; | |
2762 | case VK_NUMPAD0: id = WXK_NUMPAD0; break; | |
2763 | case VK_NUMPAD1: id = WXK_NUMPAD1; break; | |
2764 | case VK_NUMPAD2: id = WXK_NUMPAD2; break; | |
2765 | case VK_NUMPAD3: id = WXK_NUMPAD3; break; | |
2766 | case VK_NUMPAD4: id = WXK_NUMPAD4; break; | |
2767 | case VK_NUMPAD5: id = WXK_NUMPAD5; break; | |
2768 | case VK_NUMPAD6: id = WXK_NUMPAD6; break; | |
2769 | case VK_NUMPAD7: id = WXK_NUMPAD7; break; | |
2770 | case VK_NUMPAD8: id = WXK_NUMPAD8; break; | |
2771 | case VK_NUMPAD9: id = WXK_NUMPAD9; break; | |
2772 | case VK_MULTIPLY: id = WXK_MULTIPLY; break; | |
2773 | case VK_ADD: id = WXK_ADD; break; | |
2774 | case VK_SUBTRACT: id = WXK_SUBTRACT; break; | |
2775 | case VK_DECIMAL: id = WXK_DECIMAL; break; | |
2776 | case VK_DIVIDE: id = WXK_DIVIDE; break; | |
2777 | case VK_F1: id = WXK_F1; break; | |
2778 | case VK_F2: id = WXK_F2; break; | |
2779 | case VK_F3: id = WXK_F3; break; | |
2780 | case VK_F4: id = WXK_F4; break; | |
2781 | case VK_F5: id = WXK_F5; break; | |
2782 | case VK_F6: id = WXK_F6; break; | |
2783 | case VK_F7: id = WXK_F7; break; | |
2784 | case VK_F8: id = WXK_F8; break; | |
2785 | case VK_F9: id = WXK_F9; break; | |
2786 | case VK_F10: id = WXK_F10; break; | |
2787 | case VK_F11: id = WXK_F11; break; | |
2788 | case VK_F12: id = WXK_F12; break; | |
2789 | case VK_F13: id = WXK_F13; break; | |
2790 | case VK_F14: id = WXK_F14; break; | |
2791 | case VK_F15: id = WXK_F15; break; | |
2792 | case VK_F16: id = WXK_F16; break; | |
2793 | case VK_F17: id = WXK_F17; break; | |
2794 | case VK_F18: id = WXK_F18; break; | |
2795 | case VK_F19: id = WXK_F19; break; | |
2796 | case VK_F20: id = WXK_F20; break; | |
2797 | case VK_F21: id = WXK_F21; break; | |
2798 | case VK_F22: id = WXK_F22; break; | |
2799 | case VK_F23: id = WXK_F23; break; | |
2800 | case VK_F24: id = WXK_F24; break; | |
2801 | case VK_NUMLOCK: id = WXK_NUMLOCK; break; | |
2802 | case VK_SCROLL: id = WXK_SCROLL; break; | |
2bda0e17 KB |
2803 | default: |
2804 | { | |
2805 | return 0; | |
2806 | } | |
2807 | } | |
2808 | return id; | |
2809 | } | |
2810 | ||
2811 | int wxCharCodeWXToMSW(int id, bool *isVirtual) | |
2812 | { | |
2813 | *isVirtual = TRUE; | |
2814 | int keySym = 0; | |
2815 | switch (id) | |
2816 | { | |
2817 | case WXK_CANCEL: keySym = VK_CANCEL; break; | |
564b2609 VZ |
2818 | case WXK_CLEAR: keySym = VK_CLEAR; break; |
2819 | case WXK_SHIFT: keySym = VK_SHIFT; break; | |
2820 | case WXK_CONTROL: keySym = VK_CONTROL; break; | |
2821 | case WXK_MENU : keySym = VK_MENU; break; | |
2822 | case WXK_PAUSE: keySym = VK_PAUSE; break; | |
2823 | case WXK_PRIOR: keySym = VK_PRIOR; break; | |
2824 | case WXK_NEXT : keySym = VK_NEXT; break; | |
2825 | case WXK_END: keySym = VK_END; break; | |
2826 | case WXK_HOME : keySym = VK_HOME; break; | |
2827 | case WXK_LEFT : keySym = VK_LEFT; break; | |
2828 | case WXK_UP: keySym = VK_UP; break; | |
2829 | case WXK_RIGHT: keySym = VK_RIGHT; break; | |
2830 | case WXK_DOWN : keySym = VK_DOWN; break; | |
2831 | case WXK_SELECT: keySym = VK_SELECT; break; | |
2832 | case WXK_PRINT: keySym = VK_PRINT; break; | |
2833 | case WXK_EXECUTE: keySym = VK_EXECUTE; break; | |
2834 | case WXK_INSERT: keySym = VK_INSERT; break; | |
2835 | case WXK_DELETE: keySym = VK_DELETE; break; | |
2836 | case WXK_HELP : keySym = VK_HELP; break; | |
2837 | case WXK_NUMPAD0: keySym = VK_NUMPAD0; break; | |
2838 | case WXK_NUMPAD1: keySym = VK_NUMPAD1; break; | |
2839 | case WXK_NUMPAD2: keySym = VK_NUMPAD2; break; | |
2840 | case WXK_NUMPAD3: keySym = VK_NUMPAD3; break; | |
2841 | case WXK_NUMPAD4: keySym = VK_NUMPAD4; break; | |
2842 | case WXK_NUMPAD5: keySym = VK_NUMPAD5; break; | |
2843 | case WXK_NUMPAD6: keySym = VK_NUMPAD6; break; | |
2844 | case WXK_NUMPAD7: keySym = VK_NUMPAD7; break; | |
2845 | case WXK_NUMPAD8: keySym = VK_NUMPAD8; break; | |
2846 | case WXK_NUMPAD9: keySym = VK_NUMPAD9; break; | |
2847 | case WXK_MULTIPLY: keySym = VK_MULTIPLY; break; | |
2848 | case WXK_ADD: keySym = VK_ADD; break; | |
2849 | case WXK_SUBTRACT: keySym = VK_SUBTRACT; break; | |
2850 | case WXK_DECIMAL: keySym = VK_DECIMAL; break; | |
2851 | case WXK_DIVIDE: keySym = VK_DIVIDE; break; | |
2852 | case WXK_F1: keySym = VK_F1; break; | |
2853 | case WXK_F2: keySym = VK_F2; break; | |
2854 | case WXK_F3: keySym = VK_F3; break; | |
2855 | case WXK_F4: keySym = VK_F4; break; | |
2856 | case WXK_F5: keySym = VK_F5; break; | |
2857 | case WXK_F6: keySym = VK_F6; break; | |
2858 | case WXK_F7: keySym = VK_F7; break; | |
2859 | case WXK_F8: keySym = VK_F8; break; | |
2860 | case WXK_F9: keySym = VK_F9; break; | |
2861 | case WXK_F10: keySym = VK_F10; break; | |
2862 | case WXK_F11: keySym = VK_F11; break; | |
2863 | case WXK_F12: keySym = VK_F12; break; | |
2864 | case WXK_F13: keySym = VK_F13; break; | |
2865 | case WXK_F14: keySym = VK_F14; break; | |
2866 | case WXK_F15: keySym = VK_F15; break; | |
2867 | case WXK_F16: keySym = VK_F16; break; | |
2868 | case WXK_F17: keySym = VK_F17; break; | |
2869 | case WXK_F18: keySym = VK_F18; break; | |
2870 | case WXK_F19: keySym = VK_F19; break; | |
2871 | case WXK_F20: keySym = VK_F20; break; | |
2872 | case WXK_F21: keySym = VK_F21; break; | |
2873 | case WXK_F22: keySym = VK_F22; break; | |
2874 | case WXK_F23: keySym = VK_F23; break; | |
2875 | case WXK_F24: keySym = VK_F24; break; | |
2876 | case WXK_NUMLOCK: keySym = VK_NUMLOCK; break; | |
2877 | case WXK_SCROLL: keySym = VK_SCROLL; break; | |
2bda0e17 KB |
2878 | default: |
2879 | { | |
2880 | *isVirtual = FALSE; | |
2881 | keySym = id; | |
2882 | break; | |
2883 | } | |
2884 | } | |
2885 | return keySym; | |
2886 | } | |
2887 | ||
2888 | // Caret manipulation | |
debe6624 | 2889 | void wxWindow::CreateCaret(int w, int h) |
2bda0e17 KB |
2890 | { |
2891 | m_caretWidth = w; | |
2892 | m_caretHeight = h; | |
2893 | m_caretEnabled = TRUE; | |
2894 | } | |
2895 | ||
2896 | void wxWindow::CreateCaret(const wxBitmap *WXUNUSED(bitmap)) | |
2897 | { | |
2898 | // Not implemented | |
2899 | } | |
2900 | ||
debe6624 | 2901 | void wxWindow::ShowCaret(bool show) |
2bda0e17 KB |
2902 | { |
2903 | if (m_caretEnabled) | |
2904 | { | |
2905 | if (show) | |
2906 | ::ShowCaret((HWND) GetHWND()); | |
2907 | else | |
2908 | ::HideCaret((HWND) GetHWND()); | |
2909 | m_caretShown = show; | |
2910 | } | |
2911 | } | |
2912 | ||
2913 | void wxWindow::DestroyCaret(void) | |
2914 | { | |
2915 | m_caretEnabled = FALSE; | |
2916 | } | |
2917 | ||
debe6624 | 2918 | void wxWindow::SetCaretPos(int x, int y) |
2bda0e17 KB |
2919 | { |
2920 | ::SetCaretPos(x, y); | |
2921 | } | |
2922 | ||
2923 | void wxWindow::GetCaretPos(int *x, int *y) const | |
2924 | { | |
2925 | POINT point; | |
2926 | ::GetCaretPos(&point); | |
2927 | *x = point.x; | |
2928 | *y = point.y; | |
2929 | } | |
2930 | ||
2bda0e17 KB |
2931 | wxWindow *wxGetActiveWindow(void) |
2932 | { | |
2933 | HWND hWnd = GetActiveWindow(); | |
2934 | if (hWnd != 0) | |
2935 | { | |
2936 | return wxFindWinFromHandle((WXHWND) hWnd); | |
2937 | } | |
2938 | return NULL; | |
2939 | } | |
2940 | ||
2941 | // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE | |
2942 | // in active frames and dialogs, regardless of where the focus is. | |
2943 | static HHOOK wxTheKeyboardHook = 0; | |
2944 | static FARPROC wxTheKeyboardHookProc = 0; | |
2945 | int APIENTRY _EXPORT | |
2946 | wxKeyboardHook(int nCode, WORD wParam, DWORD lParam); | |
2947 | ||
2948 | void wxSetKeyboardHook(bool doIt) | |
2949 | { | |
2950 | if (doIt) | |
2951 | { | |
2952 | wxTheKeyboardHookProc = MakeProcInstance((FARPROC) wxKeyboardHook, wxGetInstance()); | |
2953 | wxTheKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) wxTheKeyboardHookProc, wxGetInstance(), | |
2954 | #ifdef __WIN32__ | |
2955 | GetCurrentThreadId()); | |
2956 | // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right? | |
2957 | #else | |
2958 | GetCurrentTask()); | |
2959 | #endif | |
2960 | } | |
2961 | else | |
2962 | { | |
2963 | UnhookWindowsHookEx(wxTheKeyboardHook); | |
2964 | FreeProcInstance(wxTheKeyboardHookProc); | |
2965 | } | |
2966 | } | |
2967 | ||
2968 | int APIENTRY _EXPORT | |
2969 | wxKeyboardHook(int nCode, WORD wParam, DWORD lParam) | |
2970 | { | |
2971 | DWORD hiWord = HIWORD(lParam); | |
2972 | if (nCode != HC_NOREMOVE && ((hiWord & KF_UP) == 0)) | |
2973 | { | |
2974 | int id; | |
2975 | if ((id = wxCharCodeMSWToWX(wParam)) != 0) | |
2976 | { | |
2977 | wxKeyEvent event(wxEVT_CHAR_HOOK); | |
2978 | if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN) | |
2979 | event.m_altDown = TRUE; | |
2980 | ||
2981 | event.m_eventObject = NULL; | |
2982 | event.m_keyCode = id; | |
2983 | /* begin Albert's fix for control and shift key 26.5 */ | |
2984 | event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE); | |
2985 | event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE); | |
2986 | /* end Albert's fix for control and shift key 26.5 */ | |
2987 | event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ | |
2988 | ||
564b2609 VZ |
2989 | wxWindow *win = wxGetActiveWindow(); |
2990 | if (win) | |
2991 | { | |
2bda0e17 | 2992 | if (win->GetEventHandler()->ProcessEvent(event)) |
564b2609 VZ |
2993 | return 1; |
2994 | } | |
2995 | else | |
2996 | { | |
2997 | if ( wxTheApp && wxTheApp->ProcessEvent(event) ) | |
2998 | return 1; | |
2999 | } | |
2bda0e17 KB |
3000 | } |
3001 | } | |
3002 | return (int)CallNextHookEx(wxTheKeyboardHook, nCode, wParam, lParam); | |
3003 | } | |
3004 | ||
debe6624 | 3005 | void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int WXUNUSED(incW), int WXUNUSED(incH)) |
2bda0e17 KB |
3006 | { |
3007 | m_minSizeX = minW; | |
3008 | m_minSizeY = minH; | |
3009 | m_maxSizeX = maxW; | |
3010 | m_maxSizeY = maxH; | |
3011 | } | |
3012 | ||
debe6624 | 3013 | void wxWindow::Centre(int direction) |
2bda0e17 KB |
3014 | { |
3015 | int x, y, width, height, panel_width, panel_height, new_x, new_y; | |
3016 | ||
3017 | wxWindow *father = (wxWindow *)GetParent(); | |
3018 | if (!father) | |
3019 | return; | |
3020 | ||
3021 | father->GetClientSize(&panel_width, &panel_height); | |
3022 | GetSize(&width, &height); | |
3023 | GetPosition(&x, &y); | |
3024 | ||
3025 | new_x = -1; | |
3026 | new_y = -1; | |
3027 | ||
3028 | if (direction & wxHORIZONTAL) | |
3029 | new_x = (int)((panel_width - width)/2); | |
3030 | ||
3031 | if (direction & wxVERTICAL) | |
3032 | new_y = (int)((panel_height - height)/2); | |
3033 | ||
3034 | SetSize(new_x, new_y, -1, -1); | |
3035 | ||
3036 | } | |
3037 | ||
3038 | /* TODO (maybe) | |
3039 | void wxWindow::OnPaint(void) | |
3040 | { | |
3041 | PaintSelectionHandles(); | |
3042 | } | |
3043 | */ | |
3044 | ||
debe6624 | 3045 | void wxWindow::WarpPointer (int x_pos, int y_pos) |
2bda0e17 | 3046 | { |
5de76427 JS |
3047 | // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in |
3048 | // pixel coordinates, relatives to the canvas -- So, we first need to | |
3049 | // substract origin of the window, then convert to screen position | |
2bda0e17 | 3050 | |
5de76427 JS |
3051 | int x = x_pos; int y = y_pos; |
3052 | RECT rect; | |
3053 | GetWindowRect ((HWND) GetHWND(), &rect); | |
2bda0e17 | 3054 | |
5de76427 JS |
3055 | x += rect.left; |
3056 | y += rect.top; | |
2bda0e17 | 3057 | |
5de76427 | 3058 | SetCursorPos (x, y); |
2bda0e17 KB |
3059 | } |
3060 | ||
3061 | void wxWindow::MSWDeviceToLogical (float *x, float *y) const | |
3062 | { | |
2bda0e17 KB |
3063 | } |
3064 | ||
debe6624 | 3065 | bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC) |
2bda0e17 KB |
3066 | { |
3067 | wxDC dc ; | |
3068 | ||
564b2609 VZ |
3069 | dc.SetHDC(pDC); |
3070 | dc.SetWindow(this); | |
3071 | dc.BeginDrawing(); | |
2bda0e17 KB |
3072 | |
3073 | wxEraseEvent event(m_windowId, &dc); | |
3074 | event.m_eventObject = this; | |
3075 | if (!GetEventHandler()->ProcessEvent(event)) | |
3076 | { | |
564b2609 VZ |
3077 | dc.EndDrawing(); |
3078 | dc.SelectOldObjects(pDC); | |
2bda0e17 KB |
3079 | return FALSE; |
3080 | } | |
3081 | else | |
3082 | { | |
564b2609 VZ |
3083 | dc.EndDrawing(); |
3084 | dc.SelectOldObjects(pDC); | |
2bda0e17 KB |
3085 | } |
3086 | ||
3087 | dc.SetHDC((WXHDC) NULL); | |
3088 | return TRUE; | |
3089 | } | |
3090 | ||
3091 | void wxWindow::OnEraseBackground(wxEraseEvent& event) | |
3092 | { | |
3093 | RECT rect; | |
3094 | ::GetClientRect((HWND) GetHWND(), &rect); | |
3095 | ||
3096 | HBRUSH hBrush = ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue())); | |
3097 | int mode = ::SetMapMode((HDC) event.GetDC()->GetHDC(), MM_TEXT); | |
3098 | ||
3099 | // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect); | |
3100 | ::FillRect ((HDC) event.GetDC()->GetHDC(), &rect, hBrush); | |
3101 | ::DeleteObject(hBrush); | |
3102 | ::SetMapMode((HDC) event.GetDC()->GetHDC(), mode); | |
3103 | /* | |
3104 | // Less efficient version (and doesn't account for scrolling) | |
3105 | int w, h; | |
3106 | GetClientSize(& w, & h); | |
3107 | wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID); | |
3108 | event.GetDC()->SetBrush(brush); | |
3109 | event.GetDC()->SetPen(wxTRANSPARENT_PEN); | |
3110 | ||
3111 | event.GetDC()->DrawRectangle(0, 0, w+1, h+1); | |
3112 | */ | |
3113 | } | |
3114 | ||
3115 | #if WXWIN_COMPATIBILITY | |
debe6624 | 3116 | void wxWindow::SetScrollRange(int orient, int range, bool refresh) |
2bda0e17 KB |
3117 | { |
3118 | #if defined(__WIN95__) | |
3119 | ||
3120 | int range1 = range; | |
3121 | ||
3122 | // Try to adjust the range to cope with page size > 1 | |
3123 | // - a Windows API quirk | |
3124 | int pageSize = GetScrollPage(orient); | |
3125 | if ( pageSize > 1 && range > 0) | |
3126 | { | |
564b2609 | 3127 | range1 += (pageSize - 1); |
2bda0e17 KB |
3128 | } |
3129 | ||
3130 | SCROLLINFO info; | |
3131 | int dir; | |
3132 | ||
3133 | if (orient == wxHORIZONTAL) { | |
564b2609 | 3134 | dir = SB_HORZ; |
2bda0e17 | 3135 | } else { |
564b2609 | 3136 | dir = SB_VERT; |
2bda0e17 KB |
3137 | } |
3138 | ||
3139 | info.cbSize = sizeof(SCROLLINFO); | |
3140 | info.nPage = pageSize; // Have to set this, or scrollbar goes awry | |
3141 | info.nMin = 0; | |
3142 | info.nMax = range1; | |
3143 | info.nPos = 0; | |
3144 | info.fMask = SIF_RANGE | SIF_PAGE; | |
3145 | ||
3146 | HWND hWnd = (HWND) GetHWND(); | |
3147 | if (hWnd) | |
3148 | ::SetScrollInfo(hWnd, dir, &info, refresh); | |
3149 | #else | |
3150 | int wOrient ; | |
3151 | if (orient == wxHORIZONTAL) | |
3152 | wOrient = SB_HORZ; | |
3153 | else | |
3154 | wOrient = SB_VERT; | |
3155 | ||
3156 | HWND hWnd = (HWND) GetHWND(); | |
3157 | if (hWnd) | |
3158 | ::SetScrollRange(hWnd, wOrient, 0, range, refresh); | |
3159 | #endif | |
3160 | } | |
3161 | ||
debe6624 | 3162 | void wxWindow::SetScrollPage(int orient, int page, bool refresh) |
2bda0e17 KB |
3163 | { |
3164 | #if defined(__WIN95__) | |
3165 | SCROLLINFO info; | |
3166 | int dir; | |
3167 | ||
3168 | if (orient == wxHORIZONTAL) { | |
564b2609 | 3169 | dir = SB_HORZ; |
2bda0e17 KB |
3170 | m_xThumbSize = page; |
3171 | } else { | |
564b2609 | 3172 | dir = SB_VERT; |
2bda0e17 KB |
3173 | m_yThumbSize = page; |
3174 | } | |
3175 | ||
3176 | info.cbSize = sizeof(SCROLLINFO); | |
3177 | info.nPage = page; | |
3178 | info.nMin = 0; | |
3179 | info.fMask = SIF_PAGE ; | |
3180 | ||
3181 | HWND hWnd = (HWND) GetHWND(); | |
3182 | if (hWnd) | |
3183 | ::SetScrollInfo(hWnd, dir, &info, refresh); | |
3184 | #else | |
3185 | if (orient == wxHORIZONTAL) | |
3186 | m_xThumbSize = page; | |
3187 | else | |
3188 | m_yThumbSize = page; | |
3189 | #endif | |
3190 | } | |
3191 | ||
debe6624 | 3192 | int wxWindow::OldGetScrollRange(int orient) const |
2bda0e17 KB |
3193 | { |
3194 | int wOrient ; | |
3195 | if (orient == wxHORIZONTAL) | |
3196 | wOrient = SB_HORZ; | |
3197 | else | |
3198 | wOrient = SB_VERT; | |
3199 | ||
3200 | #if __WATCOMC__ && defined(__WINDOWS_386__) | |
3201 | short minPos, maxPos; | |
3202 | #else | |
3203 | int minPos, maxPos; | |
3204 | #endif | |
3205 | HWND hWnd = (HWND) GetHWND(); | |
3206 | if (hWnd) | |
3207 | { | |
3208 | ::GetScrollRange(hWnd, wOrient, &minPos, &maxPos); | |
3209 | #if defined(__WIN95__) | |
3210 | // Try to adjust the range to cope with page size > 1 | |
3211 | // - a Windows API quirk | |
3212 | int pageSize = GetScrollPage(orient); | |
3213 | if ( pageSize > 1 ) | |
3214 | { | |
564b2609 | 3215 | maxPos -= (pageSize - 1); |
2bda0e17 KB |
3216 | } |
3217 | #endif | |
3218 | return maxPos; | |
3219 | } | |
3220 | else | |
3221 | return 0; | |
3222 | } | |
3223 | ||
debe6624 | 3224 | int wxWindow::GetScrollPage(int orient) const |
2bda0e17 KB |
3225 | { |
3226 | if (orient == wxHORIZONTAL) | |
3227 | return m_xThumbSize; | |
3228 | else | |
3229 | return m_yThumbSize; | |
3230 | } | |
3231 | #endif | |
3232 | ||
debe6624 | 3233 | int wxWindow::GetScrollPos(int orient) const |
2bda0e17 KB |
3234 | { |
3235 | int wOrient ; | |
3236 | if (orient == wxHORIZONTAL) | |
3237 | wOrient = SB_HORZ; | |
3238 | else | |
3239 | wOrient = SB_VERT; | |
3240 | HWND hWnd = (HWND) GetHWND(); | |
3241 | if (hWnd) | |
3242 | { | |
3243 | return ::GetScrollPos(hWnd, wOrient); | |
3244 | } | |
3245 | else | |
3246 | return 0; | |
3247 | } | |
3248 | ||
3249 | // This now returns the whole range, not just the number | |
3250 | // of positions that we can scroll. | |
debe6624 | 3251 | int wxWindow::GetScrollRange(int orient) const |
2bda0e17 KB |
3252 | { |
3253 | int wOrient ; | |
3254 | if (orient == wxHORIZONTAL) | |
3255 | wOrient = SB_HORZ; | |
3256 | else | |
3257 | wOrient = SB_VERT; | |
3258 | ||
3259 | #if __WATCOMC__ && defined(__WINDOWS_386__) | |
3260 | short minPos, maxPos; | |
3261 | #else | |
3262 | int minPos, maxPos; | |
3263 | #endif | |
3264 | HWND hWnd = (HWND) GetHWND(); | |
3265 | if (hWnd) | |
3266 | { | |
3267 | ::GetScrollRange(hWnd, wOrient, &minPos, &maxPos); | |
3268 | #if defined(__WIN95__) | |
3269 | // Try to adjust the range to cope with page size > 1 | |
3270 | // - a Windows API quirk | |
3271 | int pageSize = GetScrollPage(orient); | |
3272 | if ( pageSize > 1 ) | |
3273 | { | |
564b2609 | 3274 | maxPos -= (pageSize - 1); |
2bda0e17 KB |
3275 | } |
3276 | // October 10th: new range concept. | |
3277 | maxPos += pageSize; | |
3278 | #endif | |
3279 | ||
3280 | return maxPos; | |
3281 | } | |
3282 | else | |
3283 | return 0; | |
3284 | } | |
3285 | ||
debe6624 | 3286 | int wxWindow::GetScrollThumb(int orient) const |
2bda0e17 KB |
3287 | { |
3288 | if (orient == wxHORIZONTAL) | |
3289 | return m_xThumbSize; | |
3290 | else | |
3291 | return m_yThumbSize; | |
3292 | } | |
3293 | ||
debe6624 | 3294 | void wxWindow::SetScrollPos(int orient, int pos, bool refresh) |
2bda0e17 KB |
3295 | { |
3296 | #if defined(__WIN95__) | |
3297 | SCROLLINFO info; | |
3298 | int dir; | |
3299 | ||
3300 | if (orient == wxHORIZONTAL) { | |
564b2609 | 3301 | dir = SB_HORZ; |
2bda0e17 | 3302 | } else { |
564b2609 | 3303 | dir = SB_VERT; |
2bda0e17 KB |
3304 | } |
3305 | ||
3306 | info.cbSize = sizeof(SCROLLINFO); | |
3307 | info.nPage = 0; | |
3308 | info.nMin = 0; | |
3309 | info.nPos = pos; | |
3310 | info.fMask = SIF_POS ; | |
3311 | ||
3312 | HWND hWnd = (HWND) GetHWND(); | |
3313 | if (hWnd) | |
3314 | ::SetScrollInfo(hWnd, dir, &info, refresh); | |
3315 | #else | |
3316 | int wOrient ; | |
3317 | if (orient == wxHORIZONTAL) | |
3318 | wOrient = SB_HORZ; | |
3319 | else | |
3320 | wOrient = SB_VERT; | |
3321 | ||
3322 | HWND hWnd = (HWND) GetHWND(); | |
3323 | if (hWnd) | |
3324 | ::SetScrollPos(hWnd, wOrient, pos, refresh); | |
3325 | #endif | |
3326 | } | |
3327 | ||
3328 | // New function that will replace some of the above. | |
debe6624 JS |
3329 | void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible, |
3330 | int range, bool refresh) | |
2bda0e17 KB |
3331 | { |
3332 | /* | |
3333 | SetScrollPage(orient, thumbVisible, FALSE); | |
3334 | ||
3335 | int oldRange = range - thumbVisible ; | |
3336 | SetScrollRange(orient, oldRange, FALSE); | |
3337 | ||
3338 | SetScrollPos(orient, pos, refresh); | |
3339 | */ | |
3340 | #if defined(__WIN95__) | |
3341 | int oldRange = range - thumbVisible ; | |
3342 | ||
3343 | int range1 = oldRange; | |
3344 | ||
3345 | // Try to adjust the range to cope with page size > 1 | |
3346 | // - a Windows API quirk | |
3347 | int pageSize = thumbVisible; | |
3348 | if ( pageSize > 1 && range > 0) | |
3349 | { | |
564b2609 | 3350 | range1 += (pageSize - 1); |
2bda0e17 KB |
3351 | } |
3352 | ||
3353 | SCROLLINFO info; | |
3354 | int dir; | |
3355 | ||
3356 | if (orient == wxHORIZONTAL) { | |
564b2609 | 3357 | dir = SB_HORZ; |
2bda0e17 | 3358 | } else { |
564b2609 | 3359 | dir = SB_VERT; |
2bda0e17 KB |
3360 | } |
3361 | ||
3362 | info.cbSize = sizeof(SCROLLINFO); | |
3363 | info.nPage = pageSize; // Have to set this, or scrollbar goes awry | |
3364 | info.nMin = 0; | |
3365 | info.nMax = range1; | |
3366 | info.nPos = pos; | |
3367 | info.fMask = SIF_RANGE | SIF_PAGE | SIF_POS; | |
3368 | ||
3369 | HWND hWnd = (HWND) GetHWND(); | |
3370 | if (hWnd) | |
3371 | ::SetScrollInfo(hWnd, dir, &info, refresh); | |
3372 | #else | |
3373 | int wOrient ; | |
3374 | if (orient == wxHORIZONTAL) | |
3375 | wOrient = SB_HORZ; | |
3376 | else | |
3377 | wOrient = SB_VERT; | |
3378 | ||
3379 | HWND hWnd = (HWND) GetHWND(); | |
3380 | if (hWnd) | |
3381 | { | |
3382 | ::SetScrollRange(hWnd, wOrient, 0, range, FALSE); | |
3383 | ::SetScrollPos(hWnd, wOrient, pos, refresh); | |
3384 | } | |
3385 | #endif | |
3386 | if (orient == wxHORIZONTAL) { | |
3387 | m_xThumbSize = thumbVisible; | |
3388 | } else { | |
3389 | m_yThumbSize = thumbVisible; | |
3390 | } | |
3391 | } | |
3392 | ||
debe6624 | 3393 | void wxWindow::ScrollWindow(int dx, int dy, const wxRectangle *rect) |
2bda0e17 | 3394 | { |
564b2609 VZ |
3395 | RECT rect2; |
3396 | if ( rect ) | |
3397 | { | |
3398 | rect2.left = rect->x; | |
3399 | rect2.top = rect->y; | |
3400 | rect2.right = rect->x + rect->width; | |
3401 | rect2.bottom = rect->y + rect->height; | |
3402 | } | |
2bda0e17 | 3403 | |
564b2609 VZ |
3404 | if ( rect ) |
3405 | ::ScrollWindow((HWND) GetHWND(), dx, dy, &rect2, NULL); | |
3406 | else | |
3407 | ::ScrollWindow((HWND) GetHWND(), dx, dy, NULL, NULL); | |
2bda0e17 KB |
3408 | } |
3409 | ||
2bda0e17 KB |
3410 | void wxWindow::SetFont(const wxFont& font) |
3411 | { | |
2bda0e17 KB |
3412 | m_windowFont = font; |
3413 | ||
3414 | if (!m_windowFont.Ok()) | |
564b2609 | 3415 | return; |
2bda0e17 | 3416 | |
2bda0e17 KB |
3417 | HWND hWnd = (HWND) GetHWND(); |
3418 | if (hWnd != 0) | |
3419 | { | |
2bda0e17 KB |
3420 | if (m_windowFont.GetResourceHandle()) |
3421 | SendMessage(hWnd, WM_SETFONT, | |
3422 | (WPARAM)m_windowFont.GetResourceHandle(),TRUE); | |
3423 | } | |
3424 | } | |
3425 | ||
3426 | void wxWindow::SubclassWin(WXHWND hWnd) | |
3427 | { | |
a02eb1d2 VZ |
3428 | wxASSERT_MSG( !m_oldWndProc, "subclassing window twice?" ); |
3429 | ||
2bda0e17 KB |
3430 | wxAssociateWinWithHandle((HWND)hWnd, this); |
3431 | ||
3432 | m_oldWndProc = (WXFARPROC) GetWindowLong((HWND) hWnd, GWL_WNDPROC); | |
3433 | SetWindowLong((HWND) hWnd, GWL_WNDPROC, (LONG) wxWndProc); | |
3434 | } | |
3435 | ||
3436 | void wxWindow::UnsubclassWin(void) | |
3437 | { | |
564b2609 | 3438 | wxRemoveHandleAssociation(this); |
2bda0e17 KB |
3439 | |
3440 | // Restore old Window proc | |
3441 | if ((HWND) GetHWND()) | |
3442 | { | |
3443 | FARPROC farProc = (FARPROC) GetWindowLong((HWND) GetHWND(), GWL_WNDPROC); | |
3444 | if ((m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc)) | |
564b2609 | 3445 | { |
2bda0e17 | 3446 | SetWindowLong((HWND) GetHWND(), GWL_WNDPROC, (LONG) m_oldWndProc); |
564b2609 VZ |
3447 | m_oldWndProc = 0; |
3448 | } | |
2bda0e17 KB |
3449 | } |
3450 | } | |
3451 | ||
3452 | // Make a Windows extended style from the given wxWindows window style | |
3453 | WXDWORD wxWindow::MakeExtendedStyle(long style, bool eliminateBorders) | |
3454 | { | |
564b2609 VZ |
3455 | WXDWORD exStyle = 0; |
3456 | if ( style & wxTRANSPARENT_WINDOW ) | |
3457 | exStyle |= WS_EX_TRANSPARENT ; | |
2bda0e17 KB |
3458 | |
3459 | if ( !eliminateBorders ) | |
3460 | { | |
564b2609 VZ |
3461 | if ( style & wxSUNKEN_BORDER ) |
3462 | exStyle |= WS_EX_CLIENTEDGE ; | |
3463 | if ( style & wxDOUBLE_BORDER ) | |
3464 | exStyle |= WS_EX_DLGMODALFRAME ; | |
2bda0e17 | 3465 | #if defined(__WIN95__) |
564b2609 VZ |
3466 | if ( style & wxRAISED_BORDER ) |
3467 | exStyle |= WS_EX_WINDOWEDGE ; | |
3468 | if ( style & wxSTATIC_BORDER ) | |
3469 | exStyle |= WS_EX_STATICEDGE ; | |
2bda0e17 KB |
3470 | #endif |
3471 | } | |
3472 | return exStyle; | |
3473 | } | |
3474 | ||
3475 | // Determines whether native 3D effects or CTL3D should be used, | |
3476 | // applying a default border style if required, and returning an extended | |
3477 | // style to pass to CreateWindowEx. | |
3478 | WXDWORD wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) | |
3479 | { | |
3480 | // If matches certain criteria, then assume no 3D effects | |
3481 | // unless specifically requested (dealt with in MakeExtendedStyle) | |
3482 | if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl)) || (m_windowStyle & wxNO_BORDER) ) | |
3483 | { | |
564b2609 VZ |
3484 | *want3D = FALSE; |
3485 | return MakeExtendedStyle(m_windowStyle, FALSE); | |
2bda0e17 KB |
3486 | } |
3487 | ||
3488 | // Determine whether we should be using 3D effects or not. | |
3489 | bool nativeBorder = FALSE; // by default, we don't want a Win95 effect | |
3490 | ||
3491 | // 1) App can specify global 3D effects | |
3492 | *want3D = wxTheApp->GetAuto3D(); | |
3493 | ||
3494 | // 2) If the parent is being drawn with user colours, or simple border specified, | |
3495 | // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D | |
3496 | if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) || (m_windowStyle & wxSIMPLE_BORDER)) | |
564b2609 | 3497 | *want3D = FALSE; |
2bda0e17 KB |
3498 | |
3499 | // 3) Control can override this global setting by defining | |
3500 | // a border style, e.g. wxSUNKEN_BORDER | |
3501 | if (m_windowStyle & wxSUNKEN_BORDER ) | |
564b2609 | 3502 | *want3D = TRUE; |
2bda0e17 KB |
3503 | |
3504 | // 4) If it's a special border, CTL3D can't cope so we want a native border | |
3505 | if ( (m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || | |
3506 | (m_windowStyle & wxSTATIC_BORDER) ) | |
3507 | { | |
564b2609 VZ |
3508 | *want3D = TRUE; |
3509 | nativeBorder = TRUE; | |
2bda0e17 KB |
3510 | } |
3511 | ||
3512 | // 5) If this isn't a Win95 app, and we are using CTL3D, remove border | |
3513 | // effects from extended style | |
3514 | #if CTL3D | |
3515 | if ( *want3D ) | |
564b2609 | 3516 | nativeBorder = FALSE; |
2bda0e17 KB |
3517 | #endif |
3518 | ||
3519 | DWORD exStyle = MakeExtendedStyle(m_windowStyle, !nativeBorder); | |
3520 | ||
3521 | // If we want 3D, but haven't specified a border here, | |
3522 | // apply the default border style specified. | |
3523 | // TODO what about non-Win95 WIN32? Does it have borders? | |
3524 | #if defined(__WIN95__) && !CTL3D | |
3525 | if (defaultBorderStyle && (*want3D) && ! ((m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || | |
3526 | (m_windowStyle & wxSTATIC_BORDER) || (m_windowStyle & wxSIMPLE_BORDER) )) | |
564b2609 | 3527 | exStyle |= defaultBorderStyle; // WS_EX_CLIENTEDGE ; |
2bda0e17 KB |
3528 | #endif |
3529 | ||
3530 | return exStyle; | |
3531 | } | |
3532 | ||
2bda0e17 KB |
3533 | void wxWindow::OnChar(wxKeyEvent& event) |
3534 | { | |
47cbd6da VZ |
3535 | if ( event.KeyCode() == WXK_TAB ) { |
3536 | // propagate the TABs to the parent - it's up to it to decide what | |
3537 | // to do with it | |
3538 | if ( GetParent() ) { | |
3539 | if ( GetParent()->ProcessEvent(event) ) | |
3540 | return; | |
3541 | } | |
3542 | } | |
3543 | ||
3544 | bool isVirtual; | |
3545 | int id = wxCharCodeWXToMSW((int)event.KeyCode(), &isVirtual); | |
2bda0e17 | 3546 | |
47cbd6da VZ |
3547 | if ( id == -1 ) |
3548 | id= m_lastWParam; | |
2bda0e17 KB |
3549 | |
3550 | if ( !event.ControlDown() ) | |
47cbd6da | 3551 | (void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam); |
2bda0e17 KB |
3552 | } |
3553 | ||
3554 | void wxWindow::OnPaint(wxPaintEvent& event) | |
3555 | { | |
564b2609 | 3556 | Default(); |
2bda0e17 KB |
3557 | } |
3558 | ||
3559 | bool wxWindow::IsEnabled(void) const | |
3560 | { | |
564b2609 | 3561 | return (::IsWindowEnabled((HWND) GetHWND()) != 0); |
2bda0e17 KB |
3562 | } |
3563 | ||
3564 | // Dialog support: override these and call | |
3565 | // base class members to add functionality | |
3566 | // that can't be done using validators. | |
3567 | // NOTE: these functions assume that controls | |
3568 | // are direct children of this window, not grandchildren | |
3569 | // or other levels of descendant. | |
3570 | ||
3571 | // Transfer values to controls. If returns FALSE, | |
3572 | // it's an application error (pops up a dialog) | |
3573 | bool wxWindow::TransferDataToWindow(void) | |
3574 | { | |
564b2609 VZ |
3575 | wxNode *node = GetChildren()->First(); |
3576 | while ( node ) | |
3577 | { | |
3578 | wxWindow *child = (wxWindow *)node->Data(); | |
3579 | if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ | |
3580 | !child->GetValidator()->TransferToWindow() ) | |
3581 | { | |
3582 | wxMessageBox("Application Error", "Could not transfer data to window", wxOK|wxICON_EXCLAMATION); | |
3583 | return FALSE; | |
3584 | } | |
2bda0e17 | 3585 | |
564b2609 VZ |
3586 | node = node->Next(); |
3587 | } | |
3588 | return TRUE; | |
2bda0e17 KB |
3589 | } |
3590 | ||
3591 | // Transfer values from controls. If returns FALSE, | |
3592 | // validation failed: don't quit | |
3593 | bool wxWindow::TransferDataFromWindow(void) | |
3594 | { | |
564b2609 VZ |
3595 | wxNode *node = GetChildren()->First(); |
3596 | while ( node ) | |
3597 | { | |
3598 | wxWindow *child = (wxWindow *)node->Data(); | |
3599 | if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->TransferFromWindow() ) | |
3600 | { | |
3601 | return FALSE; | |
3602 | } | |
2bda0e17 | 3603 | |
564b2609 VZ |
3604 | node = node->Next(); |
3605 | } | |
3606 | return TRUE; | |
2bda0e17 KB |
3607 | } |
3608 | ||
3609 | bool wxWindow::Validate(void) | |
3610 | { | |
564b2609 VZ |
3611 | wxNode *node = GetChildren()->First(); |
3612 | while ( node ) | |
3613 | { | |
3614 | wxWindow *child = (wxWindow *)node->Data(); | |
3615 | if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->Validate(this) ) | |
3616 | { | |
3617 | return FALSE; | |
3618 | } | |
2bda0e17 | 3619 | |
564b2609 VZ |
3620 | node = node->Next(); |
3621 | } | |
3622 | return TRUE; | |
2bda0e17 KB |
3623 | } |
3624 | ||
3625 | // Get the window with the focus | |
3626 | wxWindow *wxWindow::FindFocus(void) | |
3627 | { | |
3628 | HWND hWnd = ::GetFocus(); | |
3629 | if ( hWnd ) | |
3630 | { | |
3631 | return wxFindWinFromHandle((WXHWND) hWnd); | |
3632 | } | |
3633 | return NULL; | |
3634 | } | |
3635 | ||
3636 | void wxWindow::AddChild(wxWindow *child) | |
3637 | { | |
3638 | GetChildren()->Append(child); | |
3639 | child->m_windowParent = this; | |
3640 | } | |
3641 | ||
3642 | void wxWindow::RemoveChild(wxWindow *child) | |
3643 | { | |
3644 | if (GetChildren()) | |
3645 | GetChildren()->DeleteObject(child); | |
3646 | child->m_windowParent = NULL; | |
3647 | } | |
3648 | ||
3649 | void wxWindow::DestroyChildren(void) | |
3650 | { | |
3651 | if (GetChildren()) { | |
3652 | wxNode *node; | |
3653 | while ((node = GetChildren()->First()) != (wxNode *)NULL) { | |
3654 | wxWindow *child; | |
3655 | if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) { | |
3656 | delete child; | |
564b2609 VZ |
3657 | if ( GetChildren()->Member(child) ) |
3658 | delete node; | |
2bda0e17 KB |
3659 | } |
3660 | } /* while */ | |
3661 | } | |
3662 | } | |
3663 | ||
debe6624 | 3664 | void wxWindow::MakeModal(bool modal) |
2bda0e17 KB |
3665 | { |
3666 | // Disable all other windows | |
3667 | if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame))) | |
3668 | { | |
3669 | wxNode *node = wxTopLevelWindows.First(); | |
3670 | while (node) | |
3671 | { | |
3672 | wxWindow *win = (wxWindow *)node->Data(); | |
3673 | if (win != this) | |
3674 | win->Enable(!modal); | |
3675 | ||
3676 | node = node->Next(); | |
3677 | } | |
3678 | } | |
3679 | } | |
3680 | ||
3681 | // If nothing defined for this, try the parent. | |
3682 | // E.g. we may be a button loaded from a resource, with no callback function | |
3683 | // defined. | |
3684 | void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event) | |
3685 | { | |
3686 | if (GetEventHandler()->ProcessEvent(event) ) | |
564b2609 | 3687 | return; |
2bda0e17 KB |
3688 | if (m_windowParent) |
3689 | m_windowParent->GetEventHandler()->OnCommand(win, event); | |
3690 | } | |
3691 | ||
3692 | void wxWindow::SetConstraints(wxLayoutConstraints *c) | |
3693 | { | |
3694 | if (m_constraints) | |
3695 | { | |
3696 | UnsetConstraints(m_constraints); | |
3697 | delete m_constraints; | |
3698 | } | |
3699 | m_constraints = c; | |
3700 | if (m_constraints) | |
3701 | { | |
3702 | // Make sure other windows know they're part of a 'meaningful relationship' | |
3703 | if (m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this)) | |
3704 | m_constraints->left.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3705 | if (m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this)) | |
3706 | m_constraints->top.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3707 | if (m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this)) | |
3708 | m_constraints->right.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3709 | if (m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this)) | |
3710 | m_constraints->bottom.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3711 | if (m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this)) | |
3712 | m_constraints->width.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3713 | if (m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this)) | |
3714 | m_constraints->height.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3715 | if (m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this)) | |
3716 | m_constraints->centreX.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3717 | if (m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this)) | |
3718 | m_constraints->centreY.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3719 | } | |
3720 | } | |
3721 | ||
3722 | // This removes any dangling pointers to this window | |
3723 | // in other windows' constraintsInvolvedIn lists. | |
3724 | void wxWindow::UnsetConstraints(wxLayoutConstraints *c) | |
3725 | { | |
3726 | if (c) | |
3727 | { | |
3728 | if (c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this)) | |
3729 | c->left.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3730 | if (c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this)) | |
3731 | c->top.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3732 | if (c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this)) | |
3733 | c->right.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3734 | if (c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this)) | |
3735 | c->bottom.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3736 | if (c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this)) | |
3737 | c->width.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3738 | if (c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this)) | |
3739 | c->height.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3740 | if (c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this)) | |
3741 | c->centreX.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3742 | if (c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this)) | |
3743 | c->centreY.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3744 | } | |
3745 | } | |
3746 | ||
3747 | // Back-pointer to other windows we're involved with, so if we delete | |
3748 | // this window, we must delete any constraints we're involved with. | |
3749 | void wxWindow::AddConstraintReference(wxWindow *otherWin) | |
3750 | { | |
3751 | if (!m_constraintsInvolvedIn) | |
3752 | m_constraintsInvolvedIn = new wxList; | |
3753 | if (!m_constraintsInvolvedIn->Member(otherWin)) | |
3754 | m_constraintsInvolvedIn->Append(otherWin); | |
3755 | } | |
3756 | ||
3757 | // REMOVE back-pointer to other windows we're involved with. | |
3758 | void wxWindow::RemoveConstraintReference(wxWindow *otherWin) | |
3759 | { | |
3760 | if (m_constraintsInvolvedIn) | |
3761 | m_constraintsInvolvedIn->DeleteObject(otherWin); | |
3762 | } | |
3763 | ||
3764 | // Reset any constraints that mention this window | |
3765 | void wxWindow::DeleteRelatedConstraints(void) | |
3766 | { | |
3767 | if (m_constraintsInvolvedIn) | |
3768 | { | |
3769 | wxNode *node = m_constraintsInvolvedIn->First(); | |
3770 | while (node) | |
3771 | { | |
3772 | wxWindow *win = (wxWindow *)node->Data(); | |
3773 | wxNode *next = node->Next(); | |
3774 | wxLayoutConstraints *constr = win->GetConstraints(); | |
3775 | ||
3776 | // Reset any constraints involving this window | |
3777 | if (constr) | |
3778 | { | |
3779 | constr->left.ResetIfWin((wxWindow *)this); | |
3780 | constr->top.ResetIfWin((wxWindow *)this); | |
3781 | constr->right.ResetIfWin((wxWindow *)this); | |
3782 | constr->bottom.ResetIfWin((wxWindow *)this); | |
3783 | constr->width.ResetIfWin((wxWindow *)this); | |
3784 | constr->height.ResetIfWin((wxWindow *)this); | |
3785 | constr->centreX.ResetIfWin((wxWindow *)this); | |
3786 | constr->centreY.ResetIfWin((wxWindow *)this); | |
3787 | } | |
3788 | delete node; | |
3789 | node = next; | |
3790 | } | |
3791 | delete m_constraintsInvolvedIn; | |
3792 | m_constraintsInvolvedIn = NULL; | |
3793 | } | |
3794 | } | |
3795 | ||
3796 | void wxWindow::SetSizer(wxSizer *sizer) | |
3797 | { | |
3798 | m_windowSizer = sizer; | |
3799 | if (sizer) | |
3800 | sizer->SetSizerParent((wxWindow *)this); | |
3801 | } | |
3802 | ||
3803 | /* | |
3804 | * New version | |
3805 | */ | |
3806 | ||
3807 | bool wxWindow::Layout(void) | |
3808 | { | |
3809 | if (GetConstraints()) | |
3810 | { | |
3811 | int w, h; | |
3812 | GetClientSize(&w, &h); | |
3813 | GetConstraints()->width.SetValue(w); | |
3814 | GetConstraints()->height.SetValue(h); | |
3815 | } | |
3816 | ||
3817 | // If top level (one sizer), evaluate the sizer's constraints. | |
3818 | if (GetSizer()) | |
3819 | { | |
3820 | int noChanges; | |
3821 | GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated | |
3822 | GetSizer()->LayoutPhase1(&noChanges); | |
3823 | GetSizer()->LayoutPhase2(&noChanges); | |
3824 | GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes | |
3825 | return TRUE; | |
3826 | } | |
3827 | else | |
3828 | { | |
3829 | // Otherwise, evaluate child constraints | |
3830 | ResetConstraints(); // Mark all constraints as unevaluated | |
3831 | DoPhase(1); // Just one phase need if no sizers involved | |
3832 | DoPhase(2); | |
3833 | SetConstraintSizes(); // Recursively set the real window sizes | |
3834 | } | |
3835 | return TRUE; | |
3836 | } | |
3837 | ||
3838 | ||
3839 | // Do a phase of evaluating constraints: | |
3840 | // the default behaviour. wxSizers may do a similar | |
3841 | // thing, but also impose their own 'constraints' | |
3842 | // and order the evaluation differently. | |
3843 | bool wxWindow::LayoutPhase1(int *noChanges) | |
3844 | { | |
3845 | wxLayoutConstraints *constr = GetConstraints(); | |
3846 | if (constr) | |
3847 | { | |
3848 | return constr->SatisfyConstraints((wxWindow *)this, noChanges); | |
3849 | } | |
3850 | else | |
3851 | return TRUE; | |
3852 | } | |
3853 | ||
3854 | bool wxWindow::LayoutPhase2(int *noChanges) | |
3855 | { | |
3856 | *noChanges = 0; | |
3857 | ||
3858 | // Layout children | |
3859 | DoPhase(1); | |
3860 | DoPhase(2); | |
3861 | return TRUE; | |
3862 | } | |
3863 | ||
3864 | // Do a phase of evaluating child constraints | |
debe6624 | 3865 | bool wxWindow::DoPhase(int phase) |
2bda0e17 KB |
3866 | { |
3867 | int noIterations = 0; | |
3868 | int maxIterations = 500; | |
3869 | int noChanges = 1; | |
3870 | int noFailures = 0; | |
3871 | wxList succeeded; | |
3872 | while ((noChanges > 0) && (noIterations < maxIterations)) | |
3873 | { | |
3874 | noChanges = 0; | |
3875 | noFailures = 0; | |
3876 | wxNode *node = GetChildren()->First(); | |
3877 | while (node) | |
3878 | { | |
3879 | wxWindow *child = (wxWindow *)node->Data(); | |
3880 | if (!child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog))) | |
3881 | { | |
3882 | wxLayoutConstraints *constr = child->GetConstraints(); | |
3883 | if (constr) | |
3884 | { | |
3885 | if (succeeded.Member(child)) | |
3886 | { | |
3887 | } | |
3888 | else | |
3889 | { | |
3890 | int tempNoChanges = 0; | |
3891 | bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ; | |
3892 | noChanges += tempNoChanges; | |
3893 | if (success) | |
3894 | { | |
3895 | succeeded.Append(child); | |
3896 | } | |
3897 | } | |
3898 | } | |
3899 | } | |
3900 | node = node->Next(); | |
3901 | } | |
3902 | noIterations ++; | |
3903 | } | |
3904 | return TRUE; | |
3905 | } | |
3906 | ||
3907 | void wxWindow::ResetConstraints(void) | |
3908 | { | |
3909 | wxLayoutConstraints *constr = GetConstraints(); | |
3910 | if (constr) | |
3911 | { | |
3912 | constr->left.SetDone(FALSE); | |
3913 | constr->top.SetDone(FALSE); | |
3914 | constr->right.SetDone(FALSE); | |
3915 | constr->bottom.SetDone(FALSE); | |
3916 | constr->width.SetDone(FALSE); | |
3917 | constr->height.SetDone(FALSE); | |
3918 | constr->centreX.SetDone(FALSE); | |
3919 | constr->centreY.SetDone(FALSE); | |
3920 | } | |
3921 | wxNode *node = GetChildren()->First(); | |
3922 | while (node) | |
3923 | { | |
3924 | wxWindow *win = (wxWindow *)node->Data(); | |
3925 | if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))) | |
3926 | win->ResetConstraints(); | |
3927 | node = node->Next(); | |
3928 | } | |
3929 | } | |
3930 | ||
3931 | // Need to distinguish between setting the 'fake' size for | |
3932 | // windows and sizers, and setting the real values. | |
debe6624 | 3933 | void wxWindow::SetConstraintSizes(bool recurse) |
2bda0e17 KB |
3934 | { |
3935 | wxLayoutConstraints *constr = GetConstraints(); | |
3936 | if (constr && constr->left.GetDone() && constr->right.GetDone() && | |
3937 | constr->width.GetDone() && constr->height.GetDone()) | |
3938 | { | |
3939 | int x = constr->left.GetValue(); | |
3940 | int y = constr->top.GetValue(); | |
3941 | int w = constr->width.GetValue(); | |
3942 | int h = constr->height.GetValue(); | |
3943 | ||
3944 | // If we don't want to resize this window, just move it... | |
3945 | if ((constr->width.GetRelationship() != wxAsIs) || | |
3946 | (constr->height.GetRelationship() != wxAsIs)) | |
3947 | { | |
3948 | // Calls Layout() recursively. AAAGH. How can we stop that. | |
3949 | // Simply take Layout() out of non-top level OnSizes. | |
3950 | SizerSetSize(x, y, w, h); | |
3951 | } | |
3952 | else | |
3953 | { | |
3954 | SizerMove(x, y); | |
3955 | } | |
3956 | } | |
3957 | else if (constr) | |
3958 | { | |
3959 | char *windowClass = this->GetClassInfo()->GetClassName(); | |
3960 | ||
3961 | wxString winName; | |
564b2609 VZ |
3962 | if (GetName() == "") |
3963 | winName = "unnamed"; | |
3964 | else | |
3965 | winName = GetName(); | |
2bda0e17 KB |
3966 | wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass, (const char *)winName); |
3967 | if (!constr->left.GetDone()) | |
3968 | wxDebugMsg(" unsatisfied 'left' constraint.\n"); | |
3969 | if (!constr->right.GetDone()) | |
3970 | wxDebugMsg(" unsatisfied 'right' constraint.\n"); | |
3971 | if (!constr->width.GetDone()) | |
3972 | wxDebugMsg(" unsatisfied 'width' constraint.\n"); | |
3973 | if (!constr->height.GetDone()) | |
3974 | wxDebugMsg(" unsatisfied 'height' constraint.\n"); | |
3975 | wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n"); | |
3976 | } | |
3977 | ||
3978 | if (recurse) | |
3979 | { | |
3980 | wxNode *node = GetChildren()->First(); | |
3981 | while (node) | |
3982 | { | |
3983 | wxWindow *win = (wxWindow *)node->Data(); | |
3984 | if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))) | |
3985 | win->SetConstraintSizes(); | |
3986 | node = node->Next(); | |
3987 | } | |
3988 | } | |
3989 | } | |
3990 | ||
3991 | // This assumes that all sizers are 'on' the same | |
3992 | // window, i.e. the parent of this window. | |
3993 | void wxWindow::TransformSizerToActual(int *x, int *y) const | |
3994 | { | |
3995 | if (!m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog)) || | |
564b2609 | 3996 | m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) ) |
2bda0e17 KB |
3997 | return; |
3998 | ||
3999 | int xp, yp; | |
4000 | m_sizerParent->GetPosition(&xp, &yp); | |
4001 | m_sizerParent->TransformSizerToActual(&xp, &yp); | |
4002 | *x += xp; | |
4003 | *y += yp; | |
4004 | } | |
4005 | ||
debe6624 | 4006 | void wxWindow::SizerSetSize(int x, int y, int w, int h) |
2bda0e17 | 4007 | { |
564b2609 VZ |
4008 | int xx = x; |
4009 | int yy = y; | |
2bda0e17 KB |
4010 | TransformSizerToActual(&xx, &yy); |
4011 | SetSize(xx, yy, w, h); | |
4012 | } | |
4013 | ||
debe6624 | 4014 | void wxWindow::SizerMove(int x, int y) |
2bda0e17 | 4015 | { |
564b2609 VZ |
4016 | int xx = x; |
4017 | int yy = y; | |
2bda0e17 KB |
4018 | TransformSizerToActual(&xx, &yy); |
4019 | Move(xx, yy); | |
4020 | } | |
4021 | ||
4022 | // Only set the size/position of the constraint (if any) | |
debe6624 | 4023 | void wxWindow::SetSizeConstraint(int x, int y, int w, int h) |
2bda0e17 KB |
4024 | { |
4025 | wxLayoutConstraints *constr = GetConstraints(); | |
4026 | if (constr) | |
4027 | { | |
4028 | if (x != -1) | |
4029 | { | |
4030 | constr->left.SetValue(x); | |
4031 | constr->left.SetDone(TRUE); | |
4032 | } | |
4033 | if (y != -1) | |
4034 | { | |
4035 | constr->top.SetValue(y); | |
4036 | constr->top.SetDone(TRUE); | |
4037 | } | |
4038 | if (w != -1) | |
4039 | { | |
4040 | constr->width.SetValue(w); | |
4041 | constr->width.SetDone(TRUE); | |
4042 | } | |
4043 | if (h != -1) | |
4044 | { | |
4045 | constr->height.SetValue(h); | |
4046 | constr->height.SetDone(TRUE); | |
4047 | } | |
4048 | } | |
4049 | } | |
4050 | ||
debe6624 | 4051 | void wxWindow::MoveConstraint(int x, int y) |
2bda0e17 KB |
4052 | { |
4053 | wxLayoutConstraints *constr = GetConstraints(); | |
4054 | if (constr) | |
4055 | { | |
4056 | if (x != -1) | |
4057 | { | |
4058 | constr->left.SetValue(x); | |
4059 | constr->left.SetDone(TRUE); | |
4060 | } | |
4061 | if (y != -1) | |
4062 | { | |
4063 | constr->top.SetValue(y); | |
4064 | constr->top.SetDone(TRUE); | |
4065 | } | |
4066 | } | |
4067 | } | |
4068 | ||
4069 | void wxWindow::GetSizeConstraint(int *w, int *h) const | |
4070 | { | |
4071 | wxLayoutConstraints *constr = GetConstraints(); | |
4072 | if (constr) | |
4073 | { | |
4074 | *w = constr->width.GetValue(); | |
4075 | *h = constr->height.GetValue(); | |
4076 | } | |
4077 | else | |
4078 | GetSize(w, h); | |
4079 | } | |
4080 | ||
4081 | void wxWindow::GetClientSizeConstraint(int *w, int *h) const | |
4082 | { | |
4083 | wxLayoutConstraints *constr = GetConstraints(); | |
4084 | if (constr) | |
4085 | { | |
4086 | *w = constr->width.GetValue(); | |
4087 | *h = constr->height.GetValue(); | |
4088 | } | |
4089 | else | |
4090 | GetClientSize(w, h); | |
4091 | } | |
4092 | ||
4093 | void wxWindow::GetPositionConstraint(int *x, int *y) const | |
4094 | { | |
4095 | wxLayoutConstraints *constr = GetConstraints(); | |
4096 | if (constr) | |
4097 | { | |
4098 | *x = constr->left.GetValue(); | |
4099 | *y = constr->top.GetValue(); | |
4100 | } | |
4101 | else | |
4102 | GetPosition(x, y); | |
4103 | } | |
4104 | ||
debe6624 | 4105 | bool wxWindow::Close(bool force) |
2bda0e17 KB |
4106 | { |
4107 | // Let's generalise it to work the same for any window. | |
4108 | /* | |
4109 | if (!IsKindOf(CLASSINFO(wxDialog)) && !IsKindOf(CLASSINFO(wxFrame))) | |
4110 | { | |
4111 | this->Destroy(); | |
4112 | return TRUE; | |
4113 | } | |
4114 | */ | |
4115 | ||
4116 | wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); | |
4117 | event.SetEventObject(this); | |
4118 | event.SetForce(force); | |
4119 | ||
4120 | return GetEventHandler()->ProcessEvent(event); | |
4121 | ||
4122 | /* | |
4123 | if ( !force && event.GetVeto() ) | |
4124 | return FALSE; | |
4125 | ||
4126 | Show(FALSE); | |
4127 | ||
4128 | if (!wxPendingDelete.Member(this)) | |
4129 | wxPendingDelete.Append(this); | |
4130 | ||
4131 | return TRUE; | |
4132 | */ | |
4133 | } | |
4134 | ||
debe6624 | 4135 | wxObject* wxWindow::GetChild(int number) const |
2bda0e17 KB |
4136 | { |
4137 | // Return a pointer to the Nth object in the Panel | |
4138 | if (!GetChildren()) | |
4139 | return(NULL) ; | |
4140 | wxNode *node = GetChildren()->First(); | |
4141 | int n = number; | |
4142 | while (node && n--) | |
4143 | node = node->Next() ; | |
4144 | if (node) | |
4145 | { | |
4146 | wxObject *obj = (wxObject *)node->Data(); | |
4147 | return(obj) ; | |
4148 | } | |
4149 | else | |
4150 | return NULL ; | |
4151 | } | |
4152 | ||
4153 | void wxWindow::OnDefaultAction(wxControl *initiatingItem) | |
4154 | { | |
debe6624 JS |
4155 | /* This is obsolete now; if we wish to intercept listbox double-clicks, |
4156 | * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED | |
4157 | * event. | |
4158 | ||
4159 | if (initiatingItem->IsKindOf(CLASSINFO(wxListBox))) | |
2bda0e17 KB |
4160 | { |
4161 | wxListBox *lbox = (wxListBox *)initiatingItem; | |
7798a18e | 4162 | wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK); |
2bda0e17 KB |
4163 | event.m_commandInt = -1; |
4164 | if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0) | |
4165 | { | |
4166 | event.m_commandString = copystring(lbox->GetStringSelection()); | |
4167 | event.m_commandInt = lbox->GetSelection(); | |
4168 | event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt); | |
4169 | } | |
4170 | event.m_eventObject = lbox; | |
4171 | ||
4172 | lbox->ProcessCommand(event); | |
4173 | ||
4174 | if (event.m_commandString) | |
4175 | delete[] event.m_commandString; | |
4176 | return; | |
4177 | } | |
4178 | ||
4179 | wxButton *but = GetDefaultItem(); | |
4180 | if (but) | |
4181 | { | |
7798a18e | 4182 | wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED); |
debe6624 | 4183 | event.SetEventObject(but); |
2bda0e17 KB |
4184 | but->Command(event); |
4185 | } | |
debe6624 | 4186 | */ |
2bda0e17 KB |
4187 | } |
4188 | ||
4189 | void wxWindow::Clear(void) | |
4190 | { | |
564b2609 | 4191 | wxClientDC dc(this); |
2bda0e17 KB |
4192 | wxBrush brush(GetBackgroundColour(), wxSOLID); |
4193 | dc.SetBackground(brush); | |
4194 | dc.Clear(); | |
4195 | } | |
4196 | ||
4197 | // Fits the panel around the items | |
4198 | void wxWindow::Fit(void) | |
4199 | { | |
564b2609 VZ |
4200 | int maxX = 0; |
4201 | int maxY = 0; | |
4202 | wxNode *node = GetChildren()->First(); | |
4203 | while ( node ) | |
4204 | { | |
4205 | wxWindow *win = (wxWindow *)node->Data(); | |
4206 | int wx, wy, ww, wh; | |
4207 | win->GetPosition(&wx, &wy); | |
4208 | win->GetSize(&ww, &wh); | |
4209 | if ( wx + ww > maxX ) | |
4210 | maxX = wx + ww; | |
4211 | if ( wy + wh > maxY ) | |
4212 | maxY = wy + wh; | |
4213 | ||
4214 | node = node->Next(); | |
4215 | } | |
4216 | SetClientSize(maxX + 5, maxY + 5); | |
2bda0e17 KB |
4217 | } |
4218 | ||
4219 | void wxWindow::SetValidator(const wxValidator& validator) | |
4220 | { | |
564b2609 VZ |
4221 | if ( m_windowValidator ) |
4222 | delete m_windowValidator; | |
4223 | m_windowValidator = validator.Clone(); | |
2bda0e17 | 4224 | |
564b2609 VZ |
4225 | if ( m_windowValidator ) |
4226 | m_windowValidator->SetWindow(this) ; | |
2bda0e17 KB |
4227 | } |
4228 | ||
4229 | // Find a window by id or name | |
debe6624 | 4230 | wxWindow *wxWindow::FindWindow(long id) |
2bda0e17 | 4231 | { |
564b2609 VZ |
4232 | if ( GetId() == id) |
4233 | return this; | |
2bda0e17 | 4234 | |
564b2609 VZ |
4235 | wxNode *node = GetChildren()->First(); |
4236 | while ( node ) | |
4237 | { | |
4238 | wxWindow *child = (wxWindow *)node->Data(); | |
4239 | wxWindow *found = child->FindWindow(id); | |
4240 | if ( found ) | |
4241 | return found; | |
4242 | node = node->Next(); | |
4243 | } | |
4244 | return NULL; | |
2bda0e17 KB |
4245 | } |
4246 | ||
4247 | wxWindow *wxWindow::FindWindow(const wxString& name) | |
4248 | { | |
564b2609 VZ |
4249 | if ( GetName() == name) |
4250 | return this; | |
2bda0e17 | 4251 | |
564b2609 VZ |
4252 | wxNode *node = GetChildren()->First(); |
4253 | while ( node ) | |
4254 | { | |
4255 | wxWindow *child = (wxWindow *)node->Data(); | |
4256 | wxWindow *found = child->FindWindow(name); | |
4257 | if ( found ) | |
4258 | return found; | |
4259 | node = node->Next(); | |
4260 | } | |
4261 | return NULL; | |
2bda0e17 KB |
4262 | } |
4263 | ||
4264 | /* TODO | |
4265 | // Default input behaviour for a scrolling canvas should be to scroll | |
4266 | // according to the cursor keys pressed | |
4267 | void wxWindow::OnChar(wxKeyEvent& event) | |
4268 | { | |
4269 | int x_page = 0; | |
4270 | int y_page = 0; | |
4271 | int start_x = 0; | |
4272 | int start_y = 0; | |
4273 | // Bugfix Begin | |
4274 | int v_width = 0; | |
4275 | int v_height = 0; | |
4276 | int y_pages = 0; | |
4277 | // Bugfix End | |
4278 | ||
4279 | GetScrollUnitsPerPage(&x_page, &y_page); | |
4280 | // Bugfix Begin | |
4281 | GetVirtualSize(&v_width,&v_height); | |
4282 | // Bugfix End | |
4283 | ViewStart(&start_x, &start_y); | |
4284 | // Bugfix begin | |
4285 | if (vert_units) | |
564b2609 | 4286 | y_pages = (int)(v_height/vert_units) - y_page; |
2bda0e17 | 4287 | |
2049ba38 | 4288 | #ifdef __WXMSW__ |
2bda0e17 KB |
4289 | int y = 0; |
4290 | #else | |
4291 | int y = y_page-1; | |
4292 | #endif | |
4293 | // Bugfix End | |
4294 | switch (event.keyCode) | |
4295 | { | |
564b2609 VZ |
4296 | case WXK_PRIOR: |
4297 | { | |
4298 | // BugFix Begin | |
4299 | if (y_page > 0) | |
4300 | { | |
4301 | if (start_y - y_page > 0) | |
4302 | Scroll(start_x, start_y - y_page); | |
4303 | else | |
4304 | Scroll(start_x, 0); | |
4305 | } | |
4306 | // Bugfix End | |
4307 | break; | |
4308 | } | |
4309 | case WXK_NEXT: | |
4310 | { | |
4311 | // Bugfix Begin | |
4312 | if ((y_page > 0) && (start_y <= y_pages-y-1)) | |
4313 | { | |
4314 | if (y_pages + y < start_y + y_page) | |
4315 | Scroll(start_x, y_pages + y); | |
4316 | else | |
4317 | Scroll(start_x, start_y + y_page); | |
4318 | } | |
4319 | // Bugfix End | |
4320 | break; | |
4321 | } | |
4322 | case WXK_UP: | |
4323 | { | |
4324 | if ((y_page > 0) && (start_y >= 1)) | |
4325 | Scroll(start_x, start_y - 1); | |
4326 | break; | |
4327 | } | |
4328 | case WXK_DOWN: | |
4329 | { | |
4330 | // Bugfix Begin | |
4331 | if ((y_page > 0) && (start_y <= y_pages-y-1)) | |
4332 | // Bugfix End | |
4333 | { | |
4334 | Scroll(start_x, start_y + 1); | |
4335 | } | |
4336 | break; | |
4337 | } | |
4338 | case WXK_LEFT: | |
4339 | { | |
4340 | if ((x_page > 0) && (start_x >= 1)) | |
4341 | Scroll(start_x - 1, start_y); | |
4342 | break; | |
4343 | } | |
4344 | case WXK_RIGHT: | |
4345 | { | |
4346 | if (x_page > 0) | |
4347 | Scroll(start_x + 1, start_y); | |
4348 | break; | |
4349 | } | |
4350 | case WXK_HOME: | |
4351 | { | |
4352 | Scroll(0, 0); | |
4353 | break; | |
4354 | } | |
4355 | // This is new | |
4356 | case WXK_END: | |
4357 | { | |
4358 | Scroll(start_x, y_pages+y); | |
4359 | break; | |
4360 | } | |
4361 | // end | |
2bda0e17 KB |
4362 | } |
4363 | } | |
4364 | */ | |
4365 | ||
4366 | // Setup background and foreground colours correctly | |
4367 | void wxWindow::SetupColours(void) | |
4368 | { | |
564b2609 VZ |
4369 | if (GetParent()) |
4370 | SetBackgroundColour(GetParent()->GetBackgroundColour()); | |
2bda0e17 KB |
4371 | } |
4372 | ||
2bda0e17 KB |
4373 | void wxWindow::OnIdle(wxIdleEvent& event) |
4374 | { | |
43d811ea JS |
4375 | // Check if we need to send a LEAVE event |
4376 | if (m_mouseInWindow) | |
4377 | { | |
4378 | POINT pt; | |
4379 | ::GetCursorPos(&pt); | |
4380 | if (::WindowFromPoint(pt) != (HWND) GetHWND()) | |
4381 | { | |
4382 | // Generate a LEAVE event | |
4383 | m_mouseInWindow = FALSE; | |
567da5c6 | 4384 | |
2d524929 | 4385 | int state = 0; |
567da5c6 JS |
4386 | if (::GetKeyState(VK_SHIFT) != 0) |
4387 | state |= MK_SHIFT; | |
4388 | if (::GetKeyState(VK_CONTROL) != 0) | |
4389 | state |= MK_CONTROL; | |
4390 | ||
4391 | // Unfortunately the mouse button and keyboard state may have changed | |
4392 | // by the time the OnIdle function is called, so 'state' may be | |
4393 | // meaningless. | |
4394 | ||
4395 | MSWOnMouseLeave(pt.x, pt.y, state); | |
43d811ea JS |
4396 | } |
4397 | } | |
564b2609 | 4398 | UpdateWindowUI(); |
2bda0e17 KB |
4399 | } |
4400 | ||
4401 | // Raise the window to the top of the Z order | |
4402 | void wxWindow::Raise(void) | |
4403 | { | |
4404 | ::BringWindowToTop((HWND) GetHWND()); | |
4405 | } | |
4406 | ||
4407 | // Lower the window to the bottom of the Z order | |
4408 | void wxWindow::Lower(void) | |
4409 | { | |
4410 | ::SetWindowPos((HWND) GetHWND(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); | |
4411 | } | |
4412 | ||
47cbd6da VZ |
4413 | long wxWindow::MSWGetDlgCode() |
4414 | { | |
4415 | // default: just forward to def window proc (the msg has no parameters) | |
4416 | return MSWDefWindowProc(WM_GETDLGCODE, 0, 0); | |
4417 | } | |
4418 | ||
4419 | bool wxWindow::AcceptsFocus() const | |
4420 | { | |
4421 | return IsShown() && IsEnabled(); | |
4422 | } | |
4423 | ||
81d66cf3 JS |
4424 | // Update region access |
4425 | wxRegion wxWindow::GetUpdateRegion() const | |
4426 | { | |
4427 | return m_updateRegion; | |
4428 | } | |
4429 | ||
4430 | bool wxWindow::IsExposed(int x, int y, int w, int h) const | |
4431 | { | |
4432 | return (m_updateRegion.Contains(x, y, w, h) != wxOutRegion); | |
4433 | } | |
4434 | ||
4435 | bool wxWindow::IsExposed(const wxPoint& pt) const | |
4436 | { | |
4437 | return (m_updateRegion.Contains(pt) != wxOutRegion); | |
4438 | } | |
4439 | ||
4440 | bool wxWindow::IsExposed(const wxRect& rect) const | |
4441 | { | |
4442 | return (m_updateRegion.Contains(rect) != wxOutRegion); | |
4443 | } | |
4444 | ||
b2aef89b | 4445 | #ifdef __WXDEBUG__ |
f449ef69 | 4446 | const char *wxGetMessageName(int message) |
47cbd6da VZ |
4447 | { |
4448 | switch ( message ) { | |
4449 | case 0x0000: return "WM_NULL"; | |
4450 | case 0x0001: return "WM_CREATE"; | |
4451 | case 0x0002: return "WM_DESTROY"; | |
4452 | case 0x0003: return "WM_MOVE"; | |
4453 | case 0x0005: return "WM_SIZE"; | |
4454 | case 0x0006: return "WM_ACTIVATE"; | |
4455 | case 0x0007: return "WM_SETFOCUS"; | |
4456 | case 0x0008: return "WM_KILLFOCUS"; | |
4457 | case 0x000A: return "WM_ENABLE"; | |
4458 | case 0x000B: return "WM_SETREDRAW"; | |
4459 | case 0x000C: return "WM_SETTEXT"; | |
4460 | case 0x000D: return "WM_GETTEXT"; | |
4461 | case 0x000E: return "WM_GETTEXTLENGTH"; | |
4462 | case 0x000F: return "WM_PAINT"; | |
4463 | case 0x0010: return "WM_CLOSE"; | |
4464 | case 0x0011: return "WM_QUERYENDSESSION"; | |
4465 | case 0x0012: return "WM_QUIT"; | |
4466 | case 0x0013: return "WM_QUERYOPEN"; | |
4467 | case 0x0014: return "WM_ERASEBKGND"; | |
4468 | case 0x0015: return "WM_SYSCOLORCHANGE"; | |
4469 | case 0x0016: return "WM_ENDSESSION"; | |
4470 | case 0x0017: return "WM_SYSTEMERROR"; | |
4471 | case 0x0018: return "WM_SHOWWINDOW"; | |
4472 | case 0x0019: return "WM_CTLCOLOR"; | |
4473 | case 0x001A: return "WM_WININICHANGE"; | |
4474 | case 0x001B: return "WM_DEVMODECHANGE"; | |
4475 | case 0x001C: return "WM_ACTIVATEAPP"; | |
4476 | case 0x001D: return "WM_FONTCHANGE"; | |
4477 | case 0x001E: return "WM_TIMECHANGE"; | |
4478 | case 0x001F: return "WM_CANCELMODE"; | |
4479 | case 0x0020: return "WM_SETCURSOR"; | |
4480 | case 0x0021: return "WM_MOUSEACTIVATE"; | |
4481 | case 0x0022: return "WM_CHILDACTIVATE"; | |
4482 | case 0x0023: return "WM_QUEUESYNC"; | |
4483 | case 0x0024: return "WM_GETMINMAXINFO"; | |
4484 | case 0x0026: return "WM_PAINTICON"; | |
4485 | case 0x0027: return "WM_ICONERASEBKGND"; | |
4486 | case 0x0028: return "WM_NEXTDLGCTL"; | |
4487 | case 0x002A: return "WM_SPOOLERSTATUS"; | |
4488 | case 0x002B: return "WM_DRAWITEM"; | |
4489 | case 0x002C: return "WM_MEASUREITEM"; | |
4490 | case 0x002D: return "WM_DELETEITEM"; | |
4491 | case 0x002E: return "WM_VKEYTOITEM"; | |
4492 | case 0x002F: return "WM_CHARTOITEM"; | |
4493 | case 0x0030: return "WM_SETFONT"; | |
4494 | case 0x0031: return "WM_GETFONT"; | |
4495 | case 0x0037: return "WM_QUERYDRAGICON"; | |
4496 | case 0x0039: return "WM_COMPAREITEM"; | |
4497 | case 0x0041: return "WM_COMPACTING"; | |
4498 | case 0x0044: return "WM_COMMNOTIFY"; | |
4499 | case 0x0046: return "WM_WINDOWPOSCHANGING"; | |
4500 | case 0x0047: return "WM_WINDOWPOSCHANGED"; | |
4501 | case 0x0048: return "WM_POWER"; | |
a02eb1d2 VZ |
4502 | |
4503 | #ifdef __WIN32__ | |
4504 | case 0x004A: return "WM_COPYDATA"; | |
4505 | case 0x004B: return "WM_CANCELJOURNAL"; | |
4506 | case 0x004E: return "WM_NOTIFY"; | |
4507 | case 0x0050: return "WM_INPUTLANGCHANGEREQUEST"; | |
4508 | case 0x0051: return "WM_INPUTLANGCHANGE"; | |
4509 | case 0x0052: return "WM_TCARD"; | |
4510 | case 0x0053: return "WM_HELP"; | |
4511 | case 0x0054: return "WM_USERCHANGED"; | |
4512 | case 0x0055: return "WM_NOTIFYFORMAT"; | |
4513 | case 0x007B: return "WM_CONTEXTMENU"; | |
4514 | case 0x007C: return "WM_STYLECHANGING"; | |
4515 | case 0x007D: return "WM_STYLECHANGED"; | |
4516 | case 0x007E: return "WM_DISPLAYCHANGE"; | |
4517 | case 0x007F: return "WM_GETICON"; | |
4518 | case 0x0080: return "WM_SETICON"; | |
4519 | #endif //WIN32 | |
4520 | ||
47cbd6da VZ |
4521 | case 0x0081: return "WM_NCCREATE"; |
4522 | case 0x0082: return "WM_NCDESTROY"; | |
4523 | case 0x0083: return "WM_NCCALCSIZE"; | |
4524 | case 0x0084: return "WM_NCHITTEST"; | |
4525 | case 0x0085: return "WM_NCPAINT"; | |
4526 | case 0x0086: return "WM_NCACTIVATE"; | |
4527 | case 0x0087: return "WM_GETDLGCODE"; | |
4528 | case 0x00A0: return "WM_NCMOUSEMOVE"; | |
4529 | case 0x00A1: return "WM_NCLBUTTONDOWN"; | |
4530 | case 0x00A2: return "WM_NCLBUTTONUP"; | |
4531 | case 0x00A3: return "WM_NCLBUTTONDBLCLK"; | |
4532 | case 0x00A4: return "WM_NCRBUTTONDOWN"; | |
4533 | case 0x00A5: return "WM_NCRBUTTONUP"; | |
4534 | case 0x00A6: return "WM_NCRBUTTONDBLCLK"; | |
4535 | case 0x00A7: return "WM_NCMBUTTONDOWN"; | |
4536 | case 0x00A8: return "WM_NCMBUTTONUP"; | |
4537 | case 0x00A9: return "WM_NCMBUTTONDBLCLK"; | |
4538 | case 0x0100: return "WM_KEYDOWN"; | |
4539 | case 0x0101: return "WM_KEYUP"; | |
4540 | case 0x0102: return "WM_CHAR"; | |
4541 | case 0x0103: return "WM_DEADCHAR"; | |
4542 | case 0x0104: return "WM_SYSKEYDOWN"; | |
4543 | case 0x0105: return "WM_SYSKEYUP"; | |
4544 | case 0x0106: return "WM_SYSCHAR"; | |
4545 | case 0x0107: return "WM_SYSDEADCHAR"; | |
4546 | case 0x0108: return "WM_KEYLAST"; | |
a02eb1d2 VZ |
4547 | |
4548 | #ifdef __WIN32__ | |
4549 | case 0x010D: return "WM_IME_STARTCOMPOSITION"; | |
4550 | case 0x010E: return "WM_IME_ENDCOMPOSITION"; | |
4551 | case 0x010F: return "WM_IME_COMPOSITION"; | |
4552 | #endif //WIN32 | |
4553 | ||
47cbd6da VZ |
4554 | case 0x0110: return "WM_INITDIALOG"; |
4555 | case 0x0111: return "WM_COMMAND"; | |
4556 | case 0x0112: return "WM_SYSCOMMAND"; | |
4557 | case 0x0113: return "WM_TIMER"; | |
4558 | case 0x0114: return "WM_HSCROLL"; | |
4559 | case 0x0115: return "WM_VSCROLL"; | |
4560 | case 0x0116: return "WM_INITMENU"; | |
4561 | case 0x0117: return "WM_INITMENUPOPUP"; | |
4562 | case 0x011F: return "WM_MENUSELECT"; | |
4563 | case 0x0120: return "WM_MENUCHAR"; | |
4564 | case 0x0121: return "WM_ENTERIDLE"; | |
4565 | case 0x0200: return "WM_MOUSEMOVE"; | |
4566 | case 0x0201: return "WM_LBUTTONDOWN"; | |
4567 | case 0x0202: return "WM_LBUTTONUP"; | |
4568 | case 0x0203: return "WM_LBUTTONDBLCLK"; | |
4569 | case 0x0204: return "WM_RBUTTONDOWN"; | |
4570 | case 0x0205: return "WM_RBUTTONUP"; | |
4571 | case 0x0206: return "WM_RBUTTONDBLCLK"; | |
4572 | case 0x0207: return "WM_MBUTTONDOWN"; | |
4573 | case 0x0208: return "WM_MBUTTONUP"; | |
4574 | case 0x0209: return "WM_MBUTTONDBLCLK"; | |
4575 | case 0x0210: return "WM_PARENTNOTIFY"; | |
a02eb1d2 VZ |
4576 | case 0x0211: return "WM_ENTERMENULOOP"; |
4577 | case 0x0212: return "WM_EXITMENULOOP"; | |
4578 | ||
4579 | #ifdef __WIN32__ | |
4580 | case 0x0213: return "WM_NEXTMENU"; | |
4581 | case 0x0214: return "WM_SIZING"; | |
4582 | case 0x0215: return "WM_CAPTURECHANGED"; | |
4583 | case 0x0216: return "WM_MOVING"; | |
4584 | case 0x0218: return "WM_POWERBROADCAST"; | |
4585 | case 0x0219: return "WM_DEVICECHANGE"; | |
4586 | #endif //WIN32 | |
4587 | ||
47cbd6da VZ |
4588 | case 0x0220: return "WM_MDICREATE"; |
4589 | case 0x0221: return "WM_MDIDESTROY"; | |
4590 | case 0x0222: return "WM_MDIACTIVATE"; | |
4591 | case 0x0223: return "WM_MDIRESTORE"; | |
4592 | case 0x0224: return "WM_MDINEXT"; | |
4593 | case 0x0225: return "WM_MDIMAXIMIZE"; | |
4594 | case 0x0226: return "WM_MDITILE"; | |
4595 | case 0x0227: return "WM_MDICASCADE"; | |
4596 | case 0x0228: return "WM_MDIICONARRANGE"; | |
4597 | case 0x0229: return "WM_MDIGETACTIVE"; | |
4598 | case 0x0230: return "WM_MDISETMENU"; | |
4599 | case 0x0233: return "WM_DROPFILES"; | |
a02eb1d2 VZ |
4600 | |
4601 | #ifdef __WIN32__ | |
4602 | case 0x0281: return "WM_IME_SETCONTEXT"; | |
4603 | case 0x0282: return "WM_IME_NOTIFY"; | |
4604 | case 0x0283: return "WM_IME_CONTROL"; | |
4605 | case 0x0284: return "WM_IME_COMPOSITIONFULL"; | |
4606 | case 0x0285: return "WM_IME_SELECT"; | |
4607 | case 0x0286: return "WM_IME_CHAR"; | |
4608 | case 0x0290: return "WM_IME_KEYDOWN"; | |
4609 | case 0x0291: return "WM_IME_KEYUP"; | |
4610 | #endif //WIN32 | |
4611 | ||
47cbd6da VZ |
4612 | case 0x0300: return "WM_CUT"; |
4613 | case 0x0301: return "WM_COPY"; | |
4614 | case 0x0302: return "WM_PASTE"; | |
4615 | case 0x0303: return "WM_CLEAR"; | |
4616 | case 0x0304: return "WM_UNDO"; | |
4617 | case 0x0305: return "WM_RENDERFORMAT"; | |
4618 | case 0x0306: return "WM_RENDERALLFORMATS"; | |
4619 | case 0x0307: return "WM_DESTROYCLIPBOARD"; | |
4620 | case 0x0308: return "WM_DRAWCLIPBOARD"; | |
4621 | case 0x0309: return "WM_PAINTCLIPBOARD"; | |
4622 | case 0x030A: return "WM_VSCROLLCLIPBOARD"; | |
4623 | case 0x030B: return "WM_SIZECLIPBOARD"; | |
4624 | case 0x030C: return "WM_ASKCBFORMATNAME"; | |
4625 | case 0x030D: return "WM_CHANGECBCHAIN"; | |
4626 | case 0x030E: return "WM_HSCROLLCLIPBOARD"; | |
4627 | case 0x030F: return "WM_QUERYNEWPALETTE"; | |
4628 | case 0x0310: return "WM_PALETTEISCHANGING"; | |
4629 | case 0x0311: return "WM_PALETTECHANGED"; | |
a02eb1d2 VZ |
4630 | |
4631 | #ifdef __WIN32__ | |
4632 | // common controls messages - although they're not strictly speaking | |
4633 | // standard, it's nice to decode them nevertheless | |
4634 | ||
4635 | // listview | |
4636 | case 0x1000 + 0: return "LVM_GETBKCOLOR"; | |
4637 | case 0x1000 + 1: return "LVM_SETBKCOLOR"; | |
4638 | case 0x1000 + 2: return "LVM_GETIMAGELIST"; | |
4639 | case 0x1000 + 3: return "LVM_SETIMAGELIST"; | |
4640 | case 0x1000 + 4: return "LVM_GETITEMCOUNT"; | |
4641 | case 0x1000 + 5: return "LVM_GETITEMA"; | |
4642 | case 0x1000 + 75: return "LVM_GETITEMW"; | |
4643 | case 0x1000 + 6: return "LVM_SETITEMA"; | |
4644 | case 0x1000 + 76: return "LVM_SETITEMW"; | |
4645 | case 0x1000 + 7: return "LVM_INSERTITEMA"; | |
4646 | case 0x1000 + 77: return "LVM_INSERTITEMW"; | |
4647 | case 0x1000 + 8: return "LVM_DELETEITEM"; | |
4648 | case 0x1000 + 9: return "LVM_DELETEALLITEMS"; | |
4649 | case 0x1000 + 10: return "LVM_GETCALLBACKMASK"; | |
4650 | case 0x1000 + 11: return "LVM_SETCALLBACKMASK"; | |
4651 | case 0x1000 + 12: return "LVM_GETNEXTITEM"; | |
4652 | case 0x1000 + 13: return "LVM_FINDITEMA"; | |
4653 | case 0x1000 + 83: return "LVM_FINDITEMW"; | |
4654 | case 0x1000 + 14: return "LVM_GETITEMRECT"; | |
4655 | case 0x1000 + 15: return "LVM_SETITEMPOSITION"; | |
4656 | case 0x1000 + 16: return "LVM_GETITEMPOSITION"; | |
4657 | case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA"; | |
4658 | case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW"; | |
4659 | case 0x1000 + 18: return "LVM_HITTEST"; | |
4660 | case 0x1000 + 19: return "LVM_ENSUREVISIBLE"; | |
4661 | case 0x1000 + 20: return "LVM_SCROLL"; | |
4662 | case 0x1000 + 21: return "LVM_REDRAWITEMS"; | |
4663 | case 0x1000 + 22: return "LVM_ARRANGE"; | |
4664 | case 0x1000 + 23: return "LVM_EDITLABELA"; | |
4665 | case 0x1000 + 118: return "LVM_EDITLABELW"; | |
4666 | case 0x1000 + 24: return "LVM_GETEDITCONTROL"; | |
4667 | case 0x1000 + 25: return "LVM_GETCOLUMNA"; | |
4668 | case 0x1000 + 95: return "LVM_GETCOLUMNW"; | |
4669 | case 0x1000 + 26: return "LVM_SETCOLUMNA"; | |
4670 | case 0x1000 + 96: return "LVM_SETCOLUMNW"; | |
4671 | case 0x1000 + 27: return "LVM_INSERTCOLUMNA"; | |
4672 | case 0x1000 + 97: return "LVM_INSERTCOLUMNW"; | |
4673 | case 0x1000 + 28: return "LVM_DELETECOLUMN"; | |
4674 | case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH"; | |
4675 | case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH"; | |
4676 | case 0x1000 + 31: return "LVM_GETHEADER"; | |
4677 | case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE"; | |
4678 | case 0x1000 + 34: return "LVM_GETVIEWRECT"; | |
4679 | case 0x1000 + 35: return "LVM_GETTEXTCOLOR"; | |
4680 | case 0x1000 + 36: return "LVM_SETTEXTCOLOR"; | |
4681 | case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR"; | |
4682 | case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR"; | |
4683 | case 0x1000 + 39: return "LVM_GETTOPINDEX"; | |
4684 | case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE"; | |
4685 | case 0x1000 + 41: return "LVM_GETORIGIN"; | |
4686 | case 0x1000 + 42: return "LVM_UPDATE"; | |
4687 | case 0x1000 + 43: return "LVM_SETITEMSTATE"; | |
4688 | case 0x1000 + 44: return "LVM_GETITEMSTATE"; | |
4689 | case 0x1000 + 45: return "LVM_GETITEMTEXTA"; | |
4690 | case 0x1000 + 115: return "LVM_GETITEMTEXTW"; | |
4691 | case 0x1000 + 46: return "LVM_SETITEMTEXTA"; | |
4692 | case 0x1000 + 116: return "LVM_SETITEMTEXTW"; | |
4693 | case 0x1000 + 47: return "LVM_SETITEMCOUNT"; | |
4694 | case 0x1000 + 48: return "LVM_SORTITEMS"; | |
4695 | case 0x1000 + 49: return "LVM_SETITEMPOSITION32"; | |
4696 | case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT"; | |
4697 | case 0x1000 + 51: return "LVM_GETITEMSPACING"; | |
4698 | case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA"; | |
4699 | case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW"; | |
4700 | case 0x1000 + 53: return "LVM_SETICONSPACING"; | |
4701 | case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE"; | |
4702 | case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE"; | |
4703 | case 0x1000 + 56: return "LVM_GETSUBITEMRECT"; | |
4704 | case 0x1000 + 57: return "LVM_SUBITEMHITTEST"; | |
4705 | case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY"; | |
4706 | case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY"; | |
4707 | case 0x1000 + 60: return "LVM_SETHOTITEM"; | |
4708 | case 0x1000 + 61: return "LVM_GETHOTITEM"; | |
4709 | case 0x1000 + 62: return "LVM_SETHOTCURSOR"; | |
4710 | case 0x1000 + 63: return "LVM_GETHOTCURSOR"; | |
4711 | case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT"; | |
4712 | case 0x1000 + 65: return "LVM_SETWORKAREA"; | |
4713 | ||
4714 | // tree view | |
4715 | case 0x1100 + 0: return "TVM_INSERTITEMA"; | |
4716 | case 0x1100 + 50: return "TVM_INSERTITEMW"; | |
4717 | case 0x1100 + 1: return "TVM_DELETEITEM"; | |
4718 | case 0x1100 + 2: return "TVM_EXPAND"; | |
4719 | case 0x1100 + 4: return "TVM_GETITEMRECT"; | |
4720 | case 0x1100 + 5: return "TVM_GETCOUNT"; | |
4721 | case 0x1100 + 6: return "TVM_GETINDENT"; | |
4722 | case 0x1100 + 7: return "TVM_SETINDENT"; | |
4723 | case 0x1100 + 8: return "TVM_GETIMAGELIST"; | |
4724 | case 0x1100 + 9: return "TVM_SETIMAGELIST"; | |
4725 | case 0x1100 + 10: return "TVM_GETNEXTITEM"; | |
4726 | case 0x1100 + 11: return "TVM_SELECTITEM"; | |
4727 | case 0x1100 + 12: return "TVM_GETITEMA"; | |
4728 | case 0x1100 + 62: return "TVM_GETITEMW"; | |
4729 | case 0x1100 + 13: return "TVM_SETITEMA"; | |
4730 | case 0x1100 + 63: return "TVM_SETITEMW"; | |
4731 | case 0x1100 + 14: return "TVM_EDITLABELA"; | |
4732 | case 0x1100 + 65: return "TVM_EDITLABELW"; | |
4733 | case 0x1100 + 15: return "TVM_GETEDITCONTROL"; | |
4734 | case 0x1100 + 16: return "TVM_GETVISIBLECOUNT"; | |
4735 | case 0x1100 + 17: return "TVM_HITTEST"; | |
4736 | case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE"; | |
4737 | case 0x1100 + 19: return "TVM_SORTCHILDREN"; | |
4738 | case 0x1100 + 20: return "TVM_ENSUREVISIBLE"; | |
4739 | case 0x1100 + 21: return "TVM_SORTCHILDRENCB"; | |
4740 | case 0x1100 + 22: return "TVM_ENDEDITLABELNOW"; | |
4741 | case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA"; | |
4742 | case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW"; | |
4743 | case 0x1100 + 24: return "TVM_SETTOOLTIPS"; | |
4744 | case 0x1100 + 25: return "TVM_GETTOOLTIPS"; | |
4745 | ||
4746 | // header | |
4747 | case 0x1200 + 0: return "HDM_GETITEMCOUNT"; | |
4748 | case 0x1200 + 1: return "HDM_INSERTITEMA"; | |
4749 | case 0x1200 + 10: return "HDM_INSERTITEMW"; | |
4750 | case 0x1200 + 2: return "HDM_DELETEITEM"; | |
4751 | case 0x1200 + 3: return "HDM_GETITEMA"; | |
4752 | case 0x1200 + 11: return "HDM_GETITEMW"; | |
4753 | case 0x1200 + 4: return "HDM_SETITEMA"; | |
4754 | case 0x1200 + 12: return "HDM_SETITEMW"; | |
4755 | case 0x1200 + 5: return "HDM_LAYOUT"; | |
4756 | case 0x1200 + 6: return "HDM_HITTEST"; | |
4757 | case 0x1200 + 7: return "HDM_GETITEMRECT"; | |
4758 | case 0x1200 + 8: return "HDM_SETIMAGELIST"; | |
4759 | case 0x1200 + 9: return "HDM_GETIMAGELIST"; | |
4760 | case 0x1200 + 15: return "HDM_ORDERTOINDEX"; | |
4761 | case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE"; | |
4762 | case 0x1200 + 17: return "HDM_GETORDERARRAY"; | |
4763 | case 0x1200 + 18: return "HDM_SETORDERARRAY"; | |
4764 | case 0x1200 + 19: return "HDM_SETHOTDIVIDER"; | |
4765 | ||
4766 | // tab control | |
4767 | case 0x1300 + 2: return "TCM_GETIMAGELIST"; | |
4768 | case 0x1300 + 3: return "TCM_SETIMAGELIST"; | |
4769 | case 0x1300 + 4: return "TCM_GETITEMCOUNT"; | |
4770 | case 0x1300 + 5: return "TCM_GETITEMA"; | |
4771 | case 0x1300 + 60: return "TCM_GETITEMW"; | |
4772 | case 0x1300 + 6: return "TCM_SETITEMA"; | |
4773 | case 0x1300 + 61: return "TCM_SETITEMW"; | |
4774 | case 0x1300 + 7: return "TCM_INSERTITEMA"; | |
4775 | case 0x1300 + 62: return "TCM_INSERTITEMW"; | |
4776 | case 0x1300 + 8: return "TCM_DELETEITEM"; | |
4777 | case 0x1300 + 9: return "TCM_DELETEALLITEMS"; | |
4778 | case 0x1300 + 10: return "TCM_GETITEMRECT"; | |
4779 | case 0x1300 + 11: return "TCM_GETCURSEL"; | |
4780 | case 0x1300 + 12: return "TCM_SETCURSEL"; | |
4781 | case 0x1300 + 13: return "TCM_HITTEST"; | |
4782 | case 0x1300 + 14: return "TCM_SETITEMEXTRA"; | |
4783 | case 0x1300 + 40: return "TCM_ADJUSTRECT"; | |
4784 | case 0x1300 + 41: return "TCM_SETITEMSIZE"; | |
4785 | case 0x1300 + 42: return "TCM_REMOVEIMAGE"; | |
4786 | case 0x1300 + 43: return "TCM_SETPADDING"; | |
4787 | case 0x1300 + 44: return "TCM_GETROWCOUNT"; | |
4788 | case 0x1300 + 45: return "TCM_GETTOOLTIPS"; | |
4789 | case 0x1300 + 46: return "TCM_SETTOOLTIPS"; | |
4790 | case 0x1300 + 47: return "TCM_GETCURFOCUS"; | |
4791 | case 0x1300 + 48: return "TCM_SETCURFOCUS"; | |
4792 | case 0x1300 + 49: return "TCM_SETMINTABWIDTH"; | |
4793 | case 0x1300 + 50: return "TCM_DESELECTALL"; | |
4794 | ||
4795 | // toolbar | |
4796 | case WM_USER+1: return "TB_ENABLEBUTTON"; | |
4797 | case WM_USER+2: return "TB_CHECKBUTTON"; | |
4798 | case WM_USER+3: return "TB_PRESSBUTTON"; | |
4799 | case WM_USER+4: return "TB_HIDEBUTTON"; | |
4800 | case WM_USER+5: return "TB_INDETERMINATE"; | |
4801 | case WM_USER+9: return "TB_ISBUTTONENABLED"; | |
4802 | case WM_USER+10: return "TB_ISBUTTONCHECKED"; | |
4803 | case WM_USER+11: return "TB_ISBUTTONPRESSED"; | |
4804 | case WM_USER+12: return "TB_ISBUTTONHIDDEN"; | |
4805 | case WM_USER+13: return "TB_ISBUTTONINDETERMINATE"; | |
4806 | case WM_USER+17: return "TB_SETSTATE"; | |
4807 | case WM_USER+18: return "TB_GETSTATE"; | |
4808 | case WM_USER+19: return "TB_ADDBITMAP"; | |
4809 | case WM_USER+20: return "TB_ADDBUTTONS"; | |
4810 | case WM_USER+21: return "TB_INSERTBUTTON"; | |
4811 | case WM_USER+22: return "TB_DELETEBUTTON"; | |
4812 | case WM_USER+23: return "TB_GETBUTTON"; | |
4813 | case WM_USER+24: return "TB_BUTTONCOUNT"; | |
4814 | case WM_USER+25: return "TB_COMMANDTOINDEX"; | |
4815 | case WM_USER+26: return "TB_SAVERESTOREA"; | |
4816 | case WM_USER+76: return "TB_SAVERESTOREW"; | |
4817 | case WM_USER+27: return "TB_CUSTOMIZE"; | |
4818 | case WM_USER+28: return "TB_ADDSTRINGA"; | |
4819 | case WM_USER+77: return "TB_ADDSTRINGW"; | |
4820 | case WM_USER+29: return "TB_GETITEMRECT"; | |
4821 | case WM_USER+30: return "TB_BUTTONSTRUCTSIZE"; | |
4822 | case WM_USER+31: return "TB_SETBUTTONSIZE"; | |
4823 | case WM_USER+32: return "TB_SETBITMAPSIZE"; | |
4824 | case WM_USER+33: return "TB_AUTOSIZE"; | |
4825 | case WM_USER+35: return "TB_GETTOOLTIPS"; | |
4826 | case WM_USER+36: return "TB_SETTOOLTIPS"; | |
4827 | case WM_USER+37: return "TB_SETPARENT"; | |
4828 | case WM_USER+39: return "TB_SETROWS"; | |
4829 | case WM_USER+40: return "TB_GETROWS"; | |
4830 | case WM_USER+42: return "TB_SETCMDID"; | |
4831 | case WM_USER+43: return "TB_CHANGEBITMAP"; | |
4832 | case WM_USER+44: return "TB_GETBITMAP"; | |
4833 | case WM_USER+45: return "TB_GETBUTTONTEXTA"; | |
4834 | case WM_USER+75: return "TB_GETBUTTONTEXTW"; | |
4835 | case WM_USER+46: return "TB_REPLACEBITMAP"; | |
4836 | case WM_USER+47: return "TB_SETINDENT"; | |
4837 | case WM_USER+48: return "TB_SETIMAGELIST"; | |
4838 | case WM_USER+49: return "TB_GETIMAGELIST"; | |
4839 | case WM_USER+50: return "TB_LOADIMAGES"; | |
4840 | case WM_USER+51: return "TB_GETRECT"; | |
4841 | case WM_USER+52: return "TB_SETHOTIMAGELIST"; | |
4842 | case WM_USER+53: return "TB_GETHOTIMAGELIST"; | |
4843 | case WM_USER+54: return "TB_SETDISABLEDIMAGELIST"; | |
4844 | case WM_USER+55: return "TB_GETDISABLEDIMAGELIST"; | |
4845 | case WM_USER+56: return "TB_SETSTYLE"; | |
4846 | case WM_USER+57: return "TB_GETSTYLE"; | |
4847 | case WM_USER+58: return "TB_GETBUTTONSIZE"; | |
4848 | case WM_USER+59: return "TB_SETBUTTONWIDTH"; | |
4849 | case WM_USER+60: return "TB_SETMAXTEXTROWS"; | |
4850 | case WM_USER+61: return "TB_GETTEXTROWS"; | |
4851 | case WM_USER+41: return "TB_GETBITMAPFLAGS"; | |
4852 | ||
4853 | #endif //WIN32 | |
4854 | ||
47cbd6da VZ |
4855 | default: |
4856 | static char s_szBuf[128]; | |
4857 | sprintf(s_szBuf, "<unknown message = %d>", message); | |
4858 | return s_szBuf; | |
4859 | } | |
4860 | } | |
c2d8daeb | 4861 | #endif //WXDEBUG |