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