Add wxDataViewTextRendererAttr, blind noop under wxMac
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49730 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,7 +20,6 @@
|
|||||||
#include "wx/textctrl.h"
|
#include "wx/textctrl.h"
|
||||||
#include "wx/bitmap.h"
|
#include "wx/bitmap.h"
|
||||||
#include "wx/variant.h"
|
#include "wx/variant.h"
|
||||||
#include "wx/listctrl.h"
|
|
||||||
#include "wx/dynarray.h"
|
#include "wx/dynarray.h"
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
|
|
||||||
@@ -118,6 +117,42 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxDataViewItemAttr: a structure containing the visual attributes of an item
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// TODO: this should be renamed to wxItemAttr or something general like this
|
||||||
|
|
||||||
|
class WXDLLIMPEXP_ADV wxDataViewItemAttr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// ctors
|
||||||
|
wxDataViewItemAttr()
|
||||||
|
{
|
||||||
|
m_bold = false;
|
||||||
|
m_italic = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// setters
|
||||||
|
void SetColour(const wxColour& colour) { m_colour = colour; }
|
||||||
|
void SetBold( bool set ) { m_bold = set; }
|
||||||
|
void SetItalic( bool set ) { m_italic = set; }
|
||||||
|
|
||||||
|
// accessors
|
||||||
|
bool HasColour() const { return m_colour.Ok(); }
|
||||||
|
const wxColour& GetColour() const { return m_colour; }
|
||||||
|
|
||||||
|
bool GetBold() const { return m_bold; }
|
||||||
|
bool GetItalic() const { return m_italic; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxColour m_colour;
|
||||||
|
bool m_bold;
|
||||||
|
bool m_italic;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// wxDataViewModel
|
// wxDataViewModel
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -143,6 +178,10 @@ public:
|
|||||||
virtual bool SetValue( const wxVariant &variant,
|
virtual bool SetValue( const wxVariant &variant,
|
||||||
const wxDataViewItem &item, unsigned int col ) = 0;
|
const wxDataViewItem &item, unsigned int col ) = 0;
|
||||||
|
|
||||||
|
// Get text attribute, return false of default attributes should be used
|
||||||
|
virtual bool GetAttr( const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
|
||||||
|
{ return false; }
|
||||||
|
|
||||||
// define hierachy
|
// define hierachy
|
||||||
virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0;
|
virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0;
|
||||||
virtual bool IsContainer( const wxDataViewItem &item ) const = 0;
|
virtual bool IsContainer( const wxDataViewItem &item ) const = 0;
|
||||||
@@ -197,6 +236,9 @@ public:
|
|||||||
virtual bool SetValue( const wxVariant &variant,
|
virtual bool SetValue( const wxVariant &variant,
|
||||||
unsigned int row, unsigned int col ) = 0;
|
unsigned int row, unsigned int col ) = 0;
|
||||||
|
|
||||||
|
virtual bool GetAttr( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
|
||||||
|
{ return false; }
|
||||||
|
|
||||||
void RowPrepended();
|
void RowPrepended();
|
||||||
void RowInserted( unsigned int before );
|
void RowInserted( unsigned int before );
|
||||||
void RowAppended();
|
void RowAppended();
|
||||||
@@ -221,6 +263,7 @@ public:
|
|||||||
const wxDataViewItem &item, unsigned int col ) const;
|
const wxDataViewItem &item, unsigned int col ) const;
|
||||||
virtual bool SetValue( const wxVariant &variant,
|
virtual bool SetValue( const wxVariant &variant,
|
||||||
const wxDataViewItem &item, unsigned int col );
|
const wxDataViewItem &item, unsigned int col );
|
||||||
|
virtual bool GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr );
|
||||||
virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
|
virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
|
||||||
virtual bool IsContainer( const wxDataViewItem &item ) const;
|
virtual bool IsContainer( const wxDataViewItem &item ) const;
|
||||||
virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
|
virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
|
||||||
|
@@ -78,11 +78,20 @@ 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() { return m_wantsAttr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxDC *m_dc;
|
wxDC *m_dc;
|
||||||
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)
|
||||||
@@ -128,13 +137,30 @@ public:
|
|||||||
virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
|
virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
|
||||||
virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
|
virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
wxString m_text;
|
wxString m_text;
|
||||||
|
|
||||||
protected:
|
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
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
@@ -43,6 +43,7 @@ public:
|
|||||||
// implementation
|
// implementation
|
||||||
GtkCellRenderer* GetGtkHandle() { return m_renderer; }
|
GtkCellRenderer* GetGtkHandle() { return m_renderer; }
|
||||||
void GtkInitHandlers();
|
void GtkInitHandlers();
|
||||||
|
virtual bool GtkHasAttributes() { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GtkCellRenderer *m_renderer;
|
GtkCellRenderer *m_renderer;
|
||||||
@@ -71,6 +72,24 @@ 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
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
@@ -232,6 +232,22 @@ 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
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
@@ -39,64 +39,6 @@
|
|||||||
#define DATAVIEW_DEFAULT_STYLE (wxDV_MULTIPLE|wxDV_HORIZ_RULES|wxDV_VERT_RULES)
|
#define DATAVIEW_DEFAULT_STYLE (wxDV_MULTIPLE|wxDV_HORIZ_RULES|wxDV_VERT_RULES)
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------
|
|
||||||
// MySpinCtrlInPlaceRenderer
|
|
||||||
// -------------------------------------
|
|
||||||
|
|
||||||
class MySpinCtrlInPlaceRenderer: public wxDataViewCustomRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MySpinCtrlInPlaceRenderer() :
|
|
||||||
wxDataViewCustomRenderer( wxT("long"), wxDATAVIEW_CELL_EDITABLE ) { }
|
|
||||||
|
|
||||||
|
|
||||||
virtual bool HasEditorCtrl()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value )
|
|
||||||
{
|
|
||||||
long l = value;
|
|
||||||
return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
|
|
||||||
labelRect.GetTopLeft(), labelRect.GetSize(), -0, -1, 2010, l );
|
|
||||||
}
|
|
||||||
virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value )
|
|
||||||
{
|
|
||||||
wxSpinCtrl *sc = (wxSpinCtrl*) editor;
|
|
||||||
long l = sc->GetValue();
|
|
||||||
value = l;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Render( wxRect rect, wxDC *dc, int WXUNUSED(state) )
|
|
||||||
{
|
|
||||||
wxString str;
|
|
||||||
str.Printf( wxT("%d"), (int) m_data );
|
|
||||||
dc->SetTextForeground( *wxBLACK );
|
|
||||||
dc->DrawText( str, rect.x, rect.y );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
wxSize GetSize() const
|
|
||||||
{
|
|
||||||
return wxSize(80,16);
|
|
||||||
}
|
|
||||||
bool SetValue( const wxVariant &value )
|
|
||||||
{
|
|
||||||
m_data = value.GetLong();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool GetValue( wxVariant &value ) const
|
|
||||||
{
|
|
||||||
value = m_data;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
long m_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------
|
// -------------------------------------
|
||||||
// MyMusicModel
|
// MyMusicModel
|
||||||
// -------------------------------------
|
// -------------------------------------
|
||||||
@@ -444,14 +386,28 @@ public:
|
|||||||
{
|
{
|
||||||
wxDataViewIconText data( "test", m_icon );
|
wxDataViewIconText data( "test", m_icon );
|
||||||
variant << data;
|
variant << data;
|
||||||
}
|
} else
|
||||||
else
|
if (col==2)
|
||||||
{
|
{
|
||||||
wxString str;
|
if ((row % 2) == 1)
|
||||||
str.Printf( "row %d col %d", row, col );
|
variant = "Blue";
|
||||||
variant = str;
|
else
|
||||||
|
variant = "Italic";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool GetAttr( unsigned int row, unsigned int col, wxDataViewItemAttr &attr )
|
||||||
|
{
|
||||||
|
if (col != 2)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ((row % 2) == 1)
|
||||||
|
attr.SetColour( *wxBLUE );
|
||||||
|
else
|
||||||
|
attr.SetItalic( true );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool SetValue( const wxVariant &variant,
|
virtual bool SetValue( const wxVariant &variant,
|
||||||
unsigned int row, unsigned int col )
|
unsigned int row, unsigned int col )
|
||||||
@@ -651,7 +607,7 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
|||||||
m_music_model = new MyMusicModel;
|
m_music_model = new MyMusicModel;
|
||||||
m_musicCtrl->AssociateModel( m_music_model.get() );
|
m_musicCtrl->AssociateModel( m_music_model.get() );
|
||||||
|
|
||||||
wxDataViewColumn *col = m_musicCtrl->AppendTextColumn( "Title", 0, wxDATAVIEW_CELL_INERT, 200,
|
/* wxDataViewColumn *col = */ m_musicCtrl->AppendTextColumn( "Title", 0, wxDATAVIEW_CELL_INERT, 200,
|
||||||
DEFAULT_ALIGN, wxDATAVIEW_COL_SORTABLE );
|
DEFAULT_ALIGN, wxDATAVIEW_COL_SORTABLE );
|
||||||
#if 0
|
#if 0
|
||||||
// Call this and sorting is enabled
|
// Call this and sorting is enabled
|
||||||
@@ -680,7 +636,10 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
|||||||
|
|
||||||
m_listCtrl->AppendTextColumn( "editable string", 0, wxDATAVIEW_CELL_EDITABLE, 120 );
|
m_listCtrl->AppendTextColumn( "editable string", 0, wxDATAVIEW_CELL_EDITABLE, 120 );
|
||||||
m_listCtrl->AppendIconTextColumn( "icon", 1, wxDATAVIEW_CELL_INERT, 60 );
|
m_listCtrl->AppendIconTextColumn( "icon", 1, wxDATAVIEW_CELL_INERT, 60 );
|
||||||
m_listCtrl->AppendTextColumn( "index", 2, wxDATAVIEW_CELL_INERT, 120 );
|
|
||||||
|
wxDataViewTextRendererAttr *ra = new wxDataViewTextRendererAttr;
|
||||||
|
column = new wxDataViewColumn( "attributes", ra, 2 );
|
||||||
|
m_listCtrl->AppendColumn( column );
|
||||||
|
|
||||||
data_sizer->Add( m_listCtrl, 2, wxGROW );
|
data_sizer->Add( m_listCtrl, 2, wxGROW );
|
||||||
|
|
||||||
@@ -716,7 +675,7 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
|
|||||||
|
|
||||||
|
|
||||||
/* XPM */
|
/* XPM */
|
||||||
static char *small1_xpm[] = {
|
static const char *small1_xpm[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"16 16 6 1",
|
"16 16 6 1",
|
||||||
". c Black",
|
". c Black",
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* XPM */
|
/* XPM */
|
||||||
static char * null_xpm[] = {
|
static const char * null_xpm[] = {
|
||||||
"16 16 11 1",
|
"16 16 11 1",
|
||||||
" c None",
|
" c None",
|
||||||
". c #000000",
|
". c #000000",
|
||||||
|
@@ -386,6 +386,11 @@ bool wxDataViewIndexListModel::SetValue( const wxVariant &variant,
|
|||||||
return SetValue( variant, GetRow(item), col );
|
return SetValue( variant, GetRow(item), col );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxDataViewIndexListModel::GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr )
|
||||||
|
{
|
||||||
|
return GetAttr( GetRow(item), col, attr );
|
||||||
|
}
|
||||||
|
|
||||||
wxDataViewItem wxDataViewIndexListModel::GetParent( const wxDataViewItem & WXUNUSED(item) ) const
|
wxDataViewItem wxDataViewIndexListModel::GetParent( const wxDataViewItem & WXUNUSED(item) ) const
|
||||||
{
|
{
|
||||||
return wxDataViewItem(0);
|
return wxDataViewItem(0);
|
||||||
|
@@ -607,6 +607,8 @@ 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()
|
||||||
@@ -713,6 +715,60 @@ wxSize wxDataViewTextRenderer::GetSize() const
|
|||||||
return wxSize(80,20);
|
return wxSize(80,20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
// 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
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -2363,6 +2419,15 @@ 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 the y offset
|
// update the y offset
|
||||||
cell_rect.y = item * m_lineHeight;
|
cell_rect.y = item * m_lineHeight;
|
||||||
@@ -3788,7 +3853,7 @@ wxDataViewColumn* wxDataViewCtrl::GetColumn( unsigned int pos ) const
|
|||||||
bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
|
bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
|
||||||
{
|
{
|
||||||
wxDataViewColumnList::compatibility_iterator ret = m_cols.Find( column );
|
wxDataViewColumnList::compatibility_iterator ret = m_cols.Find( column );
|
||||||
if (ret == NULL)
|
if (!ret)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_cols.Erase(ret);
|
m_cols.Erase(ret);
|
||||||
|
@@ -1475,6 +1475,18 @@ 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
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -2112,10 +2124,82 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *column,
|
|||||||
|
|
||||||
cell->SetValue( value );
|
cell->SetValue( value );
|
||||||
|
|
||||||
#if 0
|
if (cell->GtkHasAttributes())
|
||||||
wxListItemAttr attr;
|
{
|
||||||
wx_model->GetAttr( item, attr, cell->GetOwner()->GetModelColumn() );
|
wxDataViewItemAttr attr;
|
||||||
|
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
|
||||||
|
wxColour colour = attr.GetColour();
|
||||||
|
if (colour.IsOk())
|
||||||
|
{
|
||||||
|
const GdkColor * const gcol = colour.GetColor();
|
||||||
|
|
||||||
|
GValue gvalue = { 0, };
|
||||||
|
g_value_init( &gvalue, GDK_TYPE_COLOR );
|
||||||
|
g_value_set_boxed( &gvalue, gcol );
|
||||||
|
g_object_set_property( G_OBJECT(renderer), "foreground_gdk", &gvalue );
|
||||||
|
g_value_unset( &gvalue );
|
||||||
|
|
||||||
|
colour_set = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 );
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
GValue gvalue = { 0, };
|
||||||
|
g_value_init( &gvalue, G_TYPE_BOOLEAN );
|
||||||
|
g_value_set_boolean( &gvalue, FALSE );
|
||||||
|
g_object_set_property( G_OBJECT(renderer), "style-set", &gvalue );
|
||||||
|
g_value_unset( &gvalue );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!weight_set)
|
||||||
|
{
|
||||||
|
GValue gvalue = { 0, };
|
||||||
|
g_value_init( &gvalue, G_TYPE_BOOLEAN );
|
||||||
|
g_value_set_boolean( &gvalue, FALSE );
|
||||||
|
g_object_set_property( G_OBJECT(renderer), "weight-set", &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 (attr.HasBackgroundColour())
|
if (attr.HasBackgroundColour())
|
||||||
{
|
{
|
||||||
wxColour colour = attr.GetBackgroundColour();
|
wxColour colour = attr.GetBackgroundColour();
|
||||||
|
Reference in New Issue
Block a user