]>
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 |
55d99c7a | 9 | // Licence: wxWindows licence |
7ec1983b VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
f03fc89f VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
f701d7ab | 19 | |
14f355c2 | 20 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
58654ed0 VZ |
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" | |
106844da | 41 | #include "wx/statbox.h" |
26bf1ce0 | 42 | #include "wx/textctrl.h" |
f03fc89f VZ |
43 | #include "wx/settings.h" |
44 | #include "wx/dialog.h" | |
a02dc3e3 | 45 | #include "wx/msgdlg.h" |
a37a5a73 | 46 | #include "wx/statusbr.h" |
ed39ff57 | 47 | #include "wx/dcclient.h" |
f03fc89f VZ |
48 | #endif //WX_PRECOMP |
49 | ||
50 | #if wxUSE_CONSTRAINTS | |
51 | #include "wx/layout.h" | |
52 | #endif // wxUSE_CONSTRAINTS | |
53 | ||
461e93f9 JS |
54 | #include "wx/sizer.h" |
55 | ||
f03fc89f VZ |
56 | #if wxUSE_DRAG_AND_DROP |
57 | #include "wx/dnd.h" | |
58 | #endif // wxUSE_DRAG_AND_DROP | |
59 | ||
ed5317e5 | 60 | #if wxUSE_ACCESSIBILITY |
7de59551 | 61 | #include "wx/access.h" |
ed5317e5 JS |
62 | #endif |
63 | ||
bd83cb56 VZ |
64 | #if wxUSE_HELP |
65 | #include "wx/cshelp.h" | |
66 | #endif // wxUSE_HELP | |
67 | ||
f03fc89f VZ |
68 | #if wxUSE_TOOLTIPS |
69 | #include "wx/tooltip.h" | |
70 | #endif // wxUSE_TOOLTIPS | |
71 | ||
789295bf VZ |
72 | #if wxUSE_CARET |
73 | #include "wx/caret.h" | |
74 | #endif // wxUSE_CARET | |
75 | ||
f03fc89f VZ |
76 | // ---------------------------------------------------------------------------- |
77 | // static data | |
78 | // ---------------------------------------------------------------------------- | |
79 | ||
edd802c6 DW |
80 | #if defined(__WXPM__) |
81 | int wxWindowBase::ms_lastControlId = 2000; | |
82 | #else | |
42e69d6b | 83 | int wxWindowBase::ms_lastControlId = -200; |
edd802c6 | 84 | #endif |
f03fc89f VZ |
85 | |
86 | IMPLEMENT_ABSTRACT_CLASS(wxWindowBase, wxEvtHandler) | |
87 | ||
88 | // ---------------------------------------------------------------------------- | |
89 | // event table | |
90 | // ---------------------------------------------------------------------------- | |
91 | ||
92 | BEGIN_EVENT_TABLE(wxWindowBase, wxEvtHandler) | |
93 | EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged) | |
94 | EVT_INIT_DIALOG(wxWindowBase::OnInitDialog) | |
a02dc3e3 | 95 | EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick) |
bd83cb56 VZ |
96 | |
97 | #if wxUSE_HELP | |
e11f4636 | 98 | EVT_HELP(wxID_ANY, wxWindowBase::OnHelp) |
bd83cb56 VZ |
99 | #endif // wxUSE_HELP |
100 | ||
f03fc89f VZ |
101 | END_EVENT_TABLE() |
102 | ||
103 | // ============================================================================ | |
104 | // implementation of the common functionality of the wxWindow class | |
105 | // ============================================================================ | |
106 | ||
107 | // ---------------------------------------------------------------------------- | |
108 | // initialization | |
109 | // ---------------------------------------------------------------------------- | |
110 | ||
111 | // the default initialization | |
72795335 | 112 | wxWindowBase::wxWindowBase() |
f03fc89f VZ |
113 | { |
114 | // no window yet, no parent nor children | |
f03fc89f | 115 | m_parent = (wxWindow *)NULL; |
e11f4636 | 116 | m_windowId = wxID_ANY; |
f03fc89f VZ |
117 | |
118 | // no constraints on the minimal window size | |
119 | m_minWidth = | |
120 | m_minHeight = | |
121 | m_maxWidth = | |
122 | m_maxHeight = -1; | |
123 | ||
eefe6d4b VZ |
124 | // window are created enabled and visible by default |
125 | m_isShown = | |
e11f4636 | 126 | m_isEnabled = true; |
f03fc89f | 127 | |
f03fc89f VZ |
128 | // the default event handler is just this window |
129 | m_eventHandler = this; | |
130 | ||
88ac883a | 131 | #if wxUSE_VALIDATORS |
f03fc89f VZ |
132 | // no validator |
133 | m_windowValidator = (wxValidator *) NULL; | |
88ac883a | 134 | #endif // wxUSE_VALIDATORS |
f03fc89f VZ |
135 | |
136 | // use the system default colours | |
a756f210 VS |
137 | m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE); |
138 | m_foregroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); | |
f6e4e9ea | 139 | |
8bf30fe9 VZ |
140 | // don't set the font here for wxMSW as we don't call WM_SETFONT here and |
141 | // so the font is *not* really set - but calls to SetFont() later won't do | |
142 | // anything because m_font appears to be already set! | |
143 | #ifndef __WXMSW__ | |
a756f210 | 144 | m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); |
8bf30fe9 | 145 | #endif // __WXMSW__ |
807a903e | 146 | |
08df3e44 VZ |
147 | // the colours/fonts are default for now |
148 | m_hasBgCol = | |
149 | m_hasFgCol = | |
e11f4636 DS |
150 | m_hasFont = false; |
151 | ||
152 | m_isBeingDeleted = false; | |
08df3e44 | 153 | |
f03fc89f | 154 | // no style bits |
d80cd92a | 155 | m_exStyle = |
f03fc89f VZ |
156 | m_windowStyle = 0; |
157 | ||
f03fc89f VZ |
158 | #if wxUSE_CONSTRAINTS |
159 | // no constraints whatsoever | |
160 | m_constraints = (wxLayoutConstraints *) NULL; | |
161 | m_constraintsInvolvedIn = (wxWindowList *) NULL; | |
461e93f9 JS |
162 | #endif // wxUSE_CONSTRAINTS |
163 | ||
f03fc89f | 164 | m_windowSizer = (wxSizer *) NULL; |
be90c029 | 165 | m_containingSizer = (wxSizer *) NULL; |
e11f4636 | 166 | m_autoLayout = false; |
f03fc89f VZ |
167 | |
168 | #if wxUSE_DRAG_AND_DROP | |
169 | m_dropTarget = (wxDropTarget *)NULL; | |
170 | #endif // wxUSE_DRAG_AND_DROP | |
171 | ||
172 | #if wxUSE_TOOLTIPS | |
173 | m_tooltip = (wxToolTip *)NULL; | |
174 | #endif // wxUSE_TOOLTIPS | |
789295bf VZ |
175 | |
176 | #if wxUSE_CARET | |
177 | m_caret = (wxCaret *)NULL; | |
178 | #endif // wxUSE_CARET | |
a2d93e73 | 179 | |
574c939e | 180 | #if wxUSE_PALETTE |
e11f4636 | 181 | m_hasCustomPalette = false; |
574c939e KB |
182 | #endif // wxUSE_PALETTE |
183 | ||
ed5317e5 JS |
184 | #if wxUSE_ACCESSIBILITY |
185 | m_accessible = NULL; | |
186 | #endif | |
187 | ||
566d84a7 | 188 | m_virtualSize = wxDefaultSize; |
69d90995 | 189 | |
1e2a653b VZ |
190 | m_minVirtualWidth = |
191 | m_minVirtualHeight = | |
192 | m_maxVirtualWidth = | |
566d84a7 RL |
193 | m_maxVirtualHeight = -1; |
194 | ||
89440652 | 195 | m_windowVariant = wxWINDOW_VARIANT_NORMAL ; |
69d90995 | 196 | |
a2d93e73 | 197 | // Whether we're using the current theme for this window (wxGTK only for now) |
e11f4636 | 198 | m_themeEnabled = false; |
f03fc89f VZ |
199 | } |
200 | ||
201 | // common part of window creation process | |
202 | bool wxWindowBase::CreateBase(wxWindowBase *parent, | |
203 | wxWindowID id, | |
74e3313b VZ |
204 | const wxPoint& WXUNUSED(pos), |
205 | const wxSize& WXUNUSED(size), | |
f03fc89f | 206 | long style, |
ac8d0c11 | 207 | const wxValidator& wxVALIDATOR_PARAM(validator), |
f03fc89f VZ |
208 | const wxString& name) |
209 | { | |
106844da VZ |
210 | #if wxUSE_STATBOX |
211 | // wxGTK doesn't allow to create controls with static box as the parent so | |
212 | // this will result in a crash when the program is ported to wxGTK so warn | |
213 | // the user about it | |
214 | ||
215 | // if you get this assert, the correct solution is to create the controls | |
216 | // as siblings of the static box | |
217 | wxASSERT_MSG( !parent || !wxDynamicCast(parent, wxStaticBox), | |
218 | _T("wxStaticBox can't be used as a window parent!") ); | |
219 | #endif // wxUSE_STATBOX | |
220 | ||
925f154d VZ |
221 | // ids are limited to 16 bits under MSW so if you care about portability, |
222 | // it's not a good idea to use ids out of this range (and negative ids are | |
223 | // reserved for wxWindows own usage) | |
224 | wxASSERT_MSG( id == wxID_ANY || (id >= 0 && id < 32767), | |
225 | _T("invalid id value") ); | |
226 | ||
f03fc89f | 227 | // generate a new id if the user doesn't care about it |
925f154d | 228 | m_windowId = id == wxID_ANY ? NewControlId() : id; |
f03fc89f VZ |
229 | |
230 | SetName(name); | |
231 | SetWindowStyleFlag(style); | |
232 | SetParent(parent); | |
674ac8b9 VZ |
233 | |
234 | #if wxUSE_VALIDATORS | |
8d99be5f | 235 | SetValidator(validator); |
674ac8b9 | 236 | #endif // wxUSE_VALIDATORS |
f03fc89f | 237 | |
8ae6ce07 VZ |
238 | // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to |
239 | // have it too - like this it's possible to set it only in the top level | |
240 | // dialog/frame and all children will inherit it by defult | |
241 | if ( parent && (parent->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) ) | |
242 | { | |
9cb98d89 | 243 | SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY); |
8ae6ce07 VZ |
244 | } |
245 | ||
e11f4636 | 246 | return true; |
f03fc89f VZ |
247 | } |
248 | ||
249 | // ---------------------------------------------------------------------------- | |
250 | // destruction | |
251 | // ---------------------------------------------------------------------------- | |
252 | ||
253 | // common clean up | |
254 | wxWindowBase::~wxWindowBase() | |
255 | { | |
349d1942 VS |
256 | wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") ); |
257 | ||
f03fc89f VZ |
258 | // FIXME if these 2 cases result from programming errors in the user code |
259 | // we should probably assert here instead of silently fixing them | |
260 | ||
261 | // Just in case the window has been Closed, but we're then deleting | |
262 | // immediately: don't leave dangling pointers. | |
263 | wxPendingDelete.DeleteObject(this); | |
264 | ||
265 | // Just in case we've loaded a top-level window via LoadNativeDialog but | |
266 | // we weren't a dialog class | |
222ed1d6 | 267 | wxTopLevelWindows.DeleteObject((wxWindow*)this); |
a23fd0e1 | 268 | |
223d09f6 | 269 | wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") ); |
f03fc89f | 270 | |
8e35ab96 VZ |
271 | // reset the dangling pointer our parent window may keep to us |
272 | if ( m_parent ) | |
273 | { | |
274 | if ( m_parent->GetDefaultItem() == this ) | |
275 | { | |
276 | m_parent->SetDefaultItem(NULL); | |
277 | } | |
278 | ||
279 | m_parent->RemoveChild(this); | |
280 | } | |
281 | ||
789295bf | 282 | #if wxUSE_CARET |
a2b436fb | 283 | delete m_caret; |
789295bf VZ |
284 | #endif // wxUSE_CARET |
285 | ||
88ac883a | 286 | #if wxUSE_VALIDATORS |
a2b436fb | 287 | delete m_windowValidator; |
88ac883a | 288 | #endif // wxUSE_VALIDATORS |
f03fc89f | 289 | |
f03fc89f VZ |
290 | #if wxUSE_CONSTRAINTS |
291 | // Have to delete constraints/sizer FIRST otherwise sizers may try to look | |
292 | // at deleted windows as they delete themselves. | |
293 | DeleteRelatedConstraints(); | |
294 | ||
295 | if ( m_constraints ) | |
296 | { | |
297 | // This removes any dangling pointers to this window in other windows' | |
298 | // constraintsInvolvedIn lists. | |
299 | UnsetConstraints(m_constraints); | |
300 | delete m_constraints; | |
301 | m_constraints = NULL; | |
302 | } | |
461e93f9 JS |
303 | #endif // wxUSE_CONSTRAINTS |
304 | ||
be90c029 | 305 | if ( m_containingSizer ) |
12a3f227 | 306 | m_containingSizer->Detach( (wxWindow*)this ); |
be90c029 | 307 | |
a2b436fb | 308 | delete m_windowSizer; |
f03fc89f | 309 | |
f03fc89f | 310 | #if wxUSE_DRAG_AND_DROP |
a2b436fb | 311 | delete m_dropTarget; |
f03fc89f VZ |
312 | #endif // wxUSE_DRAG_AND_DROP |
313 | ||
314 | #if wxUSE_TOOLTIPS | |
a2b436fb | 315 | delete m_tooltip; |
f03fc89f | 316 | #endif // wxUSE_TOOLTIPS |
b0ee47ff | 317 | |
ed5317e5 | 318 | #if wxUSE_ACCESSIBILITY |
a2b436fb | 319 | delete m_accessible; |
ed5317e5 | 320 | #endif |
f03fc89f VZ |
321 | } |
322 | ||
323 | bool wxWindowBase::Destroy() | |
324 | { | |
325 | delete this; | |
326 | ||
e11f4636 | 327 | return true; |
f03fc89f VZ |
328 | } |
329 | ||
330 | bool wxWindowBase::Close(bool force) | |
331 | { | |
332 | wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); | |
333 | event.SetEventObject(this); | |
f03fc89f VZ |
334 | event.SetCanVeto(!force); |
335 | ||
e11f4636 | 336 | // return false if window wasn't closed because the application vetoed the |
f03fc89f VZ |
337 | // close event |
338 | return GetEventHandler()->ProcessEvent(event) && !event.GetVeto(); | |
339 | } | |
340 | ||
341 | bool wxWindowBase::DestroyChildren() | |
342 | { | |
222ed1d6 | 343 | wxWindowList::compatibility_iterator node; |
a23fd0e1 | 344 | for ( ;; ) |
f03fc89f | 345 | { |
a23fd0e1 VZ |
346 | // we iterate until the list becomes empty |
347 | node = GetChildren().GetFirst(); | |
348 | if ( !node ) | |
349 | break; | |
350 | ||
f03fc89f | 351 | wxWindow *child = node->GetData(); |
a23fd0e1 | 352 | |
f303564d VZ |
353 | // note that we really want to call delete and not ->Destroy() here |
354 | // because we want to delete the child immediately, before we are | |
355 | // deleted, and delayed deletion would result in problems as our (top | |
356 | // level) child could outlive its parent | |
357 | delete child; | |
a23fd0e1 VZ |
358 | |
359 | wxASSERT_MSG( !GetChildren().Find(child), | |
223d09f6 | 360 | wxT("child didn't remove itself using RemoveChild()") ); |
f03fc89f VZ |
361 | } |
362 | ||
e11f4636 | 363 | return true; |
f03fc89f VZ |
364 | } |
365 | ||
366 | // ---------------------------------------------------------------------------- | |
f68586e5 | 367 | // size/position related methods |
f03fc89f VZ |
368 | // ---------------------------------------------------------------------------- |
369 | ||
370 | // centre the window with respect to its parent in either (or both) directions | |
371 | void wxWindowBase::Centre(int direction) | |
372 | { | |
f6bcfd97 BP |
373 | // the position/size of the parent window or of the entire screen |
374 | wxPoint posParent; | |
f03fc89f VZ |
375 | int widthParent, heightParent; |
376 | ||
f6bcfd97 BP |
377 | wxWindow *parent = NULL; |
378 | ||
379 | if ( !(direction & wxCENTRE_ON_SCREEN) ) | |
f03fc89f | 380 | { |
f6bcfd97 BP |
381 | // find the parent to centre this window on: it should be the |
382 | // immediate parent for the controls but the top level parent for the | |
383 | // top level windows (like dialogs) | |
384 | parent = GetParent(); | |
385 | if ( IsTopLevel() ) | |
386 | { | |
387 | while ( parent && !parent->IsTopLevel() ) | |
388 | { | |
389 | parent = parent->GetParent(); | |
390 | } | |
391 | } | |
392 | ||
e28b0102 VZ |
393 | // there is no wxTopLevelWindow under wxMotif yet |
394 | #ifndef __WXMOTIF__ | |
085ad686 VZ |
395 | // we shouldn't center the dialog on the iconized window: under |
396 | // Windows, for example, this places it completely off the screen | |
397 | if ( parent ) | |
398 | { | |
399 | wxTopLevelWindow *winTop = wxDynamicCast(parent, wxTopLevelWindow); | |
400 | if ( winTop && winTop->IsIconized() ) | |
401 | { | |
402 | parent = NULL; | |
403 | } | |
404 | } | |
e28b0102 | 405 | #endif // __WXMOTIF__ |
085ad686 | 406 | |
f6bcfd97 BP |
407 | // did we find the parent? |
408 | if ( !parent ) | |
409 | { | |
410 | // no other choice | |
411 | direction |= wxCENTRE_ON_SCREEN; | |
412 | } | |
f03fc89f | 413 | } |
10fcf31a VZ |
414 | |
415 | if ( direction & wxCENTRE_ON_SCREEN ) | |
f03fc89f VZ |
416 | { |
417 | // centre with respect to the whole screen | |
418 | wxDisplaySize(&widthParent, &heightParent); | |
419 | } | |
10fcf31a VZ |
420 | else |
421 | { | |
f6bcfd97 BP |
422 | if ( IsTopLevel() ) |
423 | { | |
424 | // centre on the parent | |
425 | parent->GetSize(&widthParent, &heightParent); | |
426 | ||
427 | // adjust to the parents position | |
428 | posParent = parent->GetPosition(); | |
429 | } | |
430 | else | |
431 | { | |
432 | // centre inside the parents client rectangle | |
433 | parent->GetClientSize(&widthParent, &heightParent); | |
434 | } | |
10fcf31a | 435 | } |
f03fc89f VZ |
436 | |
437 | int width, height; | |
438 | GetSize(&width, &height); | |
439 | ||
c39eda94 VZ |
440 | int xNew = -1, |
441 | yNew = -1; | |
f03fc89f VZ |
442 | |
443 | if ( direction & wxHORIZONTAL ) | |
c39eda94 | 444 | xNew = (widthParent - width)/2; |
f03fc89f VZ |
445 | |
446 | if ( direction & wxVERTICAL ) | |
c39eda94 | 447 | yNew = (heightParent - height)/2; |
f03fc89f | 448 | |
f6bcfd97 BP |
449 | xNew += posParent.x; |
450 | yNew += posParent.y; | |
7631a292 | 451 | |
ef397583 GT |
452 | // Base size of the visible dimensions of the display |
453 | // to take into account the taskbar | |
454 | wxRect rect = wxGetClientDisplayRect(); | |
455 | wxSize size (rect.width,rect.height); | |
456 | ||
ede7020a VS |
457 | // NB: in wxMSW, negative position may not neccessary mean "out of screen", |
458 | // but it may mean that the window is placed on other than the main | |
459 | // display. Therefore we only make sure centered window is on the main display | |
460 | // if the parent is at least partially present here. | |
461 | if (posParent.x + widthParent >= 0) // if parent is (partially) on the main display | |
ef397583 GT |
462 | { |
463 | if (xNew < 0) | |
464 | xNew = 0; | |
465 | else if (xNew+width > size.x) | |
466 | xNew = size.x-width-1; | |
467 | } | |
ede7020a | 468 | if (posParent.y + heightParent >= 0) // if parent is (partially) on the main display |
ef397583 GT |
469 | { |
470 | if (yNew+height > size.y) | |
471 | yNew = size.y-height-1; | |
472 | ||
473 | // Make certain that the title bar is initially visible | |
474 | // always, even if this would push the bottom of the | |
475 | // dialog of the visible area of the display | |
476 | if (yNew < 0) | |
477 | yNew = 0; | |
478 | } | |
479 | ||
0fff366e VZ |
480 | // move the window to this position (keeping the old size but using |
481 | // SetSize() and not Move() to allow xNew and/or yNew to be -1) | |
db89aa76 | 482 | SetSize(xNew, yNew, width, height, wxSIZE_ALLOW_MINUS_ONE); |
7631a292 RD |
483 | } |
484 | ||
f03fc89f VZ |
485 | // fits the window around the children |
486 | void wxWindowBase::Fit() | |
487 | { | |
f68586e5 VZ |
488 | if ( GetChildren().GetCount() > 0 ) |
489 | { | |
ec5bb70d | 490 | SetClientSize(DoGetBestSize()); |
f68586e5 VZ |
491 | } |
492 | //else: do nothing if we have no children | |
493 | } | |
f03fc89f | 494 | |
2b5f62a0 VZ |
495 | // fits virtual size (ie. scrolled area etc.) around children |
496 | void wxWindowBase::FitInside() | |
497 | { | |
498 | if ( GetChildren().GetCount() > 0 ) | |
499 | { | |
500 | SetVirtualSize( GetBestVirtualSize() ); | |
501 | } | |
502 | } | |
503 | ||
f68586e5 VZ |
504 | // return the size best suited for the current window |
505 | wxSize wxWindowBase::DoGetBestSize() const | |
506 | { | |
ec5bb70d VZ |
507 | if ( m_windowSizer ) |
508 | { | |
509 | return m_windowSizer->GetMinSize(); | |
510 | } | |
511 | #if wxUSE_CONSTRAINTS | |
512 | else if ( m_constraints ) | |
513 | { | |
514 | wxConstCast(this, wxWindowBase)->SatisfyConstraints(); | |
515 | ||
516 | // our minimal acceptable size is such that all our windows fit inside | |
517 | int maxX = 0, | |
518 | maxY = 0; | |
519 | ||
222ed1d6 | 520 | for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
ec5bb70d VZ |
521 | node; |
522 | node = node->GetNext() ) | |
523 | { | |
524 | wxLayoutConstraints *c = node->GetData()->GetConstraints(); | |
525 | if ( !c ) | |
526 | { | |
527 | // it's not normal that we have an unconstrained child, but | |
528 | // what can we do about it? | |
529 | continue; | |
530 | } | |
531 | ||
532 | int x = c->right.GetValue(), | |
533 | y = c->bottom.GetValue(); | |
534 | ||
535 | if ( x > maxX ) | |
536 | maxX = x; | |
537 | ||
538 | if ( y > maxY ) | |
539 | maxY = y; | |
540 | ||
541 | // TODO: we must calculate the overlaps somehow, otherwise we | |
542 | // will never return a size bigger than the current one :-( | |
543 | } | |
544 | ||
545 | return wxSize(maxX, maxY); | |
546 | } | |
547 | #endif // wxUSE_CONSTRAINTS | |
548 | else if ( GetChildren().GetCount() > 0 ) | |
f03fc89f | 549 | { |
f68586e5 VZ |
550 | // our minimal acceptable size is such that all our windows fit inside |
551 | int maxX = 0, | |
552 | maxY = 0; | |
553 | ||
222ed1d6 | 554 | for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
f68586e5 VZ |
555 | node; |
556 | node = node->GetNext() ) | |
42e69d6b | 557 | { |
f68586e5 | 558 | wxWindow *win = node->GetData(); |
1e6feb95 VZ |
559 | if ( win->IsTopLevel() |
560 | #if wxUSE_STATUSBAR | |
561 | || wxDynamicCast(win, wxStatusBar) | |
562 | #endif // wxUSE_STATUSBAR | |
563 | ) | |
f68586e5 VZ |
564 | { |
565 | // dialogs and frames lie in different top level windows - | |
7d9fd004 VZ |
566 | // don't deal with them here; as for the status bars, they |
567 | // don't lie in the client area at all | |
f68586e5 VZ |
568 | continue; |
569 | } | |
570 | ||
571 | int wx, wy, ww, wh; | |
572 | win->GetPosition(&wx, &wy); | |
3f5513f5 VZ |
573 | |
574 | // if the window hadn't been positioned yet, assume that it is in | |
575 | // the origin | |
576 | if ( wx == -1 ) | |
577 | wx = 0; | |
578 | if ( wy == -1 ) | |
579 | wy = 0; | |
580 | ||
f68586e5 VZ |
581 | win->GetSize(&ww, &wh); |
582 | if ( wx + ww > maxX ) | |
583 | maxX = wx + ww; | |
584 | if ( wy + wh > maxY ) | |
585 | maxY = wy + wh; | |
42e69d6b VZ |
586 | } |
587 | ||
ec5bb70d VZ |
588 | // for compatibility with the old versions and because it really looks |
589 | // slightly more pretty like this, add a pad | |
590 | maxX += 7; | |
591 | maxY += 14; | |
592 | ||
ba81034d | 593 | return wxSize(maxX, maxY); |
f68586e5 VZ |
594 | } |
595 | else | |
596 | { | |
597 | // for a generic window there is no natural best size - just use the | |
598 | // current one | |
599 | return GetSize(); | |
f03fc89f | 600 | } |
f03fc89f VZ |
601 | } |
602 | ||
1e6feb95 VZ |
603 | // by default the origin is not shifted |
604 | wxPoint wxWindowBase::GetClientAreaOrigin() const | |
605 | { | |
606 | return wxPoint(0, 0); | |
607 | } | |
608 | ||
f03fc89f | 609 | // set the min/max size of the window |
f03fc89f VZ |
610 | void wxWindowBase::SetSizeHints(int minW, int minH, |
611 | int maxW, int maxH, | |
612 | int WXUNUSED(incW), int WXUNUSED(incH)) | |
613 | { | |
e587e144 VZ |
614 | // setting min width greater than max width leads to infinite loops under |
615 | // X11 and generally doesn't make any sense, so don't allow it | |
616 | wxCHECK_RET( (minW == -1 || maxW == -1 || minW <= maxW) && | |
77b0d411 | 617 | (minH == -1 || maxH == -1 || minH <= maxH), |
e587e144 VZ |
618 | _T("min width/height must be less than max width/height!") ); |
619 | ||
f03fc89f VZ |
620 | m_minWidth = minW; |
621 | m_maxWidth = maxW; | |
622 | m_minHeight = minH; | |
623 | m_maxHeight = maxH; | |
624 | } | |
625 | ||
69d90995 SC |
626 | void wxWindowBase::SetWindowVariant( wxWindowVariant variant ) |
627 | { | |
628 | if ( m_windowVariant == variant ) | |
629 | return ; | |
630 | ||
631 | m_windowVariant = variant ; | |
632 | ||
633 | DoSetWindowVariant( variant ) ; | |
634 | return ; | |
635 | } | |
636 | ||
637 | void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant ) | |
638 | { | |
639 | wxFont font = wxSystemSettings::GetSystemFont( wxSYS_DEFAULT_GUI_FONT ) ; | |
640 | int size = font.GetPointSize() ; | |
641 | switch ( variant ) | |
642 | { | |
643 | case wxWINDOW_VARIANT_NORMAL : | |
644 | break ; | |
645 | case wxWINDOW_VARIANT_SMALL : | |
646 | font.SetPointSize( size * 3 / 4 ) ; | |
647 | break ; | |
648 | case wxWINDOW_VARIANT_MINI : | |
649 | font.SetPointSize( size * 2 / 3 ) ; | |
650 | break ; | |
651 | case wxWINDOW_VARIANT_LARGE : | |
652 | font.SetPointSize( size * 5 / 4 ) ; | |
653 | break ; | |
69d90995 SC |
654 | default: |
655 | wxFAIL_MSG(_T("unexpected window variant")); | |
656 | break ; | |
657 | } | |
658 | SetFont( font ) ; | |
659 | } | |
660 | ||
566d84a7 RL |
661 | void wxWindowBase::SetVirtualSizeHints( int minW, int minH, |
662 | int maxW, int maxH ) | |
663 | { | |
664 | m_minVirtualWidth = minW; | |
665 | m_maxVirtualWidth = maxW; | |
666 | m_minVirtualHeight = minH; | |
667 | m_maxVirtualHeight = maxH; | |
566d84a7 RL |
668 | } |
669 | ||
670 | void wxWindowBase::DoSetVirtualSize( int x, int y ) | |
671 | { | |
1e2a653b VZ |
672 | if ( m_minVirtualWidth != -1 && m_minVirtualWidth > x ) |
673 | x = m_minVirtualWidth; | |
674 | if ( m_maxVirtualWidth != -1 && m_maxVirtualWidth < x ) | |
675 | x = m_maxVirtualWidth; | |
676 | if ( m_minVirtualHeight != -1 && m_minVirtualHeight > y ) | |
677 | y = m_minVirtualHeight; | |
678 | if ( m_maxVirtualHeight != -1 && m_maxVirtualHeight < y ) | |
679 | y = m_maxVirtualHeight; | |
680 | ||
681 | m_virtualSize = wxSize(x, y); | |
566d84a7 RL |
682 | } |
683 | ||
684 | wxSize wxWindowBase::DoGetVirtualSize() const | |
685 | { | |
686 | wxSize s( GetClientSize() ); | |
687 | ||
150c8d89 RL |
688 | return wxSize( wxMax( m_virtualSize.GetWidth(), s.GetWidth() ), |
689 | wxMax( m_virtualSize.GetHeight(), s.GetHeight() ) ); | |
566d84a7 RL |
690 | } |
691 | ||
f03fc89f VZ |
692 | // ---------------------------------------------------------------------------- |
693 | // show/hide/enable/disable the window | |
694 | // ---------------------------------------------------------------------------- | |
695 | ||
696 | bool wxWindowBase::Show(bool show) | |
697 | { | |
698 | if ( show != m_isShown ) | |
699 | { | |
700 | m_isShown = show; | |
701 | ||
e11f4636 | 702 | return true; |
f03fc89f VZ |
703 | } |
704 | else | |
705 | { | |
e11f4636 | 706 | return false; |
f03fc89f VZ |
707 | } |
708 | } | |
709 | ||
710 | bool wxWindowBase::Enable(bool enable) | |
711 | { | |
712 | if ( enable != m_isEnabled ) | |
713 | { | |
714 | m_isEnabled = enable; | |
715 | ||
e11f4636 | 716 | return true; |
f03fc89f VZ |
717 | } |
718 | else | |
719 | { | |
e11f4636 | 720 | return false; |
f03fc89f VZ |
721 | } |
722 | } | |
34636400 VZ |
723 | // ---------------------------------------------------------------------------- |
724 | // RTTI | |
725 | // ---------------------------------------------------------------------------- | |
726 | ||
727 | bool wxWindowBase::IsTopLevel() const | |
728 | { | |
e11f4636 | 729 | return false; |
34636400 | 730 | } |
f03fc89f VZ |
731 | |
732 | // ---------------------------------------------------------------------------- | |
733 | // reparenting the window | |
734 | // ---------------------------------------------------------------------------- | |
735 | ||
736 | void wxWindowBase::AddChild(wxWindowBase *child) | |
737 | { | |
223d09f6 | 738 | wxCHECK_RET( child, wxT("can't add a NULL child") ); |
f03fc89f | 739 | |
f6bcfd97 BP |
740 | // this should never happen and it will lead to a crash later if it does |
741 | // because RemoveChild() will remove only one node from the children list | |
742 | // and the other(s) one(s) will be left with dangling pointers in them | |
222ed1d6 | 743 | wxASSERT_MSG( !GetChildren().Find((wxWindow*)child), _T("AddChild() called twice") ); |
f6bcfd97 | 744 | |
222ed1d6 | 745 | GetChildren().Append((wxWindow*)child); |
f03fc89f VZ |
746 | child->SetParent(this); |
747 | } | |
748 | ||
749 | void wxWindowBase::RemoveChild(wxWindowBase *child) | |
750 | { | |
223d09f6 | 751 | wxCHECK_RET( child, wxT("can't remove a NULL child") ); |
f03fc89f | 752 | |
222ed1d6 MB |
753 | GetChildren().DeleteObject((wxWindow *)child); |
754 | child->SetParent(NULL); | |
f03fc89f | 755 | } |
439b3bf1 | 756 | |
f03fc89f VZ |
757 | bool wxWindowBase::Reparent(wxWindowBase *newParent) |
758 | { | |
759 | wxWindow *oldParent = GetParent(); | |
760 | if ( newParent == oldParent ) | |
761 | { | |
762 | // nothing done | |
e11f4636 | 763 | return false; |
f03fc89f VZ |
764 | } |
765 | ||
766 | // unlink this window from the existing parent. | |
767 | if ( oldParent ) | |
768 | { | |
769 | oldParent->RemoveChild(this); | |
770 | } | |
771 | else | |
772 | { | |
222ed1d6 | 773 | wxTopLevelWindows.DeleteObject((wxWindow *)this); |
f03fc89f VZ |
774 | } |
775 | ||
776 | // add it to the new one | |
777 | if ( newParent ) | |
778 | { | |
779 | newParent->AddChild(this); | |
780 | } | |
781 | else | |
782 | { | |
222ed1d6 | 783 | wxTopLevelWindows.Append((wxWindow *)this); |
f03fc89f VZ |
784 | } |
785 | ||
e11f4636 | 786 | return true; |
f03fc89f VZ |
787 | } |
788 | ||
789 | // ---------------------------------------------------------------------------- | |
790 | // event handler stuff | |
791 | // ---------------------------------------------------------------------------- | |
792 | ||
793 | void wxWindowBase::PushEventHandler(wxEvtHandler *handler) | |
794 | { | |
3a074ba8 VZ |
795 | wxEvtHandler *handlerOld = GetEventHandler(); |
796 | ||
797 | handler->SetNextHandler(handlerOld); | |
798 | ||
799 | if ( handlerOld ) | |
800 | GetEventHandler()->SetPreviousHandler(handler); | |
801 | ||
f03fc89f VZ |
802 | SetEventHandler(handler); |
803 | } | |
804 | ||
805 | wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler) | |
806 | { | |
807 | wxEvtHandler *handlerA = GetEventHandler(); | |
808 | if ( handlerA ) | |
809 | { | |
810 | wxEvtHandler *handlerB = handlerA->GetNextHandler(); | |
811 | handlerA->SetNextHandler((wxEvtHandler *)NULL); | |
3a074ba8 VZ |
812 | |
813 | if ( handlerB ) | |
814 | handlerB->SetPreviousHandler((wxEvtHandler *)NULL); | |
f03fc89f | 815 | SetEventHandler(handlerB); |
3a074ba8 | 816 | |
f03fc89f VZ |
817 | if ( deleteHandler ) |
818 | { | |
819 | delete handlerA; | |
820 | handlerA = (wxEvtHandler *)NULL; | |
821 | } | |
822 | } | |
823 | ||
824 | return handlerA; | |
825 | } | |
826 | ||
2e36d5cf VZ |
827 | bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handler) |
828 | { | |
e11f4636 | 829 | wxCHECK_MSG( handler, false, _T("RemoveEventHandler(NULL) called") ); |
2e36d5cf VZ |
830 | |
831 | wxEvtHandler *handlerPrev = NULL, | |
832 | *handlerCur = GetEventHandler(); | |
833 | while ( handlerCur ) | |
834 | { | |
835 | wxEvtHandler *handlerNext = handlerCur->GetNextHandler(); | |
836 | ||
837 | if ( handlerCur == handler ) | |
838 | { | |
839 | if ( handlerPrev ) | |
840 | { | |
841 | handlerPrev->SetNextHandler(handlerNext); | |
842 | } | |
843 | else | |
844 | { | |
845 | SetEventHandler(handlerNext); | |
846 | } | |
847 | ||
7a9c8d74 JS |
848 | if ( handlerNext ) |
849 | { | |
850 | handlerNext->SetPreviousHandler ( handlerPrev ); | |
851 | } | |
489bbac9 | 852 | |
2e36d5cf | 853 | handler->SetNextHandler(NULL); |
489bbac9 | 854 | handler->SetPreviousHandler(NULL); |
2e36d5cf | 855 | |
e11f4636 | 856 | return true; |
2e36d5cf VZ |
857 | } |
858 | ||
859 | handlerPrev = handlerCur; | |
860 | handlerCur = handlerNext; | |
861 | } | |
862 | ||
863 | wxFAIL_MSG( _T("where has the event handler gone?") ); | |
864 | ||
e11f4636 | 865 | return false; |
2e36d5cf VZ |
866 | } |
867 | ||
f03fc89f VZ |
868 | // ---------------------------------------------------------------------------- |
869 | // cursors, fonts &c | |
870 | // ---------------------------------------------------------------------------- | |
871 | ||
872 | bool wxWindowBase::SetBackgroundColour( const wxColour &colour ) | |
873 | { | |
874 | if ( !colour.Ok() || (colour == m_backgroundColour) ) | |
e11f4636 | 875 | return false; |
f03fc89f VZ |
876 | |
877 | m_backgroundColour = colour; | |
878 | ||
e11f4636 | 879 | m_hasBgCol = true; |
23895080 | 880 | |
e11f4636 | 881 | return true; |
f03fc89f VZ |
882 | } |
883 | ||
884 | bool wxWindowBase::SetForegroundColour( const wxColour &colour ) | |
885 | { | |
886 | if ( !colour.Ok() || (colour == m_foregroundColour) ) | |
e11f4636 | 887 | return false; |
f03fc89f VZ |
888 | |
889 | m_foregroundColour = colour; | |
890 | ||
e11f4636 | 891 | m_hasFgCol = true; |
23895080 | 892 | |
e11f4636 | 893 | return true; |
f03fc89f VZ |
894 | } |
895 | ||
896 | bool wxWindowBase::SetCursor(const wxCursor& cursor) | |
897 | { | |
8a9c2246 VZ |
898 | // setting an invalid cursor is ok, it means that we don't have any special |
899 | // cursor | |
13588544 | 900 | if ( m_cursor == cursor ) |
f03fc89f VZ |
901 | { |
902 | // no change | |
e11f4636 | 903 | return false; |
f03fc89f VZ |
904 | } |
905 | ||
8a9c2246 | 906 | m_cursor = cursor; |
f03fc89f | 907 | |
e11f4636 | 908 | return true; |
f03fc89f VZ |
909 | } |
910 | ||
911 | bool wxWindowBase::SetFont(const wxFont& font) | |
912 | { | |
913 | // don't try to set invalid font, always fall back to the default | |
914 | const wxFont& fontOk = font.Ok() ? font : *wxSWISS_FONT; | |
915 | ||
8bf30fe9 | 916 | if ( fontOk == m_font ) |
f03fc89f VZ |
917 | { |
918 | // no change | |
e11f4636 | 919 | return false; |
f03fc89f VZ |
920 | } |
921 | ||
922 | m_font = fontOk; | |
923 | ||
e11f4636 | 924 | m_hasFont = true; |
23895080 | 925 | |
e11f4636 | 926 | return true; |
f03fc89f VZ |
927 | } |
928 | ||
b95edd47 VZ |
929 | #if wxUSE_PALETTE |
930 | ||
931 | void wxWindowBase::SetPalette(const wxPalette& pal) | |
932 | { | |
e11f4636 | 933 | m_hasCustomPalette = true; |
b95edd47 VZ |
934 | m_palette = pal; |
935 | ||
936 | // VZ: can anyone explain me what do we do here? | |
937 | wxWindowDC d((wxWindow *) this); | |
938 | d.SetPalette(pal); | |
939 | } | |
940 | ||
941 | wxWindow *wxWindowBase::GetAncestorWithCustomPalette() const | |
942 | { | |
943 | wxWindow *win = (wxWindow *)this; | |
944 | while ( win && !win->HasCustomPalette() ) | |
945 | { | |
946 | win = win->GetParent(); | |
947 | } | |
948 | ||
949 | return win; | |
950 | } | |
951 | ||
952 | #endif // wxUSE_PALETTE | |
953 | ||
789295bf VZ |
954 | #if wxUSE_CARET |
955 | void wxWindowBase::SetCaret(wxCaret *caret) | |
956 | { | |
957 | if ( m_caret ) | |
958 | { | |
959 | delete m_caret; | |
960 | } | |
961 | ||
962 | m_caret = caret; | |
963 | ||
964 | if ( m_caret ) | |
965 | { | |
966 | wxASSERT_MSG( m_caret->GetWindow() == this, | |
223d09f6 | 967 | wxT("caret should be created associated to this window") ); |
789295bf VZ |
968 | } |
969 | } | |
970 | #endif // wxUSE_CARET | |
971 | ||
88ac883a | 972 | #if wxUSE_VALIDATORS |
f03fc89f VZ |
973 | // ---------------------------------------------------------------------------- |
974 | // validators | |
975 | // ---------------------------------------------------------------------------- | |
976 | ||
977 | void wxWindowBase::SetValidator(const wxValidator& validator) | |
978 | { | |
979 | if ( m_windowValidator ) | |
980 | delete m_windowValidator; | |
981 | ||
982 | m_windowValidator = (wxValidator *)validator.Clone(); | |
983 | ||
984 | if ( m_windowValidator ) | |
985 | m_windowValidator->SetWindow(this) ; | |
986 | } | |
88ac883a | 987 | #endif // wxUSE_VALIDATORS |
f03fc89f VZ |
988 | |
989 | // ---------------------------------------------------------------------------- | |
1e6feb95 | 990 | // update region stuff |
f03fc89f VZ |
991 | // ---------------------------------------------------------------------------- |
992 | ||
1e6feb95 VZ |
993 | wxRect wxWindowBase::GetUpdateClientRect() const |
994 | { | |
995 | wxRegion rgnUpdate = GetUpdateRegion(); | |
996 | rgnUpdate.Intersect(GetClientRect()); | |
997 | wxRect rectUpdate = rgnUpdate.GetBox(); | |
998 | wxPoint ptOrigin = GetClientAreaOrigin(); | |
999 | rectUpdate.x -= ptOrigin.x; | |
1000 | rectUpdate.y -= ptOrigin.y; | |
1001 | ||
1002 | return rectUpdate; | |
1003 | } | |
1004 | ||
f03fc89f VZ |
1005 | bool wxWindowBase::IsExposed(int x, int y) const |
1006 | { | |
1007 | return m_updateRegion.Contains(x, y) != wxOutRegion; | |
1008 | } | |
1009 | ||
1010 | bool wxWindowBase::IsExposed(int x, int y, int w, int h) const | |
1011 | { | |
1012 | return m_updateRegion.Contains(x, y, w, h) != wxOutRegion; | |
1013 | } | |
1014 | ||
5da0803c VZ |
1015 | void wxWindowBase::ClearBackground() |
1016 | { | |
1017 | // wxGTK uses its own version, no need to add never used code | |
1018 | #ifndef __WXGTK__ | |
1019 | wxClientDC dc((wxWindow *)this); | |
1020 | wxBrush brush(GetBackgroundColour(), wxSOLID); | |
1021 | dc.SetBackground(brush); | |
1022 | dc.Clear(); | |
1023 | #endif // __WXGTK__ | |
1024 | } | |
1025 | ||
f03fc89f | 1026 | // ---------------------------------------------------------------------------- |
146ba0fe | 1027 | // find child window by id or name |
f03fc89f VZ |
1028 | // ---------------------------------------------------------------------------- |
1029 | ||
1030 | wxWindow *wxWindowBase::FindWindow( long id ) | |
1031 | { | |
1032 | if ( id == m_windowId ) | |
1033 | return (wxWindow *)this; | |
1034 | ||
1035 | wxWindowBase *res = (wxWindow *)NULL; | |
222ed1d6 | 1036 | wxWindowList::compatibility_iterator node; |
f03fc89f VZ |
1037 | for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() ) |
1038 | { | |
1039 | wxWindowBase *child = node->GetData(); | |
1040 | res = child->FindWindow( id ); | |
1041 | } | |
1042 | ||
1043 | return (wxWindow *)res; | |
1044 | } | |
1045 | ||
1046 | wxWindow *wxWindowBase::FindWindow( const wxString& name ) | |
1047 | { | |
1048 | if ( name == m_windowName ) | |
1049 | return (wxWindow *)this; | |
1050 | ||
1051 | wxWindowBase *res = (wxWindow *)NULL; | |
222ed1d6 | 1052 | wxWindowList::compatibility_iterator node; |
f03fc89f VZ |
1053 | for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() ) |
1054 | { | |
1055 | wxWindow *child = node->GetData(); | |
1056 | res = child->FindWindow(name); | |
1057 | } | |
1058 | ||
1059 | return (wxWindow *)res; | |
1060 | } | |
1061 | ||
146ba0fe VZ |
1062 | |
1063 | // find any window by id or name or label: If parent is non-NULL, look through | |
1064 | // children for a label or title matching the specified string. If NULL, look | |
1065 | // through all top-level windows. | |
1066 | // | |
1067 | // to avoid duplicating code we reuse the same helper function but with | |
1068 | // different comparators | |
1069 | ||
1070 | typedef bool (*wxFindWindowCmp)(const wxWindow *win, | |
1071 | const wxString& label, long id); | |
1072 | ||
1073 | static | |
1074 | bool wxFindWindowCmpLabels(const wxWindow *win, const wxString& label, | |
1075 | long WXUNUSED(id)) | |
1076 | { | |
1077 | return win->GetLabel() == label; | |
1078 | } | |
1079 | ||
1080 | static | |
1081 | bool wxFindWindowCmpNames(const wxWindow *win, const wxString& label, | |
1082 | long WXUNUSED(id)) | |
1083 | { | |
1084 | return win->GetName() == label; | |
1085 | } | |
1086 | ||
1087 | static | |
1088 | bool wxFindWindowCmpIds(const wxWindow *win, const wxString& WXUNUSED(label), | |
1089 | long id) | |
1090 | { | |
1091 | return win->GetId() == id; | |
1092 | } | |
1093 | ||
1094 | // recursive helper for the FindWindowByXXX() functions | |
1095 | static | |
1096 | wxWindow *wxFindWindowRecursively(const wxWindow *parent, | |
1097 | const wxString& label, | |
1098 | long id, | |
1099 | wxFindWindowCmp cmp) | |
1100 | { | |
1101 | if ( parent ) | |
1102 | { | |
1103 | // see if this is the one we're looking for | |
1104 | if ( (*cmp)(parent, label, id) ) | |
1105 | return (wxWindow *)parent; | |
1106 | ||
1107 | // It wasn't, so check all its children | |
222ed1d6 | 1108 | for ( wxWindowList::compatibility_iterator node = parent->GetChildren().GetFirst(); |
146ba0fe VZ |
1109 | node; |
1110 | node = node->GetNext() ) | |
1111 | { | |
1112 | // recursively check each child | |
1113 | wxWindow *win = (wxWindow *)node->GetData(); | |
1114 | wxWindow *retwin = wxFindWindowRecursively(win, label, id, cmp); | |
1115 | if (retwin) | |
1116 | return retwin; | |
1117 | } | |
1118 | } | |
1119 | ||
1120 | // Not found | |
1121 | return NULL; | |
1122 | } | |
1123 | ||
1124 | // helper for FindWindowByXXX() | |
1125 | static | |
1126 | wxWindow *wxFindWindowHelper(const wxWindow *parent, | |
1127 | const wxString& label, | |
1128 | long id, | |
1129 | wxFindWindowCmp cmp) | |
1130 | { | |
1131 | if ( parent ) | |
1132 | { | |
1133 | // just check parent and all its children | |
1134 | return wxFindWindowRecursively(parent, label, id, cmp); | |
1135 | } | |
1136 | ||
1137 | // start at very top of wx's windows | |
222ed1d6 | 1138 | for ( wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst(); |
146ba0fe VZ |
1139 | node; |
1140 | node = node->GetNext() ) | |
1141 | { | |
1142 | // recursively check each window & its children | |
1143 | wxWindow *win = node->GetData(); | |
1144 | wxWindow *retwin = wxFindWindowRecursively(win, label, id, cmp); | |
1145 | if (retwin) | |
1146 | return retwin; | |
1147 | } | |
1148 | ||
1149 | return NULL; | |
1150 | } | |
1151 | ||
1152 | /* static */ | |
1153 | wxWindow * | |
1154 | wxWindowBase::FindWindowByLabel(const wxString& title, const wxWindow *parent) | |
1155 | { | |
1156 | return wxFindWindowHelper(parent, title, 0, wxFindWindowCmpLabels); | |
1157 | } | |
1158 | ||
1159 | /* static */ | |
1160 | wxWindow * | |
1161 | wxWindowBase::FindWindowByName(const wxString& title, const wxWindow *parent) | |
1162 | { | |
1163 | wxWindow *win = wxFindWindowHelper(parent, title, 0, wxFindWindowCmpNames); | |
1164 | ||
1165 | if ( !win ) | |
1166 | { | |
1167 | // fall back to the label | |
1168 | win = FindWindowByLabel(title, parent); | |
1169 | } | |
1170 | ||
1171 | return win; | |
1172 | } | |
1173 | ||
1174 | /* static */ | |
1175 | wxWindow * | |
1176 | wxWindowBase::FindWindowById( long id, const wxWindow* parent ) | |
1177 | { | |
1178 | return wxFindWindowHelper(parent, _T(""), id, wxFindWindowCmpIds); | |
1179 | } | |
1180 | ||
f03fc89f VZ |
1181 | // ---------------------------------------------------------------------------- |
1182 | // dialog oriented functions | |
1183 | // ---------------------------------------------------------------------------- | |
1184 | ||
34636400 | 1185 | void wxWindowBase::MakeModal(bool modal) |
f03fc89f | 1186 | { |
34636400 VZ |
1187 | // Disable all other windows |
1188 | if ( IsTopLevel() ) | |
1189 | { | |
222ed1d6 | 1190 | wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst(); |
34636400 VZ |
1191 | while (node) |
1192 | { | |
1193 | wxWindow *win = node->GetData(); | |
1194 | if (win != this) | |
1195 | win->Enable(!modal); | |
1196 | ||
1197 | node = node->GetNext(); | |
1198 | } | |
1199 | } | |
f03fc89f VZ |
1200 | } |
1201 | ||
1202 | bool wxWindowBase::Validate() | |
1203 | { | |
88ac883a | 1204 | #if wxUSE_VALIDATORS |
d80cd92a VZ |
1205 | bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0; |
1206 | ||
222ed1d6 | 1207 | wxWindowList::compatibility_iterator node; |
f03fc89f VZ |
1208 | for ( node = m_children.GetFirst(); node; node = node->GetNext() ) |
1209 | { | |
1210 | wxWindowBase *child = node->GetData(); | |
1211 | wxValidator *validator = child->GetValidator(); | |
dcd6b914 | 1212 | if ( validator && !validator->Validate((wxWindow *)this) ) |
f03fc89f | 1213 | { |
e11f4636 | 1214 | return false; |
f03fc89f | 1215 | } |
d80cd92a VZ |
1216 | |
1217 | if ( recurse && !child->Validate() ) | |
1218 | { | |
e11f4636 | 1219 | return false; |
d80cd92a | 1220 | } |
f03fc89f | 1221 | } |
88ac883a | 1222 | #endif // wxUSE_VALIDATORS |
f03fc89f | 1223 | |
e11f4636 | 1224 | return true; |
f03fc89f VZ |
1225 | } |
1226 | ||
1227 | bool wxWindowBase::TransferDataToWindow() | |
1228 | { | |
88ac883a | 1229 | #if wxUSE_VALIDATORS |
d80cd92a VZ |
1230 | bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0; |
1231 | ||
222ed1d6 | 1232 | wxWindowList::compatibility_iterator node; |
f03fc89f VZ |
1233 | for ( node = m_children.GetFirst(); node; node = node->GetNext() ) |
1234 | { | |
1235 | wxWindowBase *child = node->GetData(); | |
1236 | wxValidator *validator = child->GetValidator(); | |
1237 | if ( validator && !validator->TransferToWindow() ) | |
1238 | { | |
d80cd92a | 1239 | wxLogWarning(_("Could not transfer data to window")); |
e30285ab | 1240 | #if wxUSE_LOG |
d80cd92a | 1241 | wxLog::FlushActive(); |
e30285ab | 1242 | #endif // wxUSE_LOG |
f03fc89f | 1243 | |
e11f4636 | 1244 | return false; |
f03fc89f | 1245 | } |
d80cd92a VZ |
1246 | |
1247 | if ( recurse ) | |
1248 | { | |
a58a12e9 | 1249 | if ( !child->TransferDataToWindow() ) |
d80cd92a VZ |
1250 | { |
1251 | // warning already given | |
e11f4636 | 1252 | return false; |
d80cd92a VZ |
1253 | } |
1254 | } | |
f03fc89f | 1255 | } |
88ac883a | 1256 | #endif // wxUSE_VALIDATORS |
f03fc89f | 1257 | |
e11f4636 | 1258 | return true; |
f03fc89f VZ |
1259 | } |
1260 | ||
1261 | bool wxWindowBase::TransferDataFromWindow() | |
1262 | { | |
88ac883a | 1263 | #if wxUSE_VALIDATORS |
d80cd92a VZ |
1264 | bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0; |
1265 | ||
222ed1d6 | 1266 | wxWindowList::compatibility_iterator node; |
f03fc89f VZ |
1267 | for ( node = m_children.GetFirst(); node; node = node->GetNext() ) |
1268 | { | |
1269 | wxWindow *child = node->GetData(); | |
d80cd92a VZ |
1270 | wxValidator *validator = child->GetValidator(); |
1271 | if ( validator && !validator->TransferFromWindow() ) | |
f03fc89f | 1272 | { |
d80cd92a VZ |
1273 | // nop warning here because the application is supposed to give |
1274 | // one itself - we don't know here what might have gone wrongly | |
1275 | ||
e11f4636 | 1276 | return false; |
f03fc89f | 1277 | } |
d80cd92a VZ |
1278 | |
1279 | if ( recurse ) | |
1280 | { | |
a58a12e9 | 1281 | if ( !child->TransferDataFromWindow() ) |
d80cd92a VZ |
1282 | { |
1283 | // warning already given | |
e11f4636 | 1284 | return false; |
d80cd92a VZ |
1285 | } |
1286 | } | |
f03fc89f | 1287 | } |
88ac883a | 1288 | #endif // wxUSE_VALIDATORS |
f03fc89f | 1289 | |
e11f4636 | 1290 | return true; |
f03fc89f VZ |
1291 | } |
1292 | ||
1293 | void wxWindowBase::InitDialog() | |
1294 | { | |
1295 | wxInitDialogEvent event(GetId()); | |
1296 | event.SetEventObject( this ); | |
1297 | GetEventHandler()->ProcessEvent(event); | |
1298 | } | |
1299 | ||
1300 | // ---------------------------------------------------------------------------- | |
bd83cb56 VZ |
1301 | // context-sensitive help support |
1302 | // ---------------------------------------------------------------------------- | |
1303 | ||
1304 | #if wxUSE_HELP | |
1305 | ||
1306 | // associate this help text with this window | |
1307 | void wxWindowBase::SetHelpText(const wxString& text) | |
1308 | { | |
1309 | wxHelpProvider *helpProvider = wxHelpProvider::Get(); | |
1310 | if ( helpProvider ) | |
1311 | { | |
1312 | helpProvider->AddHelp(this, text); | |
1313 | } | |
1314 | } | |
1315 | ||
1316 | // associate this help text with all windows with the same id as this | |
1317 | // one | |
1318 | void wxWindowBase::SetHelpTextForId(const wxString& text) | |
1319 | { | |
1320 | wxHelpProvider *helpProvider = wxHelpProvider::Get(); | |
1321 | if ( helpProvider ) | |
1322 | { | |
1323 | helpProvider->AddHelp(GetId(), text); | |
1324 | } | |
1325 | } | |
1326 | ||
1327 | // get the help string associated with this window (may be empty) | |
1328 | wxString wxWindowBase::GetHelpText() const | |
1329 | { | |
1330 | wxString text; | |
1331 | wxHelpProvider *helpProvider = wxHelpProvider::Get(); | |
1332 | if ( helpProvider ) | |
1333 | { | |
1334 | text = helpProvider->GetHelp(this); | |
1335 | } | |
1336 | ||
1337 | return text; | |
1338 | } | |
1339 | ||
1340 | // show help for this window | |
1341 | void wxWindowBase::OnHelp(wxHelpEvent& event) | |
1342 | { | |
1343 | wxHelpProvider *helpProvider = wxHelpProvider::Get(); | |
1344 | if ( helpProvider ) | |
1345 | { | |
1346 | if ( helpProvider->ShowHelp(this) ) | |
1347 | { | |
1348 | // skip the event.Skip() below | |
1349 | return; | |
1350 | } | |
1351 | } | |
1352 | ||
1353 | event.Skip(); | |
1354 | } | |
1355 | ||
1356 | #endif // wxUSE_HELP | |
1357 | ||
1358 | // ---------------------------------------------------------------------------- | |
574c939e | 1359 | // tooltipsroot.Replace("\\", "/"); |
f03fc89f VZ |
1360 | // ---------------------------------------------------------------------------- |
1361 | ||
1362 | #if wxUSE_TOOLTIPS | |
1363 | ||
1364 | void wxWindowBase::SetToolTip( const wxString &tip ) | |
1365 | { | |
1366 | // don't create the new tooltip if we already have one | |
1367 | if ( m_tooltip ) | |
1368 | { | |
1369 | m_tooltip->SetTip( tip ); | |
1370 | } | |
1371 | else | |
1372 | { | |
1373 | SetToolTip( new wxToolTip( tip ) ); | |
1374 | } | |
1375 | ||
1376 | // setting empty tooltip text does not remove the tooltip any more - use | |
1377 | // SetToolTip((wxToolTip *)NULL) for this | |
1378 | } | |
1379 | ||
1380 | void wxWindowBase::DoSetToolTip(wxToolTip *tooltip) | |
1381 | { | |
1382 | if ( m_tooltip ) | |
1383 | delete m_tooltip; | |
1384 | ||
1385 | m_tooltip = tooltip; | |
1386 | } | |
1387 | ||
1388 | #endif // wxUSE_TOOLTIPS | |
1389 | ||
1390 | // ---------------------------------------------------------------------------- | |
1391 | // constraints and sizers | |
1392 | // ---------------------------------------------------------------------------- | |
1393 | ||
1394 | #if wxUSE_CONSTRAINTS | |
1395 | ||
1396 | void wxWindowBase::SetConstraints( wxLayoutConstraints *constraints ) | |
1397 | { | |
1398 | if ( m_constraints ) | |
1399 | { | |
1400 | UnsetConstraints(m_constraints); | |
1401 | delete m_constraints; | |
1402 | } | |
1403 | m_constraints = constraints; | |
1404 | if ( m_constraints ) | |
1405 | { | |
1406 | // Make sure other windows know they're part of a 'meaningful relationship' | |
1407 | if ( m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this) ) | |
1408 | m_constraints->left.GetOtherWindow()->AddConstraintReference(this); | |
1409 | if ( m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this) ) | |
1410 | m_constraints->top.GetOtherWindow()->AddConstraintReference(this); | |
1411 | if ( m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this) ) | |
1412 | m_constraints->right.GetOtherWindow()->AddConstraintReference(this); | |
1413 | if ( m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this) ) | |
1414 | m_constraints->bottom.GetOtherWindow()->AddConstraintReference(this); | |
1415 | if ( m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this) ) | |
1416 | m_constraints->width.GetOtherWindow()->AddConstraintReference(this); | |
1417 | if ( m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this) ) | |
1418 | m_constraints->height.GetOtherWindow()->AddConstraintReference(this); | |
1419 | if ( m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this) ) | |
1420 | m_constraints->centreX.GetOtherWindow()->AddConstraintReference(this); | |
1421 | if ( m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this) ) | |
1422 | m_constraints->centreY.GetOtherWindow()->AddConstraintReference(this); | |
1423 | } | |
1424 | } | |
1425 | ||
1426 | // This removes any dangling pointers to this window in other windows' | |
1427 | // constraintsInvolvedIn lists. | |
1428 | void wxWindowBase::UnsetConstraints(wxLayoutConstraints *c) | |
1429 | { | |
1430 | if ( c ) | |
1431 | { | |
1432 | if ( c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this) ) | |
1433 | c->left.GetOtherWindow()->RemoveConstraintReference(this); | |
1434 | if ( c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this) ) | |
1435 | c->top.GetOtherWindow()->RemoveConstraintReference(this); | |
1436 | if ( c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this) ) | |
1437 | c->right.GetOtherWindow()->RemoveConstraintReference(this); | |
1438 | if ( c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this) ) | |
1439 | c->bottom.GetOtherWindow()->RemoveConstraintReference(this); | |
1440 | if ( c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this) ) | |
1441 | c->width.GetOtherWindow()->RemoveConstraintReference(this); | |
1442 | if ( c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this) ) | |
1443 | c->height.GetOtherWindow()->RemoveConstraintReference(this); | |
1444 | if ( c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this) ) | |
1445 | c->centreX.GetOtherWindow()->RemoveConstraintReference(this); | |
1446 | if ( c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this) ) | |
1447 | c->centreY.GetOtherWindow()->RemoveConstraintReference(this); | |
1448 | } | |
1449 | } | |
1450 | ||
1451 | // Back-pointer to other windows we're involved with, so if we delete this | |
1452 | // window, we must delete any constraints we're involved with. | |
1453 | void wxWindowBase::AddConstraintReference(wxWindowBase *otherWin) | |
1454 | { | |
1455 | if ( !m_constraintsInvolvedIn ) | |
1456 | m_constraintsInvolvedIn = new wxWindowList; | |
222ed1d6 MB |
1457 | if ( !m_constraintsInvolvedIn->Find((wxWindow *)otherWin) ) |
1458 | m_constraintsInvolvedIn->Append((wxWindow *)otherWin); | |
f03fc89f VZ |
1459 | } |
1460 | ||
1461 | // REMOVE back-pointer to other windows we're involved with. | |
1462 | void wxWindowBase::RemoveConstraintReference(wxWindowBase *otherWin) | |
1463 | { | |
1464 | if ( m_constraintsInvolvedIn ) | |
222ed1d6 | 1465 | m_constraintsInvolvedIn->DeleteObject((wxWindow *)otherWin); |
f03fc89f VZ |
1466 | } |
1467 | ||
1468 | // Reset any constraints that mention this window | |
1469 | void wxWindowBase::DeleteRelatedConstraints() | |
1470 | { | |
1471 | if ( m_constraintsInvolvedIn ) | |
1472 | { | |
222ed1d6 | 1473 | wxWindowList::compatibility_iterator node = m_constraintsInvolvedIn->GetFirst(); |
f03fc89f VZ |
1474 | while (node) |
1475 | { | |
1476 | wxWindow *win = node->GetData(); | |
1477 | wxLayoutConstraints *constr = win->GetConstraints(); | |
1478 | ||
1479 | // Reset any constraints involving this window | |
1480 | if ( constr ) | |
1481 | { | |
1482 | constr->left.ResetIfWin(this); | |
1483 | constr->top.ResetIfWin(this); | |
1484 | constr->right.ResetIfWin(this); | |
1485 | constr->bottom.ResetIfWin(this); | |
1486 | constr->width.ResetIfWin(this); | |
1487 | constr->height.ResetIfWin(this); | |
1488 | constr->centreX.ResetIfWin(this); | |
1489 | constr->centreY.ResetIfWin(this); | |
1490 | } | |
1491 | ||
222ed1d6 MB |
1492 | wxWindowList::compatibility_iterator next = node->GetNext(); |
1493 | m_constraintsInvolvedIn->Erase(node); | |
f03fc89f VZ |
1494 | node = next; |
1495 | } | |
1496 | ||
1497 | delete m_constraintsInvolvedIn; | |
1498 | m_constraintsInvolvedIn = (wxWindowList *) NULL; | |
1499 | } | |
1500 | } | |
ec5bb70d VZ |
1501 | |
1502 | #endif // wxUSE_CONSTRAINTS | |
f03fc89f | 1503 | |
3aa5d532 | 1504 | void wxWindowBase::SetSizer(wxSizer *sizer, bool deleteOld) |
f03fc89f | 1505 | { |
fb89cfc5 RD |
1506 | if ( sizer == m_windowSizer) |
1507 | return; | |
1508 | ||
ec5bb70d VZ |
1509 | if ( deleteOld ) |
1510 | delete m_windowSizer; | |
3417c2cd | 1511 | |
f03fc89f | 1512 | m_windowSizer = sizer; |
566d84a7 | 1513 | |
ec5bb70d | 1514 | SetAutoLayout( sizer != NULL ); |
566d84a7 RL |
1515 | } |
1516 | ||
1517 | void wxWindowBase::SetSizerAndFit(wxSizer *sizer, bool deleteOld) | |
1518 | { | |
1519 | SetSizer( sizer, deleteOld ); | |
1520 | sizer->SetSizeHints( (wxWindow*) this ); | |
f03fc89f VZ |
1521 | } |
1522 | ||
ec5bb70d VZ |
1523 | #if wxUSE_CONSTRAINTS |
1524 | ||
1525 | void wxWindowBase::SatisfyConstraints() | |
1526 | { | |
1527 | wxLayoutConstraints *constr = GetConstraints(); | |
1528 | bool wasOk = constr && constr->AreSatisfied(); | |
1529 | ||
1530 | ResetConstraints(); // Mark all constraints as unevaluated | |
1531 | ||
1532 | int noChanges = 1; | |
1533 | ||
1534 | // if we're a top level panel (i.e. our parent is frame/dialog), our | |
1535 | // own constraints will never be satisfied any more unless we do it | |
1536 | // here | |
1537 | if ( wasOk ) | |
1538 | { | |
1539 | while ( noChanges > 0 ) | |
1540 | { | |
1541 | LayoutPhase1(&noChanges); | |
1542 | } | |
1543 | } | |
1544 | ||
1545 | LayoutPhase2(&noChanges); | |
1546 | } | |
1547 | ||
1548 | #endif // wxUSE_CONSTRAINTS | |
1549 | ||
f03fc89f VZ |
1550 | bool wxWindowBase::Layout() |
1551 | { | |
3417c2cd | 1552 | // If there is a sizer, use it instead of the constraints |
f03fc89f VZ |
1553 | if ( GetSizer() ) |
1554 | { | |
f1df0927 | 1555 | int w, h; |
566d84a7 | 1556 | GetVirtualSize(&w, &h); |
3417c2cd | 1557 | GetSizer()->SetDimension( 0, 0, w, h ); |
f03fc89f | 1558 | } |
461e93f9 | 1559 | #if wxUSE_CONSTRAINTS |
f1df0927 | 1560 | else |
f03fc89f | 1561 | { |
ec5bb70d | 1562 | SatisfyConstraints(); // Find the right constraints values |
f1df0927 | 1563 | SetConstraintSizes(); // Recursively set the real window sizes |
f03fc89f | 1564 | } |
461e93f9 | 1565 | #endif |
5d4b632b | 1566 | |
e11f4636 | 1567 | return true; |
f03fc89f VZ |
1568 | } |
1569 | ||
461e93f9 | 1570 | #if wxUSE_CONSTRAINTS |
ec5bb70d VZ |
1571 | |
1572 | // first phase of the constraints evaluation: set our own constraints | |
f03fc89f VZ |
1573 | bool wxWindowBase::LayoutPhase1(int *noChanges) |
1574 | { | |
1575 | wxLayoutConstraints *constr = GetConstraints(); | |
ec5bb70d VZ |
1576 | |
1577 | return !constr || constr->SatisfyConstraints(this, noChanges); | |
f03fc89f VZ |
1578 | } |
1579 | ||
ec5bb70d | 1580 | // second phase: set the constraints for our children |
f03fc89f VZ |
1581 | bool wxWindowBase::LayoutPhase2(int *noChanges) |
1582 | { | |
1583 | *noChanges = 0; | |
1584 | ||
1585 | // Layout children | |
1586 | DoPhase(1); | |
ec5bb70d VZ |
1587 | |
1588 | // Layout grand children | |
f03fc89f | 1589 | DoPhase(2); |
ec5bb70d | 1590 | |
e11f4636 | 1591 | return true; |
f03fc89f VZ |
1592 | } |
1593 | ||
1594 | // Do a phase of evaluating child constraints | |
1595 | bool wxWindowBase::DoPhase(int phase) | |
1596 | { | |
ec5bb70d VZ |
1597 | // the list containing the children for which the constraints are already |
1598 | // set correctly | |
f03fc89f | 1599 | wxWindowList succeeded; |
ec5bb70d VZ |
1600 | |
1601 | // the max number of iterations we loop before concluding that we can't set | |
1602 | // the constraints | |
1603 | static const int maxIterations = 500; | |
1604 | ||
1605 | for ( int noIterations = 0; noIterations < maxIterations; noIterations++ ) | |
f03fc89f | 1606 | { |
ec5bb70d VZ |
1607 | int noChanges = 0; |
1608 | ||
1609 | // loop over all children setting their constraints | |
222ed1d6 | 1610 | for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
ec5bb70d VZ |
1611 | node; |
1612 | node = node->GetNext() ) | |
f03fc89f VZ |
1613 | { |
1614 | wxWindow *child = node->GetData(); | |
ec5bb70d | 1615 | if ( child->IsTopLevel() ) |
f03fc89f | 1616 | { |
ec5bb70d VZ |
1617 | // top level children are not inside our client area |
1618 | continue; | |
1619 | } | |
1620 | ||
1621 | if ( !child->GetConstraints() || succeeded.Find(child) ) | |
1622 | { | |
1623 | // this one is either already ok or nothing we can do about it | |
1624 | continue; | |
1625 | } | |
1626 | ||
1627 | int tempNoChanges = 0; | |
1628 | bool success = phase == 1 ? child->LayoutPhase1(&tempNoChanges) | |
1629 | : child->LayoutPhase2(&tempNoChanges); | |
1630 | noChanges += tempNoChanges; | |
1631 | ||
1632 | if ( success ) | |
1633 | { | |
1634 | succeeded.Append(child); | |
f03fc89f | 1635 | } |
f03fc89f VZ |
1636 | } |
1637 | ||
ec5bb70d VZ |
1638 | if ( !noChanges ) |
1639 | { | |
1640 | // constraints are set | |
1641 | break; | |
1642 | } | |
f03fc89f VZ |
1643 | } |
1644 | ||
e11f4636 | 1645 | return true; |
f03fc89f VZ |
1646 | } |
1647 | ||
1648 | void wxWindowBase::ResetConstraints() | |
1649 | { | |
1650 | wxLayoutConstraints *constr = GetConstraints(); | |
1651 | if ( constr ) | |
1652 | { | |
e11f4636 DS |
1653 | constr->left.SetDone(false); |
1654 | constr->top.SetDone(false); | |
1655 | constr->right.SetDone(false); | |
1656 | constr->bottom.SetDone(false); | |
1657 | constr->width.SetDone(false); | |
1658 | constr->height.SetDone(false); | |
1659 | constr->centreX.SetDone(false); | |
1660 | constr->centreY.SetDone(false); | |
f03fc89f | 1661 | } |
f1df0927 | 1662 | |
222ed1d6 | 1663 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
f03fc89f VZ |
1664 | while (node) |
1665 | { | |
1666 | wxWindow *win = node->GetData(); | |
34636400 | 1667 | if ( !win->IsTopLevel() ) |
f03fc89f VZ |
1668 | win->ResetConstraints(); |
1669 | node = node->GetNext(); | |
1670 | } | |
1671 | } | |
1672 | ||
1673 | // Need to distinguish between setting the 'fake' size for windows and sizers, | |
1674 | // and setting the real values. | |
1675 | void wxWindowBase::SetConstraintSizes(bool recurse) | |
1676 | { | |
1677 | wxLayoutConstraints *constr = GetConstraints(); | |
4b7f2165 | 1678 | if ( constr && constr->AreSatisfied() ) |
f03fc89f VZ |
1679 | { |
1680 | int x = constr->left.GetValue(); | |
1681 | int y = constr->top.GetValue(); | |
1682 | int w = constr->width.GetValue(); | |
1683 | int h = constr->height.GetValue(); | |
1684 | ||
f03fc89f | 1685 | if ( (constr->width.GetRelationship() != wxAsIs ) || |
3417c2cd | 1686 | (constr->height.GetRelationship() != wxAsIs) ) |
f03fc89f | 1687 | { |
3417c2cd | 1688 | SetSize(x, y, w, h); |
f03fc89f VZ |
1689 | } |
1690 | else | |
1691 | { | |
3417c2cd RR |
1692 | // If we don't want to resize this window, just move it... |
1693 | Move(x, y); | |
f03fc89f VZ |
1694 | } |
1695 | } | |
1696 | else if ( constr ) | |
1697 | { | |
4b7f2165 | 1698 | wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."), |
f1df0927 | 1699 | GetClassInfo()->GetClassName(), |
4b7f2165 | 1700 | GetName().c_str()); |
f03fc89f VZ |
1701 | } |
1702 | ||
1703 | if ( recurse ) | |
1704 | { | |
222ed1d6 | 1705 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
f03fc89f VZ |
1706 | while (node) |
1707 | { | |
1708 | wxWindow *win = node->GetData(); | |
e2f9212c | 1709 | if ( !win->IsTopLevel() && win->GetConstraints() ) |
f03fc89f VZ |
1710 | win->SetConstraintSizes(); |
1711 | node = node->GetNext(); | |
1712 | } | |
1713 | } | |
1714 | } | |
1715 | ||
f03fc89f VZ |
1716 | // Only set the size/position of the constraint (if any) |
1717 | void wxWindowBase::SetSizeConstraint(int x, int y, int w, int h) | |
1718 | { | |
1719 | wxLayoutConstraints *constr = GetConstraints(); | |
1720 | if ( constr ) | |
1721 | { | |
1722 | if ( x != -1 ) | |
1723 | { | |
1724 | constr->left.SetValue(x); | |
e11f4636 | 1725 | constr->left.SetDone(true); |
f03fc89f VZ |
1726 | } |
1727 | if ( y != -1 ) | |
1728 | { | |
1729 | constr->top.SetValue(y); | |
e11f4636 | 1730 | constr->top.SetDone(true); |
f03fc89f VZ |
1731 | } |
1732 | if ( w != -1 ) | |
1733 | { | |
1734 | constr->width.SetValue(w); | |
e11f4636 | 1735 | constr->width.SetDone(true); |
f03fc89f VZ |
1736 | } |
1737 | if ( h != -1 ) | |
1738 | { | |
1739 | constr->height.SetValue(h); | |
e11f4636 | 1740 | constr->height.SetDone(true); |
f03fc89f VZ |
1741 | } |
1742 | } | |
1743 | } | |
1744 | ||
1745 | void wxWindowBase::MoveConstraint(int x, int y) | |
1746 | { | |
1747 | wxLayoutConstraints *constr = GetConstraints(); | |
1748 | if ( constr ) | |
1749 | { | |
1750 | if ( x != -1 ) | |
1751 | { | |
1752 | constr->left.SetValue(x); | |
e11f4636 | 1753 | constr->left.SetDone(true); |
f03fc89f VZ |
1754 | } |
1755 | if ( y != -1 ) | |
1756 | { | |
1757 | constr->top.SetValue(y); | |
e11f4636 | 1758 | constr->top.SetDone(true); |
f03fc89f VZ |
1759 | } |
1760 | } | |
1761 | } | |
1762 | ||
1763 | void wxWindowBase::GetSizeConstraint(int *w, int *h) const | |
1764 | { | |
1765 | wxLayoutConstraints *constr = GetConstraints(); | |
1766 | if ( constr ) | |
1767 | { | |
1768 | *w = constr->width.GetValue(); | |
1769 | *h = constr->height.GetValue(); | |
1770 | } | |
1771 | else | |
1772 | GetSize(w, h); | |
1773 | } | |
1774 | ||
1775 | void wxWindowBase::GetClientSizeConstraint(int *w, int *h) const | |
1776 | { | |
1777 | wxLayoutConstraints *constr = GetConstraints(); | |
1778 | if ( constr ) | |
1779 | { | |
1780 | *w = constr->width.GetValue(); | |
1781 | *h = constr->height.GetValue(); | |
1782 | } | |
1783 | else | |
1784 | GetClientSize(w, h); | |
1785 | } | |
1786 | ||
461e93f9 JS |
1787 | void wxWindowBase::GetPositionConstraint(int *x, int *y) const |
1788 | { | |
1789 | wxLayoutConstraints *constr = GetConstraints(); | |
1790 | if ( constr ) | |
1791 | { | |
1792 | *x = constr->left.GetValue(); | |
1793 | *y = constr->top.GetValue(); | |
1794 | } | |
1795 | else | |
1796 | GetPosition(x, y); | |
1797 | } | |
1798 | ||
1799 | #endif // wxUSE_CONSTRAINTS | |
1800 | ||
20a1eea1 | 1801 | void wxWindowBase::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) const |
a200c35e VS |
1802 | { |
1803 | // don't do it for the dialogs/frames - they float independently of their | |
1804 | // parent | |
1805 | if ( !IsTopLevel() ) | |
1806 | { | |
1807 | wxWindow *parent = GetParent(); | |
1808 | if ( !(sizeFlags & wxSIZE_NO_ADJUSTMENTS) && parent ) | |
1809 | { | |
1810 | wxPoint pt(parent->GetClientAreaOrigin()); | |
1811 | x += pt.x; | |
1812 | y += pt.y; | |
1813 | } | |
1814 | } | |
1815 | } | |
1816 | ||
f03fc89f VZ |
1817 | // ---------------------------------------------------------------------------- |
1818 | // do Update UI processing for child controls | |
1819 | // ---------------------------------------------------------------------------- | |
7ec1983b | 1820 | |
e39af974 | 1821 | void wxWindowBase::UpdateWindowUI(long flags) |
7ec1983b | 1822 | { |
26bf1ce0 VZ |
1823 | wxUpdateUIEvent event(GetId()); |
1824 | event.m_eventObject = this; | |
1825 | ||
1826 | if ( GetEventHandler()->ProcessEvent(event) ) | |
7ec1983b | 1827 | { |
e39af974 JS |
1828 | DoUpdateWindowUI(event); |
1829 | } | |
7ec1983b | 1830 | |
e39af974 JS |
1831 | if (flags & wxUPDATE_UI_RECURSE) |
1832 | { | |
222ed1d6 | 1833 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
e39af974 | 1834 | while (node) |
f03fc89f | 1835 | { |
e39af974 JS |
1836 | wxWindow* child = (wxWindow*) node->GetData(); |
1837 | child->UpdateWindowUI(flags); | |
1838 | node = node->GetNext(); | |
26bf1ce0 | 1839 | } |
e39af974 JS |
1840 | } |
1841 | } | |
f03fc89f | 1842 | |
e39af974 JS |
1843 | // do the window-specific processing after processing the update event |
1844 | // TODO: take specific knowledge out of this function and | |
1845 | // put in each control's base class. Unfortunately we don't | |
1846 | // yet have base implementation files for wxCheckBox and wxRadioButton. | |
1847 | void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event) | |
1848 | { | |
1849 | if ( event.GetSetEnabled() ) | |
1850 | Enable(event.GetEnabled()); | |
e11f4636 | 1851 | |
e39af974 JS |
1852 | #if wxUSE_CONTROLS |
1853 | if ( event.GetSetText() ) | |
1854 | { | |
1855 | wxControl *control = wxDynamicCastThis(wxControl); | |
1856 | if ( control ) | |
1857 | { | |
1858 | if ( event.GetText() != control->GetLabel() ) | |
1859 | control->SetLabel(event.GetText()); | |
1860 | } | |
88ac883a | 1861 | #if wxUSE_CHECKBOX |
f7637829 | 1862 | wxCheckBox *checkbox = wxDynamicCastThis(wxCheckBox); |
26bf1ce0 VZ |
1863 | if ( checkbox ) |
1864 | { | |
1865 | if ( event.GetSetChecked() ) | |
1866 | checkbox->SetValue(event.GetChecked()); | |
1867 | } | |
88ac883a VZ |
1868 | #endif // wxUSE_CHECKBOX |
1869 | ||
b3402d0d | 1870 | #if wxUSE_RADIOBTN |
f7637829 | 1871 | wxRadioButton *radiobtn = wxDynamicCastThis(wxRadioButton); |
26bf1ce0 VZ |
1872 | if ( radiobtn ) |
1873 | { | |
1874 | if ( event.GetSetChecked() ) | |
1875 | radiobtn->SetValue(event.GetChecked()); | |
f03fc89f | 1876 | } |
b3402d0d | 1877 | #endif // wxUSE_RADIOBTN |
e11f4636 | 1878 | } |
e39af974 JS |
1879 | #endif |
1880 | } | |
1881 | ||
5109ae5d | 1882 | #if 0 |
e39af974 | 1883 | // call internal idle recursively |
5109ae5d | 1884 | // may be obsolete (wait until OnIdle scheme stabilises) |
e39af974 JS |
1885 | void wxWindowBase::ProcessInternalIdle() |
1886 | { | |
1887 | OnInternalIdle(); | |
1888 | ||
222ed1d6 | 1889 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
e39af974 JS |
1890 | while (node) |
1891 | { | |
1892 | wxWindow *child = node->GetData(); | |
1893 | child->ProcessInternalIdle(); | |
1894 | node = node->GetNext(); | |
7ec1983b | 1895 | } |
7ec1983b | 1896 | } |
5109ae5d | 1897 | #endif |
fd71308f | 1898 | |
f03fc89f VZ |
1899 | // ---------------------------------------------------------------------------- |
1900 | // dialog units translations | |
1901 | // ---------------------------------------------------------------------------- | |
1902 | ||
1903 | wxPoint wxWindowBase::ConvertPixelsToDialog(const wxPoint& pt) | |
fd71308f JS |
1904 | { |
1905 | int charWidth = GetCharWidth(); | |
1906 | int charHeight = GetCharHeight(); | |
5d9c2818 RD |
1907 | wxPoint pt2(-1, -1); |
1908 | if (pt.x != -1) | |
1909 | pt2.x = (int) ((pt.x * 4) / charWidth) ; | |
1910 | if (pt.y != -1) | |
1911 | pt2.y = (int) ((pt.y * 8) / charHeight) ; | |
fd71308f JS |
1912 | |
1913 | return pt2; | |
1914 | } | |
1915 | ||
f03fc89f | 1916 | wxPoint wxWindowBase::ConvertDialogToPixels(const wxPoint& pt) |
fd71308f JS |
1917 | { |
1918 | int charWidth = GetCharWidth(); | |
1919 | int charHeight = GetCharHeight(); | |
5d9c2818 RD |
1920 | wxPoint pt2(-1, -1); |
1921 | if (pt.x != -1) | |
1922 | pt2.x = (int) ((pt.x * charWidth) / 4) ; | |
1923 | if (pt.y != -1) | |
1924 | pt2.y = (int) ((pt.y * charHeight) / 8) ; | |
fd71308f JS |
1925 | |
1926 | return pt2; | |
1927 | } | |
1928 | ||
f03fc89f VZ |
1929 | // ---------------------------------------------------------------------------- |
1930 | // event handlers | |
1931 | // ---------------------------------------------------------------------------- | |
1932 | ||
1933 | // propagate the colour change event to the subwindows | |
1934 | void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& event) | |
1935 | { | |
222ed1d6 | 1936 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
f03fc89f VZ |
1937 | while ( node ) |
1938 | { | |
1939 | // Only propagate to non-top-level windows | |
1940 | wxWindow *win = node->GetData(); | |
1941 | if ( !win->IsTopLevel() ) | |
1942 | { | |
1943 | wxSysColourChangedEvent event2; | |
1944 | event.m_eventObject = win; | |
1945 | win->GetEventHandler()->ProcessEvent(event2); | |
1946 | } | |
1947 | ||
1948 | node = node->GetNext(); | |
1949 | } | |
1950 | } | |
1951 | ||
e39af974 JS |
1952 | // the default action is to populate dialog with data when it's created, |
1953 | // and nudge the UI into displaying itself correctly in case | |
1954 | // we've turned the wxUpdateUIEvents frequency down low. | |
f03fc89f VZ |
1955 | void wxWindowBase::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) ) |
1956 | { | |
1957 | TransferDataToWindow(); | |
e11f4636 | 1958 | |
e39af974 JS |
1959 | // Update the UI at this point |
1960 | UpdateWindowUI(wxUPDATE_UI_RECURSE); | |
f03fc89f VZ |
1961 | } |
1962 | ||
a02dc3e3 VZ |
1963 | // process Ctrl-Alt-mclick |
1964 | void wxWindowBase::OnMiddleClick( wxMouseEvent& event ) | |
1965 | { | |
1e6feb95 | 1966 | #if wxUSE_MSGDLG |
a02dc3e3 VZ |
1967 | if ( event.ControlDown() && event.AltDown() ) |
1968 | { | |
1969 | // don't translate these strings | |
1970 | wxString port; | |
af3062a8 VZ |
1971 | |
1972 | #ifdef __WXUNIVERSAL__ | |
1973 | port = _T("Univ/"); | |
1974 | #endif // __WXUNIVERSAL__ | |
1975 | ||
a02dc3e3 VZ |
1976 | switch ( wxGetOsVersion() ) |
1977 | { | |
ea8e90b7 | 1978 | case wxMOTIF_X: port += _T("Motif"); break; |
ff8fda36 | 1979 | case wxMAC: |
ea8e90b7 VZ |
1980 | case wxMAC_DARWIN: port += _T("Mac"); break; |
1981 | case wxBEOS: port += _T("BeOS"); break; | |
a02dc3e3 VZ |
1982 | case wxGTK: |
1983 | case wxGTK_WIN32: | |
1984 | case wxGTK_OS2: | |
ea8e90b7 | 1985 | case wxGTK_BEOS: port += _T("GTK"); break; |
a02dc3e3 VZ |
1986 | case wxWINDOWS: |
1987 | case wxPENWINDOWS: | |
1988 | case wxWINDOWS_NT: | |
1989 | case wxWIN32S: | |
1990 | case wxWIN95: | |
ea8e90b7 | 1991 | case wxWIN386: port += _T("MS Windows"); break; |
a02dc3e3 VZ |
1992 | case wxMGL_UNIX: |
1993 | case wxMGL_X: | |
1994 | case wxMGL_WIN32: | |
ea8e90b7 | 1995 | case wxMGL_OS2: port += _T("MGL"); break; |
a02dc3e3 | 1996 | case wxWINDOWS_OS2: |
ea8e90b7 VZ |
1997 | case wxOS2_PM: port += _T("OS/2"); break; |
1998 | default: port += _T("unknown"); break; | |
a02dc3e3 VZ |
1999 | } |
2000 | ||
2001 | wxMessageBox(wxString::Format( | |
2002 | _T( | |
af3062a8 | 2003 | " wxWindows Library (%s port)\nVersion %u.%u.%u%s, compiled at %s %s\n Copyright (c) 1995-2002 wxWindows team" |
a02dc3e3 VZ |
2004 | ), |
2005 | port.c_str(), | |
2006 | wxMAJOR_VERSION, | |
2007 | wxMINOR_VERSION, | |
2008 | wxRELEASE_NUMBER, | |
3f562374 VZ |
2009 | #if wxUSE_UNICODE |
2010 | L" (Unicode)", | |
2011 | #else | |
2012 | "", | |
2013 | #endif | |
2014 | __TDATE__, | |
2015 | __TTIME__ | |
a02dc3e3 VZ |
2016 | ), |
2017 | _T("wxWindows information"), | |
2018 | wxICON_INFORMATION | wxOK, | |
2019 | (wxWindow *)this); | |
2020 | } | |
2021 | else | |
1e6feb95 | 2022 | #endif // wxUSE_MSGDLG |
a02dc3e3 VZ |
2023 | { |
2024 | event.Skip(); | |
2025 | } | |
2026 | } | |
2027 | ||
ed5317e5 JS |
2028 | // ---------------------------------------------------------------------------- |
2029 | // accessibility | |
2030 | // ---------------------------------------------------------------------------- | |
2031 | ||
2032 | #if wxUSE_ACCESSIBILITY | |
2033 | void wxWindowBase::SetAccessible(wxAccessible* accessible) | |
2034 | { | |
2aefc528 | 2035 | if (m_accessible && (accessible != m_accessible)) |
ed5317e5 JS |
2036 | delete m_accessible; |
2037 | m_accessible = accessible; | |
2038 | if (m_accessible) | |
2039 | m_accessible->SetWindow((wxWindow*) this); | |
2040 | } | |
2041 | ||
2042 | // Returns the accessible object, creating if necessary. | |
2043 | wxAccessible* wxWindowBase::GetOrCreateAccessible() | |
2044 | { | |
2045 | if (!m_accessible) | |
2046 | m_accessible = CreateAccessible(); | |
2047 | return m_accessible; | |
2048 | } | |
2049 | ||
2050 | // Override to create a specific accessible object. | |
2051 | wxAccessible* wxWindowBase::CreateAccessible() | |
2052 | { | |
2053 | return new wxWindowAccessible((wxWindow*) this); | |
2054 | } | |
2055 | ||
2056 | #endif | |
2057 | ||
222ed1d6 | 2058 | #if !wxUSE_STL |
f03fc89f VZ |
2059 | // ---------------------------------------------------------------------------- |
2060 | // list classes implementation | |
2061 | // ---------------------------------------------------------------------------- | |
2062 | ||
2063 | void wxWindowListNode::DeleteData() | |
2064 | { | |
2065 | delete (wxWindow *)GetData(); | |
2066 | } | |
222ed1d6 | 2067 | #endif |
f03fc89f | 2068 | |
1e6feb95 VZ |
2069 | // ---------------------------------------------------------------------------- |
2070 | // borders | |
2071 | // ---------------------------------------------------------------------------- | |
2072 | ||
aede4ebb | 2073 | wxBorder wxWindowBase::GetBorder(long flags) const |
1e6feb95 | 2074 | { |
aede4ebb | 2075 | wxBorder border = (wxBorder)(flags & wxBORDER_MASK); |
1e6feb95 VZ |
2076 | if ( border == wxBORDER_DEFAULT ) |
2077 | { | |
2078 | border = GetDefaultBorder(); | |
2079 | } | |
2080 | ||
2081 | return border; | |
2082 | } | |
2083 | ||
2084 | wxBorder wxWindowBase::GetDefaultBorder() const | |
2085 | { | |
2086 | return wxBORDER_NONE; | |
2087 | } | |
2088 | ||
2089 | // ---------------------------------------------------------------------------- | |
2090 | // hit testing | |
2091 | // ---------------------------------------------------------------------------- | |
2092 | ||
2093 | wxHitTest wxWindowBase::DoHitTest(wxCoord x, wxCoord y) const | |
2094 | { | |
2095 | // here we just check if the point is inside the window or not | |
2096 | ||
2097 | // check the top and left border first | |
2098 | bool outside = x < 0 || y < 0; | |
2099 | if ( !outside ) | |
2100 | { | |
2101 | // check the right and bottom borders too | |
2102 | wxSize size = GetSize(); | |
2103 | outside = x >= size.x || y >= size.y; | |
2104 | } | |
2105 | ||
2106 | return outside ? wxHT_WINDOW_OUTSIDE : wxHT_WINDOW_INSIDE; | |
2107 | } | |
2108 | ||
94633ad9 VZ |
2109 | // ---------------------------------------------------------------------------- |
2110 | // mouse capture | |
2111 | // ---------------------------------------------------------------------------- | |
2112 | ||
2113 | struct WXDLLEXPORT wxWindowNext | |
2114 | { | |
2115 | wxWindow *win; | |
2116 | wxWindowNext *next; | |
786646f3 | 2117 | } *wxWindowBase::ms_winCaptureNext = NULL; |
94633ad9 | 2118 | |
a83e1475 | 2119 | void wxWindowBase::CaptureMouse() |
94633ad9 | 2120 | { |
7e555446 | 2121 | wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), this); |
45e0dc94 | 2122 | |
94633ad9 VZ |
2123 | wxWindow *winOld = GetCapture(); |
2124 | if ( winOld ) | |
2125 | { | |
df2f507b | 2126 | ((wxWindowBase*) winOld)->DoReleaseMouse(); |
edd802c6 | 2127 | |
94633ad9 VZ |
2128 | // save it on stack |
2129 | wxWindowNext *item = new wxWindowNext; | |
2130 | item->win = winOld; | |
2131 | item->next = ms_winCaptureNext; | |
2132 | ms_winCaptureNext = item; | |
2133 | } | |
2134 | //else: no mouse capture to save | |
2135 | ||
2136 | DoCaptureMouse(); | |
2137 | } | |
2138 | ||
a83e1475 | 2139 | void wxWindowBase::ReleaseMouse() |
94633ad9 | 2140 | { |
7e555446 | 2141 | wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), this); |
349d1942 | 2142 | |
63fd5f0b | 2143 | wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") ); |
a7b09001 | 2144 | |
94633ad9 VZ |
2145 | DoReleaseMouse(); |
2146 | ||
2147 | if ( ms_winCaptureNext ) | |
2148 | { | |
44f8caa7 | 2149 | ((wxWindowBase*)ms_winCaptureNext->win)->DoCaptureMouse(); |
edd802c6 | 2150 | |
94633ad9 VZ |
2151 | wxWindowNext *item = ms_winCaptureNext; |
2152 | ms_winCaptureNext = item->next; | |
2153 | delete item; | |
2154 | } | |
2155 | //else: stack is empty, no previous capture | |
2156 | ||
2157 | wxLogTrace(_T("mousecapture"), | |
e11f4636 DS |
2158 | (const wxChar *) _T("After ReleaseMouse() mouse is captured by %p"), |
2159 | GetCapture()); | |
94633ad9 VZ |
2160 | } |
2161 | ||
5048c832 | 2162 | #if wxUSE_HOTKEY |
540b6b09 VZ |
2163 | |
2164 | bool | |
2165 | wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId), | |
2166 | int WXUNUSED(modifiers), | |
2167 | int WXUNUSED(keycode)) | |
5048c832 JS |
2168 | { |
2169 | // not implemented | |
2170 | return false; | |
2171 | } | |
2172 | ||
540b6b09 | 2173 | bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId)) |
5048c832 JS |
2174 | { |
2175 | // not implemented | |
2176 | return false; | |
2177 | } | |
540b6b09 VZ |
2178 | |
2179 | #endif // wxUSE_HOTKEY | |
7de59551 RD |
2180 | |
2181 | void wxWindowBase::SendDestroyEvent() | |
2182 | { | |
2183 | wxWindowDestroyEvent event; | |
2184 | event.SetEventObject(this); | |
2185 | event.SetId(GetId()); | |
2186 | GetEventHandler()->ProcessEvent(event); | |
2187 | } | |
2188 | ||
4caf847c VZ |
2189 | // ---------------------------------------------------------------------------- |
2190 | // event processing | |
2191 | // ---------------------------------------------------------------------------- | |
2192 | ||
ac8d0c11 | 2193 | bool wxWindowBase::TryValidator(wxEvent& wxVALIDATOR_PARAM(event)) |
4caf847c | 2194 | { |
6eabf58c | 2195 | #if wxUSE_VALIDATORS |
4caf847c VZ |
2196 | // Can only use the validator of the window which |
2197 | // is receiving the event | |
2198 | if ( event.GetEventObject() == this ) | |
2199 | { | |
2200 | wxValidator *validator = GetValidator(); | |
2201 | if ( validator && validator->ProcessEvent(event) ) | |
2202 | { | |
6eabf58c | 2203 | return true; |
4caf847c VZ |
2204 | } |
2205 | } | |
6eabf58c | 2206 | #endif // wxUSE_VALIDATORS |
4caf847c | 2207 | |
6eabf58c | 2208 | return false; |
4caf847c VZ |
2209 | } |
2210 | ||
4caf847c VZ |
2211 | bool wxWindowBase::TryParent(wxEvent& event) |
2212 | { | |
040e234d VZ |
2213 | // carry on up the parent-child hierarchy if the propgation count hasn't |
2214 | // reached zero yet | |
2215 | if ( event.ShouldPropagate() ) | |
4caf847c VZ |
2216 | { |
2217 | // honour the requests to stop propagation at this window: this is | |
2218 | // used by the dialogs, for example, to prevent processing the events | |
2219 | // from the dialog controls in the parent frame which rarely, if ever, | |
2220 | // makes sense | |
2221 | if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS) ) | |
2222 | { | |
2223 | wxWindow *parent = GetParent(); | |
2224 | if ( parent && !parent->IsBeingDeleted() ) | |
040e234d VZ |
2225 | { |
2226 | wxPropagateOnce propagateOnce(event); | |
2227 | ||
4caf847c | 2228 | return parent->GetEventHandler()->ProcessEvent(event); |
040e234d | 2229 | } |
4caf847c VZ |
2230 | } |
2231 | } | |
2232 | ||
2233 | return wxEvtHandler::TryParent(event); | |
2234 | } | |
2235 | ||
33b494d6 VZ |
2236 | // ---------------------------------------------------------------------------- |
2237 | // global functions | |
2238 | // ---------------------------------------------------------------------------- | |
2239 | ||
2240 | wxWindow* wxGetTopLevelParent(wxWindow *win) | |
2241 | { | |
2242 | while ( win && !win->IsTopLevel() ) | |
2243 | win = win->GetParent(); | |
2244 | ||
2245 | return win; | |
2246 | } | |
2247 | ||
ed5317e5 JS |
2248 | #if wxUSE_ACCESSIBILITY |
2249 | // ---------------------------------------------------------------------------- | |
2250 | // accessible object for windows | |
2251 | // ---------------------------------------------------------------------------- | |
2252 | ||
2253 | // Can return either a child object, or an integer | |
2254 | // representing the child element, starting from 1. | |
66b9ec3d | 2255 | wxAccStatus wxWindowAccessible::HitTest(const wxPoint& WXUNUSED(pt), int* WXUNUSED(childId), wxAccessible** WXUNUSED(childObject)) |
ed5317e5 JS |
2256 | { |
2257 | wxASSERT( GetWindow() != NULL ); | |
2258 | if (!GetWindow()) | |
2259 | return wxACC_FAIL; | |
2260 | ||
2261 | return wxACC_NOT_IMPLEMENTED; | |
2262 | } | |
2263 | ||
2264 | // Returns the rectangle for this object (id = 0) or a child element (id > 0). | |
2265 | wxAccStatus wxWindowAccessible::GetLocation(wxRect& rect, int elementId) | |
2266 | { | |
2267 | wxASSERT( GetWindow() != NULL ); | |
2268 | if (!GetWindow()) | |
2269 | return wxACC_FAIL; | |
2270 | ||
c6e2af45 JS |
2271 | wxWindow* win = NULL; |
2272 | if (elementId == 0) | |
2273 | { | |
2274 | win = GetWindow(); | |
2275 | } | |
2276 | else | |
2277 | { | |
2278 | if (elementId <= (int) GetWindow()->GetChildren().GetCount()) | |
2279 | { | |
ee6eb8d8 | 2280 | win = GetWindow()->GetChildren().Item(elementId-1)->GetData(); |
c6e2af45 JS |
2281 | } |
2282 | else | |
2283 | return wxACC_FAIL; | |
2284 | } | |
2285 | if (win) | |
2286 | { | |
2287 | rect = win->GetRect(); | |
2288 | if (win->GetParent() && !win->IsKindOf(CLASSINFO(wxTopLevelWindow))) | |
2289 | rect.SetPosition(win->GetParent()->ClientToScreen(rect.GetPosition())); | |
2290 | return wxACC_OK; | |
2291 | } | |
2292 | ||
ed5317e5 JS |
2293 | return wxACC_NOT_IMPLEMENTED; |
2294 | } | |
2295 | ||
2296 | // Navigates from fromId to toId/toObject. | |
2297 | wxAccStatus wxWindowAccessible::Navigate(wxNavDir navDir, int fromId, | |
66b9ec3d | 2298 | int* WXUNUSED(toId), wxAccessible** toObject) |
ed5317e5 JS |
2299 | { |
2300 | wxASSERT( GetWindow() != NULL ); | |
2301 | if (!GetWindow()) | |
2302 | return wxACC_FAIL; | |
2303 | ||
c6e2af45 JS |
2304 | switch (navDir) |
2305 | { | |
2306 | case wxNAVDIR_FIRSTCHILD: | |
2307 | { | |
2308 | if (GetWindow()->GetChildren().GetCount() == 0) | |
2309 | return wxACC_FALSE; | |
2310 | wxWindow* childWindow = (wxWindow*) GetWindow()->GetChildren().GetFirst()->GetData(); | |
2311 | *toObject = childWindow->GetOrCreateAccessible(); | |
2312 | ||
2313 | return wxACC_OK; | |
2314 | } | |
2315 | case wxNAVDIR_LASTCHILD: | |
2316 | { | |
2317 | if (GetWindow()->GetChildren().GetCount() == 0) | |
2318 | return wxACC_FALSE; | |
2319 | wxWindow* childWindow = (wxWindow*) GetWindow()->GetChildren().GetLast()->GetData(); | |
2320 | *toObject = childWindow->GetOrCreateAccessible(); | |
2321 | ||
2322 | return wxACC_OK; | |
2323 | } | |
2324 | case wxNAVDIR_RIGHT: | |
2325 | case wxNAVDIR_DOWN: | |
2326 | case wxNAVDIR_NEXT: | |
2327 | { | |
ee6eb8d8 MB |
2328 | wxWindowList::compatibility_iterator node = |
2329 | wxWindowList::compatibility_iterator(); | |
c6e2af45 JS |
2330 | if (fromId == 0) |
2331 | { | |
2332 | // Can't navigate to sibling of this window | |
2333 | // if we're a top-level window. | |
2334 | if (!GetWindow()->GetParent()) | |
2335 | return wxACC_NOT_IMPLEMENTED; | |
2336 | ||
2337 | node = GetWindow()->GetParent()->GetChildren().Find(GetWindow()); | |
2338 | } | |
2339 | else | |
2340 | { | |
2341 | if (fromId <= (int) GetWindow()->GetChildren().GetCount()) | |
33b3f7c3 | 2342 | node = GetWindow()->GetChildren().Item(fromId-1); |
c6e2af45 JS |
2343 | } |
2344 | ||
2345 | if (node && node->GetNext()) | |
2346 | { | |
ee6eb8d8 | 2347 | wxWindow* nextWindow = node->GetNext()->GetData(); |
c6e2af45 JS |
2348 | *toObject = nextWindow->GetOrCreateAccessible(); |
2349 | return wxACC_OK; | |
2350 | } | |
2351 | else | |
2352 | return wxACC_FALSE; | |
2353 | } | |
2354 | case wxNAVDIR_LEFT: | |
2355 | case wxNAVDIR_UP: | |
2356 | case wxNAVDIR_PREVIOUS: | |
2357 | { | |
ee6eb8d8 MB |
2358 | wxWindowList::compatibility_iterator node = |
2359 | wxWindowList::compatibility_iterator(); | |
c6e2af45 JS |
2360 | if (fromId == 0) |
2361 | { | |
2362 | // Can't navigate to sibling of this window | |
2363 | // if we're a top-level window. | |
2364 | if (!GetWindow()->GetParent()) | |
2365 | return wxACC_NOT_IMPLEMENTED; | |
2366 | ||
2367 | node = GetWindow()->GetParent()->GetChildren().Find(GetWindow()); | |
2368 | } | |
2369 | else | |
2370 | { | |
2371 | if (fromId <= (int) GetWindow()->GetChildren().GetCount()) | |
33b3f7c3 | 2372 | node = GetWindow()->GetChildren().Item(fromId-1); |
c6e2af45 JS |
2373 | } |
2374 | ||
2375 | if (node && node->GetPrevious()) | |
2376 | { | |
ee6eb8d8 | 2377 | wxWindow* previousWindow = node->GetPrevious()->GetData(); |
c6e2af45 JS |
2378 | *toObject = previousWindow->GetOrCreateAccessible(); |
2379 | return wxACC_OK; | |
2380 | } | |
2381 | else | |
2382 | return wxACC_FALSE; | |
2383 | } | |
2384 | } | |
2385 | ||
ed5317e5 JS |
2386 | return wxACC_NOT_IMPLEMENTED; |
2387 | } | |
2388 | ||
2389 | // Gets the name of the specified object. | |
2390 | wxAccStatus wxWindowAccessible::GetName(int childId, wxString* name) | |
2391 | { | |
2392 | wxASSERT( GetWindow() != NULL ); | |
2393 | if (!GetWindow()) | |
2394 | return wxACC_FAIL; | |
2395 | ||
2aefc528 JS |
2396 | wxString title; |
2397 | ||
2398 | // If a child, leave wxWindows to call the function on the actual | |
2399 | // child object. | |
2400 | if (childId > 0) | |
2401 | return wxACC_NOT_IMPLEMENTED; | |
2402 | ||
2403 | // This will eventually be replaced by specialised | |
2404 | // accessible classes, one for each kind of wxWindows | |
2405 | // control or window. | |
2406 | if (GetWindow()->IsKindOf(CLASSINFO(wxButton))) | |
2407 | title = ((wxButton*) GetWindow())->GetLabel(); | |
2408 | else | |
2409 | title = GetWindow()->GetName(); | |
e11f4636 | 2410 | |
ed5317e5 JS |
2411 | if (!title.IsEmpty()) |
2412 | { | |
2413 | *name = title; | |
2414 | return wxACC_OK; | |
2415 | } | |
2416 | else | |
2417 | return wxACC_NOT_IMPLEMENTED; | |
2418 | } | |
2419 | ||
2420 | // Gets the number of children. | |
2421 | wxAccStatus wxWindowAccessible::GetChildCount(int* childId) | |
2422 | { | |
2423 | wxASSERT( GetWindow() != NULL ); | |
2424 | if (!GetWindow()) | |
2425 | return wxACC_FAIL; | |
2426 | ||
2427 | *childId = (int) GetWindow()->GetChildren().GetCount(); | |
2428 | return wxACC_OK; | |
2429 | } | |
2430 | ||
2431 | // Gets the specified child (starting from 1). | |
2432 | // If *child is NULL and return value is wxACC_OK, | |
2433 | // this means that the child is a simple element and | |
2434 | // not an accessible object. | |
2435 | wxAccStatus wxWindowAccessible::GetChild(int childId, wxAccessible** child) | |
2436 | { | |
2437 | wxASSERT( GetWindow() != NULL ); | |
2438 | if (!GetWindow()) | |
2439 | return wxACC_FAIL; | |
2440 | ||
2441 | if (childId == 0) | |
2442 | { | |
2443 | *child = this; | |
2444 | return wxACC_OK; | |
2445 | } | |
2446 | ||
2447 | if (childId > (int) GetWindow()->GetChildren().GetCount()) | |
2448 | return wxACC_FAIL; | |
2449 | ||
ee6eb8d8 | 2450 | wxWindow* childWindow = GetWindow()->GetChildren().Item(childId-1)->GetData(); |
ed5317e5 JS |
2451 | *child = childWindow->GetOrCreateAccessible(); |
2452 | if (*child) | |
2453 | return wxACC_OK; | |
2454 | else | |
2455 | return wxACC_FAIL; | |
2456 | } | |
2457 | ||
2458 | // Gets the parent, or NULL. | |
2459 | wxAccStatus wxWindowAccessible::GetParent(wxAccessible** parent) | |
2460 | { | |
2461 | wxASSERT( GetWindow() != NULL ); | |
2462 | if (!GetWindow()) | |
2463 | return wxACC_FAIL; | |
2464 | ||
2465 | wxWindow* parentWindow = GetWindow()->GetParent(); | |
c6e2af45 | 2466 | if (!parentWindow) |
ed5317e5 JS |
2467 | { |
2468 | *parent = NULL; | |
2469 | return wxACC_OK; | |
2470 | } | |
2471 | else | |
2472 | { | |
2473 | *parent = parentWindow->GetOrCreateAccessible(); | |
2474 | if (*parent) | |
2475 | return wxACC_OK; | |
2476 | else | |
2477 | return wxACC_FAIL; | |
2478 | } | |
2479 | } | |
2480 | ||
2481 | // Performs the default action. childId is 0 (the action for this object) | |
2482 | // or > 0 (the action for a child). | |
2483 | // Return wxACC_NOT_SUPPORTED if there is no default action for this | |
2484 | // window (e.g. an edit control). | |
66b9ec3d | 2485 | wxAccStatus wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId)) |
ed5317e5 JS |
2486 | { |
2487 | wxASSERT( GetWindow() != NULL ); | |
2488 | if (!GetWindow()) | |
2489 | return wxACC_FAIL; | |
2490 | ||
2491 | return wxACC_NOT_IMPLEMENTED; | |
2492 | } | |
2493 | ||
2494 | // Gets the default action for this object (0) or > 0 (the action for a child). | |
2495 | // Return wxACC_OK even if there is no action. actionName is the action, or the empty | |
2496 | // string if there is no action. | |
2497 | // The retrieved string describes the action that is performed on an object, | |
2498 | // not what the object does as a result. For example, a toolbar button that prints | |
2499 | // a document has a default action of "Press" rather than "Prints the current document." | |
66b9ec3d | 2500 | wxAccStatus wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId), wxString* WXUNUSED(actionName)) |
ed5317e5 JS |
2501 | { |
2502 | wxASSERT( GetWindow() != NULL ); | |
2503 | if (!GetWindow()) | |
2504 | return wxACC_FAIL; | |
2505 | ||
2506 | return wxACC_NOT_IMPLEMENTED; | |
2507 | } | |
2508 | ||
2509 | // Returns the description for this object or a child. | |
66b9ec3d | 2510 | wxAccStatus wxWindowAccessible::GetDescription(int WXUNUSED(childId), wxString* description) |
ed5317e5 JS |
2511 | { |
2512 | wxASSERT( GetWindow() != NULL ); | |
2513 | if (!GetWindow()) | |
2514 | return wxACC_FAIL; | |
2515 | ||
2aefc528 JS |
2516 | wxString ht(GetWindow()->GetHelpText()); |
2517 | if (!ht.IsEmpty()) | |
2518 | { | |
2519 | *description = ht; | |
2520 | return wxACC_OK; | |
2521 | } | |
ed5317e5 JS |
2522 | return wxACC_NOT_IMPLEMENTED; |
2523 | } | |
2524 | ||
2525 | // Returns help text for this object or a child, similar to tooltip text. | |
66b9ec3d | 2526 | wxAccStatus wxWindowAccessible::GetHelpText(int WXUNUSED(childId), wxString* helpText) |
ed5317e5 JS |
2527 | { |
2528 | wxASSERT( GetWindow() != NULL ); | |
2529 | if (!GetWindow()) | |
2530 | return wxACC_FAIL; | |
2531 | ||
2532 | wxString ht(GetWindow()->GetHelpText()); | |
2533 | if (!ht.IsEmpty()) | |
2534 | { | |
2535 | *helpText = ht; | |
2536 | return wxACC_OK; | |
2537 | } | |
2538 | return wxACC_NOT_IMPLEMENTED; | |
2539 | } | |
2540 | ||
2541 | // Returns the keyboard shortcut for this object or child. | |
2542 | // Return e.g. ALT+K | |
66b9ec3d | 2543 | wxAccStatus wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId), wxString* WXUNUSED(shortcut)) |
ed5317e5 JS |
2544 | { |
2545 | wxASSERT( GetWindow() != NULL ); | |
2546 | if (!GetWindow()) | |
2547 | return wxACC_FAIL; | |
2548 | ||
2549 | return wxACC_NOT_IMPLEMENTED; | |
2550 | } | |
2551 | ||
2552 | // Returns a role constant. | |
2553 | wxAccStatus wxWindowAccessible::GetRole(int childId, wxAccRole* role) | |
2554 | { | |
2555 | wxASSERT( GetWindow() != NULL ); | |
2556 | if (!GetWindow()) | |
2557 | return wxACC_FAIL; | |
2558 | ||
2aefc528 JS |
2559 | // If a child, leave wxWindows to call the function on the actual |
2560 | // child object. | |
2561 | if (childId > 0) | |
2562 | return wxACC_NOT_IMPLEMENTED; | |
2563 | ||
2564 | if (GetWindow()->IsKindOf(CLASSINFO(wxControl))) | |
2565 | return wxACC_NOT_IMPLEMENTED; | |
2566 | #if wxUSE_STATUSBAR | |
2567 | if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar))) | |
2568 | return wxACC_NOT_IMPLEMENTED; | |
2569 | #endif | |
2570 | #if wxUSE_TOOLBAR | |
2571 | if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar))) | |
2572 | return wxACC_NOT_IMPLEMENTED; | |
2573 | #endif | |
2574 | ||
2575 | //*role = wxROLE_SYSTEM_CLIENT; | |
2576 | *role = wxROLE_SYSTEM_CLIENT; | |
2577 | return wxACC_OK; | |
2578 | ||
66b9ec3d | 2579 | #if 0 |
ed5317e5 | 2580 | return wxACC_NOT_IMPLEMENTED; |
66b9ec3d | 2581 | #endif |
ed5317e5 JS |
2582 | } |
2583 | ||
2584 | // Returns a state constant. | |
2585 | wxAccStatus wxWindowAccessible::GetState(int childId, long* state) | |
2586 | { | |
2587 | wxASSERT( GetWindow() != NULL ); | |
2588 | if (!GetWindow()) | |
2589 | return wxACC_FAIL; | |
2590 | ||
2aefc528 JS |
2591 | // If a child, leave wxWindows to call the function on the actual |
2592 | // child object. | |
2593 | if (childId > 0) | |
2594 | return wxACC_NOT_IMPLEMENTED; | |
2595 | ||
2596 | if (GetWindow()->IsKindOf(CLASSINFO(wxControl))) | |
2597 | return wxACC_NOT_IMPLEMENTED; | |
2598 | ||
2599 | #if wxUSE_STATUSBAR | |
2600 | if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar))) | |
2601 | return wxACC_NOT_IMPLEMENTED; | |
2602 | #endif | |
2603 | #if wxUSE_TOOLBAR | |
2604 | if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar))) | |
2605 | return wxACC_NOT_IMPLEMENTED; | |
2606 | #endif | |
2607 | ||
2608 | *state = 0; | |
2609 | return wxACC_OK; | |
2610 | ||
66b9ec3d | 2611 | #if 0 |
ed5317e5 | 2612 | return wxACC_NOT_IMPLEMENTED; |
66b9ec3d | 2613 | #endif |
ed5317e5 JS |
2614 | } |
2615 | ||
2616 | // Returns a localized string representing the value for the object | |
2617 | // or child. | |
66b9ec3d | 2618 | wxAccStatus wxWindowAccessible::GetValue(int WXUNUSED(childId), wxString* WXUNUSED(strValue)) |
ed5317e5 JS |
2619 | { |
2620 | wxASSERT( GetWindow() != NULL ); | |
2621 | if (!GetWindow()) | |
2622 | return wxACC_FAIL; | |
2623 | ||
2624 | return wxACC_NOT_IMPLEMENTED; | |
2625 | } | |
2626 | ||
2627 | // Selects the object or child. | |
66b9ec3d | 2628 | wxAccStatus wxWindowAccessible::Select(int WXUNUSED(childId), wxAccSelectionFlags WXUNUSED(selectFlags)) |
ed5317e5 JS |
2629 | { |
2630 | wxASSERT( GetWindow() != NULL ); | |
2631 | if (!GetWindow()) | |
2632 | return wxACC_FAIL; | |
2633 | ||
2634 | return wxACC_NOT_IMPLEMENTED; | |
2635 | } | |
2636 | ||
2637 | // Gets the window with the keyboard focus. | |
2638 | // If childId is 0 and child is NULL, no object in | |
2639 | // this subhierarchy has the focus. | |
2640 | // If this object has the focus, child should be 'this'. | |
66b9ec3d | 2641 | wxAccStatus wxWindowAccessible::GetFocus(int* WXUNUSED(childId), wxAccessible** WXUNUSED(child)) |
ed5317e5 JS |
2642 | { |
2643 | wxASSERT( GetWindow() != NULL ); | |
2644 | if (!GetWindow()) | |
2645 | return wxACC_FAIL; | |
2646 | ||
2647 | return wxACC_NOT_IMPLEMENTED; | |
2648 | } | |
2649 | ||
2650 | // Gets a variant representing the selected children | |
2651 | // of this object. | |
2652 | // Acceptable values: | |
2653 | // - a null variant (IsNull() returns TRUE) | |
2654 | // - a list variant (GetType() == wxT("list") | |
2655 | // - an integer representing the selected child element, | |
2656 | // or 0 if this object is selected (GetType() == wxT("long") | |
2657 | // - a "void*" pointer to a wxAccessible child object | |
66b9ec3d | 2658 | wxAccStatus wxWindowAccessible::GetSelections(wxVariant* WXUNUSED(selections)) |
ed5317e5 JS |
2659 | { |
2660 | wxASSERT( GetWindow() != NULL ); | |
2661 | if (!GetWindow()) | |
2662 | return wxACC_FAIL; | |
2663 | ||
2664 | return wxACC_NOT_IMPLEMENTED; | |
2665 | } | |
2666 | ||
2667 | #endif // wxUSE_ACCESSIBILITY |