void wxPGCellRenderer::DrawText( wxDC& dc, const wxRect& rect,
int xOffset, const wxString& text ) const
{
- if ( xOffset )
- xOffset += wxCC_CUSTOM_IMAGE_MARGIN1 + wxCC_CUSTOM_IMAGE_MARGIN2;
dc.DrawText( text,
rect.x+xOffset+wxPG_XBEFORETEXT,
rect.y+((rect.height-dc.GetCharHeight())/2) );
wxPGProperty* property,
const wxPGEditor* editor ) const
{
- if ( xOffset )
- xOffset += wxCC_CUSTOM_IMAGE_MARGIN1 + wxCC_CUSTOM_IMAGE_MARGIN2;
-
int yOffset = ((rect.height-dc.GetCharHeight())/2);
if ( editor )
int wxPGCellRenderer::PreDrawCell( wxDC& dc, const wxRect& rect, const wxPGCell& cell, int flags ) const
{
- int imageOffset = 0;
+ int imageWidth = 0;
// If possible, use cell colours
if ( !(flags & DontUseCellBgCol) )
rect.x + wxPG_CONTROL_MARGIN + wxCC_CUSTOM_IMAGE_MARGIN1,
rect.y + wxPG_CUSTOM_IMAGE_SPACINGY,
true );
- imageOffset = bmp.GetWidth();
+ imageWidth = bmp.GetWidth();
}
- return imageOffset;
+ return imageWidth;
}
// -----------------------------------------------------------------------
const wxPGCell* cell = NULL;
wxString text;
- int imageOffset = 0;
+ int imageWidth = 0;
int preDrawFlags = flags;
property->GetDisplayInfo(column, item, flags, &text, &cell);
- imageOffset = PreDrawCell( dc, rect, *cell, preDrawFlags );
+ imageWidth = PreDrawCell( dc, rect, *cell, preDrawFlags );
if ( column == 1 )
{
property->OnCustomPaint( dc, imageRect, paintdata );
- imageOffset = paintdata.m_drawnWidth;
+ imageWidth = paintdata.m_drawnWidth;
}
text = property->GetValueAsString();
}
}
+ int imageOffset = property->GetImageOffset(imageWidth);
+
DrawEditorValue( dc, rect, imageOffset, text, property, editor );
// active caption gets nice dotted rectangle
{
if ( flags & Selected )
{
- if ( imageOffset > 0 )
- imageOffset += wxCC_CUSTOM_IMAGE_MARGIN2 + 4;
+ if ( imageWidth > 0 )
+ {
+ imageOffset -= DEFAULT_IMAGE_OFFSET_INCREMENT;
+ imageWidth += wxCC_CUSTOM_IMAGE_MARGIN2 + 4;
+ }
DrawCaptionSelectionRect( dc,
rect.x+wxPG_XBEFORETEXT-wxPG_CAPRECTXMARGIN+imageOffset,
if ( GetChildCount() )
{
// Check parental flags
- wxASSERT_MSG( (m_flags & wxPG_PROP_PARENTAL_FLAGS),
- "Call SetFlag(wxPG_PROP_MISC_PARENT) or"
- "SetFlag(wxPG_PROP_AGGREGATE) before calling"
- "wxPGProperty::AddChild()." );
+ wxASSERT_MSG( ((m_flags & wxPG_PROP_PARENTAL_FLAGS) ==
+ wxPG_PROP_AGGREGATE) ||
+ ((m_flags & wxPG_PROP_PARENTAL_FLAGS) ==
+ wxPG_PROP_MISC_PARENT),
+ "wxPGProperty parental flags set incorrectly at "
+ "this time" );
if ( HasFlag(wxPG_PROP_AGGREGATE) )
{
return wxSize(0,0);
}
+int wxPGProperty::GetImageOffset( int imageWidth ) const
+{
+ int imageOffset = 0;
+
+ if ( imageWidth )
+ {
+ // Do not increment offset too much for wide images
+ if ( imageWidth <= (wxPG_CUSTOM_IMAGE_WIDTH+5) )
+ imageOffset = imageWidth + DEFAULT_IMAGE_OFFSET_INCREMENT;
+ else
+ imageOffset = imageWidth + 1;
+ }
+
+ return imageOffset;
+}
+
wxPGCellRenderer* wxPGProperty::GetCellRenderer( int WXUNUSED(column) ) const
{
return wxPGGlobalVars->m_defaultRenderer;
wxSize maxSz = GetGrid()->GetImageSize();
wxSize imSz(bmp.GetWidth(),bmp.GetHeight());
- if ( imSz.x != maxSz.x || imSz.y != maxSz.y )
+ if ( imSz.y != maxSz.y )
{
// Create a memory DC
wxBitmap* bmpNew = new wxBitmap(maxSz.x,maxSz.y,bmp.GetDepth());
// Scale
// FIXME: This is ugly - use image or wait for scaling patch.
- double scaleX = (double)maxSz.x / (double)imSz.x;
double scaleY = (double)maxSz.y / (double)imSz.y;
- dc.SetUserScale(scaleX,scaleY);
+ dc.SetUserScale(scaleY, scaleY);
- dc.DrawBitmap( bmp, 0, 0 );
+ dc.DrawBitmap(bmp, 0, 0);
m_valueBitmap = bmpNew;
}
}
// This is used by Insert etc.
-void wxPGProperty::AddChild2( wxPGProperty* prop, int index, bool correct_mode )
+void wxPGProperty::DoAddChild( wxPGProperty* prop, int index,
+ bool correct_mode )
{
if ( index < 0 || (size_t)index >= m_children.size() )
{
prop->m_parent = this;
}
-// This is used by properties that have fixed sub-properties
-void wxPGProperty::AddChild( wxPGProperty* prop )
+void wxPGProperty::DoPreAddChild( int index, wxPGProperty* prop )
{
wxASSERT_MSG( prop->GetBaseName().length(),
- "Property's children must have unique, non-empty names within their scope" );
+ "Property's children must have unique, non-empty "
+ "names within their scope" );
- prop->m_arrIndex = m_children.size();
- m_children.push_back( prop );
+ prop->m_arrIndex = index;
+ m_children.insert( m_children.begin()+index,
+ prop );
int custImgHeight = prop->OnMeasureImage().y;
if ( custImgHeight < 0 /*|| custImgHeight > 1*/ )
prop->m_parent = this;
}
+void wxPGProperty::AddPrivateChild( wxPGProperty* prop )
+{
+ if ( !(m_flags & wxPG_PROP_PARENTAL_FLAGS) )
+ SetParentalType(wxPG_PROP_AGGREGATE);
+
+ wxASSERT_MSG( (m_flags & wxPG_PROP_PARENTAL_FLAGS) ==
+ wxPG_PROP_AGGREGATE,
+ "Do not mix up AddPrivateChild() calls with other "
+ "property adders." );
+
+ DoPreAddChild( m_children.size(), prop );
+}
+
+#if wxPG_COMPATIBILITY_1_4
+void wxPGProperty::AddChild( wxPGProperty* prop )
+{
+ AddPrivateChild(prop);
+}
+#endif
+
+wxPGProperty* wxPGProperty::InsertChild( int index,
+ wxPGProperty* childProperty )
+{
+ if ( index < 0 )
+ index = m_children.size();
+
+ if ( m_parentState )
+ {
+ m_parentState->DoInsert(this, index, childProperty);
+ }
+ else
+ {
+ if ( !(m_flags & wxPG_PROP_PARENTAL_FLAGS) )
+ SetParentalType(wxPG_PROP_MISC_PARENT);
+
+ wxASSERT_MSG( (m_flags & wxPG_PROP_PARENTAL_FLAGS) ==
+ wxPG_PROP_MISC_PARENT,
+ "Do not mix up AddPrivateChild() calls with other "
+ "property adders." );
+
+ DoPreAddChild( index, childProperty );
+ }
+
+ return childProperty;
+}
+
void wxPGProperty::RemoveChild( wxPGProperty* p )
{
wxArrayPGProperty::iterator it;