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