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