Added wxPGCell::SetFont() and GetFont(); Documented wxPGCell class.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62412 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -137,14 +137,28 @@ public:
|
||||
wxPGProperty* property,
|
||||
const wxPGEditor* editor ) const;
|
||||
|
||||
/** Utility to render cell bitmap and set text colour plus bg brush colour.
|
||||
/** Utility to render cell bitmap and set text colour plus bg brush
|
||||
colour.
|
||||
|
||||
Returns image width that, for instance, can be passed to DrawText.
|
||||
@return Returns image width, which, for instance, can be passed to
|
||||
DrawText.
|
||||
*/
|
||||
int PreDrawCell( wxDC& dc,
|
||||
const wxRect& rect,
|
||||
const wxPGCell& cell,
|
||||
int flags ) const;
|
||||
|
||||
/**
|
||||
Utility to be called after drawing is done, to revert whatever
|
||||
changes PreDrawCell() did.
|
||||
|
||||
@param flags
|
||||
Same as those passed to PreDrawCell().
|
||||
*/
|
||||
void PostDrawCell( wxDC& dc,
|
||||
const wxPropertyGrid* propGrid,
|
||||
const wxPGCell& cell,
|
||||
int flags ) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -162,6 +176,7 @@ public:
|
||||
void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; }
|
||||
void SetFgCol( const wxColour& col ) { m_fgCol = col; }
|
||||
void SetBgCol( const wxColour& col ) { m_bgCol = col; }
|
||||
void SetFont( const wxFont& font ) { m_font = font; }
|
||||
|
||||
protected:
|
||||
virtual ~wxPGCellData() { }
|
||||
@@ -170,14 +185,16 @@ protected:
|
||||
wxBitmap m_bitmap;
|
||||
wxColour m_fgCol;
|
||||
wxColour m_bgCol;
|
||||
wxFont m_font;
|
||||
|
||||
// True if m_text is valid and specified
|
||||
bool m_hasValidText;
|
||||
};
|
||||
|
||||
/** @class wxPGCell
|
||||
/**
|
||||
@class wxPGCell
|
||||
|
||||
Base class for simple wxPropertyGrid cell information.
|
||||
Base class for wxPropertyGrid cell information.
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxPGCell : public wxObject
|
||||
{
|
||||
@@ -218,11 +235,32 @@ public:
|
||||
void SetText( const wxString& text );
|
||||
void SetBitmap( const wxBitmap& bitmap );
|
||||
void SetFgCol( const wxColour& col );
|
||||
|
||||
/**
|
||||
Sets font of the cell.
|
||||
|
||||
@remarks Because wxPropertyGrid does not support rows of
|
||||
different height, it makes little sense to change
|
||||
size of the font. Therefore it is recommended
|
||||
to use return value of wxPropertyGrid::GetFont()
|
||||
or wxPropertyGrid::GetCaptionFont() as a basis
|
||||
for the font that, after modifications, is passed
|
||||
to this member function.
|
||||
*/
|
||||
void SetFont( const wxFont& font );
|
||||
|
||||
void SetBgCol( const wxColour& col );
|
||||
|
||||
const wxString& GetText() const { return GetData()->m_text; }
|
||||
const wxBitmap& GetBitmap() const { return GetData()->m_bitmap; }
|
||||
const wxColour& GetFgCol() const { return GetData()->m_fgCol; }
|
||||
|
||||
/**
|
||||
Returns font of the cell. If no specific font is set for this
|
||||
cell, then the font will be invalid.
|
||||
*/
|
||||
const wxFont& GetFont() const { return GetData()->m_font; }
|
||||
|
||||
const wxColour& GetBgCol() const { return GetData()->m_bgCol; }
|
||||
|
||||
wxPGCell& operator=( const wxPGCell& other )
|
||||
|
@@ -1505,6 +1505,73 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@class wxPGCell
|
||||
|
||||
Base class for wxPropertyGrid cell information.
|
||||
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class wxPGCell : public wxObject
|
||||
{
|
||||
public:
|
||||
wxPGCell();
|
||||
wxPGCell(const wxPGCell& other);
|
||||
wxPGCell( const wxString& text,
|
||||
const wxBitmap& bitmap = wxNullBitmap,
|
||||
const wxColour& fgCol = wxNullColour,
|
||||
const wxColour& bgCol = wxNullColour );
|
||||
|
||||
virtual ~wxPGCell();
|
||||
|
||||
const wxPGCellData* GetData() const;
|
||||
|
||||
/**
|
||||
Returns @true if this cell has custom text stored within.
|
||||
*/
|
||||
bool HasText() const;
|
||||
|
||||
/**
|
||||
Merges valid data from srcCell into this.
|
||||
*/
|
||||
void MergeFrom( const wxPGCell& srcCell );
|
||||
|
||||
void SetText( const wxString& text );
|
||||
void SetBitmap( const wxBitmap& bitmap );
|
||||
void SetFgCol( const wxColour& col );
|
||||
|
||||
/**
|
||||
Sets font of the cell.
|
||||
|
||||
@remarks Because wxPropertyGrid does not support rows of
|
||||
different height, it makes little sense to change
|
||||
size of the font. Therefore it is recommended
|
||||
to use return value of wxPropertyGrid::GetFont()
|
||||
or wxPropertyGrid::GetCaptionFont() as a basis
|
||||
for the font that, after modifications, is passed
|
||||
to this member function.
|
||||
*/
|
||||
void SetFont( const wxFont& font );
|
||||
|
||||
void SetBgCol( const wxColour& col );
|
||||
|
||||
const wxString& GetText() const;
|
||||
const wxBitmap& GetBitmap() const;
|
||||
const wxColour& GetFgCol() const;
|
||||
|
||||
/**
|
||||
Returns font of the cell. If no specific font is set for this
|
||||
cell, then the font will be invalid.
|
||||
*/
|
||||
const wxFont& GetFont() const;
|
||||
|
||||
const wxColour& GetBgCol() const;
|
||||
|
||||
wxPGCell& operator=( const wxPGCell& other );
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@class wxPGChoices
|
||||
|
||||
@@ -1522,7 +1589,7 @@ public:
|
||||
@library{wxpropgrid}
|
||||
@category{propgrid}
|
||||
*/
|
||||
class WXDLLIMPEXP_PROPGRID wxPGChoices
|
||||
class wxPGChoices
|
||||
{
|
||||
public:
|
||||
typedef long ValArrItem;
|
||||
|
@@ -1793,9 +1793,19 @@ void FormMain::PopulateWithLibraryConfig ()
|
||||
|
||||
wxPGProperty* pid;
|
||||
|
||||
wxFont italicFont = pgman->GetGrid()->GetCaptionFont();
|
||||
italicFont.SetStyle(wxFONTSTYLE_ITALIC);
|
||||
|
||||
wxString italicFontHelp = "Font of this property's wxPGCell has "
|
||||
"been modified. Obtain property's cell "
|
||||
"with wxPGProperty::"
|
||||
"GetOrCreateCell(column).";
|
||||
|
||||
#define ADD_WX_LIB_CONF_GROUP(A) \
|
||||
cat = pg->AppendIn( pid, new wxPropertyCategory(A) ); \
|
||||
pg->SetPropertyCell( cat, 0, wxPG_LABEL, bmp );
|
||||
pg->SetPropertyCell( cat, 0, wxPG_LABEL, bmp ); \
|
||||
cat->GetCell(0).SetFont(italicFont); \
|
||||
cat->SetHelpString(italicFontHelp);
|
||||
|
||||
#define ADD_WX_LIB_CONF(A) pg->Append( new wxBoolProperty(wxT(#A),wxPG_LABEL,(bool)((A>0)?true:false)));
|
||||
#define ADD_WX_LIB_CONF_NODEF(A) pg->Append( new wxBoolProperty(wxT(#A),wxPG_LABEL,(bool)false) ); \
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -149,6 +149,11 @@ int wxPGCellRenderer::PreDrawCell( wxDC& dc, const wxRect& rect, const wxPGCell&
|
||||
if ( !(flags & (Control|ChoicePopup)) )
|
||||
dc.DrawRectangle(rect);
|
||||
|
||||
// Use cell font, if provided
|
||||
const wxFont& font = cell.GetFont();
|
||||
if ( font.IsOk() )
|
||||
dc.SetFont(font);
|
||||
|
||||
const wxBitmap& bmp = cell.GetBitmap();
|
||||
if ( bmp.Ok() &&
|
||||
// Do not draw oversized bitmap outside choice popup
|
||||
@@ -165,6 +170,17 @@ int wxPGCellRenderer::PreDrawCell( wxDC& dc, const wxRect& rect, const wxPGCell&
|
||||
return imageWidth;
|
||||
}
|
||||
|
||||
void wxPGCellRenderer::PostDrawCell( wxDC& dc,
|
||||
const wxPropertyGrid* propGrid,
|
||||
const wxPGCell& cell,
|
||||
int WXUNUSED(flags) ) const
|
||||
{
|
||||
// Revert font
|
||||
const wxFont& font = cell.GetFont();
|
||||
if ( font.IsOk() )
|
||||
dc.SetFont(propGrid->GetFont());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// wxPGDefaultRenderer
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -276,6 +292,8 @@ void wxPGDefaultRenderer::Render( wxDC& dc, const wxRect& rect,
|
||||
propertyGrid->GetFontHeight()+(wxPG_CAPRECTYMARGIN*2) );
|
||||
}
|
||||
}
|
||||
|
||||
PostDrawCell(dc, propertyGrid, *cell, preDrawFlags);
|
||||
}
|
||||
|
||||
wxSize wxPGDefaultRenderer::GetImageSize( const wxPGProperty* property,
|
||||
@@ -362,6 +380,13 @@ void wxPGCell::SetFgCol( const wxColour& col )
|
||||
GetData()->SetFgCol(col);
|
||||
}
|
||||
|
||||
void wxPGCell::SetFont( const wxFont& font )
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
GetData()->SetFont(font);
|
||||
}
|
||||
|
||||
void wxPGCell::SetBgCol( const wxColour& col )
|
||||
{
|
||||
AllocExclusive();
|
||||
|
Reference in New Issue
Block a user