X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c6e2af4570ee868c93fc504b02f321efe5d5acee..c9fcf5817fe8079ebf2f7a51aef8035ca25ab52e:/src/common/wincmn.cpp diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 221d6dbf2f..5962b4b353 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -6,7 +6,7 @@ // Created: 13/07/98 // RCS-ID: $Id$ // Copyright: (c) wxWindows team -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -58,7 +58,7 @@ #endif // wxUSE_DRAG_AND_DROP #if wxUSE_ACCESSIBILITY - #include "wx/access.h" + #include "wx/access.h" #endif #if wxUSE_HELP @@ -149,6 +149,8 @@ void wxWindowBase::InitBase() m_hasBgCol = m_hasFgCol = m_hasFont = FALSE; + + m_isBeingDeleted = FALSE; // no style bits m_exStyle = @@ -224,8 +226,14 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent, _T("wxStaticBox can't be used as a window parent!") ); #endif // wxUSE_STATBOX + // ids are limited to 16 bits under MSW so if you care about portability, + // it's not a good idea to use ids out of this range (and negative ids are + // reserved for wxWindows own usage) + wxASSERT_MSG( id == wxID_ANY || (id >= 0 && id < 32767), + _T("invalid id value") ); + // generate a new id if the user doesn't care about it - m_windowId = id == -1 ? NewControlId() : id; + m_windowId = id == wxID_ANY ? NewControlId() : id; SetName(name); SetWindowStyleFlag(style); @@ -615,6 +623,12 @@ void wxWindowBase::SetSizeHints(int minW, int minH, int maxW, int maxH, int WXUNUSED(incW), int WXUNUSED(incH)) { + // setting min width greater than max width leads to infinite loops under + // X11 and generally doesn't make any sense, so don't allow it + wxCHECK_RET( (minW == -1 || maxW == -1 || minW <= maxW) && + (minH == -1 || maxH == -1 || minH <= maxH), + _T("min width/height must be less than max width/height!") ); + m_minWidth = minW; m_maxWidth = maxW; m_minHeight = minH; @@ -1953,7 +1967,7 @@ void wxWindowBase::OnMiddleClick( wxMouseEvent& event ) #if wxUSE_ACCESSIBILITY void wxWindowBase::SetAccessible(wxAccessible* accessible) { - if (m_accessible) + if (m_accessible && (accessible != m_accessible)) delete m_accessible; m_accessible = accessible; if (m_accessible) @@ -2078,6 +2092,15 @@ void wxWindowBase::ReleaseMouse() GetCapture()); } + +void wxWindowBase::SendDestroyEvent() +{ + wxWindowDestroyEvent event; + event.SetEventObject(this); + event.SetId(GetId()); + GetEventHandler()->ProcessEvent(event); +} + // ---------------------------------------------------------------------------- // global functions // ---------------------------------------------------------------------------- @@ -2236,7 +2259,21 @@ wxAccStatus wxWindowAccessible::GetName(int childId, wxString* name) if (!GetWindow()) return wxACC_FAIL; - wxString title(GetWindow()->GetTitle()); + wxString title; + + // If a child, leave wxWindows to call the function on the actual + // child object. + if (childId > 0) + return wxACC_NOT_IMPLEMENTED; + + // This will eventually be replaced by specialised + // accessible classes, one for each kind of wxWindows + // control or window. + if (GetWindow()->IsKindOf(CLASSINFO(wxButton))) + title = ((wxButton*) GetWindow())->GetLabel(); + else + title = GetWindow()->GetName(); + if (!title.IsEmpty()) { *name = title; @@ -2342,6 +2379,12 @@ wxAccStatus wxWindowAccessible::GetDescription(int childId, wxString* descriptio if (!GetWindow()) return wxACC_FAIL; + wxString ht(GetWindow()->GetHelpText()); + if (!ht.IsEmpty()) + { + *description = ht; + return wxACC_OK; + } return wxACC_NOT_IMPLEMENTED; } @@ -2379,6 +2422,26 @@ wxAccStatus wxWindowAccessible::GetRole(int childId, wxAccRole* role) if (!GetWindow()) return wxACC_FAIL; + // If a child, leave wxWindows to call the function on the actual + // child object. + if (childId > 0) + return wxACC_NOT_IMPLEMENTED; + + if (GetWindow()->IsKindOf(CLASSINFO(wxControl))) + return wxACC_NOT_IMPLEMENTED; +#if wxUSE_STATUSBAR + if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar))) + return wxACC_NOT_IMPLEMENTED; +#endif +#if wxUSE_TOOLBAR + if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar))) + return wxACC_NOT_IMPLEMENTED; +#endif + + //*role = wxROLE_SYSTEM_CLIENT; + *role = wxROLE_SYSTEM_CLIENT; + return wxACC_OK; + return wxACC_NOT_IMPLEMENTED; } @@ -2389,6 +2452,26 @@ wxAccStatus wxWindowAccessible::GetState(int childId, long* state) if (!GetWindow()) return wxACC_FAIL; + // If a child, leave wxWindows to call the function on the actual + // child object. + if (childId > 0) + return wxACC_NOT_IMPLEMENTED; + + if (GetWindow()->IsKindOf(CLASSINFO(wxControl))) + return wxACC_NOT_IMPLEMENTED; + +#if wxUSE_STATUSBAR + if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar))) + return wxACC_NOT_IMPLEMENTED; +#endif +#if wxUSE_TOOLBAR + if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar))) + return wxACC_NOT_IMPLEMENTED; +#endif + + *state = 0; + return wxACC_OK; + return wxACC_NOT_IMPLEMENTED; }