X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ac8d0c118b7403e2838e75124b442051299e6f6c..73fe67bd60b57f95dc63809f7843ed2a15928436:/src/common/wincmn.cpp diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index dc4f307488..5f892e172d 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -95,7 +95,7 @@ BEGIN_EVENT_TABLE(wxWindowBase, wxEvtHandler) EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick) #if wxUSE_HELP - EVT_HELP(-1, wxWindowBase::OnHelp) + EVT_HELP(wxID_ANY, wxWindowBase::OnHelp) #endif // wxUSE_HELP END_EVENT_TABLE() @@ -109,11 +109,11 @@ END_EVENT_TABLE() // ---------------------------------------------------------------------------- // the default initialization -void wxWindowBase::InitBase() +wxWindowBase::wxWindowBase() { // no window yet, no parent nor children m_parent = (wxWindow *)NULL; - m_windowId = -1; + m_windowId = wxID_ANY; // no constraints on the minimal window size m_minWidth = @@ -121,9 +121,9 @@ void wxWindowBase::InitBase() m_maxWidth = m_maxHeight = -1; - // window is created enabled but it's not visible yet - m_isShown = FALSE; - m_isEnabled = TRUE; + // window are created enabled and visible by default + m_isShown = + m_isEnabled = true; // the default event handler is just this window m_eventHandler = this; @@ -147,9 +147,9 @@ void wxWindowBase::InitBase() // the colours/fonts are default for now m_hasBgCol = m_hasFgCol = - m_hasFont = FALSE; - - m_isBeingDeleted = FALSE; + m_hasFont = false; + + m_isBeingDeleted = false; // no style bits m_exStyle = @@ -163,7 +163,7 @@ void wxWindowBase::InitBase() m_windowSizer = (wxSizer *) NULL; m_containingSizer = (wxSizer *) NULL; - m_autoLayout = FALSE; + m_autoLayout = false; #if wxUSE_DRAG_AND_DROP m_dropTarget = (wxDropTarget *)NULL; @@ -178,7 +178,7 @@ void wxWindowBase::InitBase() #endif // wxUSE_CARET #if wxUSE_PALETTE - m_hasCustomPalette = FALSE; + m_hasCustomPalette = false; #endif // wxUSE_PALETTE #if wxUSE_ACCESSIBILITY @@ -186,14 +186,16 @@ void wxWindowBase::InitBase() #endif m_virtualSize = wxDefaultSize; - + m_minVirtualWidth = m_minVirtualHeight = m_maxVirtualWidth = m_maxVirtualHeight = -1; + m_windowVariant = wxWINDOW_VARIANT_NORMAL ; + // Whether we're using the current theme for this window (wxGTK only for now) - m_themeEnabled = FALSE; + m_themeEnabled = false; } // common part of window creation process @@ -241,7 +243,7 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent, SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY); } - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -322,7 +324,7 @@ bool wxWindowBase::Destroy() { delete this; - return TRUE; + return true; } bool wxWindowBase::Close(bool force) @@ -331,7 +333,7 @@ bool wxWindowBase::Close(bool force) event.SetEventObject(this); event.SetCanVeto(!force); - // return FALSE if window wasn't closed because the application vetoed the + // return false if window wasn't closed because the application vetoed the // close event return GetEventHandler()->ProcessEvent(event) && !event.GetVeto(); } @@ -348,13 +350,17 @@ bool wxWindowBase::DestroyChildren() wxWindow *child = node->GetData(); - child->Destroy(); + // note that we really want to call delete and not ->Destroy() here + // because we want to delete the child immediately, before we are + // deleted, and delayed deletion would result in problems as our (top + // level) child could outlive its parent + delete child; wxASSERT_MSG( !GetChildren().Find(child), wxT("child didn't remove itself using RemoveChild()") ); } - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -617,6 +623,41 @@ void wxWindowBase::SetSizeHints(int minW, int minH, m_maxHeight = maxH; } +void wxWindowBase::SetWindowVariant( wxWindowVariant variant ) +{ + if ( m_windowVariant == variant ) + return ; + + m_windowVariant = variant ; + + DoSetWindowVariant( variant ) ; + return ; +} + +void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant ) +{ + wxFont font = wxSystemSettings::GetSystemFont( wxSYS_DEFAULT_GUI_FONT ) ; + int size = font.GetPointSize() ; + switch ( variant ) + { + case wxWINDOW_VARIANT_NORMAL : + break ; + case wxWINDOW_VARIANT_SMALL : + font.SetPointSize( size * 3 / 4 ) ; + break ; + case wxWINDOW_VARIANT_MINI : + font.SetPointSize( size * 2 / 3 ) ; + break ; + case wxWINDOW_VARIANT_LARGE : + font.SetPointSize( size * 5 / 4 ) ; + break ; + default: + wxFAIL_MSG(_T("unexpected window variant")); + break ; + } + SetFont( font ) ; +} + void wxWindowBase::SetVirtualSizeHints( int minW, int minH, int maxW, int maxH ) { @@ -658,11 +699,11 @@ bool wxWindowBase::Show(bool show) { m_isShown = show; - return TRUE; + return true; } else { - return FALSE; + return false; } } @@ -672,11 +713,11 @@ bool wxWindowBase::Enable(bool enable) { m_isEnabled = enable; - return TRUE; + return true; } else { - return FALSE; + return false; } } // ---------------------------------------------------------------------------- @@ -685,7 +726,7 @@ bool wxWindowBase::Enable(bool enable) bool wxWindowBase::IsTopLevel() const { - return FALSE; + return false; } // ---------------------------------------------------------------------------- @@ -719,7 +760,7 @@ bool wxWindowBase::Reparent(wxWindowBase *newParent) if ( newParent == oldParent ) { // nothing done - return FALSE; + return false; } // unlink this window from the existing parent. @@ -742,7 +783,7 @@ bool wxWindowBase::Reparent(wxWindowBase *newParent) wxTopLevelWindows.Append((wxWindow *)this); } - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -785,7 +826,7 @@ wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler) bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handler) { - wxCHECK_MSG( handler, FALSE, _T("RemoveEventHandler(NULL) called") ); + wxCHECK_MSG( handler, false, _T("RemoveEventHandler(NULL) called") ); wxEvtHandler *handlerPrev = NULL, *handlerCur = GetEventHandler(); @@ -808,9 +849,11 @@ bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handler) { handlerNext->SetPreviousHandler ( handlerPrev ); } + handler->SetNextHandler(NULL); + handler->SetPreviousHandler(NULL); - return TRUE; + return true; } handlerPrev = handlerCur; @@ -819,7 +862,7 @@ bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handler) wxFAIL_MSG( _T("where has the event handler gone?") ); - return FALSE; + return false; } // ---------------------------------------------------------------------------- @@ -829,25 +872,25 @@ bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handler) bool wxWindowBase::SetBackgroundColour( const wxColour &colour ) { if ( !colour.Ok() || (colour == m_backgroundColour) ) - return FALSE; + return false; m_backgroundColour = colour; - m_hasBgCol = TRUE; + m_hasBgCol = true; - return TRUE; + return true; } bool wxWindowBase::SetForegroundColour( const wxColour &colour ) { if ( !colour.Ok() || (colour == m_foregroundColour) ) - return FALSE; + return false; m_foregroundColour = colour; - m_hasFgCol = TRUE; + m_hasFgCol = true; - return TRUE; + return true; } bool wxWindowBase::SetCursor(const wxCursor& cursor) @@ -857,12 +900,12 @@ bool wxWindowBase::SetCursor(const wxCursor& cursor) if ( m_cursor == cursor ) { // no change - return FALSE; + return false; } m_cursor = cursor; - return TRUE; + return true; } bool wxWindowBase::SetFont(const wxFont& font) @@ -873,21 +916,21 @@ bool wxWindowBase::SetFont(const wxFont& font) if ( fontOk == m_font ) { // no change - return FALSE; + return false; } m_font = fontOk; - m_hasFont = TRUE; + m_hasFont = true; - return TRUE; + return true; } #if wxUSE_PALETTE void wxWindowBase::SetPalette(const wxPalette& pal) { - m_hasCustomPalette = TRUE; + m_hasCustomPalette = true; m_palette = pal; // VZ: can anyone explain me what do we do here? @@ -1168,17 +1211,17 @@ bool wxWindowBase::Validate() wxValidator *validator = child->GetValidator(); if ( validator && !validator->Validate((wxWindow *)this) ) { - return FALSE; + return false; } if ( recurse && !child->Validate() ) { - return FALSE; + return false; } } #endif // wxUSE_VALIDATORS - return TRUE; + return true; } bool wxWindowBase::TransferDataToWindow() @@ -1198,7 +1241,7 @@ bool wxWindowBase::TransferDataToWindow() wxLog::FlushActive(); #endif // wxUSE_LOG - return FALSE; + return false; } if ( recurse ) @@ -1206,13 +1249,13 @@ bool wxWindowBase::TransferDataToWindow() if ( !child->TransferDataToWindow() ) { // warning already given - return FALSE; + return false; } } } #endif // wxUSE_VALIDATORS - return TRUE; + return true; } bool wxWindowBase::TransferDataFromWindow() @@ -1230,7 +1273,7 @@ bool wxWindowBase::TransferDataFromWindow() // nop warning here because the application is supposed to give // one itself - we don't know here what might have gone wrongly - return FALSE; + return false; } if ( recurse ) @@ -1238,13 +1281,13 @@ bool wxWindowBase::TransferDataFromWindow() if ( !child->TransferDataFromWindow() ) { // warning already given - return FALSE; + return false; } } } #endif // wxUSE_VALIDATORS - return TRUE; + return true; } void wxWindowBase::InitDialog() @@ -1460,6 +1503,9 @@ void wxWindowBase::DeleteRelatedConstraints() void wxWindowBase::SetSizer(wxSizer *sizer, bool deleteOld) { + if ( sizer == m_windowSizer) + return; + if ( deleteOld ) delete m_windowSizer; @@ -1518,7 +1564,7 @@ bool wxWindowBase::Layout() } #endif - return TRUE; + return true; } #if wxUSE_CONSTRAINTS @@ -1542,7 +1588,7 @@ bool wxWindowBase::LayoutPhase2(int *noChanges) // Layout grand children DoPhase(2); - return TRUE; + return true; } // Do a phase of evaluating child constraints @@ -1596,7 +1642,7 @@ bool wxWindowBase::DoPhase(int phase) } } - return TRUE; + return true; } void wxWindowBase::ResetConstraints() @@ -1604,14 +1650,14 @@ void wxWindowBase::ResetConstraints() wxLayoutConstraints *constr = GetConstraints(); if ( constr ) { - constr->left.SetDone(FALSE); - constr->top.SetDone(FALSE); - constr->right.SetDone(FALSE); - constr->bottom.SetDone(FALSE); - constr->width.SetDone(FALSE); - constr->height.SetDone(FALSE); - constr->centreX.SetDone(FALSE); - constr->centreY.SetDone(FALSE); + constr->left.SetDone(false); + constr->top.SetDone(false); + constr->right.SetDone(false); + constr->bottom.SetDone(false); + constr->width.SetDone(false); + constr->height.SetDone(false); + constr->centreX.SetDone(false); + constr->centreY.SetDone(false); } wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); @@ -1676,22 +1722,22 @@ void wxWindowBase::SetSizeConstraint(int x, int y, int w, int h) if ( x != -1 ) { constr->left.SetValue(x); - constr->left.SetDone(TRUE); + constr->left.SetDone(true); } if ( y != -1 ) { constr->top.SetValue(y); - constr->top.SetDone(TRUE); + constr->top.SetDone(true); } if ( w != -1 ) { constr->width.SetValue(w); - constr->width.SetDone(TRUE); + constr->width.SetDone(true); } if ( h != -1 ) { constr->height.SetValue(h); - constr->height.SetDone(TRUE); + constr->height.SetDone(true); } } } @@ -1704,12 +1750,12 @@ void wxWindowBase::MoveConstraint(int x, int y) if ( x != -1 ) { constr->left.SetValue(x); - constr->left.SetDone(TRUE); + constr->left.SetDone(true); } if ( y != -1 ) { constr->top.SetValue(y); - constr->top.SetDone(TRUE); + constr->top.SetDone(true); } } } @@ -1802,7 +1848,7 @@ void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event) { if ( event.GetSetEnabled() ) Enable(event.GetEnabled()); - + #if wxUSE_CONTROLS if ( event.GetSetText() ) { @@ -1829,7 +1875,7 @@ void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event) radiobtn->SetValue(event.GetChecked()); } #endif // wxUSE_RADIOBTN - } + } #endif } @@ -1909,7 +1955,7 @@ void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& event) void wxWindowBase::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) ) { TransferDataToWindow(); - + // Update the UI at this point UpdateWindowUI(wxUPDATE_UI_RECURSE); } @@ -2109,8 +2155,8 @@ void wxWindowBase::ReleaseMouse() //else: stack is empty, no previous capture wxLogTrace(_T("mousecapture"), - _T("After ReleaseMouse() mouse is captured by %p"), - GetCapture()); + (const wxChar *) _T("After ReleaseMouse() mouse is captured by %p"), + GetCapture()); } #if wxUSE_HOTKEY @@ -2206,7 +2252,7 @@ wxWindow* wxGetTopLevelParent(wxWindow *win) // Can return either a child object, or an integer // representing the child element, starting from 1. -wxAccStatus wxWindowAccessible::HitTest(const wxPoint& pt, int* childId, wxAccessible** childObject) +wxAccStatus wxWindowAccessible::HitTest(const wxPoint& WXUNUSED(pt), int* WXUNUSED(childId), wxAccessible** WXUNUSED(childObject)) { wxASSERT( GetWindow() != NULL ); if (!GetWindow()) @@ -2249,7 +2295,7 @@ wxAccStatus wxWindowAccessible::GetLocation(wxRect& rect, int elementId) // Navigates from fromId to toId/toObject. wxAccStatus wxWindowAccessible::Navigate(wxNavDir navDir, int fromId, - int* toId, wxAccessible** toObject) + int* WXUNUSED(toId), wxAccessible** toObject) { wxASSERT( GetWindow() != NULL ); if (!GetWindow()) @@ -2361,7 +2407,7 @@ wxAccStatus wxWindowAccessible::GetName(int childId, wxString* name) title = ((wxButton*) GetWindow())->GetLabel(); else title = GetWindow()->GetName(); - + if (!title.IsEmpty()) { *name = title; @@ -2436,7 +2482,7 @@ wxAccStatus wxWindowAccessible::GetParent(wxAccessible** parent) // or > 0 (the action for a child). // Return wxACC_NOT_SUPPORTED if there is no default action for this // window (e.g. an edit control). -wxAccStatus wxWindowAccessible::DoDefaultAction(int childId) +wxAccStatus wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId)) { wxASSERT( GetWindow() != NULL ); if (!GetWindow()) @@ -2451,7 +2497,7 @@ wxAccStatus wxWindowAccessible::DoDefaultAction(int childId) // The retrieved string describes the action that is performed on an object, // not what the object does as a result. For example, a toolbar button that prints // a document has a default action of "Press" rather than "Prints the current document." -wxAccStatus wxWindowAccessible::GetDefaultAction(int childId, wxString* actionName) +wxAccStatus wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId), wxString* WXUNUSED(actionName)) { wxASSERT( GetWindow() != NULL ); if (!GetWindow()) @@ -2461,7 +2507,7 @@ wxAccStatus wxWindowAccessible::GetDefaultAction(int childId, wxString* actionNa } // Returns the description for this object or a child. -wxAccStatus wxWindowAccessible::GetDescription(int childId, wxString* description) +wxAccStatus wxWindowAccessible::GetDescription(int WXUNUSED(childId), wxString* description) { wxASSERT( GetWindow() != NULL ); if (!GetWindow()) @@ -2477,7 +2523,7 @@ wxAccStatus wxWindowAccessible::GetDescription(int childId, wxString* descriptio } // Returns help text for this object or a child, similar to tooltip text. -wxAccStatus wxWindowAccessible::GetHelpText(int childId, wxString* helpText) +wxAccStatus wxWindowAccessible::GetHelpText(int WXUNUSED(childId), wxString* helpText) { wxASSERT( GetWindow() != NULL ); if (!GetWindow()) @@ -2494,7 +2540,7 @@ wxAccStatus wxWindowAccessible::GetHelpText(int childId, wxString* helpText) // Returns the keyboard shortcut for this object or child. // Return e.g. ALT+K -wxAccStatus wxWindowAccessible::GetKeyboardShortcut(int childId, wxString* shortcut) +wxAccStatus wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId), wxString* WXUNUSED(shortcut)) { wxASSERT( GetWindow() != NULL ); if (!GetWindow()) @@ -2530,7 +2576,9 @@ wxAccStatus wxWindowAccessible::GetRole(int childId, wxAccRole* role) *role = wxROLE_SYSTEM_CLIENT; return wxACC_OK; + #if 0 return wxACC_NOT_IMPLEMENTED; + #endif } // Returns a state constant. @@ -2560,12 +2608,14 @@ wxAccStatus wxWindowAccessible::GetState(int childId, long* state) *state = 0; return wxACC_OK; + #if 0 return wxACC_NOT_IMPLEMENTED; + #endif } // Returns a localized string representing the value for the object // or child. -wxAccStatus wxWindowAccessible::GetValue(int childId, wxString* strValue) +wxAccStatus wxWindowAccessible::GetValue(int WXUNUSED(childId), wxString* WXUNUSED(strValue)) { wxASSERT( GetWindow() != NULL ); if (!GetWindow()) @@ -2575,7 +2625,7 @@ wxAccStatus wxWindowAccessible::GetValue(int childId, wxString* strValue) } // Selects the object or child. -wxAccStatus wxWindowAccessible::Select(int childId, wxAccSelectionFlags selectFlags) +wxAccStatus wxWindowAccessible::Select(int WXUNUSED(childId), wxAccSelectionFlags WXUNUSED(selectFlags)) { wxASSERT( GetWindow() != NULL ); if (!GetWindow()) @@ -2588,7 +2638,7 @@ wxAccStatus wxWindowAccessible::Select(int childId, wxAccSelectionFlags selectFl // If childId is 0 and child is NULL, no object in // this subhierarchy has the focus. // If this object has the focus, child should be 'this'. -wxAccStatus wxWindowAccessible::GetFocus(int* childId, wxAccessible** child) +wxAccStatus wxWindowAccessible::GetFocus(int* WXUNUSED(childId), wxAccessible** WXUNUSED(child)) { wxASSERT( GetWindow() != NULL ); if (!GetWindow()) @@ -2605,7 +2655,7 @@ wxAccStatus wxWindowAccessible::GetFocus(int* childId, wxAccessible** child) // - an integer representing the selected child element, // or 0 if this object is selected (GetType() == wxT("long") // - a "void*" pointer to a wxAccessible child object -wxAccStatus wxWindowAccessible::GetSelections(wxVariant* selections) +wxAccStatus wxWindowAccessible::GetSelections(wxVariant* WXUNUSED(selections)) { wxASSERT( GetWindow() != NULL ); if (!GetWindow())