Use wxBitmapBundle in wxPropertyGrid
This commit is contained in:
@@ -471,7 +471,7 @@ public:
|
|||||||
|
|
||||||
void Add( const wxString& label, int id = -2 );
|
void Add( const wxString& label, int id = -2 );
|
||||||
#if wxUSE_BMPBUTTON
|
#if wxUSE_BMPBUTTON
|
||||||
void Add( const wxBitmap& bitmap, int id = -2 );
|
void Add( const wxBitmapBundle& bitmap, int id = -2 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxSize GetPrimarySize() const
|
wxSize GetPrimarySize() const
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "wx/propgrid/propgriddefs.h"
|
#include "wx/propgrid/propgriddefs.h"
|
||||||
#include "wx/bitmap.h"
|
#include "wx/bitmap.h"
|
||||||
|
#include "wx/bmpbndl.h"
|
||||||
#include "wx/font.h"
|
#include "wx/font.h"
|
||||||
#include "wx/validate.h"
|
#include "wx/validate.h"
|
||||||
|
|
||||||
@@ -135,6 +136,7 @@ public:
|
|||||||
// can be passed to DrawText.
|
// can be passed to DrawText.
|
||||||
int PreDrawCell( wxDC& dc,
|
int PreDrawCell( wxDC& dc,
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
|
const wxPropertyGrid* propGrid,
|
||||||
const wxPGCell& cell,
|
const wxPGCell& cell,
|
||||||
int flags ) const;
|
int flags ) const;
|
||||||
|
|
||||||
@@ -180,7 +182,7 @@ public:
|
|||||||
m_text = text;
|
m_text = text;
|
||||||
m_hasValidText = true;
|
m_hasValidText = true;
|
||||||
}
|
}
|
||||||
void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; }
|
void SetBitmap( const wxBitmapBundle& bitmap ) { m_bitmapBundle = bitmap; }
|
||||||
void SetFgCol( const wxColour& col ) { m_fgCol = col; }
|
void SetFgCol( const wxColour& col ) { m_fgCol = col; }
|
||||||
void SetBgCol( const wxColour& col ) { m_bgCol = col; }
|
void SetBgCol( const wxColour& col ) { m_bgCol = col; }
|
||||||
void SetFont( const wxFont& font ) { m_font = font; }
|
void SetFont( const wxFont& font ) { m_font = font; }
|
||||||
@@ -189,7 +191,7 @@ protected:
|
|||||||
virtual ~wxPGCellData() { }
|
virtual ~wxPGCellData() { }
|
||||||
|
|
||||||
wxString m_text;
|
wxString m_text;
|
||||||
wxBitmap m_bitmap;
|
wxBitmapBundle m_bitmapBundle;
|
||||||
wxColour m_fgCol;
|
wxColour m_fgCol;
|
||||||
wxColour m_bgCol;
|
wxColour m_bgCol;
|
||||||
wxFont m_font;
|
wxFont m_font;
|
||||||
@@ -210,7 +212,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxPGCell( const wxString& text,
|
wxPGCell( const wxString& text,
|
||||||
const wxBitmap& bitmap = wxNullBitmap,
|
const wxBitmapBundle& bitmap = wxBitmapBundle(),
|
||||||
const wxColour& fgCol = wxNullColour,
|
const wxColour& fgCol = wxNullColour,
|
||||||
const wxColour& bgCol = wxNullColour );
|
const wxColour& bgCol = wxNullColour );
|
||||||
|
|
||||||
@@ -238,7 +240,7 @@ public:
|
|||||||
void MergeFrom( const wxPGCell& srcCell );
|
void MergeFrom( const wxPGCell& srcCell );
|
||||||
|
|
||||||
void SetText( const wxString& text );
|
void SetText( const wxString& text );
|
||||||
void SetBitmap( const wxBitmap& bitmap );
|
void SetBitmap( const wxBitmapBundle& bitmap );
|
||||||
void SetFgCol( const wxColour& col );
|
void SetFgCol( const wxColour& col );
|
||||||
|
|
||||||
// Sets font of the cell.
|
// Sets font of the cell.
|
||||||
@@ -254,7 +256,7 @@ public:
|
|||||||
void SetBgCol( const wxColour& col );
|
void SetBgCol( const wxColour& col );
|
||||||
|
|
||||||
const wxString& GetText() const { return GetData()->m_text; }
|
const wxString& GetText() const { return GetData()->m_text; }
|
||||||
const wxBitmap& GetBitmap() const { return GetData()->m_bitmap; }
|
const wxBitmapBundle& GetBitmap() const { return GetData()->m_bitmapBundle; }
|
||||||
const wxColour& GetFgCol() const { return GetData()->m_fgCol; }
|
const wxColour& GetFgCol() const { return GetData()->m_fgCol; }
|
||||||
|
|
||||||
// Returns font of the cell. If no specific font is set for this
|
// Returns font of the cell. If no specific font is set for this
|
||||||
@@ -818,7 +820,7 @@ public:
|
|||||||
|
|
||||||
// Adds a single item, with bitmap.
|
// Adds a single item, with bitmap.
|
||||||
wxPGChoiceEntry& Add( const wxString& label,
|
wxPGChoiceEntry& Add( const wxString& label,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
int value = wxPG_INVALID_VALUE );
|
int value = wxPG_INVALID_VALUE );
|
||||||
|
|
||||||
// Adds a single item with full entry information.
|
// Adds a single item with full entry information.
|
||||||
@@ -1539,10 +1541,7 @@ public:
|
|||||||
|
|
||||||
// Returns bitmap that appears next to value text. Only returns non-@NULL
|
// Returns bitmap that appears next to value text. Only returns non-@NULL
|
||||||
// bitmap if one was set with SetValueImage().
|
// bitmap if one was set with SetValueImage().
|
||||||
wxBitmap* GetValueImage() const
|
wxBitmap* GetValueImage() const;
|
||||||
{
|
|
||||||
return m_valueBitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns property attribute value, null variant if not found.
|
// Returns property attribute value, null variant if not found.
|
||||||
wxVariant GetAttribute( const wxString& name ) const;
|
wxVariant GetAttribute( const wxString& name ) const;
|
||||||
@@ -1696,7 +1695,7 @@ public:
|
|||||||
|
|
||||||
// Set wxBitmap in front of the value. This bitmap may be ignored
|
// Set wxBitmap in front of the value. This bitmap may be ignored
|
||||||
// by custom cell renderers.
|
// by custom cell renderers.
|
||||||
void SetValueImage( wxBitmap& bmp );
|
void SetValueImage( const wxBitmapBundle& bmp );
|
||||||
|
|
||||||
// Sets selected choice and changes property value.
|
// Sets selected choice and changes property value.
|
||||||
// Tries to retain value type, although currently if it is not string,
|
// Tries to retain value type, although currently if it is not string,
|
||||||
@@ -2047,7 +2046,8 @@ protected:
|
|||||||
// Show this in front of the value
|
// Show this in front of the value
|
||||||
//
|
//
|
||||||
// TODO: Can bitmap be implemented with wxPGCell?
|
// TODO: Can bitmap be implemented with wxPGCell?
|
||||||
wxBitmap* m_valueBitmap;
|
wxBitmapBundle m_valueBitmapBundle;
|
||||||
|
wxBitmap m_valueBitmap;
|
||||||
|
|
||||||
wxVariant m_value;
|
wxVariant m_value;
|
||||||
wxPGAttributeStorage m_attributes;
|
wxPGAttributeStorage m_attributes;
|
||||||
|
|||||||
@@ -812,7 +812,7 @@ public:
|
|||||||
void SetPropertyCell( wxPGPropArg id,
|
void SetPropertyCell( wxPGPropArg id,
|
||||||
int column,
|
int column,
|
||||||
const wxString& text = wxEmptyString,
|
const wxString& text = wxEmptyString,
|
||||||
const wxBitmap& bitmap = wxNullBitmap,
|
const wxBitmapBundle& bitmap = wxBitmapBundle(),
|
||||||
const wxColour& fgCol = wxNullColour,
|
const wxColour& fgCol = wxNullColour,
|
||||||
const wxColour& bgCol = wxNullColour );
|
const wxColour& bgCol = wxNullColour );
|
||||||
|
|
||||||
@@ -910,7 +910,7 @@ public:
|
|||||||
// Set wxBitmap in front of the value.
|
// Set wxBitmap in front of the value.
|
||||||
// Bitmap will be scaled to a size returned by
|
// Bitmap will be scaled to a size returned by
|
||||||
// wxPropertyGrid::GetImageSize();
|
// wxPropertyGrid::GetImageSize();
|
||||||
void SetPropertyImage( wxPGPropArg id, wxBitmap& bmp )
|
void SetPropertyImage( wxPGPropArg id, const wxBitmapBundle& bmp )
|
||||||
{
|
{
|
||||||
wxPG_PROP_ARG_CALL_PROLOG()
|
wxPG_PROP_ARG_CALL_PROLOG()
|
||||||
p->SetValueImage(bmp);
|
p->SetValueImage(bmp);
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
Adds new bitmap button.
|
Adds new bitmap button.
|
||||||
*/
|
*/
|
||||||
void Add( const wxBitmap& bitmap, int id = -2 );
|
void Add( const wxBitmapBundle& bitmap, int id = -2 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Call this in CreateControls() of your custom editor class
|
Call this in CreateControls() of your custom editor class
|
||||||
|
|||||||
@@ -2041,10 +2041,10 @@ public:
|
|||||||
int flags = wxPG_SETVAL_REFRESH_EDITOR );
|
int flags = wxPG_SETVAL_REFRESH_EDITOR );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set wxBitmap in front of the value. This bitmap may be ignored
|
Set wxBitmap taken from wxBitmapBundle in front of the value.
|
||||||
by custom cell renderers.
|
This bitmap may be ignored by custom cell renderers.
|
||||||
*/
|
*/
|
||||||
void SetValueImage( wxBitmap& bmp );
|
void SetValueImage( wxBitmapBundle& bmp );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Call this function in OnEvent(), OnButtonClick() etc. to change the
|
Call this function in OnEvent(), OnButtonClick() etc. to change the
|
||||||
@@ -2342,6 +2342,9 @@ public:
|
|||||||
@param rect
|
@param rect
|
||||||
Box reserved for drawing.
|
Box reserved for drawing.
|
||||||
|
|
||||||
|
@param propGrid
|
||||||
|
Property grid to which the cell belongs.
|
||||||
|
|
||||||
@param cell
|
@param cell
|
||||||
Cell information.
|
Cell information.
|
||||||
|
|
||||||
@@ -2354,6 +2357,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
int PreDrawCell( wxDC& dc,
|
int PreDrawCell( wxDC& dc,
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
|
const wxPropertyGrid* propGrid,
|
||||||
const wxPGCell& cell,
|
const wxPGCell& cell,
|
||||||
int flags ) const;
|
int flags ) const;
|
||||||
|
|
||||||
@@ -2447,7 +2451,7 @@ public:
|
|||||||
wxPGCellData();
|
wxPGCellData();
|
||||||
|
|
||||||
void SetText( const wxString& text );
|
void SetText( const wxString& text );
|
||||||
void SetBitmap( const wxBitmap& bitmap );
|
void SetBitmap( const wxBitmapBundle& bitmap );
|
||||||
void SetFgCol( const wxColour& col );
|
void SetFgCol( const wxColour& col );
|
||||||
void SetBgCol( const wxColour& col );
|
void SetBgCol( const wxColour& col );
|
||||||
void SetFont( const wxFont& font );
|
void SetFont( const wxFont& font );
|
||||||
@@ -2456,7 +2460,7 @@ protected:
|
|||||||
virtual ~wxPGCellData();
|
virtual ~wxPGCellData();
|
||||||
|
|
||||||
wxString m_text;
|
wxString m_text;
|
||||||
wxBitmap m_bitmap;
|
wxBitmapBundle m_bitmapBundle;
|
||||||
wxColour m_fgCol;
|
wxColour m_fgCol;
|
||||||
wxColour m_bgCol;
|
wxColour m_bgCol;
|
||||||
wxFont m_font;
|
wxFont m_font;
|
||||||
@@ -2481,7 +2485,7 @@ public:
|
|||||||
wxPGCell();
|
wxPGCell();
|
||||||
wxPGCell(const wxPGCell& other);
|
wxPGCell(const wxPGCell& other);
|
||||||
wxPGCell( const wxString& text,
|
wxPGCell( const wxString& text,
|
||||||
const wxBitmap& bitmap = wxNullBitmap,
|
const wxBitmapBundle& bitmap = wxBitmapBundle(),
|
||||||
const wxColour& fgCol = wxNullColour,
|
const wxColour& fgCol = wxNullColour,
|
||||||
const wxColour& bgCol = wxNullColour );
|
const wxColour& bgCol = wxNullColour );
|
||||||
|
|
||||||
@@ -2506,7 +2510,7 @@ public:
|
|||||||
void MergeFrom( const wxPGCell& srcCell );
|
void MergeFrom( const wxPGCell& srcCell );
|
||||||
|
|
||||||
void SetText( const wxString& text );
|
void SetText( const wxString& text );
|
||||||
void SetBitmap( const wxBitmap& bitmap );
|
void SetBitmap( const wxBitmapBundle& bitmap );
|
||||||
void SetFgCol( const wxColour& col );
|
void SetFgCol( const wxColour& col );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2525,7 +2529,7 @@ public:
|
|||||||
void SetBgCol( const wxColour& col );
|
void SetBgCol( const wxColour& col );
|
||||||
|
|
||||||
const wxString& GetText() const;
|
const wxString& GetText() const;
|
||||||
const wxBitmap& GetBitmap() const;
|
const wxBitmapBundle& GetBitmap() const;
|
||||||
const wxColour& GetFgCol() const;
|
const wxColour& GetFgCol() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -927,7 +927,7 @@ public:
|
|||||||
void SetPropertyCell( wxPGPropArg id,
|
void SetPropertyCell( wxPGPropArg id,
|
||||||
int column,
|
int column,
|
||||||
const wxString& text = wxEmptyString,
|
const wxString& text = wxEmptyString,
|
||||||
const wxBitmap& bitmap = wxNullBitmap,
|
const wxBitmapBundle& bitmap = wxBitmapBundle(),
|
||||||
const wxColour& fgCol = wxNullColour,
|
const wxColour& fgCol = wxNullColour,
|
||||||
const wxColour& bgCol = wxNullColour );
|
const wxColour& bgCol = wxNullColour );
|
||||||
|
|
||||||
@@ -1047,12 +1047,12 @@ public:
|
|||||||
void SetPropertyHelpString( wxPGPropArg id, const wxString& helpString );
|
void SetPropertyHelpString( wxPGPropArg id, const wxString& helpString );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set wxBitmap in front of the value.
|
Set wxBitmap taken from wxBitmapBundle in front of the value.
|
||||||
|
|
||||||
@remarks Bitmap will be scaled to a size returned by
|
@remarks Bitmap will be scaled to a size returned by
|
||||||
wxPropertyGrid::GetImageSize();
|
wxPropertyGrid::GetImageSize();
|
||||||
*/
|
*/
|
||||||
void SetPropertyImage( wxPGPropArg id, wxBitmap& bmp );
|
void SetPropertyImage( wxPGPropArg id, wxBitmapBundle& bmp );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets maximum length of text in property text editor.
|
Sets maximum length of text in property text editor.
|
||||||
|
|||||||
@@ -1159,7 +1159,7 @@ void FormMain::PopulateWithStandardItems ()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
pg->SetPropertyCell( p, 3, "Cell 3", bmp );
|
pg->SetPropertyCell( p, 3, "Cell 3", bmp );
|
||||||
pg->SetPropertyCell( p, 4, "Cell 4", wxNullBitmap, *wxWHITE, *wxBLACK );
|
pg->SetPropertyCell( p, 4, "Cell 4", wxBitmapBundle(), *wxWHITE, *wxBLACK );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1384,16 +1384,35 @@ void FormMain::PopulateWithExamples ()
|
|||||||
pg->Append( new wxStringProperty( "StringPropertyWithBitmap",
|
pg->Append( new wxStringProperty( "StringPropertyWithBitmap",
|
||||||
wxPG_LABEL,
|
wxPG_LABEL,
|
||||||
"Test Text") );
|
"Test Text") );
|
||||||
wxBitmap myTestBitmap(60, 15, 32);
|
wxBitmap myTestBitmap1x(60, 15, 32);
|
||||||
wxMemoryDC mdc;
|
{
|
||||||
mdc.SelectObject(myTestBitmap);
|
wxMemoryDC mdc(myTestBitmap1x);
|
||||||
mdc.SetBackground(*wxWHITE_BRUSH);
|
mdc.SetBackground(*wxWHITE_BRUSH);
|
||||||
mdc.Clear();
|
mdc.Clear();
|
||||||
mdc.SetPen(*wxBLACK);
|
mdc.SetPen(*wxBLACK_PEN);
|
||||||
mdc.DrawLine(0, 0, 60, 15);
|
mdc.SetBrush(*wxWHITE_BRUSH);
|
||||||
mdc.SelectObject(wxNullBitmap);
|
mdc.DrawRectangle(0, 0, 60, 15);
|
||||||
pg->SetPropertyImage( "StringPropertyWithBitmap", myTestBitmap );
|
mdc.DrawLine(0, 0, 59, 14);
|
||||||
|
mdc.SetTextForeground(*wxBLACK);
|
||||||
|
mdc.DrawText("x1", 0, 0);
|
||||||
|
}
|
||||||
|
wxBitmap myTestBitmap2x(120, 30, 32);
|
||||||
|
{
|
||||||
|
wxMemoryDC mdc(myTestBitmap2x);
|
||||||
|
mdc.SetBackground(*wxWHITE_BRUSH);
|
||||||
|
mdc.Clear();
|
||||||
|
mdc.SetPen(wxPen(*wxBLUE, 2));
|
||||||
|
mdc.SetBrush(*wxWHITE_BRUSH);
|
||||||
|
mdc.DrawRectangle(0, 0, 120, 30);
|
||||||
|
mdc.DrawLine(0, 0, 119, 31);
|
||||||
|
mdc.SetTextForeground(*wxBLUE);
|
||||||
|
wxFont f = mdc.GetFont();
|
||||||
|
f.SetPixelSize(2 * f.GetPixelSize());
|
||||||
|
mdc.SetFont(f);
|
||||||
|
mdc.DrawText("x2", 0, 0);
|
||||||
|
}
|
||||||
|
myTestBitmap2x.SetScaleFactor(2);
|
||||||
|
pg->SetPropertyImage( "StringPropertyWithBitmap", wxBitmapBundle::FromBitmaps(myTestBitmap1x, myTestBitmap2x));
|
||||||
|
|
||||||
// this value array would be optional if values matched string indexes
|
// this value array would be optional if values matched string indexes
|
||||||
//long flags_prop_values[] = { wxICONIZE, wxCAPTION, wxMINIMIZE_BOX, wxMAXIMIZE_BOX };
|
//long flags_prop_values[] = { wxICONIZE, wxCAPTION, wxMINIMIZE_BOX, wxMAXIMIZE_BOX };
|
||||||
|
|||||||
@@ -745,18 +745,18 @@ void wxPropertyGrid::OnComboItemPaint( const wxPGComboBox* pCb,
|
|||||||
if ( item < 0 )
|
if ( item < 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const wxBitmap* itemBitmap = NULL;
|
wxBitmap itemBitmap;
|
||||||
|
|
||||||
if ( comValIndex == -1 && choices.IsOk() && choices.Item(item).GetBitmap().IsOk() )
|
if ( comValIndex == -1 && choices.IsOk() && choices.Item(item).GetBitmap().IsOk() )
|
||||||
itemBitmap = &choices.Item(item).GetBitmap();
|
itemBitmap = choices.Item(item).GetBitmap().GetBitmapFor(this);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Decide what custom image size to use
|
// Decide what custom image size to use
|
||||||
// (Use item-specific bitmap only if not drawn in the control field.)
|
// (Use item-specific bitmap only if not drawn in the control field.)
|
||||||
wxSize cis;
|
wxSize cis;
|
||||||
if ( itemBitmap && !(flags & wxODCB_PAINTING_CONTROL) )
|
if ( itemBitmap.IsOk() && !(flags & wxODCB_PAINTING_CONTROL) )
|
||||||
{
|
{
|
||||||
cis = itemBitmap->GetSize();
|
cis = itemBitmap.GetSize();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -778,7 +778,7 @@ void wxPropertyGrid::OnComboItemPaint( const wxPGComboBox* pCb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxPGPaintData paintdata;
|
wxPGPaintData paintdata;
|
||||||
paintdata.m_parent = NULL;
|
paintdata.m_parent = this;
|
||||||
paintdata.m_choiceItem = item;
|
paintdata.m_choiceItem = item;
|
||||||
|
|
||||||
// This is by the current (1.0.0b) spec - if painting control, item is -1
|
// This is by the current (1.0.0b) spec - if painting control, item is -1
|
||||||
@@ -834,7 +834,7 @@ void wxPropertyGrid::OnComboItemPaint( const wxPGComboBox* pCb,
|
|||||||
// If current choice had a bitmap set by the application, then
|
// If current choice had a bitmap set by the application, then
|
||||||
// use it instead of any custom paint procedure
|
// use it instead of any custom paint procedure
|
||||||
// (only if not drawn in the control field).
|
// (only if not drawn in the control field).
|
||||||
else if ( itemBitmap && !(flags & wxODCB_PAINTING_CONTROL) )
|
else if ( itemBitmap.IsOk() && !(flags & wxODCB_PAINTING_CONTROL) )
|
||||||
useCustomPaintProcedure = false;
|
useCustomPaintProcedure = false;
|
||||||
|
|
||||||
if ( useCustomPaintProcedure )
|
if ( useCustomPaintProcedure )
|
||||||
@@ -883,7 +883,7 @@ void wxPropertyGrid::OnComboItemPaint( const wxPGComboBox* pCb,
|
|||||||
|
|
||||||
cell = &choices.Item(item);
|
cell = &choices.Item(item);
|
||||||
renderer = wxPGGlobalVars->m_defaultRenderer;
|
renderer = wxPGGlobalVars->m_defaultRenderer;
|
||||||
int imageOffset = renderer->PreDrawCell(dc, r, *cell,
|
int imageOffset = renderer->PreDrawCell(dc, r, this, *cell,
|
||||||
renderFlags );
|
renderFlags );
|
||||||
if ( imageOffset )
|
if ( imageOffset )
|
||||||
imageOffset += wxCC_CUSTOM_IMAGE_MARGIN1 +
|
imageOffset += wxCC_CUSTOM_IMAGE_MARGIN1 +
|
||||||
@@ -2198,7 +2198,7 @@ typedef wxBitmapButton wxPGEditorBitmapButton;
|
|||||||
|
|
||||||
#endif // __WXGTK__ / !__WXGTK__
|
#endif // __WXGTK__ / !__WXGTK__
|
||||||
|
|
||||||
void wxPGMultiButton::Add( const wxBitmap& bitmap, int itemid )
|
void wxPGMultiButton::Add( const wxBitmapBundle& bitmap, int itemid )
|
||||||
{
|
{
|
||||||
itemid = GenId(itemid);
|
itemid = GenId(itemid);
|
||||||
wxSize sz = GetSize();
|
wxSize sz = GetSize();
|
||||||
@@ -2219,16 +2219,17 @@ void wxPGMultiButton::Add( const wxBitmap& bitmap, int itemid )
|
|||||||
// Maximal heigth of the bitmap
|
// Maximal heigth of the bitmap
|
||||||
const int hMax = wxMax(4, sz.y - margins);
|
const int hMax = wxMax(4, sz.y - margins);
|
||||||
|
|
||||||
|
wxBitmap bmp = bitmap.GetBitmapFor(this);
|
||||||
wxBitmap scaledBmp;
|
wxBitmap scaledBmp;
|
||||||
// Scale bitmap down if necessary
|
// Scale bitmap down if necessary
|
||||||
if ( bitmap.GetHeight() > hMax )
|
if ( bmp.GetHeight() > hMax )
|
||||||
{
|
{
|
||||||
double scale = (double)hMax / bitmap.GetHeight();
|
double scale = (double)hMax / bmp.GetHeight();
|
||||||
scaledBmp = wxPropertyGrid::RescaleBitmap(bitmap, scale, scale);
|
scaledBmp = wxPropertyGrid::RescaleBitmap(bmp, scale, scale);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
scaledBmp = bitmap;
|
scaledBmp = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmapButton* button = new wxPGEditorBitmapButton(this, itemid, scaledBmp,
|
wxBitmapButton* button = new wxPGEditorBitmapButton(this, itemid, scaledBmp,
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ void wxPGCellRenderer::DrawCaptionSelectionRect(wxWindow* win, wxDC& dc,
|
|||||||
}
|
}
|
||||||
#endif // WXWIN_COMPATIBILITY_3_0/!WXWIN_COMPATIBILITY_3_0
|
#endif // WXWIN_COMPATIBILITY_3_0/!WXWIN_COMPATIBILITY_3_0
|
||||||
|
|
||||||
int wxPGCellRenderer::PreDrawCell( wxDC& dc, const wxRect& rect, const wxPGCell& cell, int flags ) const
|
int wxPGCellRenderer::PreDrawCell( wxDC& dc, const wxRect& rect, const wxPropertyGrid* propGrid, const wxPGCell& cell, int flags ) const
|
||||||
{
|
{
|
||||||
int imageWidth = 0;
|
int imageWidth = 0;
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ int wxPGCellRenderer::PreDrawCell( wxDC& dc, const wxRect& rect, const wxPGCell&
|
|||||||
if ( font.IsOk() )
|
if ( font.IsOk() )
|
||||||
dc.SetFont(font);
|
dc.SetFont(font);
|
||||||
|
|
||||||
const wxBitmap& bmp = cell.GetBitmap();
|
wxBitmap bmp = cell.GetBitmap().GetBitmapFor(propGrid);
|
||||||
if ( bmp.IsOk() )
|
if ( bmp.IsOk() )
|
||||||
{
|
{
|
||||||
int hMax = rect.height - wxPG_CUSTOM_IMAGE_SPACINGY;
|
int hMax = rect.height - wxPG_CUSTOM_IMAGE_SPACINGY;
|
||||||
@@ -229,9 +229,9 @@ bool wxPGDefaultRenderer::Render( wxDC& dc, const wxRect& rect,
|
|||||||
|
|
||||||
// Property image takes precedence over cell image
|
// Property image takes precedence over cell image
|
||||||
if ( column == 1 && !isUnspecified && property->GetValueImage() )
|
if ( column == 1 && !isUnspecified && property->GetValueImage() )
|
||||||
cell.SetBitmap(wxNullBitmap);
|
cell.SetBitmap(wxBitmapBundle());
|
||||||
|
|
||||||
imageWidth = PreDrawCell( dc, rect, cell, preDrawFlags );
|
imageWidth = PreDrawCell( dc, rect, propertyGrid, cell, preDrawFlags );
|
||||||
|
|
||||||
if ( column == 1 )
|
if ( column == 1 )
|
||||||
{
|
{
|
||||||
@@ -368,7 +368,7 @@ wxPGCell::wxPGCell()
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxPGCell::wxPGCell( const wxString& text,
|
wxPGCell::wxPGCell( const wxString& text,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
const wxColour& fgCol,
|
const wxColour& fgCol,
|
||||||
const wxColour& bgCol )
|
const wxColour& bgCol )
|
||||||
: wxObject()
|
: wxObject()
|
||||||
@@ -376,7 +376,7 @@ wxPGCell::wxPGCell( const wxString& text,
|
|||||||
wxPGCellData* data = new wxPGCellData();
|
wxPGCellData* data = new wxPGCellData();
|
||||||
m_refData = data;
|
m_refData = data;
|
||||||
data->m_text = text;
|
data->m_text = text;
|
||||||
data->m_bitmap = bitmap;
|
data->m_bitmapBundle = bitmap;
|
||||||
data->m_fgCol = fgCol;
|
data->m_fgCol = fgCol;
|
||||||
data->m_bgCol = bgCol;
|
data->m_bgCol = bgCol;
|
||||||
data->m_hasValidText = true;
|
data->m_hasValidText = true;
|
||||||
@@ -387,7 +387,7 @@ wxObjectRefData *wxPGCell::CloneRefData( const wxObjectRefData *data ) const
|
|||||||
wxPGCellData* c = new wxPGCellData();
|
wxPGCellData* c = new wxPGCellData();
|
||||||
const wxPGCellData* o = (const wxPGCellData*) data;
|
const wxPGCellData* o = (const wxPGCellData*) data;
|
||||||
c->m_text = o->m_text;
|
c->m_text = o->m_text;
|
||||||
c->m_bitmap = o->m_bitmap;
|
c->m_bitmapBundle = o->m_bitmapBundle;
|
||||||
c->m_fgCol = o->m_fgCol;
|
c->m_fgCol = o->m_fgCol;
|
||||||
c->m_bgCol = o->m_bgCol;
|
c->m_bgCol = o->m_bgCol;
|
||||||
c->m_hasValidText = o->m_hasValidText;
|
c->m_hasValidText = o->m_hasValidText;
|
||||||
@@ -401,7 +401,7 @@ void wxPGCell::SetText( const wxString& text )
|
|||||||
GetData()->SetText(text);
|
GetData()->SetText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPGCell::SetBitmap( const wxBitmap& bitmap )
|
void wxPGCell::SetBitmap( const wxBitmapBundle& bitmap )
|
||||||
{
|
{
|
||||||
AllocExclusive();
|
AllocExclusive();
|
||||||
|
|
||||||
@@ -477,7 +477,6 @@ void wxPGProperty::Init()
|
|||||||
#if wxUSE_VALIDATORS
|
#if wxUSE_VALIDATORS
|
||||||
m_validator = NULL;
|
m_validator = NULL;
|
||||||
#endif
|
#endif
|
||||||
m_valueBitmap = NULL;
|
|
||||||
|
|
||||||
m_maxLen = 0; // infinite maximum length
|
m_maxLen = 0; // infinite maximum length
|
||||||
|
|
||||||
@@ -690,7 +689,7 @@ wxPGProperty::~wxPGProperty()
|
|||||||
|
|
||||||
Empty(); // this deletes items
|
Empty(); // this deletes items
|
||||||
|
|
||||||
delete m_valueBitmap;
|
// delete m_valueBitmap;
|
||||||
#if wxUSE_VALIDATORS
|
#if wxUSE_VALIDATORS
|
||||||
delete m_validator;
|
delete m_validator;
|
||||||
#endif
|
#endif
|
||||||
@@ -1313,20 +1312,26 @@ bool wxPGProperty::SetValueFromInt( long number, int argFlags )
|
|||||||
|
|
||||||
wxSize wxPGProperty::OnMeasureImage( int WXUNUSED(item) ) const
|
wxSize wxPGProperty::OnMeasureImage( int WXUNUSED(item) ) const
|
||||||
{
|
{
|
||||||
if ( m_valueBitmap )
|
if ( m_valueBitmapBundle.IsOk() )
|
||||||
{
|
{
|
||||||
wxPropertyGrid* pg = GetGrid();
|
wxPropertyGrid* pg = GetGrid();
|
||||||
|
wxBitmap bmp;
|
||||||
double scale = 1.0;
|
double scale = 1.0;
|
||||||
if ( pg )
|
if ( pg )
|
||||||
{
|
{
|
||||||
|
bmp = m_valueBitmapBundle.GetBitmapFor(pg);
|
||||||
int hMax = pg->GetImageSize().GetHeight();
|
int hMax = pg->GetImageSize().GetHeight();
|
||||||
if ( m_valueBitmap->GetHeight() > hMax )
|
if ( bmp.GetHeight() > hMax )
|
||||||
{
|
{
|
||||||
scale = (double)hMax / m_valueBitmap->GetHeight();
|
scale = (double)hMax / bmp.GetHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bmp = m_valueBitmapBundle.GetBitmap(m_valueBitmapBundle.GetDefaultSize());
|
||||||
|
}
|
||||||
|
|
||||||
return wxSize(wxRound(scale*m_valueBitmap->GetWidth()), wxDefaultCoord);
|
return wxSize(wxRound(scale*bmp.GetWidth()), wxDefaultCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxSize(0,0);
|
return wxSize(0,0);
|
||||||
@@ -1355,21 +1360,22 @@ wxPGCellRenderer* wxPGProperty::GetCellRenderer( int WXUNUSED(column) ) const
|
|||||||
|
|
||||||
void wxPGProperty::OnCustomPaint( wxDC& dc,
|
void wxPGProperty::OnCustomPaint( wxDC& dc,
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
wxPGPaintData& )
|
wxPGPaintData& paintData)
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_valueBitmap && m_valueBitmap->IsOk(), wxS("invalid bitmap") );
|
wxCHECK_RET( m_valueBitmapBundle.IsOk(), wxS("invalid bitmap bundle") );
|
||||||
|
|
||||||
|
wxBitmap bmp = m_valueBitmapBundle.GetBitmapFor(paintData.m_parent);
|
||||||
wxBitmap scaledBmp;
|
wxBitmap scaledBmp;
|
||||||
int yOfs;
|
int yOfs;
|
||||||
if ( m_valueBitmap->GetHeight() <= rect.height )
|
if ( bmp.GetHeight() <= rect.height )
|
||||||
{
|
{
|
||||||
scaledBmp = *m_valueBitmap;
|
scaledBmp = bmp;
|
||||||
yOfs = (rect.height - m_valueBitmap->GetHeight()) / 2;
|
yOfs = (rect.height - bmp.GetHeight()) / 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double scale = (double)rect.height / m_valueBitmap->GetHeight();
|
double scale = (double)rect.height / bmp.GetHeight();
|
||||||
scaledBmp = wxPropertyGrid::RescaleBitmap(*m_valueBitmap, scale, scale);
|
scaledBmp = wxPropertyGrid::RescaleBitmap(bmp, scale, scale);
|
||||||
yOfs = 0;
|
yOfs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2187,21 +2193,19 @@ bool wxPGProperty::RecreateEditor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxPGProperty::SetValueImage( wxBitmap& bmp )
|
void wxPGProperty::SetValueImage( const wxBitmapBundle& bmp )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( GetGrid(),
|
wxCHECK_RET( GetGrid(),
|
||||||
wxS("Cannot set image for detached property") );
|
wxS("Cannot set image for detached property") );
|
||||||
|
|
||||||
delete m_valueBitmap;
|
|
||||||
|
|
||||||
if ( bmp.IsOk() )
|
if ( bmp.IsOk() )
|
||||||
{
|
{
|
||||||
m_valueBitmap = new wxBitmap(bmp);
|
m_valueBitmapBundle = bmp;
|
||||||
m_flags |= wxPG_PROP_CUSTOMIMAGE;
|
m_flags |= wxPG_PROP_CUSTOMIMAGE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_valueBitmap = NULL;
|
m_valueBitmapBundle = wxBitmapBundle();
|
||||||
m_flags &= ~(wxPG_PROP_CUSTOMIMAGE);
|
m_flags &= ~(wxPG_PROP_CUSTOMIMAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2829,6 +2833,20 @@ bool wxPGProperty::SetMaxLength(int maxLen)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxBitmap* wxPGProperty::GetValueImage() const
|
||||||
|
{
|
||||||
|
if ( !m_valueBitmapBundle.IsOk() )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
wxPropertyGrid* pg = GetGrid();
|
||||||
|
if ( pg )
|
||||||
|
*const_cast<wxBitmap*>(&m_valueBitmap) = m_valueBitmapBundle.GetBitmapFor(pg);
|
||||||
|
else
|
||||||
|
*const_cast<wxBitmap*>(&m_valueBitmap) = m_valueBitmapBundle.GetBitmap(m_valueBitmapBundle.GetDefaultSize());
|
||||||
|
|
||||||
|
return const_cast<wxBitmap*>(&m_valueBitmap);
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// wxPGRootProperty
|
// wxPGRootProperty
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@@ -2944,7 +2962,7 @@ wxPGChoiceEntry& wxPGChoices::Add( const wxString& label, int value )
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
wxPGChoiceEntry& wxPGChoices::Add( const wxString& label, const wxBitmap& bitmap, int value )
|
wxPGChoiceEntry& wxPGChoices::Add( const wxString& label, const wxBitmapBundle& bitmap, int value )
|
||||||
{
|
{
|
||||||
AllocExclusive();
|
AllocExclusive();
|
||||||
|
|
||||||
|
|||||||
@@ -5093,7 +5093,7 @@ bool wxPropertyGrid::HandleMouseMove( int x, unsigned int y,
|
|||||||
int space = m_pState->GetColumnWidth(m_colHover);
|
int space = m_pState->GetColumnWidth(m_colHover);
|
||||||
|
|
||||||
int imageWidth = 0;
|
int imageWidth = 0;
|
||||||
const wxBitmap& bmp = cell.GetBitmap();
|
const wxBitmap& bmp = cell.GetBitmap().GetBitmapFor(this);
|
||||||
if ( bmp.IsOk() )
|
if ( bmp.IsOk() )
|
||||||
{
|
{
|
||||||
imageWidth = bmp.GetWidth();
|
imageWidth = bmp.GetWidth();
|
||||||
|
|||||||
@@ -739,7 +739,7 @@ void wxPropertyGridInterface::SetPropertyColoursToDefault(wxPGPropArg id, int fl
|
|||||||
void wxPropertyGridInterface::SetPropertyCell( wxPGPropArg id,
|
void wxPropertyGridInterface::SetPropertyCell( wxPGPropArg id,
|
||||||
int column,
|
int column,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
const wxColour& fgCol,
|
const wxColour& fgCol,
|
||||||
const wxColour& bgCol )
|
const wxColour& bgCol )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user