]>
Commit | Line | Data |
---|---|---|
93cf77c0 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: windows.cpp | |
3 | // Purpose: wxWindow | |
4 | // Author: AUTHOR | |
5 | // Modified by: | |
6 | // Created: ??/??/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "window.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/setup.h" | |
17 | #include "wx/menu.h" | |
18 | #include "wx/dc.h" | |
19 | #include "wx/dcclient.h" | |
20 | #include "wx/utils.h" | |
21 | #include "wx/app.h" | |
22 | #include "wx/panel.h" | |
23 | #include "wx/layout.h" | |
24 | #include "wx/dialog.h" | |
25 | #include "wx/listbox.h" | |
26 | #include "wx/button.h" | |
27 | #include "wx/settings.h" | |
28 | #include "wx/msgdlg.h" | |
34138703 | 29 | #include "wx/frame.h" |
93cf77c0 JS |
30 | |
31 | #include "wx/menuitem.h" | |
32 | #include "wx/log.h" | |
33 | ||
47d67540 | 34 | #if wxUSE_DRAG_AND_DROP |
93cf77c0 JS |
35 | #include "wx/dnd.h" |
36 | #endif | |
37 | ||
38 | #include <string.h> | |
39 | ||
40 | extern wxList wxPendingDelete; | |
41 | ||
42 | #if !USE_SHARED_LIBRARY | |
43 | IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler) | |
44 | ||
45 | BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler) | |
46 | EVT_CHAR(wxWindow::OnChar) | |
4ce81a75 JS |
47 | EVT_KEY_DOWN(wxWindow::OnKeyDown) |
48 | EVT_KEY_UP(wxWindow::OnKeyUp) | |
93cf77c0 JS |
49 | EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground) |
50 | EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged) | |
51 | EVT_INIT_DIALOG(wxWindow::OnInitDialog) | |
52 | EVT_IDLE(wxWindow::OnIdle) | |
53 | END_EVENT_TABLE() | |
54 | ||
55 | #endif | |
56 | ||
57 | ||
58 | // Constructor | |
59 | wxWindow::wxWindow() | |
60 | { | |
61 | // Generic | |
62 | m_windowId = 0; | |
63 | m_windowStyle = 0; | |
64 | m_windowParent = NULL; | |
65 | m_windowEventHandler = this; | |
66 | m_windowName = ""; | |
67 | m_windowCursor = *wxSTANDARD_CURSOR; | |
68 | m_children = new wxList; | |
69 | m_constraints = NULL; | |
70 | m_constraintsInvolvedIn = NULL; | |
71 | m_windowSizer = NULL; | |
72 | m_sizerParent = NULL; | |
73 | m_autoLayout = FALSE; | |
74 | m_windowValidator = NULL; | |
75 | m_defaultItem = NULL; | |
76 | m_returnCode = 0; | |
77 | m_caretWidth = 0; m_caretHeight = 0; | |
78 | m_caretEnabled = FALSE; | |
79 | m_caretShown = FALSE; | |
fd71308f JS |
80 | m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; |
81 | // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; | |
93cf77c0 | 82 | m_foregroundColour = *wxBLACK; |
93cf77c0 | 83 | |
47d67540 | 84 | #if wxUSE_DRAG_AND_DROP |
93cf77c0 JS |
85 | m_pDropTarget = NULL; |
86 | #endif | |
87 | } | |
88 | ||
89 | // Destructor | |
90 | wxWindow::~wxWindow() | |
91 | { | |
92 | // Have to delete constraints/sizer FIRST otherwise | |
93 | // sizers may try to look at deleted windows as they | |
94 | // delete themselves. | |
47d67540 | 95 | #if wxUSE_CONSTRAINTS |
93cf77c0 JS |
96 | DeleteRelatedConstraints(); |
97 | if (m_constraints) | |
98 | { | |
99 | // This removes any dangling pointers to this window | |
100 | // in other windows' constraintsInvolvedIn lists. | |
101 | UnsetConstraints(m_constraints); | |
102 | delete m_constraints; | |
103 | m_constraints = NULL; | |
104 | } | |
105 | if (m_windowSizer) | |
106 | { | |
107 | delete m_windowSizer; | |
108 | m_windowSizer = NULL; | |
109 | } | |
110 | // If this is a child of a sizer, remove self from parent | |
111 | if (m_sizerParent) | |
112 | m_sizerParent->RemoveChild((wxWindow *)this); | |
113 | #endif | |
114 | ||
115 | if (m_windowParent) | |
116 | m_windowParent->RemoveChild(this); | |
117 | ||
118 | DestroyChildren(); | |
119 | ||
120 | // TODO: destroy the window | |
121 | ||
122 | delete m_children; | |
123 | m_children = NULL; | |
124 | ||
125 | // Just in case the window has been Closed, but | |
126 | // we're then deleting immediately: don't leave | |
127 | // dangling pointers. | |
128 | wxPendingDelete.DeleteObject(this); | |
129 | ||
130 | if ( m_windowValidator ) | |
131 | delete m_windowValidator; | |
132 | } | |
133 | ||
134 | // Destroy the window (delayed, if a managed window) | |
135 | bool wxWindow::Destroy() | |
136 | { | |
137 | delete this; | |
138 | return TRUE; | |
139 | } | |
140 | ||
141 | // Constructor | |
142 | bool wxWindow::Create(wxWindow *parent, wxWindowID id, | |
143 | const wxPoint& pos, | |
144 | const wxSize& size, | |
145 | long style, | |
146 | const wxString& name) | |
147 | { | |
148 | // Generic | |
149 | m_windowId = 0; | |
150 | m_windowStyle = 0; | |
151 | m_windowParent = NULL; | |
152 | m_windowEventHandler = this; | |
153 | m_windowName = ""; | |
154 | m_windowCursor = *wxSTANDARD_CURSOR; | |
155 | m_constraints = NULL; | |
156 | m_constraintsInvolvedIn = NULL; | |
157 | m_windowSizer = NULL; | |
158 | m_sizerParent = NULL; | |
159 | m_autoLayout = FALSE; | |
160 | m_windowValidator = NULL; | |
161 | ||
47d67540 | 162 | #if wxUSE_DRAG_AND_DROP |
93cf77c0 JS |
163 | m_pDropTarget = NULL; |
164 | #endif | |
165 | ||
166 | m_caretWidth = 0; m_caretHeight = 0; | |
167 | m_caretEnabled = FALSE; | |
168 | m_caretShown = FALSE; | |
169 | m_minSizeX = -1; | |
170 | m_minSizeY = -1; | |
171 | m_maxSizeX = -1; | |
172 | m_maxSizeY = -1; | |
173 | m_defaultItem = NULL; | |
174 | m_windowParent = NULL; | |
175 | if (!parent) | |
176 | return FALSE; | |
177 | ||
178 | if (parent) parent->AddChild(this); | |
179 | ||
180 | m_returnCode = 0; | |
181 | ||
182 | SetName(name); | |
183 | ||
184 | if ( id == -1 ) | |
185 | m_windowId = (int)NewControlId(); | |
186 | else | |
187 | m_windowId = id; | |
188 | ||
fd71308f JS |
189 | // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; |
190 | m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; | |
93cf77c0 | 191 | m_foregroundColour = *wxBLACK; |
93cf77c0 JS |
192 | |
193 | m_windowStyle = style; | |
194 | ||
195 | if ( id == -1 ) | |
196 | m_windowId = (int)NewControlId(); | |
197 | else | |
198 | m_windowId = id; | |
199 | ||
200 | // TODO: create the window | |
201 | ||
202 | return TRUE; | |
203 | } | |
204 | ||
205 | void wxWindow::SetFocus() | |
206 | { | |
207 | // TODO | |
208 | } | |
209 | ||
210 | void wxWindow::Enable(bool enable) | |
211 | { | |
212 | // TODO | |
213 | } | |
214 | ||
215 | void wxWindow::CaptureMouse() | |
216 | { | |
217 | // TODO | |
218 | } | |
219 | ||
220 | void wxWindow::ReleaseMouse() | |
221 | { | |
222 | // TODO | |
223 | } | |
224 | ||
225 | // Push/pop event handler (i.e. allow a chain of event handlers | |
226 | // be searched) | |
227 | void wxWindow::PushEventHandler(wxEvtHandler *handler) | |
228 | { | |
229 | handler->SetNextHandler(GetEventHandler()); | |
230 | SetEventHandler(handler); | |
231 | } | |
232 | ||
233 | wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler) | |
234 | { | |
235 | if ( GetEventHandler() ) | |
236 | { | |
237 | wxEvtHandler *handlerA = GetEventHandler(); | |
238 | wxEvtHandler *handlerB = handlerA->GetNextHandler(); | |
239 | handlerA->SetNextHandler(NULL); | |
240 | SetEventHandler(handlerB); | |
241 | if ( deleteHandler ) | |
242 | { | |
243 | delete handlerA; | |
244 | return NULL; | |
245 | } | |
246 | else | |
247 | return handlerA; | |
248 | } | |
249 | else | |
250 | return NULL; | |
251 | } | |
252 | ||
47d67540 | 253 | #if wxUSE_DRAG_AND_DROP |
93cf77c0 JS |
254 | |
255 | void wxWindow::SetDropTarget(wxDropTarget *pDropTarget) | |
256 | { | |
257 | if ( m_pDropTarget != 0 ) { | |
93cf77c0 JS |
258 | delete m_pDropTarget; |
259 | } | |
260 | ||
261 | m_pDropTarget = pDropTarget; | |
262 | if ( m_pDropTarget != 0 ) | |
34138703 JS |
263 | { |
264 | // TODO | |
265 | } | |
93cf77c0 JS |
266 | } |
267 | ||
268 | #endif | |
269 | ||
270 | // Old style file-manager drag&drop | |
271 | void wxWindow::DragAcceptFiles(bool accept) | |
272 | { | |
273 | // TODO | |
274 | } | |
275 | ||
276 | // Get total size | |
277 | void wxWindow::GetSize(int *x, int *y) const | |
278 | { | |
279 | // TODO | |
280 | } | |
281 | ||
282 | void wxWindow::GetPosition(int *x, int *y) const | |
283 | { | |
284 | // TODO | |
285 | } | |
286 | ||
287 | void wxWindow::ScreenToClient(int *x, int *y) const | |
288 | { | |
289 | // TODO | |
290 | } | |
291 | ||
292 | void wxWindow::ClientToScreen(int *x, int *y) const | |
293 | { | |
294 | // TODO | |
295 | } | |
296 | ||
297 | void wxWindow::SetCursor(const wxCursor& cursor) | |
298 | { | |
299 | m_windowCursor = cursor; | |
300 | if (m_windowCursor.Ok()) | |
301 | { | |
302 | // TODO | |
303 | } | |
304 | } | |
305 | ||
306 | ||
307 | // Get size *available for subwindows* i.e. excluding menu bar etc. | |
308 | void wxWindow::GetClientSize(int *x, int *y) const | |
309 | { | |
310 | // TODO | |
311 | } | |
312 | ||
313 | void wxWindow::SetSize(int x, int y, int width, int height, int sizeFlags) | |
314 | { | |
315 | // TODO | |
316 | } | |
317 | ||
318 | void wxWindow::SetClientSize(int width, int height) | |
319 | { | |
320 | // TODO | |
321 | } | |
322 | ||
323 | // For implementation purposes - sometimes decorations make the client area | |
324 | // smaller | |
325 | wxPoint wxWindow::GetClientAreaOrigin() const | |
326 | { | |
327 | return wxPoint(0, 0); | |
328 | } | |
329 | ||
330 | // Makes an adjustment to the window position (for example, a frame that has | |
331 | // a toolbar that it manages itself). | |
332 | void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) | |
333 | { | |
334 | if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent()) | |
335 | { | |
336 | wxPoint pt(GetParent()->GetClientAreaOrigin()); | |
337 | x += pt.x; y += pt.y; | |
338 | } | |
339 | } | |
340 | ||
341 | bool wxWindow::Show(bool show) | |
342 | { | |
343 | // TODO | |
344 | return FALSE; | |
345 | } | |
346 | ||
347 | bool wxWindow::IsShown() const | |
348 | { | |
349 | // TODO | |
350 | return FALSE; | |
351 | } | |
352 | ||
353 | int wxWindow::GetCharHeight() const | |
354 | { | |
355 | // TODO | |
356 | return 0; | |
357 | } | |
358 | ||
359 | int wxWindow::GetCharWidth() const | |
360 | { | |
361 | // TODO | |
362 | return 0; | |
363 | } | |
364 | ||
365 | void wxWindow::GetTextExtent(const wxString& string, int *x, int *y, | |
366 | int *descent, int *externalLeading, const wxFont *theFont, bool) const | |
367 | { | |
368 | wxFont *fontToUse = (wxFont *)theFont; | |
369 | if (!fontToUse) | |
370 | fontToUse = (wxFont *) & m_windowFont; | |
371 | ||
372 | // TODO | |
373 | } | |
374 | ||
16e93305 | 375 | void wxWindow::Refresh(bool eraseBack, const wxRect *rect) |
93cf77c0 JS |
376 | { |
377 | // TODO | |
378 | } | |
379 | ||
380 | // Responds to colour changes: passes event on to children. | |
381 | void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event) | |
382 | { | |
c0ed460c | 383 | wxNode *node = GetChildren().First(); |
93cf77c0 JS |
384 | while ( node ) |
385 | { | |
386 | // Only propagate to non-top-level windows | |
387 | wxWindow *win = (wxWindow *)node->Data(); | |
388 | if ( win->GetParent() ) | |
389 | { | |
390 | wxSysColourChangedEvent event2; | |
391 | event.m_eventObject = win; | |
392 | win->GetEventHandler()->ProcessEvent(event2); | |
393 | } | |
394 | ||
395 | node = node->Next(); | |
396 | } | |
397 | } | |
398 | ||
399 | // This can be called by the app (or wxWindows) to do default processing for the current | |
400 | // event. Save message/event info in wxWindow so they can be used in this function. | |
401 | long wxWindow::Default() | |
402 | { | |
403 | // TODO | |
404 | return 0; | |
405 | } | |
406 | ||
407 | void wxWindow::InitDialog() | |
408 | { | |
409 | wxInitDialogEvent event(GetId()); | |
410 | event.SetEventObject( this ); | |
411 | GetEventHandler()->ProcessEvent(event); | |
412 | } | |
413 | ||
414 | // Default init dialog behaviour is to transfer data to window | |
415 | void wxWindow::OnInitDialog(wxInitDialogEvent& event) | |
416 | { | |
417 | TransferDataToWindow(); | |
418 | } | |
419 | ||
420 | // Caret manipulation | |
421 | void wxWindow::CreateCaret(int w, int h) | |
422 | { | |
423 | m_caretWidth = w; | |
424 | m_caretHeight = h; | |
425 | m_caretEnabled = TRUE; | |
426 | } | |
427 | ||
428 | void wxWindow::CreateCaret(const wxBitmap *WXUNUSED(bitmap)) | |
429 | { | |
430 | // TODO | |
431 | } | |
432 | ||
433 | void wxWindow::ShowCaret(bool show) | |
434 | { | |
435 | // TODO | |
436 | } | |
437 | ||
438 | void wxWindow::DestroyCaret() | |
439 | { | |
440 | // TODO | |
441 | m_caretEnabled = FALSE; | |
442 | } | |
443 | ||
444 | void wxWindow::SetCaretPos(int x, int y) | |
445 | { | |
446 | // TODO | |
447 | } | |
448 | ||
449 | void wxWindow::GetCaretPos(int *x, int *y) const | |
450 | { | |
451 | // TODO | |
452 | } | |
453 | ||
454 | wxWindow *wxGetActiveWindow() | |
455 | { | |
456 | // TODO | |
457 | return NULL; | |
458 | } | |
459 | ||
460 | void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int WXUNUSED(incW), int WXUNUSED(incH)) | |
461 | { | |
462 | m_minSizeX = minW; | |
463 | m_minSizeY = minH; | |
464 | m_maxSizeX = maxW; | |
465 | m_maxSizeY = maxH; | |
466 | } | |
467 | ||
468 | void wxWindow::Centre(int direction) | |
469 | { | |
470 | int x, y, width, height, panel_width, panel_height, new_x, new_y; | |
471 | ||
472 | wxWindow *father = (wxWindow *)GetParent(); | |
473 | if (!father) | |
474 | return; | |
475 | ||
476 | father->GetClientSize(&panel_width, &panel_height); | |
477 | GetSize(&width, &height); | |
478 | GetPosition(&x, &y); | |
479 | ||
480 | new_x = -1; | |
481 | new_y = -1; | |
482 | ||
483 | if (direction & wxHORIZONTAL) | |
484 | new_x = (int)((panel_width - width)/2); | |
485 | ||
486 | if (direction & wxVERTICAL) | |
487 | new_y = (int)((panel_height - height)/2); | |
488 | ||
489 | SetSize(new_x, new_y, -1, -1); | |
490 | ||
491 | } | |
492 | ||
493 | // Coordinates relative to the window | |
494 | void wxWindow::WarpPointer (int x_pos, int y_pos) | |
495 | { | |
496 | // TODO | |
497 | } | |
498 | ||
499 | void wxWindow::OnEraseBackground(wxEraseEvent& event) | |
500 | { | |
501 | // TODO | |
502 | Default(); | |
503 | } | |
504 | ||
505 | int wxWindow::GetScrollPos(int orient) const | |
506 | { | |
507 | // TODO | |
508 | return 0; | |
509 | } | |
510 | ||
511 | // This now returns the whole range, not just the number | |
512 | // of positions that we can scroll. | |
513 | int wxWindow::GetScrollRange(int orient) const | |
514 | { | |
515 | // TODO | |
516 | return 0; | |
517 | } | |
518 | ||
519 | int wxWindow::GetScrollThumb(int orient) const | |
520 | { | |
521 | // TODO | |
522 | return 0; | |
523 | } | |
524 | ||
525 | void wxWindow::SetScrollPos(int orient, int pos, bool refresh) | |
526 | { | |
527 | // TODO | |
34138703 | 528 | return; |
93cf77c0 JS |
529 | } |
530 | ||
531 | // New function that will replace some of the above. | |
532 | void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible, | |
533 | int range, bool refresh) | |
534 | { | |
535 | // TODO | |
536 | } | |
537 | ||
538 | // Does a physical scroll | |
16e93305 | 539 | void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) |
93cf77c0 JS |
540 | { |
541 | // TODO | |
34138703 | 542 | return; |
93cf77c0 JS |
543 | } |
544 | ||
545 | void wxWindow::SetFont(const wxFont& font) | |
546 | { | |
547 | m_windowFont = font; | |
548 | ||
549 | if (!m_windowFont.Ok()) | |
550 | return; | |
551 | // TODO | |
552 | } | |
553 | ||
554 | void wxWindow::OnChar(wxKeyEvent& event) | |
555 | { | |
4ce81a75 | 556 | /* ?? |
93cf77c0 JS |
557 | if ( event.KeyCode() == WXK_TAB ) { |
558 | // propagate the TABs to the parent - it's up to it to decide what | |
559 | // to do with it | |
560 | if ( GetParent() ) { | |
561 | if ( GetParent()->ProcessEvent(event) ) | |
562 | return; | |
563 | } | |
564 | } | |
4ce81a75 JS |
565 | */ |
566 | Default(); | |
567 | } | |
568 | ||
569 | void wxWindow::OnKeyDown(wxKeyEvent& event) | |
570 | { | |
571 | Default(); | |
572 | } | |
573 | ||
574 | void wxWindow::OnKeyUp(wxKeyEvent& event) | |
575 | { | |
576 | Default(); | |
93cf77c0 JS |
577 | } |
578 | ||
579 | void wxWindow::OnPaint(wxPaintEvent& event) | |
580 | { | |
581 | Default(); | |
582 | } | |
583 | ||
584 | bool wxWindow::IsEnabled() const | |
585 | { | |
586 | // TODO | |
587 | return FALSE; | |
588 | } | |
589 | ||
590 | // Dialog support: override these and call | |
591 | // base class members to add functionality | |
592 | // that can't be done using validators. | |
593 | // NOTE: these functions assume that controls | |
594 | // are direct children of this window, not grandchildren | |
595 | // or other levels of descendant. | |
596 | ||
597 | // Transfer values to controls. If returns FALSE, | |
598 | // it's an application error (pops up a dialog) | |
599 | bool wxWindow::TransferDataToWindow() | |
600 | { | |
c0ed460c | 601 | wxNode *node = GetChildren().First(); |
93cf77c0 JS |
602 | while ( node ) |
603 | { | |
604 | wxWindow *child = (wxWindow *)node->Data(); | |
605 | if ( child->GetValidator() && | |
606 | !child->GetValidator()->TransferToWindow() ) | |
607 | { | |
608 | wxMessageBox("Application Error", "Could not transfer data to window", wxOK|wxICON_EXCLAMATION); | |
609 | return FALSE; | |
610 | } | |
611 | ||
612 | node = node->Next(); | |
613 | } | |
614 | return TRUE; | |
615 | } | |
616 | ||
617 | // Transfer values from controls. If returns FALSE, | |
618 | // validation failed: don't quit | |
619 | bool wxWindow::TransferDataFromWindow() | |
620 | { | |
c0ed460c | 621 | wxNode *node = GetChildren().First(); |
93cf77c0 JS |
622 | while ( node ) |
623 | { | |
624 | wxWindow *child = (wxWindow *)node->Data(); | |
625 | if ( child->GetValidator() && !child->GetValidator()->TransferFromWindow() ) | |
626 | { | |
627 | return FALSE; | |
628 | } | |
629 | ||
630 | node = node->Next(); | |
631 | } | |
632 | return TRUE; | |
633 | } | |
634 | ||
635 | bool wxWindow::Validate() | |
636 | { | |
c0ed460c | 637 | wxNode *node = GetChildren().First(); |
93cf77c0 JS |
638 | while ( node ) |
639 | { | |
640 | wxWindow *child = (wxWindow *)node->Data(); | |
641 | if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->Validate(this) ) | |
642 | { | |
643 | return FALSE; | |
644 | } | |
645 | ||
646 | node = node->Next(); | |
647 | } | |
648 | return TRUE; | |
649 | } | |
650 | ||
651 | // Get the window with the focus | |
652 | wxWindow *wxWindow::FindFocus() | |
653 | { | |
654 | // TODO | |
655 | return NULL; | |
656 | } | |
657 | ||
658 | void wxWindow::AddChild(wxWindow *child) | |
659 | { | |
c0ed460c | 660 | GetChildren().Append(child); |
93cf77c0 JS |
661 | child->m_windowParent = this; |
662 | } | |
663 | ||
664 | void wxWindow::RemoveChild(wxWindow *child) | |
665 | { | |
c0ed460c | 666 | GetChildren().DeleteObject(child); |
93cf77c0 JS |
667 | child->m_windowParent = NULL; |
668 | } | |
669 | ||
670 | void wxWindow::DestroyChildren() | |
671 | { | |
93cf77c0 | 672 | wxNode *node; |
c0ed460c | 673 | while ((node = GetChildren().First()) != (wxNode *)NULL) { |
93cf77c0 JS |
674 | wxWindow *child; |
675 | if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) { | |
676 | delete child; | |
c0ed460c | 677 | if ( GetChildren().Member(child) ) |
93cf77c0 JS |
678 | delete node; |
679 | } | |
680 | } /* while */ | |
93cf77c0 JS |
681 | } |
682 | ||
683 | void wxWindow::MakeModal(bool modal) | |
684 | { | |
685 | // Disable all other windows | |
686 | if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame))) | |
687 | { | |
688 | wxNode *node = wxTopLevelWindows.First(); | |
689 | while (node) | |
690 | { | |
691 | wxWindow *win = (wxWindow *)node->Data(); | |
692 | if (win != this) | |
693 | win->Enable(!modal); | |
694 | ||
695 | node = node->Next(); | |
696 | } | |
697 | } | |
698 | } | |
699 | ||
02e8b2f9 JS |
700 | // If nothing defined for this, try the parent. |
701 | // E.g. we may be a button loaded from a resource, with no callback function | |
702 | // defined. | |
703 | void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event) | |
704 | { | |
705 | if (GetEventHandler()->ProcessEvent(event) ) | |
706 | return; | |
707 | if (m_windowParent) | |
708 | m_windowParent->GetEventHandler()->OnCommand(win, event); | |
709 | } | |
710 | ||
93cf77c0 JS |
711 | void wxWindow::SetConstraints(wxLayoutConstraints *c) |
712 | { | |
713 | if (m_constraints) | |
714 | { | |
715 | UnsetConstraints(m_constraints); | |
716 | delete m_constraints; | |
717 | } | |
718 | m_constraints = c; | |
719 | if (m_constraints) | |
720 | { | |
721 | // Make sure other windows know they're part of a 'meaningful relationship' | |
722 | if (m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this)) | |
723 | m_constraints->left.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
724 | if (m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this)) | |
725 | m_constraints->top.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
726 | if (m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this)) | |
727 | m_constraints->right.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
728 | if (m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this)) | |
729 | m_constraints->bottom.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
730 | if (m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this)) | |
731 | m_constraints->width.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
732 | if (m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this)) | |
733 | m_constraints->height.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
734 | if (m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this)) | |
735 | m_constraints->centreX.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
736 | if (m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this)) | |
737 | m_constraints->centreY.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
738 | } | |
739 | } | |
740 | ||
741 | // This removes any dangling pointers to this window | |
742 | // in other windows' constraintsInvolvedIn lists. | |
743 | void wxWindow::UnsetConstraints(wxLayoutConstraints *c) | |
744 | { | |
745 | if (c) | |
746 | { | |
747 | if (c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this)) | |
748 | c->left.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
749 | if (c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this)) | |
750 | c->top.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
751 | if (c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this)) | |
752 | c->right.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
753 | if (c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this)) | |
754 | c->bottom.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
755 | if (c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this)) | |
756 | c->width.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
757 | if (c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this)) | |
758 | c->height.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
759 | if (c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this)) | |
760 | c->centreX.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
761 | if (c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this)) | |
762 | c->centreY.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
763 | } | |
764 | } | |
765 | ||
766 | // Back-pointer to other windows we're involved with, so if we delete | |
767 | // this window, we must delete any constraints we're involved with. | |
768 | void wxWindow::AddConstraintReference(wxWindow *otherWin) | |
769 | { | |
770 | if (!m_constraintsInvolvedIn) | |
771 | m_constraintsInvolvedIn = new wxList; | |
772 | if (!m_constraintsInvolvedIn->Member(otherWin)) | |
773 | m_constraintsInvolvedIn->Append(otherWin); | |
774 | } | |
775 | ||
776 | // REMOVE back-pointer to other windows we're involved with. | |
777 | void wxWindow::RemoveConstraintReference(wxWindow *otherWin) | |
778 | { | |
779 | if (m_constraintsInvolvedIn) | |
780 | m_constraintsInvolvedIn->DeleteObject(otherWin); | |
781 | } | |
782 | ||
783 | // Reset any constraints that mention this window | |
784 | void wxWindow::DeleteRelatedConstraints() | |
785 | { | |
786 | if (m_constraintsInvolvedIn) | |
787 | { | |
788 | wxNode *node = m_constraintsInvolvedIn->First(); | |
789 | while (node) | |
790 | { | |
791 | wxWindow *win = (wxWindow *)node->Data(); | |
792 | wxNode *next = node->Next(); | |
793 | wxLayoutConstraints *constr = win->GetConstraints(); | |
794 | ||
795 | // Reset any constraints involving this window | |
796 | if (constr) | |
797 | { | |
798 | constr->left.ResetIfWin((wxWindow *)this); | |
799 | constr->top.ResetIfWin((wxWindow *)this); | |
800 | constr->right.ResetIfWin((wxWindow *)this); | |
801 | constr->bottom.ResetIfWin((wxWindow *)this); | |
802 | constr->width.ResetIfWin((wxWindow *)this); | |
803 | constr->height.ResetIfWin((wxWindow *)this); | |
804 | constr->centreX.ResetIfWin((wxWindow *)this); | |
805 | constr->centreY.ResetIfWin((wxWindow *)this); | |
806 | } | |
807 | delete node; | |
808 | node = next; | |
809 | } | |
810 | delete m_constraintsInvolvedIn; | |
811 | m_constraintsInvolvedIn = NULL; | |
812 | } | |
813 | } | |
814 | ||
815 | void wxWindow::SetSizer(wxSizer *sizer) | |
816 | { | |
817 | m_windowSizer = sizer; | |
818 | if (sizer) | |
819 | sizer->SetSizerParent((wxWindow *)this); | |
820 | } | |
821 | ||
822 | /* | |
823 | * New version | |
824 | */ | |
825 | ||
826 | bool wxWindow::Layout() | |
827 | { | |
828 | if (GetConstraints()) | |
829 | { | |
830 | int w, h; | |
831 | GetClientSize(&w, &h); | |
832 | GetConstraints()->width.SetValue(w); | |
833 | GetConstraints()->height.SetValue(h); | |
834 | } | |
835 | ||
836 | // If top level (one sizer), evaluate the sizer's constraints. | |
837 | if (GetSizer()) | |
838 | { | |
839 | int noChanges; | |
840 | GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated | |
841 | GetSizer()->LayoutPhase1(&noChanges); | |
842 | GetSizer()->LayoutPhase2(&noChanges); | |
843 | GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes | |
844 | return TRUE; | |
845 | } | |
846 | else | |
847 | { | |
848 | // Otherwise, evaluate child constraints | |
849 | ResetConstraints(); // Mark all constraints as unevaluated | |
850 | DoPhase(1); // Just one phase need if no sizers involved | |
851 | DoPhase(2); | |
852 | SetConstraintSizes(); // Recursively set the real window sizes | |
853 | } | |
854 | return TRUE; | |
855 | } | |
856 | ||
857 | ||
858 | // Do a phase of evaluating constraints: | |
859 | // the default behaviour. wxSizers may do a similar | |
860 | // thing, but also impose their own 'constraints' | |
861 | // and order the evaluation differently. | |
862 | bool wxWindow::LayoutPhase1(int *noChanges) | |
863 | { | |
864 | wxLayoutConstraints *constr = GetConstraints(); | |
865 | if (constr) | |
866 | { | |
867 | return constr->SatisfyConstraints((wxWindow *)this, noChanges); | |
868 | } | |
869 | else | |
870 | return TRUE; | |
871 | } | |
872 | ||
873 | bool wxWindow::LayoutPhase2(int *noChanges) | |
874 | { | |
875 | *noChanges = 0; | |
876 | ||
877 | // Layout children | |
878 | DoPhase(1); | |
879 | DoPhase(2); | |
880 | return TRUE; | |
881 | } | |
882 | ||
883 | // Do a phase of evaluating child constraints | |
884 | bool wxWindow::DoPhase(int phase) | |
885 | { | |
886 | int noIterations = 0; | |
887 | int maxIterations = 500; | |
888 | int noChanges = 1; | |
889 | int noFailures = 0; | |
890 | wxList succeeded; | |
891 | while ((noChanges > 0) && (noIterations < maxIterations)) | |
892 | { | |
893 | noChanges = 0; | |
894 | noFailures = 0; | |
c0ed460c | 895 | wxNode *node = GetChildren().First(); |
93cf77c0 JS |
896 | while (node) |
897 | { | |
898 | wxWindow *child = (wxWindow *)node->Data(); | |
899 | if (!child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog))) | |
900 | { | |
901 | wxLayoutConstraints *constr = child->GetConstraints(); | |
902 | if (constr) | |
903 | { | |
904 | if (succeeded.Member(child)) | |
905 | { | |
906 | } | |
907 | else | |
908 | { | |
909 | int tempNoChanges = 0; | |
910 | bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ; | |
911 | noChanges += tempNoChanges; | |
912 | if (success) | |
913 | { | |
914 | succeeded.Append(child); | |
915 | } | |
916 | } | |
917 | } | |
918 | } | |
919 | node = node->Next(); | |
920 | } | |
921 | noIterations ++; | |
922 | } | |
923 | return TRUE; | |
924 | } | |
925 | ||
926 | void wxWindow::ResetConstraints() | |
927 | { | |
928 | wxLayoutConstraints *constr = GetConstraints(); | |
929 | if (constr) | |
930 | { | |
931 | constr->left.SetDone(FALSE); | |
932 | constr->top.SetDone(FALSE); | |
933 | constr->right.SetDone(FALSE); | |
934 | constr->bottom.SetDone(FALSE); | |
935 | constr->width.SetDone(FALSE); | |
936 | constr->height.SetDone(FALSE); | |
937 | constr->centreX.SetDone(FALSE); | |
938 | constr->centreY.SetDone(FALSE); | |
939 | } | |
c0ed460c | 940 | wxNode *node = GetChildren().First(); |
93cf77c0 JS |
941 | while (node) |
942 | { | |
943 | wxWindow *win = (wxWindow *)node->Data(); | |
944 | if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))) | |
945 | win->ResetConstraints(); | |
946 | node = node->Next(); | |
947 | } | |
948 | } | |
949 | ||
950 | // Need to distinguish between setting the 'fake' size for | |
951 | // windows and sizers, and setting the real values. | |
952 | void wxWindow::SetConstraintSizes(bool recurse) | |
953 | { | |
954 | wxLayoutConstraints *constr = GetConstraints(); | |
955 | if (constr && constr->left.GetDone() && constr->right.GetDone() && | |
956 | constr->width.GetDone() && constr->height.GetDone()) | |
957 | { | |
958 | int x = constr->left.GetValue(); | |
959 | int y = constr->top.GetValue(); | |
960 | int w = constr->width.GetValue(); | |
961 | int h = constr->height.GetValue(); | |
962 | ||
963 | // If we don't want to resize this window, just move it... | |
964 | if ((constr->width.GetRelationship() != wxAsIs) || | |
965 | (constr->height.GetRelationship() != wxAsIs)) | |
966 | { | |
967 | // Calls Layout() recursively. AAAGH. How can we stop that. | |
968 | // Simply take Layout() out of non-top level OnSizes. | |
969 | SizerSetSize(x, y, w, h); | |
970 | } | |
971 | else | |
972 | { | |
973 | SizerMove(x, y); | |
974 | } | |
975 | } | |
976 | else if (constr) | |
977 | { | |
978 | char *windowClass = this->GetClassInfo()->GetClassName(); | |
979 | ||
980 | wxString winName; | |
981 | if (GetName() == "") | |
982 | winName = "unnamed"; | |
983 | else | |
984 | winName = GetName(); | |
985 | wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass, (const char *)winName); | |
986 | if (!constr->left.GetDone()) | |
987 | wxDebugMsg(" unsatisfied 'left' constraint.\n"); | |
988 | if (!constr->right.GetDone()) | |
989 | wxDebugMsg(" unsatisfied 'right' constraint.\n"); | |
990 | if (!constr->width.GetDone()) | |
991 | wxDebugMsg(" unsatisfied 'width' constraint.\n"); | |
992 | if (!constr->height.GetDone()) | |
993 | wxDebugMsg(" unsatisfied 'height' constraint.\n"); | |
994 | wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n"); | |
995 | } | |
996 | ||
997 | if (recurse) | |
998 | { | |
c0ed460c | 999 | wxNode *node = GetChildren().First(); |
93cf77c0 JS |
1000 | while (node) |
1001 | { | |
1002 | wxWindow *win = (wxWindow *)node->Data(); | |
1003 | if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))) | |
1004 | win->SetConstraintSizes(); | |
1005 | node = node->Next(); | |
1006 | } | |
1007 | } | |
1008 | } | |
1009 | ||
1010 | // This assumes that all sizers are 'on' the same | |
1011 | // window, i.e. the parent of this window. | |
1012 | void wxWindow::TransformSizerToActual(int *x, int *y) const | |
1013 | { | |
1014 | if (!m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog)) || | |
1015 | m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) ) | |
1016 | return; | |
1017 | ||
1018 | int xp, yp; | |
1019 | m_sizerParent->GetPosition(&xp, &yp); | |
1020 | m_sizerParent->TransformSizerToActual(&xp, &yp); | |
1021 | *x += xp; | |
1022 | *y += yp; | |
1023 | } | |
1024 | ||
1025 | void wxWindow::SizerSetSize(int x, int y, int w, int h) | |
1026 | { | |
1027 | int xx = x; | |
1028 | int yy = y; | |
1029 | TransformSizerToActual(&xx, &yy); | |
1030 | SetSize(xx, yy, w, h); | |
1031 | } | |
1032 | ||
1033 | void wxWindow::SizerMove(int x, int y) | |
1034 | { | |
1035 | int xx = x; | |
1036 | int yy = y; | |
1037 | TransformSizerToActual(&xx, &yy); | |
1038 | Move(xx, yy); | |
1039 | } | |
1040 | ||
1041 | // Only set the size/position of the constraint (if any) | |
1042 | void wxWindow::SetSizeConstraint(int x, int y, int w, int h) | |
1043 | { | |
1044 | wxLayoutConstraints *constr = GetConstraints(); | |
1045 | if (constr) | |
1046 | { | |
1047 | if (x != -1) | |
1048 | { | |
1049 | constr->left.SetValue(x); | |
1050 | constr->left.SetDone(TRUE); | |
1051 | } | |
1052 | if (y != -1) | |
1053 | { | |
1054 | constr->top.SetValue(y); | |
1055 | constr->top.SetDone(TRUE); | |
1056 | } | |
1057 | if (w != -1) | |
1058 | { | |
1059 | constr->width.SetValue(w); | |
1060 | constr->width.SetDone(TRUE); | |
1061 | } | |
1062 | if (h != -1) | |
1063 | { | |
1064 | constr->height.SetValue(h); | |
1065 | constr->height.SetDone(TRUE); | |
1066 | } | |
1067 | } | |
1068 | } | |
1069 | ||
1070 | void wxWindow::MoveConstraint(int x, int y) | |
1071 | { | |
1072 | wxLayoutConstraints *constr = GetConstraints(); | |
1073 | if (constr) | |
1074 | { | |
1075 | if (x != -1) | |
1076 | { | |
1077 | constr->left.SetValue(x); | |
1078 | constr->left.SetDone(TRUE); | |
1079 | } | |
1080 | if (y != -1) | |
1081 | { | |
1082 | constr->top.SetValue(y); | |
1083 | constr->top.SetDone(TRUE); | |
1084 | } | |
1085 | } | |
1086 | } | |
1087 | ||
1088 | void wxWindow::GetSizeConstraint(int *w, int *h) const | |
1089 | { | |
1090 | wxLayoutConstraints *constr = GetConstraints(); | |
1091 | if (constr) | |
1092 | { | |
1093 | *w = constr->width.GetValue(); | |
1094 | *h = constr->height.GetValue(); | |
1095 | } | |
1096 | else | |
1097 | GetSize(w, h); | |
1098 | } | |
1099 | ||
1100 | void wxWindow::GetClientSizeConstraint(int *w, int *h) const | |
1101 | { | |
1102 | wxLayoutConstraints *constr = GetConstraints(); | |
1103 | if (constr) | |
1104 | { | |
1105 | *w = constr->width.GetValue(); | |
1106 | *h = constr->height.GetValue(); | |
1107 | } | |
1108 | else | |
1109 | GetClientSize(w, h); | |
1110 | } | |
1111 | ||
1112 | void wxWindow::GetPositionConstraint(int *x, int *y) const | |
1113 | { | |
1114 | wxLayoutConstraints *constr = GetConstraints(); | |
1115 | if (constr) | |
1116 | { | |
1117 | *x = constr->left.GetValue(); | |
1118 | *y = constr->top.GetValue(); | |
1119 | } | |
1120 | else | |
1121 | GetPosition(x, y); | |
1122 | } | |
1123 | ||
1124 | bool wxWindow::Close(bool force) | |
1125 | { | |
1126 | wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); | |
1127 | event.SetEventObject(this); | |
1128 | event.SetForce(force); | |
1129 | ||
1130 | return GetEventHandler()->ProcessEvent(event); | |
1131 | } | |
1132 | ||
1133 | wxObject* wxWindow::GetChild(int number) const | |
1134 | { | |
1135 | // Return a pointer to the Nth object in the window | |
c0ed460c | 1136 | wxNode *node = GetChildren().First(); |
93cf77c0 JS |
1137 | int n = number; |
1138 | while (node && n--) | |
1139 | node = node->Next() ; | |
1140 | if (node) | |
1141 | { | |
1142 | wxObject *obj = (wxObject *)node->Data(); | |
1143 | return(obj) ; | |
1144 | } | |
1145 | else | |
1146 | return NULL ; | |
1147 | } | |
1148 | ||
1149 | void wxWindow::OnDefaultAction(wxControl *initiatingItem) | |
1150 | { | |
1151 | // Obsolete function | |
1152 | } | |
1153 | ||
1154 | void wxWindow::Clear() | |
1155 | { | |
1156 | wxClientDC dc(this); | |
1157 | wxBrush brush(GetBackgroundColour(), wxSOLID); | |
1158 | dc.SetBackground(brush); | |
1159 | dc.Clear(); | |
1160 | } | |
1161 | ||
1162 | // Fits the panel around the items | |
1163 | void wxWindow::Fit() | |
1164 | { | |
1165 | int maxX = 0; | |
1166 | int maxY = 0; | |
c0ed460c | 1167 | wxNode *node = GetChildren().First(); |
93cf77c0 JS |
1168 | while ( node ) |
1169 | { | |
1170 | wxWindow *win = (wxWindow *)node->Data(); | |
1171 | int wx, wy, ww, wh; | |
1172 | win->GetPosition(&wx, &wy); | |
1173 | win->GetSize(&ww, &wh); | |
1174 | if ( wx + ww > maxX ) | |
1175 | maxX = wx + ww; | |
1176 | if ( wy + wh > maxY ) | |
1177 | maxY = wy + wh; | |
1178 | ||
1179 | node = node->Next(); | |
1180 | } | |
1181 | SetClientSize(maxX + 5, maxY + 5); | |
1182 | } | |
1183 | ||
1184 | void wxWindow::SetValidator(const wxValidator& validator) | |
1185 | { | |
1186 | if ( m_windowValidator ) | |
1187 | delete m_windowValidator; | |
1188 | m_windowValidator = validator.Clone(); | |
1189 | ||
1190 | if ( m_windowValidator ) | |
1191 | m_windowValidator->SetWindow(this) ; | |
1192 | } | |
1193 | ||
46ccb510 JS |
1194 | void wxWindow::SetAcceleratorTable(const wxAcceleratorTable& accel) |
1195 | { | |
1196 | m_acceleratorTable = accel; | |
1197 | } | |
1198 | ||
93cf77c0 JS |
1199 | // Find a window by id or name |
1200 | wxWindow *wxWindow::FindWindow(long id) | |
1201 | { | |
1202 | if ( GetId() == id) | |
1203 | return this; | |
1204 | ||
c0ed460c | 1205 | wxNode *node = GetChildren().First(); |
93cf77c0 JS |
1206 | while ( node ) |
1207 | { | |
1208 | wxWindow *child = (wxWindow *)node->Data(); | |
1209 | wxWindow *found = child->FindWindow(id); | |
1210 | if ( found ) | |
1211 | return found; | |
1212 | node = node->Next(); | |
1213 | } | |
1214 | return NULL; | |
1215 | } | |
1216 | ||
1217 | wxWindow *wxWindow::FindWindow(const wxString& name) | |
1218 | { | |
1219 | if ( GetName() == name) | |
1220 | return this; | |
1221 | ||
c0ed460c | 1222 | wxNode *node = GetChildren().First(); |
93cf77c0 JS |
1223 | while ( node ) |
1224 | { | |
1225 | wxWindow *child = (wxWindow *)node->Data(); | |
1226 | wxWindow *found = child->FindWindow(name); | |
1227 | if ( found ) | |
1228 | return found; | |
1229 | node = node->Next(); | |
1230 | } | |
1231 | return NULL; | |
1232 | } | |
1233 | ||
1234 | void wxWindow::OnIdle(wxIdleEvent& event) | |
1235 | { | |
1236 | /* TODO: you may need to do something like this | |
1237 | * if your GUI doesn't generate enter/leave events | |
1238 | ||
1239 | // Check if we need to send a LEAVE event | |
1240 | if (m_mouseInWindow) | |
1241 | { | |
1242 | POINT pt; | |
1243 | ::GetCursorPos(&pt); | |
1244 | if (::WindowFromPoint(pt) != (HWND) GetHWND()) | |
1245 | { | |
1246 | // Generate a LEAVE event | |
1247 | m_mouseInWindow = FALSE; | |
1248 | MSWOnMouseLeave(pt.x, pt.y, 0); | |
1249 | } | |
1250 | } | |
1251 | */ | |
1252 | ||
1253 | // This calls the UI-update mechanism (querying windows for | |
1254 | // menu/toolbar/control state information) | |
1255 | UpdateWindowUI(); | |
1256 | } | |
1257 | ||
1258 | // Raise the window to the top of the Z order | |
1259 | void wxWindow::Raise() | |
1260 | { | |
1261 | // TODO | |
1262 | } | |
1263 | ||
1264 | // Lower the window to the bottom of the Z order | |
1265 | void wxWindow::Lower() | |
1266 | { | |
1267 | // TODO | |
1268 | } | |
1269 | ||
1270 | bool wxWindow::AcceptsFocus() const | |
1271 | { | |
1272 | return IsShown() && IsEnabled(); | |
1273 | } | |
1274 | ||
1275 | // Update region access | |
1276 | wxRegion wxWindow::GetUpdateRegion() const | |
1277 | { | |
1278 | return m_updateRegion; | |
1279 | } | |
1280 | ||
1281 | bool wxWindow::IsExposed(int x, int y, int w, int h) const | |
1282 | { | |
1283 | return (m_updateRegion.Contains(x, y, w, h) != wxOutRegion); | |
1284 | } | |
1285 | ||
1286 | bool wxWindow::IsExposed(const wxPoint& pt) const | |
1287 | { | |
1288 | return (m_updateRegion.Contains(pt) != wxOutRegion); | |
1289 | } | |
1290 | ||
1291 | bool wxWindow::IsExposed(const wxRect& rect) const | |
1292 | { | |
1293 | return (m_updateRegion.Contains(rect) != wxOutRegion); | |
1294 | } | |
1295 | ||
34138703 JS |
1296 | /* |
1297 | * Allocates control IDs | |
1298 | */ | |
1299 | ||
1300 | int wxWindow::NewControlId() | |
1301 | { | |
1302 | static int s_controlId = 0; | |
1303 | s_controlId ++; | |
1304 | return s_controlId; | |
1305 | } | |
1306 | ||
93cf77c0 | 1307 |