Declare wxPG_DEFAULT_IMAGE_SIZE as wxDefaultSize constant.

wxDefaultSize is an equivalent of wxSize(-1,-1) but is more portable.
This commit is contained in:
Artur Wieczorek
2015-07-15 21:40:24 +02:00
parent 4398e20655
commit 79794391e9
5 changed files with 13 additions and 14 deletions

View File

@@ -1293,7 +1293,7 @@ public:
@remarks @remarks
- Default behaviour is to return wxSize(0,0), which means no image. - Default behaviour is to return wxSize(0,0), which means no image.
- Default image width or height is indicated with dimension -1. - Default image width or height is indicated with dimension -1.
- You can also return wxPG_DEFAULT_IMAGE_SIZE, i.e. wxSize(-1, -1). - You can also return wxPG_DEFAULT_IMAGE_SIZE, i.e. wxDefaultSize.
*/ */
virtual wxSize OnMeasureImage( int item = -1 ) const; virtual wxSize OnMeasureImage( int item = -1 ) const;

View File

@@ -246,7 +246,7 @@ class wxPGValidationInfo;
/** If property is supposed to have custom-painted image, then returning /** If property is supposed to have custom-painted image, then returning
this in OnMeasureImage() will usually be enough. this in OnMeasureImage() will usually be enough.
*/ */
#define wxPG_DEFAULT_IMAGE_SIZE wxSize(-1, -1) #define wxPG_DEFAULT_IMAGE_SIZE wxDefaultSize
/** This callback function is used for sorting properties. /** This callback function is used for sorting properties.

View File

@@ -802,7 +802,7 @@ wxVariant wxFontProperty::ChildChanged( wxVariant& thisValue,
/* /*
wxSize wxFontProperty::OnMeasureImage() const wxSize wxFontProperty::OnMeasureImage() const
{ {
return wxSize(-1,-1); return wxPG_DEFAULT_IMAGE_SIZE;
} }
void wxFontProperty::OnCustomPaint(wxDC& dc, void wxFontProperty::OnCustomPaint(wxDC& dc,

View File

@@ -543,7 +543,7 @@ void wxPGProperty::InitAfterAdded( wxPropertyGridPageState* pageState,
// Set custom image flag. // Set custom image flag.
int custImgHeight = OnMeasureImage().y; int custImgHeight = OnMeasureImage().y;
if ( custImgHeight < 0 ) if ( custImgHeight == wxDefaultCoord )
{ {
SetFlag(wxPG_PROP_CUSTOMIMAGE); SetFlag(wxPG_PROP_CUSTOMIMAGE);
} }
@@ -2288,7 +2288,7 @@ void wxPGProperty::DoPreAddChild( int index, wxPGProperty* prop )
prop ); prop );
int custImgHeight = prop->OnMeasureImage().y; int custImgHeight = prop->OnMeasureImage().y;
if ( custImgHeight < 0 /*|| custImgHeight > 1*/ ) if ( custImgHeight == wxDefaultCoord /*|| custImgHeight > 1*/ )
prop->m_flags |= wxPG_PROP_CUSTOMIMAGE; prop->m_flags |= wxPG_PROP_CUSTOMIMAGE;
prop->m_parent = this; prop->m_parent = this;

View File

@@ -3777,7 +3777,8 @@ wxRect wxPropertyGrid::GetEditorWidgetRect( wxPGProperty* p, int column ) const
{ {
//m_iFlags |= wxPG_FL_CUR_USES_CUSTOM_IMAGE; //m_iFlags |= wxPG_FL_CUR_USES_CUSTOM_IMAGE;
int iw = p->OnMeasureImage().x; int iw = p->OnMeasureImage().x;
if ( iw < 1 ) wxASSERT( iw == wxDefaultCoord || iw >= 0 );
if ( iw == wxDefaultCoord || iw == 0 )
iw = wxPG_CUSTOM_IMAGE_WIDTH; iw = wxPG_CUSTOM_IMAGE_WIDTH;
imageOffset = p->GetImageOffset(iw); imageOffset = p->GetImageOffset(iw);
} }
@@ -3827,17 +3828,15 @@ wxSize wxPropertyGrid::GetImageSize( wxPGProperty* p, int item ) const
else if ( item >= 0 && choiceCount == 0 ) else if ( item >= 0 && choiceCount == 0 )
return wxSize(0, 0); return wxSize(0, 0);
if ( cis.x < 0 ) wxASSERT( cis.x == wxDefaultCoord || cis.x >= 0 );
if ( cis.x == wxDefaultCoord )
{ {
if ( cis.x <= -1 ) cis.x = wxPG_CUSTOM_IMAGE_WIDTH;
cis.x = wxPG_CUSTOM_IMAGE_WIDTH;
} }
if ( cis.y <= 0 ) wxASSERT( cis.y == wxDefaultCoord || cis.y >= 0 );
if ( cis.y == wxDefaultCoord || cis.y == 0 )
{ {
if ( cis.y >= -1 ) cis.y = wxPG_STD_CUST_IMAGE_HEIGHT(m_lineHeight);
cis.y = wxPG_STD_CUST_IMAGE_HEIGHT(m_lineHeight);
else
cis.y = -cis.y;
} }
return cis; return cis;
} }