X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/abbd88b52b3080023a46af19e43a839fdf5c6fb0..7198c3368055d88249a338eb33b21f051f674806:/src/propgrid/propgrid.cpp diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index fac6436c3b..5af8805a19 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -375,9 +375,7 @@ void wxPropertyGrid::Init1() m_coloursCustomized = 0; m_frozen = 0; -#if wxPG_DOUBLE_BUFFER m_doubleBuffer = NULL; -#endif #ifndef wxPG_ICON_WIDTH m_expandbmp = NULL; @@ -544,10 +542,8 @@ wxPropertyGrid::~wxPropertyGrid() wxS("Close(false).)") ); } -#if wxPG_DOUBLE_BUFFER if ( m_doubleBuffer ) delete m_doubleBuffer; -#endif if ( m_iFlags & wxPG_FL_CREATEDSTATE ) delete m_pState; @@ -1127,9 +1123,7 @@ void wxPropertyGrid::SetExtraStyle( long exStyle ) } else { - #if wxPG_DOUBLE_BUFFER wxDELETE(m_doubleBuffer); - #endif } } @@ -1688,7 +1682,7 @@ wxPoint wxPropertyGrid::GetGoodEditorDialogPosition( wxPGProperty* p, wxString& wxPropertyGrid::ExpandEscapeSequences( wxString& dst_str, wxString& src_str ) { - if ( src_str.length() == 0 ) + if ( src_str.empty() ) { dst_str = src_str; return src_str; @@ -1747,7 +1741,7 @@ wxString& wxPropertyGrid::ExpandEscapeSequences( wxString& dst_str, wxString& sr wxString& wxPropertyGrid::CreateEscapeSequences( wxString& dst_str, wxString& src_str ) { - if ( src_str.length() == 0 ) + if ( src_str.empty() ) { dst_str = src_str; return src_str; @@ -1965,7 +1959,6 @@ void wxPropertyGrid::DrawItems( wxDC& dc, wxDC* dcPtr = &dc; bool isBuffered = false; - #if wxPG_DOUBLE_BUFFER wxMemoryDC* bufferDC = NULL; if ( !(GetExtraStyle() & wxPG_EX_NATIVE_DOUBLE_BUFFERING) ) @@ -1986,7 +1979,6 @@ void wxPropertyGrid::DrawItems( wxDC& dc, isBuffered = true; } } - #endif if ( dcPtr ) { @@ -2005,7 +1997,6 @@ void wxPropertyGrid::DrawItems( wxDC& dc, } } - #if wxPG_DOUBLE_BUFFER if ( bufferDC ) { dc.Blit( drawRect.x, drawRect.y, drawRect.width, @@ -2013,7 +2004,6 @@ void wxPropertyGrid::DrawItems( wxDC& dc, bufferDC, 0, 0, wxCOPY ); delete bufferDC; } - #endif } else { @@ -2085,10 +2075,11 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc, int xRelMod = 0; // - // With wxPG_DOUBLE_BUFFER, do double buffering + // For now, do some manual calculation for double buffering // - buffer's y = 0, so align itemsRect and coordinates to that // -#if wxPG_DOUBLE_BUFFER + // TODO: In future use wxAutoBufferedPaintDC (for example) + // int yRelMod = 0; wxRect cr2; @@ -2107,9 +2098,6 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc, firstItemTopY -= yRelMod; lastItemBottomY -= yRelMod; } -#else - wxUnusedVar(isBuffered); -#endif int x = m_marginWidth - xRelMod; @@ -2612,7 +2600,7 @@ void wxPropertyGrid::DrawItems( const wxPGProperty* p1, const wxPGProperty* p2 ) void wxPropertyGrid::RefreshProperty( wxPGProperty* p ) { - if ( m_pState->DoIsPropertySelected(p) ) + if ( m_pState->DoIsPropertySelected(p) || p->IsChildSelected(true) ) { // NB: We must copy the selection. wxArrayPGProperty selection = m_pState->m_selection; @@ -3162,7 +3150,7 @@ wxStatusBar* wxPropertyGrid::GetStatusBar() void wxPropertyGrid::DoShowPropertyError( wxPGProperty* WXUNUSED(property), const wxString& msg ) { - if ( !msg.length() ) + if ( msg.empty() ) return; #if wxUSE_STATUSBAR @@ -3290,7 +3278,7 @@ bool wxPropertyGrid::DoOnValidationFailure( wxPGProperty* property, wxVariant& W { wxString msg = m_validationInfo.m_failureMessage; - if ( !msg.length() ) + if ( msg.empty() ) msg = _("You have entered invalid value. Press ESC to cancel editing."); #if wxUSE_STATUSBAR @@ -3608,6 +3596,12 @@ bool wxPropertyGrid::HandleCustomEditorEvent( wxEvent &event ) } else if ( wnd->IsKindOf(CLASSINFO(wxComboCtrl)) ) { + // In some cases we might stumble unintentionally on + // wxComboCtrl's embedded wxTextCtrl's events. Let's + // avoid them. + if ( editorWnd->IsKindOf(CLASSINFO(wxTextCtrl)) ) + return false; + wxComboCtrl* cc = (wxComboCtrl*) wnd; wxString newTcValue = cc->GetTextCtrl()->GetValue(); @@ -3982,20 +3976,7 @@ void wxPropertyGrid::FreeEditors() // Return focus back to canvas from children (this is required at least for // GTK+, which, unlike Windows, clears focus when control is destroyed // instead of moving it to closest parent). - wxWindow* focus = wxWindow::FindFocus(); - if ( focus ) - { - wxWindow* parent = focus->GetParent(); - while ( parent ) - { - if ( parent == this ) - { - SetFocusOnCanvas(); - break; - } - parent = parent->GetParent(); - } - } + SetFocusOnCanvas(); // Do not free editors immediately if processing events if ( m_wndEditor2 ) @@ -4339,7 +4320,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags ) wxStatusBar* statusbar = GetStatusBar(); if ( statusbar ) { - if ( pHelpString && pHelpString->length() ) + if ( pHelpString && !pHelpString->empty() ) { // Set help box text. statusbar->SetStatusText( *pHelpString ); @@ -4361,7 +4342,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags ) // // Show help as a tool tip on the editor control. // - if ( pHelpString && pHelpString->length() && + if ( pHelpString && !pHelpString->empty() && primaryCtrl ) { primaryCtrl->SetToolTip(*pHelpString); @@ -4626,7 +4607,6 @@ void wxPropertyGrid::OnResize( wxSizeEvent& event ) m_width = width; m_height = height; -#if wxPG_DOUBLE_BUFFER if ( !(GetExtraStyle() & wxPG_EX_NATIVE_DOUBLE_BUFFERING) ) { int dblh = (m_lineHeight*2); @@ -4654,8 +4634,6 @@ void wxPropertyGrid::OnResize( wxSizeEvent& event ) } } -#endif - m_pState->OnClientWidthChange( width, event.GetSize().x - m_ncWidth, true ); m_ncWidth = event.GetSize().x; @@ -4691,7 +4669,24 @@ void wxPropertyGrid::SetVirtualWidth( int width ) void wxPropertyGrid::SetFocusOnCanvas() { - SetFocus(); + // To prevent wxPropertyGrid from stealing focus from other controls, + // only move focus to the grid if it was already in one if its child + // controls. + wxWindow* focus = wxWindow::FindFocus(); + if ( focus ) + { + wxWindow* parent = focus->GetParent(); + while ( parent ) + { + if ( parent == this ) + { + SetFocus(); + break; + } + parent = parent->GetParent(); + } + } + m_editorFocused = 0; } @@ -4824,7 +4819,7 @@ bool wxPropertyGrid::HandleMouseClick( int x, unsigned int y, wxMouseEvent &even } // Do not Skip() the event after selection has been made. - // Otherwise default event handling behavior kicks in + // Otherwise default event handling behaviour kicks in // and may revert focus back to the main canvas. res = true; } @@ -6020,7 +6015,7 @@ wxPGEditor* wxPropertyGrid::DoRegisterEditorClass( wxPGEditor* editorClass, RegisterDefaultEditors(); wxString name = editorName; - if ( name.length() == 0 ) + if ( name.empty() ) name = editorClass->GetName(); // Existing editor under this name? @@ -6421,7 +6416,7 @@ wxPGChoices wxPropertyGridPopulator::ParseChoices( const wxString& choicesString else { bool found = false; - if ( idString.length() ) + if ( !idString.empty() ) { wxPGHashMapS2P::iterator it = m_dictIdChoices.find(idString); if ( it != m_dictIdChoices.end() ) @@ -6497,7 +6492,7 @@ wxPGChoices wxPropertyGridPopulator::ParseChoices( const wxString& choicesString } // Assign to id - if ( idString.length() ) + if ( !idString.empty() ) m_dictIdChoices[idString] = choices.GetData(); } } @@ -6538,7 +6533,7 @@ bool wxPropertyGridPopulator::AddAttribute( const wxString& name, wxString valuel = value.Lower(); wxVariant variant; - if ( type.length() == 0 ) + if ( type.empty() ) { long v;