X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/83110b757032329cb53d23e336ce5bd7468e86d9..960615f41009ac62e99f833afbec10d96bd2d2f9:/src/propgrid/editors.cpp diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index e0a6d71cf1..9f6d5a5a3d 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -77,10 +77,6 @@ #include "wx/odcombo.h" -#ifdef __WXMSW__ - #include "wx/msw/private.h" -#endif - // ----------------------------------------------------------------------- #if defined(__WXMSW__) @@ -150,7 +146,8 @@ #define wxPG_CHOICEYADJUST 0 #endif -#define ODCB_CUST_PAINT_MARGIN 6 // Number added to image width for SetCustomPaintWidth +// Number added to image width for SetCustomPaintWidth +#define ODCB_CUST_PAINT_MARGIN 6 // Milliseconds to wait for two mouse-ups after focus inorder // to trigger a double-click. @@ -288,12 +285,7 @@ void wxPGTextCtrlEditor::UpdateControl( wxPGProperty* property, wxWindow* ctrl ) // // Fix indentation, just in case (change in font boldness is one good // reason). -#if defined(__WXMSW__) && !defined(__WXWINCE__) - ::SendMessage(GetHwndOf(tc), - EM_SETMARGINS, - EC_LEFTMARGIN | EC_RIGHTMARGIN, - MAKELONG(0, 0)); -#endif + tc->SetMargins(0); } // Provided so that, for example, ComboBox editor can use the same code @@ -566,7 +558,7 @@ public: wxPropertyGrid* GetGrid() const { - wxPropertyGrid* pg = wxDynamicCast(GetParent()->GetParent(), + wxPropertyGrid* pg = wxDynamicCast(GetParent(), wxPropertyGrid); wxASSERT(pg); return pg; @@ -582,13 +574,16 @@ public: return rect.width; } - virtual void PositionTextCtrl( int WXUNUSED(textCtrlXAdjust), + virtual void PositionTextCtrl( int textCtrlXAdjust, int WXUNUSED(textCtrlYAdjust) ) { wxPropertyGrid* pg = GetGrid(); + #ifdef wxPG_TEXTCTRLXADJUST + textCtrlXAdjust = wxPG_TEXTCTRLXADJUST - + (wxPG_XBEFOREWIDGET+wxPG_CONTROL_MARGIN+1) - 1, + #endif wxOwnerDrawnComboBox::PositionTextCtrl( - wxPG_TEXTCTRLXADJUST - - (wxPG_XBEFOREWIDGET+wxPG_CONTROL_MARGIN+1) - 1, + textCtrlXAdjust, pg->GetSpacingY() + 2 ); } @@ -687,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 ) { // @@ -755,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; } } @@ -773,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 { @@ -791,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 @@ -877,7 +885,7 @@ wxWindow* wxPGChoiceEditor::CreateControlsBase( wxPropertyGrid* propGrid, odcbFlags); cb->SetButtonPosition(si.y,0,wxRIGHT); - cb->SetTextIndent(wxPG_XBEFORETEXT-1); + cb->SetMargins(wxPG_XBEFORETEXT-1); wxPGChoiceEditor_SetCustomPaintWidth( propGrid, cb, property->GetCommonValue() ); @@ -1377,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); } @@ -1598,7 +1606,7 @@ void wxPropertyGrid::CorrectEditorWidgetPosY() // Fixes position of wxTextCtrl-like control (wxSpinCtrl usually // fits into that category as well). void wxPropertyGrid::FixPosForTextCtrl( wxWindow* ctrl, - unsigned int forColumn, + unsigned int WXUNUSED(forColumn), const wxPoint& offset ) { // Center the control vertically @@ -1612,10 +1620,14 @@ void wxPropertyGrid::FixPosForTextCtrl( wxWindow* ctrl, finalPos.y += y_adj; finalPos.height -= (y_adj+sz_dec); - int textCtrlXAdjust = wxPG_TEXTCTRLXADJUST; +#ifndef wxPG_TEXTCTRLXADJUST + int textCtrlXAdjust = wxPG_XBEFORETEXT - 1; - if ( forColumn != 1 ) - textCtrlXAdjust -= 3; // magic number! + wxTextCtrl* tc = static_cast(ctrl); + tc->SetMargins(0); +#else + int textCtrlXAdjust = wxPG_TEXTCTRLXADJUST; +#endif finalPos.x += textCtrlXAdjust; finalPos.width -= textCtrlXAdjust;