]>
Commit | Line | Data |
---|---|---|
7ec1983b | 1 | ///////////////////////////////////////////////////////////////////////////// |
f03fc89f | 2 | // Name: common/window.cpp |
7ec1983b VZ |
3 | // Purpose: common (to all ports) wxWindow functions |
4 | // Author: Julian Smart, Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 13/07/98 | |
7 | // RCS-ID: $Id$ | |
f03fc89f | 8 | // Copyright: (c) wxWindows team |
7ec1983b VZ |
9 | // Licence: wxWindows license |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
f03fc89f VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
f701d7ab | 19 | |
58654ed0 VZ |
20 | #ifdef __GNUG__ |
21 | #pragma implementation "windowbase.h" | |
22 | #endif | |
23 | ||
341287bf JS |
24 | // For compilers that support precompilation, includes "wx.h". |
25 | #include "wx/wxprec.h" | |
26 | ||
f701d7ab | 27 | #ifdef __BORLANDC__ |
f03fc89f | 28 | #pragma hdrstop |
f701d7ab JS |
29 | #endif |
30 | ||
f03fc89f VZ |
31 | #ifndef WX_PRECOMP |
32 | #include "wx/string.h" | |
33 | #include "wx/log.h" | |
34 | #include "wx/intl.h" | |
35 | #include "wx/frame.h" | |
36 | #include "wx/defs.h" | |
37 | #include "wx/window.h" | |
1e6feb95 | 38 | #include "wx/control.h" |
f03fc89f VZ |
39 | #include "wx/checkbox.h" |
40 | #include "wx/radiobut.h" | |
26bf1ce0 | 41 | #include "wx/textctrl.h" |
f03fc89f VZ |
42 | #include "wx/settings.h" |
43 | #include "wx/dialog.h" | |
a02dc3e3 | 44 | #include "wx/msgdlg.h" |
a37a5a73 | 45 | #include "wx/statusbr.h" |
f03fc89f VZ |
46 | #endif //WX_PRECOMP |
47 | ||
48 | #if wxUSE_CONSTRAINTS | |
49 | #include "wx/layout.h" | |
3417c2cd | 50 | #include "wx/sizer.h" |
f03fc89f VZ |
51 | #endif // wxUSE_CONSTRAINTS |
52 | ||
53 | #if wxUSE_DRAG_AND_DROP | |
54 | #include "wx/dnd.h" | |
55 | #endif // wxUSE_DRAG_AND_DROP | |
56 | ||
bd83cb56 VZ |
57 | #if wxUSE_HELP |
58 | #include "wx/cshelp.h" | |
59 | #endif // wxUSE_HELP | |
60 | ||
f03fc89f VZ |
61 | #if wxUSE_TOOLTIPS |
62 | #include "wx/tooltip.h" | |
63 | #endif // wxUSE_TOOLTIPS | |
64 | ||
789295bf VZ |
65 | #if wxUSE_CARET |
66 | #include "wx/caret.h" | |
67 | #endif // wxUSE_CARET | |
68 | ||
f03fc89f VZ |
69 | // ---------------------------------------------------------------------------- |
70 | // static data | |
71 | // ---------------------------------------------------------------------------- | |
72 | ||
42e69d6b | 73 | int wxWindowBase::ms_lastControlId = -200; |
f03fc89f VZ |
74 | |
75 | IMPLEMENT_ABSTRACT_CLASS(wxWindowBase, wxEvtHandler) | |
76 | ||
77 | // ---------------------------------------------------------------------------- | |
78 | // event table | |
79 | // ---------------------------------------------------------------------------- | |
80 | ||
81 | BEGIN_EVENT_TABLE(wxWindowBase, wxEvtHandler) | |
82 | EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged) | |
83 | EVT_INIT_DIALOG(wxWindowBase::OnInitDialog) | |
a02dc3e3 | 84 | EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick) |
bd83cb56 VZ |
85 | |
86 | #if wxUSE_HELP | |
87 | EVT_HELP(-1, wxWindowBase::OnHelp) | |
88 | #endif // wxUSE_HELP | |
89 | ||
f03fc89f VZ |
90 | END_EVENT_TABLE() |
91 | ||
92 | // ============================================================================ | |
93 | // implementation of the common functionality of the wxWindow class | |
94 | // ============================================================================ | |
95 | ||
96 | // ---------------------------------------------------------------------------- | |
97 | // initialization | |
98 | // ---------------------------------------------------------------------------- | |
99 | ||
100 | // the default initialization | |
101 | void wxWindowBase::InitBase() | |
102 | { | |
103 | // no window yet, no parent nor children | |
f03fc89f VZ |
104 | m_parent = (wxWindow *)NULL; |
105 | m_windowId = -1; | |
106 | m_children.DeleteContents( FALSE ); // don't auto delete node data | |
107 | ||
108 | // no constraints on the minimal window size | |
109 | m_minWidth = | |
110 | m_minHeight = | |
111 | m_maxWidth = | |
112 | m_maxHeight = -1; | |
113 | ||
114 | // window is created enabled but it's not visible yet | |
115 | m_isShown = FALSE; | |
116 | m_isEnabled = TRUE; | |
117 | ||
f03fc89f VZ |
118 | // the default event handler is just this window |
119 | m_eventHandler = this; | |
120 | ||
88ac883a | 121 | #if wxUSE_VALIDATORS |
f03fc89f VZ |
122 | // no validator |
123 | m_windowValidator = (wxValidator *) NULL; | |
88ac883a | 124 | #endif // wxUSE_VALIDATORS |
f03fc89f VZ |
125 | |
126 | // use the system default colours | |
a756f210 VS |
127 | m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE); |
128 | m_foregroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); | |
f6e4e9ea | 129 | |
8bf30fe9 VZ |
130 | // don't set the font here for wxMSW as we don't call WM_SETFONT here and |
131 | // so the font is *not* really set - but calls to SetFont() later won't do | |
132 | // anything because m_font appears to be already set! | |
133 | #ifndef __WXMSW__ | |
a756f210 | 134 | m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); |
8bf30fe9 | 135 | #endif // __WXMSW__ |
807a903e | 136 | |
08df3e44 VZ |
137 | // the colours/fonts are default for now |
138 | m_hasBgCol = | |
139 | m_hasFgCol = | |
140 | m_hasFont = FALSE; | |
141 | ||
f03fc89f | 142 | // no style bits |
d80cd92a | 143 | m_exStyle = |
f03fc89f VZ |
144 | m_windowStyle = 0; |
145 | ||
146 | // an optimization for the event processing: checking this flag is much | |
147 | // faster than using IsKindOf(CLASSINFO(wxWindow)) | |
148 | m_isWindow = TRUE; | |
149 | ||
150 | #if wxUSE_CONSTRAINTS | |
151 | // no constraints whatsoever | |
152 | m_constraints = (wxLayoutConstraints *) NULL; | |
153 | m_constraintsInvolvedIn = (wxWindowList *) NULL; | |
154 | m_windowSizer = (wxSizer *) NULL; | |
f03fc89f VZ |
155 | m_autoLayout = FALSE; |
156 | #endif // wxUSE_CONSTRAINTS | |
157 | ||
158 | #if wxUSE_DRAG_AND_DROP | |
159 | m_dropTarget = (wxDropTarget *)NULL; | |
160 | #endif // wxUSE_DRAG_AND_DROP | |
161 | ||
162 | #if wxUSE_TOOLTIPS | |
163 | m_tooltip = (wxToolTip *)NULL; | |
164 | #endif // wxUSE_TOOLTIPS | |
789295bf VZ |
165 | |
166 | #if wxUSE_CARET | |
167 | m_caret = (wxCaret *)NULL; | |
168 | #endif // wxUSE_CARET | |
a2d93e73 JS |
169 | |
170 | // Whether we're using the current theme for this window (wxGTK only for now) | |
171 | m_themeEnabled = FALSE; | |
f03fc89f VZ |
172 | } |
173 | ||
174 | // common part of window creation process | |
175 | bool wxWindowBase::CreateBase(wxWindowBase *parent, | |
176 | wxWindowID id, | |
74e3313b VZ |
177 | const wxPoint& WXUNUSED(pos), |
178 | const wxSize& WXUNUSED(size), | |
f03fc89f | 179 | long style, |
8d99be5f | 180 | const wxValidator& validator, |
f03fc89f VZ |
181 | const wxString& name) |
182 | { | |
183 | // m_isWindow is set to TRUE in wxWindowBase::Init() as well as many other | |
184 | // member variables - check that it has been called (will catch the case | |
185 | // when a new ctor is added which doesn't call InitWindow) | |
223d09f6 | 186 | wxASSERT_MSG( m_isWindow, wxT("Init() must have been called before!") ); |
f03fc89f VZ |
187 | |
188 | // generate a new id if the user doesn't care about it | |
69418a8e | 189 | m_windowId = id == -1 ? NewControlId() : id; |
f03fc89f VZ |
190 | |
191 | SetName(name); | |
192 | SetWindowStyleFlag(style); | |
193 | SetParent(parent); | |
674ac8b9 VZ |
194 | |
195 | #if wxUSE_VALIDATORS | |
8d99be5f | 196 | SetValidator(validator); |
674ac8b9 | 197 | #endif // wxUSE_VALIDATORS |
f03fc89f | 198 | |
8ae6ce07 VZ |
199 | // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to |
200 | // have it too - like this it's possible to set it only in the top level | |
201 | // dialog/frame and all children will inherit it by defult | |
202 | if ( parent && (parent->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) ) | |
203 | { | |
204 | SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY); | |
205 | } | |
206 | ||
f03fc89f VZ |
207 | return TRUE; |
208 | } | |
209 | ||
210 | // ---------------------------------------------------------------------------- | |
211 | // destruction | |
212 | // ---------------------------------------------------------------------------- | |
213 | ||
214 | // common clean up | |
215 | wxWindowBase::~wxWindowBase() | |
216 | { | |
349d1942 VS |
217 | wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") ); |
218 | ||
f03fc89f VZ |
219 | // FIXME if these 2 cases result from programming errors in the user code |
220 | // we should probably assert here instead of silently fixing them | |
221 | ||
222 | // Just in case the window has been Closed, but we're then deleting | |
223 | // immediately: don't leave dangling pointers. | |
224 | wxPendingDelete.DeleteObject(this); | |
225 | ||
226 | // Just in case we've loaded a top-level window via LoadNativeDialog but | |
227 | // we weren't a dialog class | |
228 | wxTopLevelWindows.DeleteObject(this); | |
a23fd0e1 | 229 | |
223d09f6 | 230 | wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") ); |
f03fc89f | 231 | |
789295bf VZ |
232 | #if wxUSE_CARET |
233 | if ( m_caret ) | |
234 | delete m_caret; | |
235 | #endif // wxUSE_CARET | |
236 | ||
88ac883a | 237 | #if wxUSE_VALIDATORS |
f03fc89f VZ |
238 | if ( m_windowValidator ) |
239 | delete m_windowValidator; | |
88ac883a | 240 | #endif // wxUSE_VALIDATORS |
f03fc89f | 241 | |
f03fc89f VZ |
242 | #if wxUSE_CONSTRAINTS |
243 | // Have to delete constraints/sizer FIRST otherwise sizers may try to look | |
244 | // at deleted windows as they delete themselves. | |
245 | DeleteRelatedConstraints(); | |
246 | ||
247 | if ( m_constraints ) | |
248 | { | |
249 | // This removes any dangling pointers to this window in other windows' | |
250 | // constraintsInvolvedIn lists. | |
251 | UnsetConstraints(m_constraints); | |
252 | delete m_constraints; | |
253 | m_constraints = NULL; | |
254 | } | |
255 | ||
256 | if ( m_windowSizer ) | |
257 | delete m_windowSizer; | |
258 | ||
f03fc89f VZ |
259 | #endif // wxUSE_CONSTRAINTS |
260 | ||
261 | #if wxUSE_DRAG_AND_DROP | |
262 | if ( m_dropTarget ) | |
263 | delete m_dropTarget; | |
264 | #endif // wxUSE_DRAG_AND_DROP | |
265 | ||
266 | #if wxUSE_TOOLTIPS | |
267 | if ( m_tooltip ) | |
268 | delete m_tooltip; | |
269 | #endif // wxUSE_TOOLTIPS | |
b0ee47ff VZ |
270 | |
271 | // reset the dangling pointer our parent window may keep to us | |
272 | if ( m_parent && m_parent->GetDefaultItem() == this ) | |
273 | { | |
274 | m_parent->SetDefaultItem(NULL); | |
275 | } | |
f03fc89f VZ |
276 | } |
277 | ||
278 | bool wxWindowBase::Destroy() | |
279 | { | |
280 | delete this; | |
281 | ||
282 | return TRUE; | |
283 | } | |
284 | ||
285 | bool wxWindowBase::Close(bool force) | |
286 | { | |
287 | wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); | |
288 | event.SetEventObject(this); | |
289 | #if WXWIN_COMPATIBILITY | |
290 | event.SetForce(force); | |
291 | #endif // WXWIN_COMPATIBILITY | |
292 | event.SetCanVeto(!force); | |
293 | ||
294 | // return FALSE if window wasn't closed because the application vetoed the | |
295 | // close event | |
296 | return GetEventHandler()->ProcessEvent(event) && !event.GetVeto(); | |
297 | } | |
298 | ||
299 | bool wxWindowBase::DestroyChildren() | |
300 | { | |
301 | wxWindowList::Node *node; | |
a23fd0e1 | 302 | for ( ;; ) |
f03fc89f | 303 | { |
a23fd0e1 VZ |
304 | // we iterate until the list becomes empty |
305 | node = GetChildren().GetFirst(); | |
306 | if ( !node ) | |
307 | break; | |
308 | ||
f03fc89f | 309 | wxWindow *child = node->GetData(); |
a23fd0e1 | 310 | |
223d09f6 | 311 | wxASSERT_MSG( child, wxT("children list contains empty nodes") ); |
a23fd0e1 | 312 | |
1a77875b | 313 | child->Show(FALSE); |
eb082a08 | 314 | delete child; |
a23fd0e1 VZ |
315 | |
316 | wxASSERT_MSG( !GetChildren().Find(child), | |
223d09f6 | 317 | wxT("child didn't remove itself using RemoveChild()") ); |
f03fc89f VZ |
318 | } |
319 | ||
320 | return TRUE; | |
321 | } | |
322 | ||
323 | // ---------------------------------------------------------------------------- | |
f68586e5 | 324 | // size/position related methods |
f03fc89f VZ |
325 | // ---------------------------------------------------------------------------- |
326 | ||
327 | // centre the window with respect to its parent in either (or both) directions | |
328 | void wxWindowBase::Centre(int direction) | |
329 | { | |
f6bcfd97 BP |
330 | // the position/size of the parent window or of the entire screen |
331 | wxPoint posParent; | |
f03fc89f VZ |
332 | int widthParent, heightParent; |
333 | ||
f6bcfd97 BP |
334 | wxWindow *parent = NULL; |
335 | ||
336 | if ( !(direction & wxCENTRE_ON_SCREEN) ) | |
f03fc89f | 337 | { |
f6bcfd97 BP |
338 | // find the parent to centre this window on: it should be the |
339 | // immediate parent for the controls but the top level parent for the | |
340 | // top level windows (like dialogs) | |
341 | parent = GetParent(); | |
342 | if ( IsTopLevel() ) | |
343 | { | |
344 | while ( parent && !parent->IsTopLevel() ) | |
345 | { | |
346 | parent = parent->GetParent(); | |
347 | } | |
348 | } | |
349 | ||
350 | // did we find the parent? | |
351 | if ( !parent ) | |
352 | { | |
353 | // no other choice | |
354 | direction |= wxCENTRE_ON_SCREEN; | |
355 | } | |
f03fc89f | 356 | } |
10fcf31a VZ |
357 | |
358 | if ( direction & wxCENTRE_ON_SCREEN ) | |
f03fc89f VZ |
359 | { |
360 | // centre with respect to the whole screen | |
361 | wxDisplaySize(&widthParent, &heightParent); | |
362 | } | |
10fcf31a VZ |
363 | else |
364 | { | |
f6bcfd97 BP |
365 | if ( IsTopLevel() ) |
366 | { | |
367 | // centre on the parent | |
368 | parent->GetSize(&widthParent, &heightParent); | |
369 | ||
370 | // adjust to the parents position | |
371 | posParent = parent->GetPosition(); | |
372 | } | |
373 | else | |
374 | { | |
375 | // centre inside the parents client rectangle | |
376 | parent->GetClientSize(&widthParent, &heightParent); | |
377 | } | |
10fcf31a | 378 | } |
f03fc89f VZ |
379 | |
380 | int width, height; | |
381 | GetSize(&width, &height); | |
382 | ||
c39eda94 VZ |
383 | int xNew = -1, |
384 | yNew = -1; | |
f03fc89f VZ |
385 | |
386 | if ( direction & wxHORIZONTAL ) | |
c39eda94 | 387 | xNew = (widthParent - width)/2; |
f03fc89f VZ |
388 | |
389 | if ( direction & wxVERTICAL ) | |
c39eda94 | 390 | yNew = (heightParent - height)/2; |
f03fc89f | 391 | |
f6bcfd97 BP |
392 | xNew += posParent.x; |
393 | yNew += posParent.y; | |
7631a292 | 394 | |
ef397583 GT |
395 | // Base size of the visible dimensions of the display |
396 | // to take into account the taskbar | |
397 | wxRect rect = wxGetClientDisplayRect(); | |
398 | wxSize size (rect.width,rect.height); | |
399 | ||
400 | if (posParent.x >= 0) // if parent is on the main display | |
401 | { | |
402 | if (xNew < 0) | |
403 | xNew = 0; | |
404 | else if (xNew+width > size.x) | |
405 | xNew = size.x-width-1; | |
406 | } | |
407 | if (posParent.y >= 0) // if parent is on the main display | |
408 | { | |
409 | if (yNew+height > size.y) | |
410 | yNew = size.y-height-1; | |
411 | ||
412 | // Make certain that the title bar is initially visible | |
413 | // always, even if this would push the bottom of the | |
414 | // dialog of the visible area of the display | |
415 | if (yNew < 0) | |
416 | yNew = 0; | |
417 | } | |
418 | ||
0fff366e VZ |
419 | // move the window to this position (keeping the old size but using |
420 | // SetSize() and not Move() to allow xNew and/or yNew to be -1) | |
db89aa76 | 421 | SetSize(xNew, yNew, width, height, wxSIZE_ALLOW_MINUS_ONE); |
7631a292 RD |
422 | } |
423 | ||
f03fc89f VZ |
424 | // fits the window around the children |
425 | void wxWindowBase::Fit() | |
426 | { | |
f68586e5 VZ |
427 | if ( GetChildren().GetCount() > 0 ) |
428 | { | |
ba81034d VZ |
429 | wxSize size = DoGetBestSize(); |
430 | ||
431 | // for compatibility with the old versions and because it really looks | |
432 | // slightly more pretty like this, add a pad | |
433 | size.x += 7; | |
434 | size.y += 14; | |
435 | ||
436 | SetClientSize(size); | |
f68586e5 VZ |
437 | } |
438 | //else: do nothing if we have no children | |
439 | } | |
f03fc89f | 440 | |
f68586e5 VZ |
441 | // return the size best suited for the current window |
442 | wxSize wxWindowBase::DoGetBestSize() const | |
443 | { | |
444 | if ( GetChildren().GetCount() > 0 ) | |
f03fc89f | 445 | { |
f68586e5 VZ |
446 | // our minimal acceptable size is such that all our windows fit inside |
447 | int maxX = 0, | |
448 | maxY = 0; | |
449 | ||
450 | for ( wxWindowList::Node *node = GetChildren().GetFirst(); | |
451 | node; | |
452 | node = node->GetNext() ) | |
42e69d6b | 453 | { |
f68586e5 | 454 | wxWindow *win = node->GetData(); |
1e6feb95 VZ |
455 | if ( win->IsTopLevel() |
456 | #if wxUSE_STATUSBAR | |
457 | || wxDynamicCast(win, wxStatusBar) | |
458 | #endif // wxUSE_STATUSBAR | |
459 | ) | |
f68586e5 VZ |
460 | { |
461 | // dialogs and frames lie in different top level windows - | |
7d9fd004 VZ |
462 | // don't deal with them here; as for the status bars, they |
463 | // don't lie in the client area at all | |
f68586e5 VZ |
464 | continue; |
465 | } | |
466 | ||
467 | int wx, wy, ww, wh; | |
468 | win->GetPosition(&wx, &wy); | |
3f5513f5 VZ |
469 | |
470 | // if the window hadn't been positioned yet, assume that it is in | |
471 | // the origin | |
472 | if ( wx == -1 ) | |
473 | wx = 0; | |
474 | if ( wy == -1 ) | |
475 | wy = 0; | |
476 | ||
f68586e5 VZ |
477 | win->GetSize(&ww, &wh); |
478 | if ( wx + ww > maxX ) | |
479 | maxX = wx + ww; | |
480 | if ( wy + wh > maxY ) | |
481 | maxY = wy + wh; | |
42e69d6b VZ |
482 | } |
483 | ||
ba81034d | 484 | return wxSize(maxX, maxY); |
f68586e5 VZ |
485 | } |
486 | else | |
487 | { | |
488 | // for a generic window there is no natural best size - just use the | |
489 | // current one | |
490 | return GetSize(); | |
f03fc89f | 491 | } |
f03fc89f VZ |
492 | } |
493 | ||
1e6feb95 VZ |
494 | // by default the origin is not shifted |
495 | wxPoint wxWindowBase::GetClientAreaOrigin() const | |
496 | { | |
497 | return wxPoint(0, 0); | |
498 | } | |
499 | ||
f03fc89f | 500 | // set the min/max size of the window |
f03fc89f VZ |
501 | void wxWindowBase::SetSizeHints(int minW, int minH, |
502 | int maxW, int maxH, | |
503 | int WXUNUSED(incW), int WXUNUSED(incH)) | |
504 | { | |
505 | m_minWidth = minW; | |
506 | m_maxWidth = maxW; | |
507 | m_minHeight = minH; | |
508 | m_maxHeight = maxH; | |
509 | } | |
510 | ||
511 | // ---------------------------------------------------------------------------- | |
512 | // show/hide/enable/disable the window | |
513 | // ---------------------------------------------------------------------------- | |
514 | ||
515 | bool wxWindowBase::Show(bool show) | |
516 | { | |
517 | if ( show != m_isShown ) | |
518 | { | |
519 | m_isShown = show; | |
520 | ||
521 | return TRUE; | |
522 | } | |
523 | else | |
524 | { | |
525 | return FALSE; | |
526 | } | |
527 | } | |
528 | ||
529 | bool wxWindowBase::Enable(bool enable) | |
530 | { | |
531 | if ( enable != m_isEnabled ) | |
532 | { | |
533 | m_isEnabled = enable; | |
534 | ||
535 | return TRUE; | |
536 | } | |
537 | else | |
538 | { | |
539 | return FALSE; | |
540 | } | |
541 | } | |
34636400 VZ |
542 | // ---------------------------------------------------------------------------- |
543 | // RTTI | |
544 | // ---------------------------------------------------------------------------- | |
545 | ||
546 | bool wxWindowBase::IsTopLevel() const | |
547 | { | |
8487f887 | 548 | return FALSE; |
34636400 | 549 | } |
f03fc89f VZ |
550 | |
551 | // ---------------------------------------------------------------------------- | |
552 | // reparenting the window | |
553 | // ---------------------------------------------------------------------------- | |
554 | ||
555 | void wxWindowBase::AddChild(wxWindowBase *child) | |
556 | { | |
223d09f6 | 557 | wxCHECK_RET( child, wxT("can't add a NULL child") ); |
f03fc89f | 558 | |
f6bcfd97 BP |
559 | // this should never happen and it will lead to a crash later if it does |
560 | // because RemoveChild() will remove only one node from the children list | |
561 | // and the other(s) one(s) will be left with dangling pointers in them | |
562 | wxASSERT_MSG( !GetChildren().Find(child), _T("AddChild() called twice") ); | |
563 | ||
f03fc89f VZ |
564 | GetChildren().Append(child); |
565 | child->SetParent(this); | |
566 | } | |
567 | ||
568 | void wxWindowBase::RemoveChild(wxWindowBase *child) | |
569 | { | |
223d09f6 | 570 | wxCHECK_RET( child, wxT("can't remove a NULL child") ); |
f03fc89f VZ |
571 | |
572 | GetChildren().DeleteObject(child); | |
573 | child->SetParent((wxWindow *)NULL); | |
574 | } | |
439b3bf1 | 575 | |
f03fc89f VZ |
576 | bool wxWindowBase::Reparent(wxWindowBase *newParent) |
577 | { | |
578 | wxWindow *oldParent = GetParent(); | |
579 | if ( newParent == oldParent ) | |
580 | { | |
581 | // nothing done | |
582 | return FALSE; | |
583 | } | |
584 | ||
585 | // unlink this window from the existing parent. | |
586 | if ( oldParent ) | |
587 | { | |
588 | oldParent->RemoveChild(this); | |
589 | } | |
590 | else | |
591 | { | |
592 | wxTopLevelWindows.DeleteObject(this); | |
593 | } | |
594 | ||
595 | // add it to the new one | |
596 | if ( newParent ) | |
597 | { | |
598 | newParent->AddChild(this); | |
599 | } | |
600 | else | |
601 | { | |
602 | wxTopLevelWindows.Append(this); | |
603 | } | |
604 | ||
605 | return TRUE; | |
606 | } | |
607 | ||
608 | // ---------------------------------------------------------------------------- | |
609 | // event handler stuff | |
610 | // ---------------------------------------------------------------------------- | |
611 | ||
612 | void wxWindowBase::PushEventHandler(wxEvtHandler *handler) | |
613 | { | |
614 | handler->SetNextHandler(GetEventHandler()); | |
615 | SetEventHandler(handler); | |
616 | } | |
617 | ||
618 | wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler) | |
619 | { | |
620 | wxEvtHandler *handlerA = GetEventHandler(); | |
621 | if ( handlerA ) | |
622 | { | |
623 | wxEvtHandler *handlerB = handlerA->GetNextHandler(); | |
624 | handlerA->SetNextHandler((wxEvtHandler *)NULL); | |
625 | SetEventHandler(handlerB); | |
626 | if ( deleteHandler ) | |
627 | { | |
628 | delete handlerA; | |
629 | handlerA = (wxEvtHandler *)NULL; | |
630 | } | |
631 | } | |
632 | ||
633 | return handlerA; | |
634 | } | |
635 | ||
2e36d5cf VZ |
636 | bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handler) |
637 | { | |
638 | wxCHECK_MSG( handler, FALSE, _T("RemoveEventHandler(NULL) called") ); | |
639 | ||
640 | wxEvtHandler *handlerPrev = NULL, | |
641 | *handlerCur = GetEventHandler(); | |
642 | while ( handlerCur ) | |
643 | { | |
644 | wxEvtHandler *handlerNext = handlerCur->GetNextHandler(); | |
645 | ||
646 | if ( handlerCur == handler ) | |
647 | { | |
648 | if ( handlerPrev ) | |
649 | { | |
650 | handlerPrev->SetNextHandler(handlerNext); | |
651 | } | |
652 | else | |
653 | { | |
654 | SetEventHandler(handlerNext); | |
655 | } | |
656 | ||
657 | handler->SetNextHandler(NULL); | |
658 | ||
659 | return TRUE; | |
660 | } | |
661 | ||
662 | handlerPrev = handlerCur; | |
663 | handlerCur = handlerNext; | |
664 | } | |
665 | ||
666 | wxFAIL_MSG( _T("where has the event handler gone?") ); | |
667 | ||
668 | return FALSE; | |
669 | } | |
670 | ||
f03fc89f VZ |
671 | // ---------------------------------------------------------------------------- |
672 | // cursors, fonts &c | |
673 | // ---------------------------------------------------------------------------- | |
674 | ||
675 | bool wxWindowBase::SetBackgroundColour( const wxColour &colour ) | |
676 | { | |
677 | if ( !colour.Ok() || (colour == m_backgroundColour) ) | |
678 | return FALSE; | |
679 | ||
680 | m_backgroundColour = colour; | |
681 | ||
23895080 VZ |
682 | m_hasBgCol = TRUE; |
683 | ||
f03fc89f VZ |
684 | return TRUE; |
685 | } | |
686 | ||
687 | bool wxWindowBase::SetForegroundColour( const wxColour &colour ) | |
688 | { | |
689 | if ( !colour.Ok() || (colour == m_foregroundColour) ) | |
690 | return FALSE; | |
691 | ||
692 | m_foregroundColour = colour; | |
693 | ||
23895080 VZ |
694 | m_hasFgCol = TRUE; |
695 | ||
f03fc89f VZ |
696 | return TRUE; |
697 | } | |
698 | ||
699 | bool wxWindowBase::SetCursor(const wxCursor& cursor) | |
700 | { | |
8a9c2246 VZ |
701 | // setting an invalid cursor is ok, it means that we don't have any special |
702 | // cursor | |
13588544 | 703 | if ( m_cursor == cursor ) |
f03fc89f VZ |
704 | { |
705 | // no change | |
706 | return FALSE; | |
707 | } | |
708 | ||
8a9c2246 | 709 | m_cursor = cursor; |
f03fc89f VZ |
710 | |
711 | return TRUE; | |
712 | } | |
713 | ||
714 | bool wxWindowBase::SetFont(const wxFont& font) | |
715 | { | |
716 | // don't try to set invalid font, always fall back to the default | |
717 | const wxFont& fontOk = font.Ok() ? font : *wxSWISS_FONT; | |
718 | ||
8bf30fe9 | 719 | if ( fontOk == m_font ) |
f03fc89f VZ |
720 | { |
721 | // no change | |
722 | return FALSE; | |
723 | } | |
724 | ||
725 | m_font = fontOk; | |
726 | ||
23895080 VZ |
727 | m_hasFont = TRUE; |
728 | ||
f03fc89f VZ |
729 | return TRUE; |
730 | } | |
731 | ||
789295bf VZ |
732 | #if wxUSE_CARET |
733 | void wxWindowBase::SetCaret(wxCaret *caret) | |
734 | { | |
735 | if ( m_caret ) | |
736 | { | |
737 | delete m_caret; | |
738 | } | |
739 | ||
740 | m_caret = caret; | |
741 | ||
742 | if ( m_caret ) | |
743 | { | |
744 | wxASSERT_MSG( m_caret->GetWindow() == this, | |
223d09f6 | 745 | wxT("caret should be created associated to this window") ); |
789295bf VZ |
746 | } |
747 | } | |
748 | #endif // wxUSE_CARET | |
749 | ||
88ac883a | 750 | #if wxUSE_VALIDATORS |
f03fc89f VZ |
751 | // ---------------------------------------------------------------------------- |
752 | // validators | |
753 | // ---------------------------------------------------------------------------- | |
754 | ||
755 | void wxWindowBase::SetValidator(const wxValidator& validator) | |
756 | { | |
757 | if ( m_windowValidator ) | |
758 | delete m_windowValidator; | |
759 | ||
760 | m_windowValidator = (wxValidator *)validator.Clone(); | |
761 | ||
762 | if ( m_windowValidator ) | |
763 | m_windowValidator->SetWindow(this) ; | |
764 | } | |
88ac883a | 765 | #endif // wxUSE_VALIDATORS |
f03fc89f VZ |
766 | |
767 | // ---------------------------------------------------------------------------- | |
1e6feb95 | 768 | // update region stuff |
f03fc89f VZ |
769 | // ---------------------------------------------------------------------------- |
770 | ||
1e6feb95 VZ |
771 | wxRect wxWindowBase::GetUpdateClientRect() const |
772 | { | |
773 | wxRegion rgnUpdate = GetUpdateRegion(); | |
774 | rgnUpdate.Intersect(GetClientRect()); | |
775 | wxRect rectUpdate = rgnUpdate.GetBox(); | |
776 | wxPoint ptOrigin = GetClientAreaOrigin(); | |
777 | rectUpdate.x -= ptOrigin.x; | |
778 | rectUpdate.y -= ptOrigin.y; | |
779 | ||
780 | return rectUpdate; | |
781 | } | |
782 | ||
f03fc89f VZ |
783 | bool wxWindowBase::IsExposed(int x, int y) const |
784 | { | |
785 | return m_updateRegion.Contains(x, y) != wxOutRegion; | |
786 | } | |
787 | ||
788 | bool wxWindowBase::IsExposed(int x, int y, int w, int h) const | |
789 | { | |
790 | return m_updateRegion.Contains(x, y, w, h) != wxOutRegion; | |
791 | } | |
792 | ||
793 | // ---------------------------------------------------------------------------- | |
794 | // find window by id or name | |
795 | // ---------------------------------------------------------------------------- | |
796 | ||
797 | wxWindow *wxWindowBase::FindWindow( long id ) | |
798 | { | |
799 | if ( id == m_windowId ) | |
800 | return (wxWindow *)this; | |
801 | ||
802 | wxWindowBase *res = (wxWindow *)NULL; | |
803 | wxWindowList::Node *node; | |
804 | for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() ) | |
805 | { | |
806 | wxWindowBase *child = node->GetData(); | |
807 | res = child->FindWindow( id ); | |
808 | } | |
809 | ||
810 | return (wxWindow *)res; | |
811 | } | |
812 | ||
813 | wxWindow *wxWindowBase::FindWindow( const wxString& name ) | |
814 | { | |
815 | if ( name == m_windowName ) | |
816 | return (wxWindow *)this; | |
817 | ||
818 | wxWindowBase *res = (wxWindow *)NULL; | |
819 | wxWindowList::Node *node; | |
820 | for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() ) | |
821 | { | |
822 | wxWindow *child = node->GetData(); | |
823 | res = child->FindWindow(name); | |
824 | } | |
825 | ||
826 | return (wxWindow *)res; | |
827 | } | |
828 | ||
829 | // ---------------------------------------------------------------------------- | |
830 | // dialog oriented functions | |
831 | // ---------------------------------------------------------------------------- | |
832 | ||
34636400 | 833 | void wxWindowBase::MakeModal(bool modal) |
f03fc89f | 834 | { |
34636400 VZ |
835 | // Disable all other windows |
836 | if ( IsTopLevel() ) | |
837 | { | |
838 | wxWindowList::Node *node = wxTopLevelWindows.GetFirst(); | |
839 | while (node) | |
840 | { | |
841 | wxWindow *win = node->GetData(); | |
842 | if (win != this) | |
843 | win->Enable(!modal); | |
844 | ||
845 | node = node->GetNext(); | |
846 | } | |
847 | } | |
f03fc89f VZ |
848 | } |
849 | ||
850 | bool wxWindowBase::Validate() | |
851 | { | |
88ac883a | 852 | #if wxUSE_VALIDATORS |
d80cd92a VZ |
853 | bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0; |
854 | ||
f03fc89f VZ |
855 | wxWindowList::Node *node; |
856 | for ( node = m_children.GetFirst(); node; node = node->GetNext() ) | |
857 | { | |
858 | wxWindowBase *child = node->GetData(); | |
859 | wxValidator *validator = child->GetValidator(); | |
dcd6b914 | 860 | if ( validator && !validator->Validate((wxWindow *)this) ) |
f03fc89f VZ |
861 | { |
862 | return FALSE; | |
863 | } | |
d80cd92a VZ |
864 | |
865 | if ( recurse && !child->Validate() ) | |
866 | { | |
867 | return FALSE; | |
868 | } | |
f03fc89f | 869 | } |
88ac883a | 870 | #endif // wxUSE_VALIDATORS |
f03fc89f VZ |
871 | |
872 | return TRUE; | |
873 | } | |
874 | ||
875 | bool wxWindowBase::TransferDataToWindow() | |
876 | { | |
88ac883a | 877 | #if wxUSE_VALIDATORS |
d80cd92a VZ |
878 | bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0; |
879 | ||
f03fc89f VZ |
880 | wxWindowList::Node *node; |
881 | for ( node = m_children.GetFirst(); node; node = node->GetNext() ) | |
882 | { | |
883 | wxWindowBase *child = node->GetData(); | |
884 | wxValidator *validator = child->GetValidator(); | |
885 | if ( validator && !validator->TransferToWindow() ) | |
886 | { | |
d80cd92a VZ |
887 | wxLogWarning(_("Could not transfer data to window")); |
888 | wxLog::FlushActive(); | |
f03fc89f VZ |
889 | |
890 | return FALSE; | |
891 | } | |
d80cd92a VZ |
892 | |
893 | if ( recurse ) | |
894 | { | |
a58a12e9 | 895 | if ( !child->TransferDataToWindow() ) |
d80cd92a VZ |
896 | { |
897 | // warning already given | |
898 | return FALSE; | |
899 | } | |
900 | } | |
f03fc89f | 901 | } |
88ac883a | 902 | #endif // wxUSE_VALIDATORS |
f03fc89f VZ |
903 | |
904 | return TRUE; | |
905 | } | |
906 | ||
907 | bool wxWindowBase::TransferDataFromWindow() | |
908 | { | |
88ac883a | 909 | #if wxUSE_VALIDATORS |
d80cd92a VZ |
910 | bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0; |
911 | ||
f03fc89f VZ |
912 | wxWindowList::Node *node; |
913 | for ( node = m_children.GetFirst(); node; node = node->GetNext() ) | |
914 | { | |
915 | wxWindow *child = node->GetData(); | |
d80cd92a VZ |
916 | wxValidator *validator = child->GetValidator(); |
917 | if ( validator && !validator->TransferFromWindow() ) | |
f03fc89f | 918 | { |
d80cd92a VZ |
919 | // nop warning here because the application is supposed to give |
920 | // one itself - we don't know here what might have gone wrongly | |
921 | ||
f03fc89f VZ |
922 | return FALSE; |
923 | } | |
d80cd92a VZ |
924 | |
925 | if ( recurse ) | |
926 | { | |
a58a12e9 | 927 | if ( !child->TransferDataFromWindow() ) |
d80cd92a VZ |
928 | { |
929 | // warning already given | |
930 | return FALSE; | |
931 | } | |
932 | } | |
f03fc89f | 933 | } |
88ac883a | 934 | #endif // wxUSE_VALIDATORS |
f03fc89f VZ |
935 | |
936 | return TRUE; | |
937 | } | |
938 | ||
939 | void wxWindowBase::InitDialog() | |
940 | { | |
941 | wxInitDialogEvent event(GetId()); | |
942 | event.SetEventObject( this ); | |
943 | GetEventHandler()->ProcessEvent(event); | |
944 | } | |
945 | ||
946 | // ---------------------------------------------------------------------------- | |
bd83cb56 VZ |
947 | // context-sensitive help support |
948 | // ---------------------------------------------------------------------------- | |
949 | ||
950 | #if wxUSE_HELP | |
951 | ||
952 | // associate this help text with this window | |
953 | void wxWindowBase::SetHelpText(const wxString& text) | |
954 | { | |
955 | wxHelpProvider *helpProvider = wxHelpProvider::Get(); | |
956 | if ( helpProvider ) | |
957 | { | |
958 | helpProvider->AddHelp(this, text); | |
959 | } | |
960 | } | |
961 | ||
962 | // associate this help text with all windows with the same id as this | |
963 | // one | |
964 | void wxWindowBase::SetHelpTextForId(const wxString& text) | |
965 | { | |
966 | wxHelpProvider *helpProvider = wxHelpProvider::Get(); | |
967 | if ( helpProvider ) | |
968 | { | |
969 | helpProvider->AddHelp(GetId(), text); | |
970 | } | |
971 | } | |
972 | ||
973 | // get the help string associated with this window (may be empty) | |
974 | wxString wxWindowBase::GetHelpText() const | |
975 | { | |
976 | wxString text; | |
977 | wxHelpProvider *helpProvider = wxHelpProvider::Get(); | |
978 | if ( helpProvider ) | |
979 | { | |
980 | text = helpProvider->GetHelp(this); | |
981 | } | |
982 | ||
983 | return text; | |
984 | } | |
985 | ||
986 | // show help for this window | |
987 | void wxWindowBase::OnHelp(wxHelpEvent& event) | |
988 | { | |
989 | wxHelpProvider *helpProvider = wxHelpProvider::Get(); | |
990 | if ( helpProvider ) | |
991 | { | |
992 | if ( helpProvider->ShowHelp(this) ) | |
993 | { | |
994 | // skip the event.Skip() below | |
995 | return; | |
996 | } | |
997 | } | |
998 | ||
999 | event.Skip(); | |
1000 | } | |
1001 | ||
1002 | #endif // wxUSE_HELP | |
1003 | ||
1004 | // ---------------------------------------------------------------------------- | |
f03fc89f VZ |
1005 | // tooltips |
1006 | // ---------------------------------------------------------------------------- | |
1007 | ||
1008 | #if wxUSE_TOOLTIPS | |
1009 | ||
1010 | void wxWindowBase::SetToolTip( const wxString &tip ) | |
1011 | { | |
1012 | // don't create the new tooltip if we already have one | |
1013 | if ( m_tooltip ) | |
1014 | { | |
1015 | m_tooltip->SetTip( tip ); | |
1016 | } | |
1017 | else | |
1018 | { | |
1019 | SetToolTip( new wxToolTip( tip ) ); | |
1020 | } | |
1021 | ||
1022 | // setting empty tooltip text does not remove the tooltip any more - use | |
1023 | // SetToolTip((wxToolTip *)NULL) for this | |
1024 | } | |
1025 | ||
1026 | void wxWindowBase::DoSetToolTip(wxToolTip *tooltip) | |
1027 | { | |
1028 | if ( m_tooltip ) | |
1029 | delete m_tooltip; | |
1030 | ||
1031 | m_tooltip = tooltip; | |
1032 | } | |
1033 | ||
1034 | #endif // wxUSE_TOOLTIPS | |
1035 | ||
1036 | // ---------------------------------------------------------------------------- | |
1037 | // constraints and sizers | |
1038 | // ---------------------------------------------------------------------------- | |
1039 | ||
1040 | #if wxUSE_CONSTRAINTS | |
1041 | ||
1042 | void wxWindowBase::SetConstraints( wxLayoutConstraints *constraints ) | |
1043 | { | |
1044 | if ( m_constraints ) | |
1045 | { | |
1046 | UnsetConstraints(m_constraints); | |
1047 | delete m_constraints; | |
1048 | } | |
1049 | m_constraints = constraints; | |
1050 | if ( m_constraints ) | |
1051 | { | |
1052 | // Make sure other windows know they're part of a 'meaningful relationship' | |
1053 | if ( m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this) ) | |
1054 | m_constraints->left.GetOtherWindow()->AddConstraintReference(this); | |
1055 | if ( m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this) ) | |
1056 | m_constraints->top.GetOtherWindow()->AddConstraintReference(this); | |
1057 | if ( m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this) ) | |
1058 | m_constraints->right.GetOtherWindow()->AddConstraintReference(this); | |
1059 | if ( m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this) ) | |
1060 | m_constraints->bottom.GetOtherWindow()->AddConstraintReference(this); | |
1061 | if ( m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this) ) | |
1062 | m_constraints->width.GetOtherWindow()->AddConstraintReference(this); | |
1063 | if ( m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this) ) | |
1064 | m_constraints->height.GetOtherWindow()->AddConstraintReference(this); | |
1065 | if ( m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this) ) | |
1066 | m_constraints->centreX.GetOtherWindow()->AddConstraintReference(this); | |
1067 | if ( m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this) ) | |
1068 | m_constraints->centreY.GetOtherWindow()->AddConstraintReference(this); | |
1069 | } | |
1070 | } | |
1071 | ||
1072 | // This removes any dangling pointers to this window in other windows' | |
1073 | // constraintsInvolvedIn lists. | |
1074 | void wxWindowBase::UnsetConstraints(wxLayoutConstraints *c) | |
1075 | { | |
1076 | if ( c ) | |
1077 | { | |
1078 | if ( c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this) ) | |
1079 | c->left.GetOtherWindow()->RemoveConstraintReference(this); | |
1080 | if ( c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this) ) | |
1081 | c->top.GetOtherWindow()->RemoveConstraintReference(this); | |
1082 | if ( c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this) ) | |
1083 | c->right.GetOtherWindow()->RemoveConstraintReference(this); | |
1084 | if ( c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this) ) | |
1085 | c->bottom.GetOtherWindow()->RemoveConstraintReference(this); | |
1086 | if ( c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this) ) | |
1087 | c->width.GetOtherWindow()->RemoveConstraintReference(this); | |
1088 | if ( c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this) ) | |
1089 | c->height.GetOtherWindow()->RemoveConstraintReference(this); | |
1090 | if ( c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this) ) | |
1091 | c->centreX.GetOtherWindow()->RemoveConstraintReference(this); | |
1092 | if ( c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this) ) | |
1093 | c->centreY.GetOtherWindow()->RemoveConstraintReference(this); | |
1094 | } | |
1095 | } | |
1096 | ||
1097 | // Back-pointer to other windows we're involved with, so if we delete this | |
1098 | // window, we must delete any constraints we're involved with. | |
1099 | void wxWindowBase::AddConstraintReference(wxWindowBase *otherWin) | |
1100 | { | |
1101 | if ( !m_constraintsInvolvedIn ) | |
1102 | m_constraintsInvolvedIn = new wxWindowList; | |
1103 | if ( !m_constraintsInvolvedIn->Find(otherWin) ) | |
1104 | m_constraintsInvolvedIn->Append(otherWin); | |
1105 | } | |
1106 | ||
1107 | // REMOVE back-pointer to other windows we're involved with. | |
1108 | void wxWindowBase::RemoveConstraintReference(wxWindowBase *otherWin) | |
1109 | { | |
1110 | if ( m_constraintsInvolvedIn ) | |
1111 | m_constraintsInvolvedIn->DeleteObject(otherWin); | |
1112 | } | |
1113 | ||
1114 | // Reset any constraints that mention this window | |
1115 | void wxWindowBase::DeleteRelatedConstraints() | |
1116 | { | |
1117 | if ( m_constraintsInvolvedIn ) | |
1118 | { | |
1119 | wxWindowList::Node *node = m_constraintsInvolvedIn->GetFirst(); | |
1120 | while (node) | |
1121 | { | |
1122 | wxWindow *win = node->GetData(); | |
1123 | wxLayoutConstraints *constr = win->GetConstraints(); | |
1124 | ||
1125 | // Reset any constraints involving this window | |
1126 | if ( constr ) | |
1127 | { | |
1128 | constr->left.ResetIfWin(this); | |
1129 | constr->top.ResetIfWin(this); | |
1130 | constr->right.ResetIfWin(this); | |
1131 | constr->bottom.ResetIfWin(this); | |
1132 | constr->width.ResetIfWin(this); | |
1133 | constr->height.ResetIfWin(this); | |
1134 | constr->centreX.ResetIfWin(this); | |
1135 | constr->centreY.ResetIfWin(this); | |
1136 | } | |
1137 | ||
1138 | wxWindowList::Node *next = node->GetNext(); | |
1139 | delete node; | |
1140 | node = next; | |
1141 | } | |
1142 | ||
1143 | delete m_constraintsInvolvedIn; | |
1144 | m_constraintsInvolvedIn = (wxWindowList *) NULL; | |
1145 | } | |
1146 | } | |
1147 | ||
1148 | void wxWindowBase::SetSizer(wxSizer *sizer) | |
1149 | { | |
3417c2cd RR |
1150 | if (m_windowSizer) delete m_windowSizer; |
1151 | ||
f03fc89f | 1152 | m_windowSizer = sizer; |
f03fc89f VZ |
1153 | } |
1154 | ||
1155 | bool wxWindowBase::Layout() | |
1156 | { | |
3417c2cd | 1157 | // If there is a sizer, use it instead of the constraints |
f03fc89f VZ |
1158 | if ( GetSizer() ) |
1159 | { | |
f1df0927 VZ |
1160 | int w, h; |
1161 | GetClientSize(&w, &h); | |
1162 | ||
3417c2cd | 1163 | GetSizer()->SetDimension( 0, 0, w, h ); |
f03fc89f | 1164 | } |
f1df0927 | 1165 | else |
f03fc89f | 1166 | { |
4b7f2165 VZ |
1167 | wxLayoutConstraints *constr = GetConstraints(); |
1168 | bool wasOk = constr && constr->AreSatisfied(); | |
1169 | ||
f1df0927 | 1170 | ResetConstraints(); // Mark all constraints as unevaluated |
4b7f2165 VZ |
1171 | |
1172 | // if we're a top level panel (i.e. our parent is frame/dialog), our | |
1173 | // own constraints will never be satisfied any more unless we do it | |
1174 | // here | |
1175 | if ( wasOk ) | |
1176 | { | |
1177 | int noChanges = 1; | |
1178 | while ( noChanges > 0 ) | |
1179 | { | |
1180 | constr->SatisfyConstraints(this, &noChanges); | |
1181 | } | |
1182 | } | |
1183 | ||
1184 | DoPhase(1); // Layout children | |
1185 | DoPhase(2); // Layout grand children | |
f1df0927 | 1186 | SetConstraintSizes(); // Recursively set the real window sizes |
f03fc89f | 1187 | } |
5d4b632b | 1188 | |
f03fc89f VZ |
1189 | return TRUE; |
1190 | } | |
1191 | ||
1192 | ||
1193 | // Do a phase of evaluating constraints: the default behaviour. wxSizers may | |
1194 | // do a similar thing, but also impose their own 'constraints' and order the | |
1195 | // evaluation differently. | |
1196 | bool wxWindowBase::LayoutPhase1(int *noChanges) | |
1197 | { | |
1198 | wxLayoutConstraints *constr = GetConstraints(); | |
1199 | if ( constr ) | |
1200 | { | |
1201 | return constr->SatisfyConstraints(this, noChanges); | |
1202 | } | |
1203 | else | |
1204 | return TRUE; | |
1205 | } | |
1206 | ||
1207 | bool wxWindowBase::LayoutPhase2(int *noChanges) | |
1208 | { | |
1209 | *noChanges = 0; | |
1210 | ||
1211 | // Layout children | |
1212 | DoPhase(1); | |
1213 | DoPhase(2); | |
1214 | return TRUE; | |
1215 | } | |
1216 | ||
1217 | // Do a phase of evaluating child constraints | |
1218 | bool wxWindowBase::DoPhase(int phase) | |
1219 | { | |
1220 | int noIterations = 0; | |
1221 | int maxIterations = 500; | |
1222 | int noChanges = 1; | |
1223 | int noFailures = 0; | |
1224 | wxWindowList succeeded; | |
1225 | while ((noChanges > 0) && (noIterations < maxIterations)) | |
1226 | { | |
1227 | noChanges = 0; | |
1228 | noFailures = 0; | |
1229 | wxWindowList::Node *node = GetChildren().GetFirst(); | |
1230 | while (node) | |
1231 | { | |
1232 | wxWindow *child = node->GetData(); | |
34636400 | 1233 | if ( !child->IsTopLevel() ) |
f03fc89f VZ |
1234 | { |
1235 | wxLayoutConstraints *constr = child->GetConstraints(); | |
1236 | if ( constr ) | |
1237 | { | |
1238 | if ( !succeeded.Find(child) ) | |
1239 | { | |
1240 | int tempNoChanges = 0; | |
1241 | bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ; | |
1242 | noChanges += tempNoChanges; | |
1243 | if ( success ) | |
1244 | { | |
1245 | succeeded.Append(child); | |
1246 | } | |
1247 | } | |
1248 | } | |
1249 | } | |
1250 | node = node->GetNext(); | |
1251 | } | |
1252 | ||
1253 | noIterations++; | |
1254 | } | |
1255 | ||
1256 | return TRUE; | |
1257 | } | |
1258 | ||
1259 | void wxWindowBase::ResetConstraints() | |
1260 | { | |
1261 | wxLayoutConstraints *constr = GetConstraints(); | |
1262 | if ( constr ) | |
1263 | { | |
1264 | constr->left.SetDone(FALSE); | |
1265 | constr->top.SetDone(FALSE); | |
1266 | constr->right.SetDone(FALSE); | |
1267 | constr->bottom.SetDone(FALSE); | |
1268 | constr->width.SetDone(FALSE); | |
1269 | constr->height.SetDone(FALSE); | |
1270 | constr->centreX.SetDone(FALSE); | |
1271 | constr->centreY.SetDone(FALSE); | |
1272 | } | |
f1df0927 | 1273 | |
f03fc89f VZ |
1274 | wxWindowList::Node *node = GetChildren().GetFirst(); |
1275 | while (node) | |
1276 | { | |
1277 | wxWindow *win = node->GetData(); | |
34636400 | 1278 | if ( !win->IsTopLevel() ) |
f03fc89f VZ |
1279 | win->ResetConstraints(); |
1280 | node = node->GetNext(); | |
1281 | } | |
1282 | } | |
1283 | ||
1284 | // Need to distinguish between setting the 'fake' size for windows and sizers, | |
1285 | // and setting the real values. | |
1286 | void wxWindowBase::SetConstraintSizes(bool recurse) | |
1287 | { | |
1288 | wxLayoutConstraints *constr = GetConstraints(); | |
4b7f2165 | 1289 | if ( constr && constr->AreSatisfied() ) |
f03fc89f VZ |
1290 | { |
1291 | int x = constr->left.GetValue(); | |
1292 | int y = constr->top.GetValue(); | |
1293 | int w = constr->width.GetValue(); | |
1294 | int h = constr->height.GetValue(); | |
1295 | ||
f03fc89f | 1296 | if ( (constr->width.GetRelationship() != wxAsIs ) || |
3417c2cd | 1297 | (constr->height.GetRelationship() != wxAsIs) ) |
f03fc89f | 1298 | { |
3417c2cd | 1299 | SetSize(x, y, w, h); |
f03fc89f VZ |
1300 | } |
1301 | else | |
1302 | { | |
3417c2cd RR |
1303 | // If we don't want to resize this window, just move it... |
1304 | Move(x, y); | |
f03fc89f VZ |
1305 | } |
1306 | } | |
1307 | else if ( constr ) | |
1308 | { | |
4b7f2165 | 1309 | wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."), |
f1df0927 | 1310 | GetClassInfo()->GetClassName(), |
4b7f2165 | 1311 | GetName().c_str()); |
f03fc89f VZ |
1312 | } |
1313 | ||
1314 | if ( recurse ) | |
1315 | { | |
1316 | wxWindowList::Node *node = GetChildren().GetFirst(); | |
1317 | while (node) | |
1318 | { | |
1319 | wxWindow *win = node->GetData(); | |
e2f9212c | 1320 | if ( !win->IsTopLevel() && win->GetConstraints() ) |
f03fc89f VZ |
1321 | win->SetConstraintSizes(); |
1322 | node = node->GetNext(); | |
1323 | } | |
1324 | } | |
1325 | } | |
1326 | ||
f03fc89f VZ |
1327 | // Only set the size/position of the constraint (if any) |
1328 | void wxWindowBase::SetSizeConstraint(int x, int y, int w, int h) | |
1329 | { | |
1330 | wxLayoutConstraints *constr = GetConstraints(); | |
1331 | if ( constr ) | |
1332 | { | |
1333 | if ( x != -1 ) | |
1334 | { | |
1335 | constr->left.SetValue(x); | |
1336 | constr->left.SetDone(TRUE); | |
1337 | } | |
1338 | if ( y != -1 ) | |
1339 | { | |
1340 | constr->top.SetValue(y); | |
1341 | constr->top.SetDone(TRUE); | |
1342 | } | |
1343 | if ( w != -1 ) | |
1344 | { | |
1345 | constr->width.SetValue(w); | |
1346 | constr->width.SetDone(TRUE); | |
1347 | } | |
1348 | if ( h != -1 ) | |
1349 | { | |
1350 | constr->height.SetValue(h); | |
1351 | constr->height.SetDone(TRUE); | |
1352 | } | |
1353 | } | |
1354 | } | |
1355 | ||
1356 | void wxWindowBase::MoveConstraint(int x, int y) | |
1357 | { | |
1358 | wxLayoutConstraints *constr = GetConstraints(); | |
1359 | if ( constr ) | |
1360 | { | |
1361 | if ( x != -1 ) | |
1362 | { | |
1363 | constr->left.SetValue(x); | |
1364 | constr->left.SetDone(TRUE); | |
1365 | } | |
1366 | if ( y != -1 ) | |
1367 | { | |
1368 | constr->top.SetValue(y); | |
1369 | constr->top.SetDone(TRUE); | |
1370 | } | |
1371 | } | |
1372 | } | |
1373 | ||
1374 | void wxWindowBase::GetSizeConstraint(int *w, int *h) const | |
1375 | { | |
1376 | wxLayoutConstraints *constr = GetConstraints(); | |
1377 | if ( constr ) | |
1378 | { | |
1379 | *w = constr->width.GetValue(); | |
1380 | *h = constr->height.GetValue(); | |
1381 | } | |
1382 | else | |
1383 | GetSize(w, h); | |
1384 | } | |
1385 | ||
1386 | void wxWindowBase::GetClientSizeConstraint(int *w, int *h) const | |
1387 | { | |
1388 | wxLayoutConstraints *constr = GetConstraints(); | |
1389 | if ( constr ) | |
1390 | { | |
1391 | *w = constr->width.GetValue(); | |
1392 | *h = constr->height.GetValue(); | |
1393 | } | |
1394 | else | |
1395 | GetClientSize(w, h); | |
1396 | } | |
1397 | ||
a200c35e VS |
1398 | void wxWindowBase::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) |
1399 | { | |
1400 | // don't do it for the dialogs/frames - they float independently of their | |
1401 | // parent | |
1402 | if ( !IsTopLevel() ) | |
1403 | { | |
1404 | wxWindow *parent = GetParent(); | |
1405 | if ( !(sizeFlags & wxSIZE_NO_ADJUSTMENTS) && parent ) | |
1406 | { | |
1407 | wxPoint pt(parent->GetClientAreaOrigin()); | |
1408 | x += pt.x; | |
1409 | y += pt.y; | |
1410 | } | |
1411 | } | |
1412 | } | |
1413 | ||
1414 | ||
f03fc89f VZ |
1415 | void wxWindowBase::GetPositionConstraint(int *x, int *y) const |
1416 | { | |
1417 | wxLayoutConstraints *constr = GetConstraints(); | |
1418 | if ( constr ) | |
1419 | { | |
1420 | *x = constr->left.GetValue(); | |
1421 | *y = constr->top.GetValue(); | |
1422 | } | |
1423 | else | |
1424 | GetPosition(x, y); | |
1425 | } | |
1426 | ||
1427 | #endif // wxUSE_CONSTRAINTS | |
1428 | ||
1429 | // ---------------------------------------------------------------------------- | |
1430 | // do Update UI processing for child controls | |
1431 | // ---------------------------------------------------------------------------- | |
7ec1983b VZ |
1432 | |
1433 | // TODO: should this be implemented for the child window rather | |
1434 | // than the parent? Then you can override it e.g. for wxCheckBox | |
1435 | // to do the Right Thing rather than having to assume a fixed number | |
1436 | // of control classes. | |
f03fc89f | 1437 | void wxWindowBase::UpdateWindowUI() |
7ec1983b | 1438 | { |
1e6feb95 | 1439 | #if wxUSE_CONTROLS |
26bf1ce0 VZ |
1440 | wxUpdateUIEvent event(GetId()); |
1441 | event.m_eventObject = this; | |
1442 | ||
1443 | if ( GetEventHandler()->ProcessEvent(event) ) | |
7ec1983b | 1444 | { |
26bf1ce0 VZ |
1445 | if ( event.GetSetEnabled() ) |
1446 | Enable(event.GetEnabled()); | |
7ec1983b | 1447 | |
26bf1ce0 | 1448 | if ( event.GetSetText() ) |
f03fc89f | 1449 | { |
f7637829 | 1450 | wxControl *control = wxDynamicCastThis(wxControl); |
26bf1ce0 | 1451 | if ( control ) |
34636400 | 1452 | { |
1e6feb95 | 1453 | #if wxUSE_TEXTCTRL |
26bf1ce0 VZ |
1454 | wxTextCtrl *text = wxDynamicCast(control, wxTextCtrl); |
1455 | if ( text ) | |
1456 | text->SetValue(event.GetText()); | |
1457 | else | |
1e6feb95 | 1458 | #endif // wxUSE_TEXTCTRL |
34636400 VZ |
1459 | control->SetLabel(event.GetText()); |
1460 | } | |
26bf1ce0 | 1461 | } |
f03fc89f | 1462 | |
88ac883a | 1463 | #if wxUSE_CHECKBOX |
f7637829 | 1464 | wxCheckBox *checkbox = wxDynamicCastThis(wxCheckBox); |
26bf1ce0 VZ |
1465 | if ( checkbox ) |
1466 | { | |
1467 | if ( event.GetSetChecked() ) | |
1468 | checkbox->SetValue(event.GetChecked()); | |
1469 | } | |
88ac883a VZ |
1470 | #endif // wxUSE_CHECKBOX |
1471 | ||
b3402d0d | 1472 | #if wxUSE_RADIOBTN |
f7637829 | 1473 | wxRadioButton *radiobtn = wxDynamicCastThis(wxRadioButton); |
26bf1ce0 VZ |
1474 | if ( radiobtn ) |
1475 | { | |
1476 | if ( event.GetSetChecked() ) | |
1477 | radiobtn->SetValue(event.GetChecked()); | |
f03fc89f | 1478 | } |
b3402d0d | 1479 | #endif // wxUSE_RADIOBTN |
7ec1983b | 1480 | } |
1e6feb95 | 1481 | #endif // wxUSE_CONTROLS |
7ec1983b | 1482 | } |
fd71308f | 1483 | |
f03fc89f VZ |
1484 | // ---------------------------------------------------------------------------- |
1485 | // dialog units translations | |
1486 | // ---------------------------------------------------------------------------- | |
1487 | ||
1488 | wxPoint wxWindowBase::ConvertPixelsToDialog(const wxPoint& pt) | |
fd71308f JS |
1489 | { |
1490 | int charWidth = GetCharWidth(); | |
1491 | int charHeight = GetCharHeight(); | |
5d9c2818 RD |
1492 | wxPoint pt2(-1, -1); |
1493 | if (pt.x != -1) | |
1494 | pt2.x = (int) ((pt.x * 4) / charWidth) ; | |
1495 | if (pt.y != -1) | |
1496 | pt2.y = (int) ((pt.y * 8) / charHeight) ; | |
fd71308f JS |
1497 | |
1498 | return pt2; | |
1499 | } | |
1500 | ||
f03fc89f | 1501 | wxPoint wxWindowBase::ConvertDialogToPixels(const wxPoint& pt) |
fd71308f JS |
1502 | { |
1503 | int charWidth = GetCharWidth(); | |
1504 | int charHeight = GetCharHeight(); | |
5d9c2818 RD |
1505 | wxPoint pt2(-1, -1); |
1506 | if (pt.x != -1) | |
1507 | pt2.x = (int) ((pt.x * charWidth) / 4) ; | |
1508 | if (pt.y != -1) | |
1509 | pt2.y = (int) ((pt.y * charHeight) / 8) ; | |
fd71308f JS |
1510 | |
1511 | return pt2; | |
1512 | } | |
1513 | ||
f03fc89f VZ |
1514 | // ---------------------------------------------------------------------------- |
1515 | // event handlers | |
1516 | // ---------------------------------------------------------------------------- | |
1517 | ||
1518 | // propagate the colour change event to the subwindows | |
1519 | void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& event) | |
1520 | { | |
1521 | wxWindowList::Node *node = GetChildren().GetFirst(); | |
1522 | while ( node ) | |
1523 | { | |
1524 | // Only propagate to non-top-level windows | |
1525 | wxWindow *win = node->GetData(); | |
1526 | if ( !win->IsTopLevel() ) | |
1527 | { | |
1528 | wxSysColourChangedEvent event2; | |
1529 | event.m_eventObject = win; | |
1530 | win->GetEventHandler()->ProcessEvent(event2); | |
1531 | } | |
1532 | ||
1533 | node = node->GetNext(); | |
1534 | } | |
1535 | } | |
1536 | ||
1537 | // the default action is to populate dialog with data when it's created | |
1538 | void wxWindowBase::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) ) | |
1539 | { | |
1540 | TransferDataToWindow(); | |
1541 | } | |
1542 | ||
a02dc3e3 VZ |
1543 | // process Ctrl-Alt-mclick |
1544 | void wxWindowBase::OnMiddleClick( wxMouseEvent& event ) | |
1545 | { | |
1e6feb95 | 1546 | #if wxUSE_MSGDLG |
a02dc3e3 VZ |
1547 | if ( event.ControlDown() && event.AltDown() ) |
1548 | { | |
1549 | // don't translate these strings | |
1550 | wxString port; | |
1551 | switch ( wxGetOsVersion() ) | |
1552 | { | |
1553 | case wxMOTIF_X: port = _T("Motif"); break; | |
ff8fda36 GD |
1554 | case wxMAC: |
1555 | case wxMAC_DARWIN: port = _T("Mac"); break; | |
a02dc3e3 VZ |
1556 | case wxBEOS: port = _T("BeOS"); break; |
1557 | case wxGTK: | |
1558 | case wxGTK_WIN32: | |
1559 | case wxGTK_OS2: | |
1560 | case wxGTK_BEOS: port = _T("GTK"); break; | |
1561 | case wxWINDOWS: | |
1562 | case wxPENWINDOWS: | |
1563 | case wxWINDOWS_NT: | |
1564 | case wxWIN32S: | |
1565 | case wxWIN95: | |
1566 | case wxWIN386: port = _T("MS Windows"); break; | |
1567 | case wxMGL_UNIX: | |
1568 | case wxMGL_X: | |
1569 | case wxMGL_WIN32: | |
1570 | case wxMGL_OS2: port = _T("MGL"); break; | |
1571 | case wxWINDOWS_OS2: | |
1572 | case wxOS2_PM: port = _T("OS/2"); break; | |
1573 | default: port = _T("unknown"); break; | |
1574 | } | |
1575 | ||
1576 | wxMessageBox(wxString::Format( | |
1577 | _T( | |
3f562374 | 1578 | " wxWindows Library (%s port)\nVersion %u.%u.%u%s, compiled at %s %s\n Copyright (c) 1995-2001 wxWindows team" |
a02dc3e3 VZ |
1579 | ), |
1580 | port.c_str(), | |
1581 | wxMAJOR_VERSION, | |
1582 | wxMINOR_VERSION, | |
1583 | wxRELEASE_NUMBER, | |
3f562374 VZ |
1584 | #if wxUSE_UNICODE |
1585 | L" (Unicode)", | |
1586 | #else | |
1587 | "", | |
1588 | #endif | |
1589 | __TDATE__, | |
1590 | __TTIME__ | |
a02dc3e3 VZ |
1591 | ), |
1592 | _T("wxWindows information"), | |
1593 | wxICON_INFORMATION | wxOK, | |
1594 | (wxWindow *)this); | |
1595 | } | |
1596 | else | |
1e6feb95 | 1597 | #endif // wxUSE_MSGDLG |
a02dc3e3 VZ |
1598 | { |
1599 | event.Skip(); | |
1600 | } | |
1601 | } | |
1602 | ||
f03fc89f VZ |
1603 | // ---------------------------------------------------------------------------- |
1604 | // list classes implementation | |
1605 | // ---------------------------------------------------------------------------- | |
1606 | ||
1607 | void wxWindowListNode::DeleteData() | |
1608 | { | |
1609 | delete (wxWindow *)GetData(); | |
1610 | } | |
1611 | ||
1e6feb95 VZ |
1612 | // ---------------------------------------------------------------------------- |
1613 | // borders | |
1614 | // ---------------------------------------------------------------------------- | |
1615 | ||
1616 | wxBorder wxWindowBase::GetBorder() const | |
1617 | { | |
1618 | wxBorder border = (wxBorder)(m_windowStyle & wxBORDER_MASK); | |
1619 | if ( border == wxBORDER_DEFAULT ) | |
1620 | { | |
1621 | border = GetDefaultBorder(); | |
1622 | } | |
1623 | ||
1624 | return border; | |
1625 | } | |
1626 | ||
1627 | wxBorder wxWindowBase::GetDefaultBorder() const | |
1628 | { | |
1629 | return wxBORDER_NONE; | |
1630 | } | |
1631 | ||
1632 | // ---------------------------------------------------------------------------- | |
1633 | // hit testing | |
1634 | // ---------------------------------------------------------------------------- | |
1635 | ||
1636 | wxHitTest wxWindowBase::DoHitTest(wxCoord x, wxCoord y) const | |
1637 | { | |
1638 | // here we just check if the point is inside the window or not | |
1639 | ||
1640 | // check the top and left border first | |
1641 | bool outside = x < 0 || y < 0; | |
1642 | if ( !outside ) | |
1643 | { | |
1644 | // check the right and bottom borders too | |
1645 | wxSize size = GetSize(); | |
1646 | outside = x >= size.x || y >= size.y; | |
1647 | } | |
1648 | ||
1649 | return outside ? wxHT_WINDOW_OUTSIDE : wxHT_WINDOW_INSIDE; | |
1650 | } | |
1651 | ||
94633ad9 VZ |
1652 | // ---------------------------------------------------------------------------- |
1653 | // mouse capture | |
1654 | // ---------------------------------------------------------------------------- | |
1655 | ||
1656 | struct WXDLLEXPORT wxWindowNext | |
1657 | { | |
1658 | wxWindow *win; | |
1659 | wxWindowNext *next; | |
786646f3 | 1660 | } *wxWindowBase::ms_winCaptureNext = NULL; |
94633ad9 | 1661 | |
a83e1475 | 1662 | void wxWindowBase::CaptureMouse() |
94633ad9 VZ |
1663 | { |
1664 | wxLogTrace(_T("mousecapture"), _T("CaptureMouse(0x%08x)"), this); | |
349d1942 | 1665 | |
94633ad9 VZ |
1666 | wxWindow *winOld = GetCapture(); |
1667 | if ( winOld ) | |
1668 | { | |
1669 | // save it on stack | |
1670 | wxWindowNext *item = new wxWindowNext; | |
1671 | item->win = winOld; | |
1672 | item->next = ms_winCaptureNext; | |
1673 | ms_winCaptureNext = item; | |
1674 | } | |
1675 | //else: no mouse capture to save | |
1676 | ||
1677 | DoCaptureMouse(); | |
1678 | } | |
1679 | ||
a83e1475 | 1680 | void wxWindowBase::ReleaseMouse() |
94633ad9 | 1681 | { |
349d1942 VS |
1682 | wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(0x%08x)"), this); |
1683 | ||
a7b09001 VS |
1684 | wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") ) |
1685 | ||
94633ad9 VZ |
1686 | DoReleaseMouse(); |
1687 | ||
1688 | if ( ms_winCaptureNext ) | |
1689 | { | |
1690 | ms_winCaptureNext->win->CaptureMouse(); | |
1691 | ||
1692 | wxWindowNext *item = ms_winCaptureNext; | |
1693 | ms_winCaptureNext = item->next; | |
1694 | delete item; | |
1695 | } | |
1696 | //else: stack is empty, no previous capture | |
1697 | ||
1698 | wxLogTrace(_T("mousecapture"), | |
1699 | _T("After ReleaseMouse() mouse is captured by 0x%08x"), | |
1700 | GetCapture()); | |
1701 | } | |
1702 |