X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0847e36eff0512bf3c50c01e8d9dcff5e693ada5..b5aaf62e977b828214d65c3712478410fb2c8a05:/src/propgrid/editors.cpp diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index a05bed43d0..3dfbb8a12c 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -147,7 +147,7 @@ #endif // Number added to image width for SetCustomPaintWidth -#define ODCB_CUST_PAINT_MARGIN 9 +#define ODCB_CUST_PAINT_MARGIN 6 // Milliseconds to wait for two mouse-ups after focus inorder // to trigger a double-click. @@ -558,7 +558,7 @@ public: wxPropertyGrid* GetGrid() const { - wxPropertyGrid* pg = wxDynamicCast(GetParent()->GetParent(), + wxPropertyGrid* pg = wxDynamicCast(GetParent(), wxPropertyGrid); wxASSERT(pg); return pg; @@ -682,6 +682,9 @@ void wxPropertyGrid::OnComboItemPaint( const wxPGComboBox* pCb, if ( pDc ) pDc->SetBrush(*wxWHITE_BRUSH); + wxPGCellRenderer* renderer = NULL; + const wxPGChoiceEntry* cell = NULL; + if ( rect.x >= 0 ) { // @@ -750,11 +753,13 @@ void wxPropertyGrid::OnComboItemPaint( const wxPGComboBox* pCb, if ( choices.IsOk() && item >= 0 && comValIndex < 0 ) { - const wxPGChoiceEntry& cell = choices.Item(item); - wxPGCellRenderer* renderer = wxPGGlobalVars->m_defaultRenderer; - int imageOffset = renderer->PreDrawCell( dc, rect, cell, renderFlags ); + cell = &choices.Item(item); + renderer = wxPGGlobalVars->m_defaultRenderer; + int imageOffset = renderer->PreDrawCell(dc, rect, *cell, + renderFlags ); if ( imageOffset ) - imageOffset += wxCC_CUSTOM_IMAGE_MARGIN1 + wxCC_CUSTOM_IMAGE_MARGIN2; + imageOffset += wxCC_CUSTOM_IMAGE_MARGIN1 + + wxCC_CUSTOM_IMAGE_MARGIN2; pt.x += imageOffset; } } @@ -768,6 +773,9 @@ void wxPropertyGrid::OnComboItemPaint( const wxPGComboBox* pCb, pt.x += 1; dc.DrawText( text, pt.x + wxPG_XBEFORETEXT, pt.y ); + + if ( renderer ) + renderer->PostDrawCell(dc, this, *cell, renderFlags); } else { @@ -786,23 +794,28 @@ bool wxPGChoiceEditor_SetCustomPaintWidth( wxPropertyGrid* propGrid, wxPGComboBo wxPGProperty* property = propGrid->GetSelectedProperty(); wxASSERT( property ); + wxSize imageSize; + bool res; + if ( cmnVal >= 0 ) { // Yes, a common value is being selected property->SetCommonValue( cmnVal ); - wxSize imageSize = propGrid->GetCommonValue(cmnVal)-> + imageSize = propGrid->GetCommonValue(cmnVal)-> GetRenderer()->GetImageSize(property, 1, cmnVal); - if ( imageSize.x ) imageSize.x += ODCB_CUST_PAINT_MARGIN; - cb->SetCustomPaintWidth( imageSize.x ); - return false; + res = false; } else { - wxSize imageSize = propGrid->GetImageSize(property, -1); - if ( imageSize.x ) imageSize.x += ODCB_CUST_PAINT_MARGIN; - cb->SetCustomPaintWidth( imageSize.x ); - return true; + imageSize = propGrid->GetImageSize(property, -1); + res = true; } + + if ( imageSize.x ) + imageSize.x += ODCB_CUST_PAINT_MARGIN; + cb->SetCustomPaintWidth( imageSize.x ); + + return res; } // CreateControls calls this with CB_READONLY in extraStyle @@ -1372,7 +1385,7 @@ void wxSimpleCheckBox::SetValue( int value ) wxCommandEvent evt(wxEVT_COMMAND_CHECKBOX_CLICKED,GetParent()->GetId()); - wxPropertyGrid* propGrid = (wxPropertyGrid*) GetParent()->GetParent(); + wxPropertyGrid* propGrid = (wxPropertyGrid*) GetParent(); wxASSERT( propGrid->IsKindOf(CLASSINFO(wxPropertyGrid)) ); propGrid->HandleCustomEditorEvent(evt); } @@ -1497,7 +1510,7 @@ void wxPGCheckBoxEditor::SetControlIntValue( wxPGProperty* WXUNUSED(property), w void wxPGCheckBoxEditor::SetValueToUnspecified( wxPGProperty* WXUNUSED(property), wxWindow* ctrl ) const { - ((wxSimpleCheckBox*)ctrl)->m_state = 0; + ((wxSimpleCheckBox*)ctrl)->m_state = wxSCB_STATE_UNSPECIFIED; ctrl->Refresh(); } @@ -1682,6 +1695,18 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos, SetupTextCtrlValue(value); tc->Create(ctrlParent,id,value, p, s,tcFlags); +#if defined(__WXMSW__) + // On Windows, we need to override read-only text ctrl's background + // colour to white. One problem with native 'grey' background is that + // tc->GetBackgroundColour() doesn't seem to return correct value + // for it. + if ( tcFlags & wxTE_READONLY ) + { + wxVisualAttributes vattrs = tc->GetDefaultAttributes(); + tc->SetBackgroundColour(vattrs.colBg); + } +#endif + // Center the control vertically if ( !hasSpecialSize ) FixPosForTextCtrl(tc, forColumn);