Remove wxDataViewTextRendererAttr by merging it with wxDataViewTextRenderer.
There is no reason to have a separate class for rendering the text honouring the attributes defined for it, wxDataViewTextRenderer itself already does this perfectly well. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62383 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -144,6 +144,7 @@ public:
|
|||||||
bool HasColour() const { return m_colour.Ok(); }
|
bool HasColour() const { return m_colour.Ok(); }
|
||||||
const wxColour& GetColour() const { return m_colour; }
|
const wxColour& GetColour() const { return m_colour; }
|
||||||
|
|
||||||
|
bool HasFont() const { return m_bold || m_italic; }
|
||||||
bool GetBold() const { return m_bold; }
|
bool GetBold() const { return m_bold; }
|
||||||
bool GetItalic() const { return m_italic; }
|
bool GetItalic() const { return m_italic; }
|
||||||
|
|
||||||
@@ -983,6 +984,10 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// this class is obsolete, its functionality was merged in
|
||||||
|
// wxDataViewTextRenderer itself now, don't use it any more
|
||||||
|
#define wxDataViewTextRendererAttr wxDataViewTextRenderer
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxDataViewListStore
|
// wxDataViewListStore
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -38,7 +38,22 @@ public:
|
|||||||
int align = wxDVR_DEFAULT_ALIGNMENT );
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
||||||
virtual ~wxDataViewRenderer();
|
virtual ~wxDataViewRenderer();
|
||||||
|
|
||||||
|
// these methods are used to draw the cell contents, Render() doesn't care
|
||||||
|
// about the attributes while RenderWithAttr() does -- override it if you
|
||||||
|
// want to take the attributes defined for this cell into account, otherwise
|
||||||
|
// overriding Render() is enough
|
||||||
virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
|
virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
|
||||||
|
|
||||||
|
// NB: RenderWithAttr() also has more standard parameter order and types
|
||||||
|
virtual bool
|
||||||
|
RenderWithAttr(wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
const wxDataViewItemAttr * WXUNUSED(attr), // NULL if none
|
||||||
|
int state)
|
||||||
|
{
|
||||||
|
return Render(rect, &dc, state);
|
||||||
|
}
|
||||||
|
|
||||||
virtual wxSize GetSize() const = 0;
|
virtual wxSize GetSize() const = 0;
|
||||||
|
|
||||||
virtual void SetAlignment( int align );
|
virtual void SetAlignment( int align );
|
||||||
@@ -77,10 +92,6 @@ public:
|
|||||||
// Create DC on request
|
// Create DC on request
|
||||||
virtual wxDC *GetDC();
|
virtual wxDC *GetDC();
|
||||||
|
|
||||||
void SetHasAttr( bool set ) { m_hasAttr = set; }
|
|
||||||
void SetAttr( const wxDataViewItemAttr &attr ) { m_attr = attr; }
|
|
||||||
bool GetWantsAttr() const { return m_wantsAttr; }
|
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
int CalculateAlignment() const;
|
int CalculateAlignment() const;
|
||||||
|
|
||||||
@@ -89,11 +100,6 @@ private:
|
|||||||
int m_align;
|
int m_align;
|
||||||
wxDataViewCellMode m_mode;
|
wxDataViewCellMode m_mode;
|
||||||
|
|
||||||
protected:
|
|
||||||
bool m_wantsAttr;
|
|
||||||
bool m_hasAttr;
|
|
||||||
wxDataViewItemAttr m_attr;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
|
||||||
};
|
};
|
||||||
@@ -109,6 +115,15 @@ public:
|
|||||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
||||||
int align = wxDVR_DEFAULT_ALIGNMENT );
|
int align = wxDVR_DEFAULT_ALIGNMENT );
|
||||||
|
|
||||||
|
// Draw the text using the provided attributes
|
||||||
|
void RenderText(wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
const wxString& text,
|
||||||
|
const wxDataViewItemAttr *attr, // may be NULL if none
|
||||||
|
int state,
|
||||||
|
int xoffset = 0);
|
||||||
|
|
||||||
|
// Overload using standard attributes
|
||||||
void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state );
|
void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -130,7 +145,15 @@ public:
|
|||||||
bool SetValue( const wxVariant &value );
|
bool SetValue( const wxVariant &value );
|
||||||
bool GetValue( wxVariant &value ) const;
|
bool GetValue( wxVariant &value ) const;
|
||||||
|
|
||||||
bool Render( wxRect cell, wxDC *dc, int state );
|
virtual bool RenderWithAttr(wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
const wxDataViewItemAttr *attr,
|
||||||
|
int state);
|
||||||
|
virtual bool Render( wxRect cell, wxDC *dc, int state )
|
||||||
|
{
|
||||||
|
return RenderWithAttr(*dc, cell, NULL, state);
|
||||||
|
}
|
||||||
|
|
||||||
wxSize GetSize() const;
|
wxSize GetSize() const;
|
||||||
|
|
||||||
// in-place editing
|
// in-place editing
|
||||||
@@ -146,23 +169,6 @@ protected:
|
|||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
// wxDataViewTextRendererAttr
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_ADV wxDataViewTextRendererAttr: public wxDataViewTextRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxDataViewTextRendererAttr( const wxString &varianttype = wxT("string"),
|
|
||||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
||||||
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
||||||
|
|
||||||
bool Render( wxRect cell, wxDC *dc, int state );
|
|
||||||
|
|
||||||
protected:
|
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRendererAttr)
|
|
||||||
};
|
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// wxDataViewBitmapRenderer
|
// wxDataViewBitmapRenderer
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
@@ -40,7 +40,6 @@ public:
|
|||||||
// implementation
|
// implementation
|
||||||
GtkCellRenderer* GetGtkHandle() { return m_renderer; }
|
GtkCellRenderer* GetGtkHandle() { return m_renderer; }
|
||||||
void GtkInitHandlers();
|
void GtkInitHandlers();
|
||||||
virtual bool GtkHasAttributes() { return false; }
|
|
||||||
void GtkUpdateAlignment();
|
void GtkUpdateAlignment();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -71,24 +70,6 @@ protected:
|
|||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
// wxDataViewTextRendererAttr
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_ADV wxDataViewTextRendererAttr: public wxDataViewTextRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxDataViewTextRendererAttr( const wxString &varianttype = wxT("string"),
|
|
||||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
||||||
int align = wxDVR_DEFAULT_ALIGNMENT );
|
|
||||||
|
|
||||||
// implementation
|
|
||||||
bool GtkHasAttributes() { return true; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRendererAttr)
|
|
||||||
};
|
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// wxDataViewBitmapRenderer
|
// wxDataViewBitmapRenderer
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
@@ -191,22 +191,6 @@ private:
|
|||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
// wxDataViewTextRendererAttr
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_ADV wxDataViewTextRendererAttr: public wxDataViewTextRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//
|
|
||||||
// constructors / destructor
|
|
||||||
//
|
|
||||||
wxDataViewTextRendererAttr(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
|
|
||||||
|
|
||||||
private:
|
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRendererAttr)
|
|
||||||
};
|
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// wxDataViewBitmapRenderer
|
// wxDataViewBitmapRenderer
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
@@ -1033,7 +1033,6 @@ enum wxDataViewCellRenderState
|
|||||||
One instance of a renderer class is owned by a wxDataViewColumn.
|
One instance of a renderer class is owned by a wxDataViewColumn.
|
||||||
There is a number of ready-to-use renderers provided:
|
There is a number of ready-to-use renderers provided:
|
||||||
- wxDataViewTextRenderer,
|
- wxDataViewTextRenderer,
|
||||||
- wxDataViewTextRendererAttr,
|
|
||||||
- wxDataViewIconTextRenderer,
|
- wxDataViewIconTextRenderer,
|
||||||
- wxDataViewToggleRenderer,
|
- wxDataViewToggleRenderer,
|
||||||
- wxDataViewProgressRenderer,
|
- wxDataViewProgressRenderer,
|
||||||
@@ -1263,30 +1262,6 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
@class wxDataViewTextRendererAttr
|
|
||||||
|
|
||||||
The same as wxDataViewTextRenderer but with support for font attributes.
|
|
||||||
Font attributes are currently only supported under GTK+ and MSW.
|
|
||||||
|
|
||||||
@see wxDataViewModel::GetAttr and wxDataViewItemAttr.
|
|
||||||
|
|
||||||
@library{wxadv}
|
|
||||||
@category{dvc}
|
|
||||||
*/
|
|
||||||
class wxDataViewTextRendererAttr : public wxDataViewTextRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
The ctor.
|
|
||||||
*/
|
|
||||||
wxDataViewTextRendererAttr(const wxString& varianttype = "string",
|
|
||||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
|
||||||
int align = wxDVR_DEFAULT_ALIGNMENT);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class wxDataViewCustomRenderer
|
@class wxDataViewCustomRenderer
|
||||||
|
|
||||||
|
@@ -553,7 +553,7 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
|
|||||||
m_ctrl[1]->AppendIconTextColumn("icon", 1, wxDATAVIEW_CELL_INERT);
|
m_ctrl[1]->AppendIconTextColumn("icon", 1, wxDATAVIEW_CELL_INERT);
|
||||||
#endif
|
#endif
|
||||||
m_ctrl[1]->AppendColumn(
|
m_ctrl[1]->AppendColumn(
|
||||||
new wxDataViewColumn("attributes", new wxDataViewTextRendererAttr, 2 ));
|
new wxDataViewColumn("attributes", new wxDataViewTextRenderer, 2 ));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -612,8 +612,6 @@ wxDataViewRenderer::wxDataViewRenderer( const wxString &varianttype,
|
|||||||
m_dc = NULL;
|
m_dc = NULL;
|
||||||
m_align = align;
|
m_align = align;
|
||||||
m_mode = mode;
|
m_mode = mode;
|
||||||
m_wantsAttr = false;
|
|
||||||
m_hasAttr = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataViewRenderer::~wxDataViewRenderer()
|
wxDataViewRenderer::~wxDataViewRenderer()
|
||||||
@@ -674,14 +672,42 @@ wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString &varianttype,
|
|||||||
void wxDataViewCustomRenderer::RenderText( const wxString &text, int xoffset,
|
void wxDataViewCustomRenderer::RenderText( const wxString &text, int xoffset,
|
||||||
wxRect cell, wxDC *dc, int state )
|
wxRect cell, wxDC *dc, int state )
|
||||||
{
|
{
|
||||||
wxDataViewCtrl *view = GetOwner()->GetOwner();
|
wxColour col = state & wxDATAVIEW_CELL_SELECTED
|
||||||
wxColour col = (state & wxDATAVIEW_CELL_SELECTED) ?
|
? wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)
|
||||||
wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) :
|
: GetOwner()->GetOwner()->GetForegroundColour();
|
||||||
view->GetForegroundColour();
|
|
||||||
dc->SetTextForeground(col);
|
wxDataViewItemAttr attr;
|
||||||
dc->DrawText( text,
|
attr.SetColour(col);
|
||||||
cell.x + xoffset,
|
RenderText(*dc, cell, text, &attr, state, xoffset);
|
||||||
cell.y + ((cell.height - dc->GetCharHeight()) / 2));
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wxDataViewCustomRenderer::RenderText(wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
const wxString& text,
|
||||||
|
const wxDataViewItemAttr *attr,
|
||||||
|
int WXUNUSED(state),
|
||||||
|
int xoffset)
|
||||||
|
{
|
||||||
|
wxDCTextColourChanger changeFg(dc);
|
||||||
|
if ( attr && attr->HasColour() )
|
||||||
|
changeFg.Set(attr->GetColour());
|
||||||
|
|
||||||
|
wxDCFontChanger changeFont(dc);
|
||||||
|
if ( attr && attr->HasFont() )
|
||||||
|
{
|
||||||
|
wxFont font(dc.GetFont());
|
||||||
|
if ( attr->GetBold() )
|
||||||
|
font.MakeBold();
|
||||||
|
if ( attr->GetItalic() )
|
||||||
|
font.MakeItalic();
|
||||||
|
|
||||||
|
changeFont.Set(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
dc.DrawText(text,
|
||||||
|
rect.x + xoffset,
|
||||||
|
rect.y + ((rect.height - dc.GetCharHeight()) / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -734,9 +760,13 @@ bool wxDataViewTextRenderer::GetValueFromEditorCtrl( wxControl *editor, wxVarian
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewTextRenderer::Render( wxRect cell, wxDC *dc, int state )
|
bool
|
||||||
|
wxDataViewTextRenderer::RenderWithAttr(wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
const wxDataViewItemAttr *attr,
|
||||||
|
int state)
|
||||||
{
|
{
|
||||||
RenderText( m_text, 0, cell, dc, state );
|
RenderText(dc, rect, m_text, attr, state);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -748,60 +778,6 @@ wxSize wxDataViewTextRenderer::GetSize() const
|
|||||||
return wxSize(wxDVC_DEFAULT_RENDERER_SIZE,wxDVC_DEFAULT_RENDERER_SIZE);
|
return wxSize(wxDVC_DEFAULT_RENDERER_SIZE,wxDVC_DEFAULT_RENDERER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
// wxDataViewTextRendererAttr
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(wxDataViewTextRendererAttr, wxDataViewTextRenderer)
|
|
||||||
|
|
||||||
wxDataViewTextRendererAttr::wxDataViewTextRendererAttr( const wxString &varianttype,
|
|
||||||
wxDataViewCellMode mode, int align ) :
|
|
||||||
wxDataViewTextRenderer( varianttype, mode, align )
|
|
||||||
{
|
|
||||||
m_wantsAttr = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxDataViewTextRendererAttr::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
|
|
||||||
{
|
|
||||||
wxFont font;
|
|
||||||
wxColour colour;
|
|
||||||
|
|
||||||
if (m_hasAttr)
|
|
||||||
{
|
|
||||||
if (m_attr.HasColour())
|
|
||||||
{
|
|
||||||
colour = dc->GetTextForeground();
|
|
||||||
dc->SetTextForeground( m_attr.GetColour() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_attr.GetBold() || m_attr.GetItalic())
|
|
||||||
{
|
|
||||||
font = dc->GetFont();
|
|
||||||
wxFont myfont = font;
|
|
||||||
if (m_attr.GetBold())
|
|
||||||
myfont.SetWeight( wxFONTWEIGHT_BOLD );
|
|
||||||
if (m_attr.GetItalic())
|
|
||||||
myfont.SetStyle( wxFONTSTYLE_ITALIC );
|
|
||||||
dc->SetFont( myfont );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dc->DrawText( m_text, cell.x, cell.y + ((cell.height - dc->GetCharHeight()) / 2));
|
|
||||||
|
|
||||||
// restore dc
|
|
||||||
if (m_hasAttr)
|
|
||||||
{
|
|
||||||
if (m_attr.HasColour())
|
|
||||||
dc->SetTextForeground( colour );
|
|
||||||
|
|
||||||
if (m_attr.GetBold() || m_attr.GetItalic())
|
|
||||||
dc->SetFont( font );
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// wxDataViewBitmapRenderer
|
// wxDataViewBitmapRenderer
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -1602,15 +1578,6 @@ wxBitmap wxDataViewMainWindow::CreateItemBitmap( unsigned int row, int &indent )
|
|||||||
model->GetValue( value, item, column->GetModelColumn());
|
model->GetValue( value, item, column->GetModelColumn());
|
||||||
cell->SetValue( value );
|
cell->SetValue( value );
|
||||||
|
|
||||||
if (cell->GetWantsAttr())
|
|
||||||
{
|
|
||||||
wxDataViewItemAttr attr;
|
|
||||||
bool ret = model->GetAttr( item, column->GetModelColumn(), attr );
|
|
||||||
if (ret)
|
|
||||||
cell->SetAttr( attr );
|
|
||||||
cell->SetHasAttr( ret );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSize size = cell->GetSize();
|
wxSize size = cell->GetSize();
|
||||||
size.x = wxMin( 2*PADDING_RIGHTLEFT + size.x, width );
|
size.x = wxMin( 2*PADDING_RIGHTLEFT + size.x, width );
|
||||||
size.y = height;
|
size.y = height;
|
||||||
@@ -1638,7 +1605,10 @@ wxBitmap wxDataViewMainWindow::CreateItemBitmap( unsigned int row, int &indent )
|
|||||||
item_rect.width = size.x - 2 * PADDING_RIGHTLEFT;
|
item_rect.width = size.x - 2 * PADDING_RIGHTLEFT;
|
||||||
|
|
||||||
// dc.SetClippingRegion( item_rect );
|
// dc.SetClippingRegion( item_rect );
|
||||||
cell->Render( item_rect, &dc, 0 );
|
wxDataViewItemAttr attr;
|
||||||
|
const bool
|
||||||
|
hasAttr = model->GetAttr(item, column->GetModelColumn(), attr);
|
||||||
|
cell->RenderWithAttr(dc, item_rect, hasAttr ? &attr : NULL, 0);
|
||||||
// dc.DestroyClippingRegion();
|
// dc.DestroyClippingRegion();
|
||||||
|
|
||||||
x += width;
|
x += width;
|
||||||
@@ -1830,15 +1800,6 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
model->GetValue( value, dataitem, col->GetModelColumn());
|
model->GetValue( value, dataitem, col->GetModelColumn());
|
||||||
cell->SetValue( value );
|
cell->SetValue( value );
|
||||||
|
|
||||||
if (cell->GetWantsAttr())
|
|
||||||
{
|
|
||||||
wxDataViewItemAttr attr;
|
|
||||||
bool ret = model->GetAttr( dataitem, col->GetModelColumn(), attr );
|
|
||||||
if (ret)
|
|
||||||
cell->SetAttr( attr );
|
|
||||||
cell->SetHasAttr( ret );
|
|
||||||
}
|
|
||||||
|
|
||||||
// update cell_rect
|
// update cell_rect
|
||||||
cell_rect.y = GetLineStart( item );
|
cell_rect.y = GetLineStart( item );
|
||||||
cell_rect.height = GetLineHeight( item );
|
cell_rect.height = GetLineHeight( item );
|
||||||
@@ -1936,7 +1897,12 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
// violating only the left & right coords - however the user can
|
// violating only the left & right coords - however the user can
|
||||||
// make its own renderer and thus we cannot be sure of that.
|
// make its own renderer and thus we cannot be sure of that.
|
||||||
dc.SetClippingRegion( item_rect );
|
dc.SetClippingRegion( item_rect );
|
||||||
cell->Render( item_rect, &dc, state );
|
|
||||||
|
wxDataViewItemAttr attr;
|
||||||
|
const bool
|
||||||
|
hasAttr = model->GetAttr(dataitem, col->GetModelColumn(), attr);
|
||||||
|
cell->RenderWithAttr(dc, item_rect, hasAttr ? &attr : NULL, state);
|
||||||
|
|
||||||
dc.DestroyClippingRegion();
|
dc.DestroyClippingRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1790,18 +1790,6 @@ void wxDataViewTextRenderer::SetAlignment( int align )
|
|||||||
g_value_unset( &gvalue );
|
g_value_unset( &gvalue );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
// wxDataViewTextRendererAttr
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(wxDataViewTextRendererAttr,wxDataViewTextRenderer)
|
|
||||||
|
|
||||||
wxDataViewTextRendererAttr::wxDataViewTextRendererAttr( const wxString &varianttype,
|
|
||||||
wxDataViewCellMode mode, int align ) :
|
|
||||||
wxDataViewTextRenderer( varianttype, mode, align )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// wxDataViewBitmapRenderer
|
// wxDataViewBitmapRenderer
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -2580,54 +2568,37 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column),
|
|||||||
|
|
||||||
cell->SetValue( value );
|
cell->SetValue( value );
|
||||||
|
|
||||||
if (cell->GtkHasAttributes())
|
wxDataViewItemAttr attr;
|
||||||
|
if (wx_model->GetAttr( item, cell->GetOwner()->GetModelColumn(), attr ))
|
||||||
{
|
{
|
||||||
wxDataViewItemAttr attr;
|
if (attr.HasColour())
|
||||||
bool colour_set = false;
|
|
||||||
bool style_set = false;
|
|
||||||
bool weight_set = false;
|
|
||||||
|
|
||||||
if (wx_model->GetAttr( item, cell->GetOwner()->GetModelColumn(), attr ))
|
|
||||||
{
|
{
|
||||||
// this must be a GtkCellRendererText
|
const GdkColor * const gcol = attr.GetColour().GetColor();
|
||||||
wxColour colour = attr.GetColour();
|
|
||||||
if (colour.IsOk())
|
|
||||||
{
|
|
||||||
const GdkColor * const gcol = colour.GetColor();
|
|
||||||
|
|
||||||
GValue gvalue = { 0, };
|
GValue gvalue = { 0, };
|
||||||
g_value_init( &gvalue, GDK_TYPE_COLOR );
|
g_value_init( &gvalue, GDK_TYPE_COLOR );
|
||||||
g_value_set_boxed( &gvalue, gcol );
|
g_value_set_boxed( &gvalue, gcol );
|
||||||
g_object_set_property( G_OBJECT(renderer), "foreground_gdk", &gvalue );
|
g_object_set_property( G_OBJECT(renderer), "foreground_gdk", &gvalue );
|
||||||
g_value_unset( &gvalue );
|
g_value_unset( &gvalue );
|
||||||
|
}
|
||||||
colour_set = true;
|
else
|
||||||
}
|
{
|
||||||
|
GValue gvalue = { 0, };
|
||||||
if (attr.GetItalic())
|
g_value_init( &gvalue, G_TYPE_BOOLEAN );
|
||||||
{
|
g_value_set_boolean( &gvalue, FALSE );
|
||||||
GValue gvalue = { 0, };
|
g_object_set_property( G_OBJECT(renderer), "foreground-set", &gvalue );
|
||||||
g_value_init( &gvalue, PANGO_TYPE_STYLE );
|
g_value_unset( &gvalue );
|
||||||
g_value_set_enum( &gvalue, PANGO_STYLE_ITALIC );
|
|
||||||
g_object_set_property( G_OBJECT(renderer), "style", &gvalue );
|
|
||||||
g_value_unset( &gvalue );
|
|
||||||
|
|
||||||
style_set = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attr.GetBold())
|
|
||||||
{
|
|
||||||
GValue gvalue = { 0, };
|
|
||||||
g_value_init( &gvalue, PANGO_TYPE_WEIGHT );
|
|
||||||
g_value_set_enum( &gvalue, PANGO_WEIGHT_BOLD );
|
|
||||||
g_object_set_property( G_OBJECT(renderer), "weight", &gvalue );
|
|
||||||
g_value_unset( &gvalue );
|
|
||||||
|
|
||||||
weight_set = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!style_set)
|
if (attr.GetItalic())
|
||||||
|
{
|
||||||
|
GValue gvalue = { 0, };
|
||||||
|
g_value_init( &gvalue, PANGO_TYPE_STYLE );
|
||||||
|
g_value_set_enum( &gvalue, PANGO_STYLE_ITALIC );
|
||||||
|
g_object_set_property( G_OBJECT(renderer), "style", &gvalue );
|
||||||
|
g_value_unset( &gvalue );
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
GValue gvalue = { 0, };
|
GValue gvalue = { 0, };
|
||||||
g_value_init( &gvalue, G_TYPE_BOOLEAN );
|
g_value_init( &gvalue, G_TYPE_BOOLEAN );
|
||||||
@@ -2636,7 +2607,16 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column),
|
|||||||
g_value_unset( &gvalue );
|
g_value_unset( &gvalue );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!weight_set)
|
|
||||||
|
if (attr.GetBold())
|
||||||
|
{
|
||||||
|
GValue gvalue = { 0, };
|
||||||
|
g_value_init( &gvalue, PANGO_TYPE_WEIGHT );
|
||||||
|
g_value_set_enum( &gvalue, PANGO_WEIGHT_BOLD );
|
||||||
|
g_object_set_property( G_OBJECT(renderer), "weight", &gvalue );
|
||||||
|
g_value_unset( &gvalue );
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
GValue gvalue = { 0, };
|
GValue gvalue = { 0, };
|
||||||
g_value_init( &gvalue, G_TYPE_BOOLEAN );
|
g_value_init( &gvalue, G_TYPE_BOOLEAN );
|
||||||
@@ -2644,15 +2624,6 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column),
|
|||||||
g_object_set_property( G_OBJECT(renderer), "weight-set", &gvalue );
|
g_object_set_property( G_OBJECT(renderer), "weight-set", &gvalue );
|
||||||
g_value_unset( &gvalue );
|
g_value_unset( &gvalue );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!colour_set)
|
|
||||||
{
|
|
||||||
GValue gvalue = { 0, };
|
|
||||||
g_value_init( &gvalue, G_TYPE_BOOLEAN );
|
|
||||||
g_value_set_boolean( &gvalue, FALSE );
|
|
||||||
g_object_set_property( G_OBJECT(renderer), "foreground-set", &gvalue );
|
|
||||||
g_value_unset( &gvalue );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@@ -325,16 +325,6 @@ void wxDataViewCustomRenderer::SetDC(wxDC* newDCPtr)
|
|||||||
m_DCPtr = newDCPtr;
|
m_DCPtr = newDCPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
// wxDataViewTextRendererAttr
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
wxDataViewTextRendererAttr::wxDataViewTextRendererAttr(wxString const& varianttype, wxDataViewCellMode mode, int align)
|
|
||||||
:wxDataViewTextRenderer(varianttype,mode,align)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(wxDataViewTextRendererAttr,wxDataViewTextRenderer)
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxDataViewCtrl
|
// wxDataViewCtrl
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user