Added some column width contrl code.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38818 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -245,21 +245,34 @@ enum wxDataViewColumnFlags
|
||||
wxDATAVIEW_COL_HIDDEN = 4
|
||||
};
|
||||
|
||||
enum wxDataViewColumnSizing
|
||||
{
|
||||
wxDATAVIEW_COL_WIDTH_FIXED,
|
||||
wxDATAVIEW_COL_WIDTH_AUTO,
|
||||
wxDATAVIEW_COL_WIDTH_GROW
|
||||
};
|
||||
|
||||
class wxDataViewColumnBase: public wxObject
|
||||
{
|
||||
public:
|
||||
wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags = 0 );
|
||||
wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column,
|
||||
int fixed_width = 80, wxDataViewColumnSizing sizing = wxDATAVIEW_COL_WIDTH_FIXED, int flags = 0 );
|
||||
~wxDataViewColumnBase();
|
||||
|
||||
virtual void SetTitle( const wxString &title );
|
||||
virtual wxString GetTitle();
|
||||
|
||||
|
||||
wxDataViewCell* GetCell() { return m_cell; }
|
||||
|
||||
size_t GetModelColumn() { return m_model_column; }
|
||||
|
||||
void SetOwner( wxDataViewCtrl *owner ) { m_owner = owner; }
|
||||
wxDataViewCtrl *GetOwner() { return m_owner; }
|
||||
|
||||
virtual int GetWidth() = 0;
|
||||
|
||||
virtual void SetFixedWidth( int width ) = 0;
|
||||
virtual int GetFixedWidth() = 0;
|
||||
|
||||
private:
|
||||
wxDataViewCtrl *m_ctrl;
|
||||
|
@@ -189,16 +189,21 @@ protected:
|
||||
class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase
|
||||
{
|
||||
public:
|
||||
wxDataViewColumn( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags = 0 );
|
||||
wxDataViewColumn( const wxString &title, wxDataViewCell *cell, size_t model_column,
|
||||
int fixed_width = 80, wxDataViewColumnSizing sizing = wxDATAVIEW_COL_WIDTH_FIXED, int flags = 0 );
|
||||
virtual ~wxDataViewColumn();
|
||||
|
||||
virtual void SetTitle( const wxString &title );
|
||||
|
||||
void SetWidth( int width ) { m_width = width; }
|
||||
int GetWidth() { return m_width; }
|
||||
virtual int GetWidth();
|
||||
|
||||
virtual void SetFixedWidth( int width );
|
||||
virtual int GetFixedWidth();
|
||||
|
||||
private:
|
||||
int m_width;
|
||||
int m_width;
|
||||
wxDataViewColumnSizing m_sizing;
|
||||
int m_fixedWidth;
|
||||
|
||||
protected:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
|
||||
|
@@ -171,11 +171,17 @@ protected:
|
||||
class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase
|
||||
{
|
||||
public:
|
||||
wxDataViewColumn( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags = 0 );
|
||||
wxDataViewColumn( const wxString &title, wxDataViewCell *cell, size_t model_column,
|
||||
int fixed_width = 80, wxDataViewColumnSizing sizing = wxDATAVIEW_COL_WIDTH_FIXED, int flags = 0 );
|
||||
virtual ~wxDataViewColumn();
|
||||
|
||||
virtual void SetTitle( const wxString &title );
|
||||
|
||||
virtual int GetWidth();
|
||||
|
||||
virtual void SetFixedWidth( int width );
|
||||
virtual int GetFixedWidth();
|
||||
|
||||
// implementation
|
||||
void* GetGtkHandle() { return m_column; }
|
||||
|
||||
|
@@ -381,7 +381,7 @@ MyFrame::MyFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h):
|
||||
dataview_right->AppendTextColumn( wxT("first"), 0 );
|
||||
dataview_right->AppendTextColumn( wxT("second"), 1 );
|
||||
wxDataViewToggleCell *toggle_cell = new wxDataViewToggleCell( wxT("bool"), wxDATAVIEW_CELL_ACTIVATABLE );
|
||||
column = new wxDataViewColumn( wxT("bool"), toggle_cell, 3 );
|
||||
column = new wxDataViewColumn( wxT("bool"), toggle_cell, 3, 30 );
|
||||
dataview_right->AppendColumn( column );
|
||||
|
||||
dataview_right->AppendDateColumn( wxT("date"), 6 );
|
||||
|
@@ -515,7 +515,8 @@ wxDataViewCellBase::wxDataViewCellBase( const wxString &varianttype, wxDataViewC
|
||||
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject)
|
||||
|
||||
wxDataViewColumnBase::wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags)
|
||||
wxDataViewColumnBase::wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column,
|
||||
int fixed_width, wxDataViewColumnSizing sizing, int flags )
|
||||
{
|
||||
m_cell = cell;
|
||||
m_model_column = model_column;
|
||||
@@ -581,12 +582,12 @@ bool wxDataViewCtrlBase::AppendTextColumn( const wxString &label, size_t model_c
|
||||
|
||||
bool wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, size_t model_column )
|
||||
{
|
||||
return AppendColumn( new wxDataViewColumn( label, new wxDataViewToggleCell(), model_column ) );
|
||||
return AppendColumn( new wxDataViewColumn( label, new wxDataViewToggleCell(), model_column, 30 ) );
|
||||
}
|
||||
|
||||
bool wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, size_t model_column )
|
||||
{
|
||||
return AppendColumn( new wxDataViewColumn( label, new wxDataViewProgressCell(), model_column ) );
|
||||
return AppendColumn( new wxDataViewColumn( label, new wxDataViewProgressCell(), model_column, 70 ) );
|
||||
}
|
||||
|
||||
bool wxDataViewCtrlBase::AppendDateColumn( const wxString &label, size_t model_column )
|
||||
|
@@ -503,11 +503,14 @@ bool wxDataViewDateCell::Activate( wxRect WXUNUSED(cell), wxDataViewListModel *m
|
||||
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
|
||||
|
||||
wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell,
|
||||
size_t model_column, int flags ) :
|
||||
wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell, size_t model_column,
|
||||
int fixed_width, wxDataViewColumnSizing sizing, int flags ) :
|
||||
wxDataViewColumnBase( title, cell, model_column, flags )
|
||||
{
|
||||
m_width = 80;
|
||||
m_sizing = sizing;
|
||||
|
||||
m_width = fixed_width;
|
||||
m_fixedWidth = fixed_width;
|
||||
}
|
||||
|
||||
wxDataViewColumn::~wxDataViewColumn()
|
||||
@@ -520,6 +523,27 @@ void wxDataViewColumn::SetTitle( const wxString &title )
|
||||
|
||||
}
|
||||
|
||||
int wxDataViewColumn::GetWidth()
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
void wxDataViewColumn::SetFixedWidth( int width )
|
||||
{
|
||||
m_fixedWidth = width;
|
||||
|
||||
if (m_sizing == wxDATAVIEW_COL_WIDTH_FIXED)
|
||||
{
|
||||
m_width = width;
|
||||
// Set dirty
|
||||
}
|
||||
}
|
||||
|
||||
int wxDataViewColumn::GetFixedWidth()
|
||||
{
|
||||
return m_fixedWidth;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDataViewHeaderWindow
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -948,8 +972,8 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||
|
||||
wxDataViewListModel *model = GetOwner()->GetModel();
|
||||
|
||||
size_t item_start = wxMax( 0, update.y / m_lineHeight );
|
||||
size_t item_count = wxMin( (update.height / m_lineHeight) + 1,
|
||||
size_t item_start = wxMax( 0, (update.y / m_lineHeight) - 1 );
|
||||
size_t item_count = wxMin( (update.height / m_lineHeight) + 2,
|
||||
(int)(model->GetNumberOfRows()-item_start) );
|
||||
|
||||
wxRect cell_rect;
|
||||
|
@@ -1340,8 +1340,8 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *column,
|
||||
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
|
||||
|
||||
wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell,
|
||||
size_t model_column, int flags ) :
|
||||
wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell, size_t model_column,
|
||||
int fixed_width, wxDataViewColumnSizing sizing, int flags ) :
|
||||
wxDataViewColumnBase( title, cell, model_column, flags )
|
||||
{
|
||||
GtkCellRenderer *renderer = (GtkCellRenderer *) cell->GetGtkHandle();
|
||||
@@ -1349,7 +1349,17 @@ wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell,
|
||||
GtkTreeViewColumn *column = gtk_tree_view_column_new();
|
||||
|
||||
gtk_tree_view_column_set_title( column, wxGTK_CONV(title) );
|
||||
|
||||
|
||||
if (sizing == wxDATAVIEW_COL_WIDTH_FIXED)
|
||||
gtk_tree_view_column_set_sizing( column, GTK_TREE_VIEW_COLUMN_FIXED );
|
||||
else if (sizing == wxDATAVIEW_COL_WIDTH_GROW)
|
||||
gtk_tree_view_column_set_sizing( column, GTK_TREE_VIEW_COLUMN_GROW_ONLY );
|
||||
else
|
||||
gtk_tree_view_column_set_sizing( column, GTK_TREE_VIEW_COLUMN_AUTOSIZE );
|
||||
|
||||
if (fixed_width > 0)
|
||||
gtk_tree_view_column_set_fixed_width( column, fixed_width );
|
||||
|
||||
gtk_tree_view_column_pack_start( column, renderer, TRUE );
|
||||
|
||||
gtk_tree_view_column_set_cell_data_func( column, renderer,
|
||||
@@ -1370,6 +1380,21 @@ void wxDataViewColumn::SetTitle( const wxString &title )
|
||||
gtk_tree_view_column_set_title( column, wxGTK_CONV(title) );
|
||||
}
|
||||
|
||||
int wxDataViewColumn::GetWidth()
|
||||
{
|
||||
return gtk_tree_view_column_get_width( (GtkTreeViewColumn *)m_column );
|
||||
}
|
||||
|
||||
void wxDataViewColumn::SetFixedWidth( int width )
|
||||
{
|
||||
gtk_tree_view_column_set_fixed_width( (GtkTreeViewColumn *)m_column, width );
|
||||
}
|
||||
|
||||
int wxDataViewColumn::GetFixedWidth()
|
||||
{
|
||||
return gtk_tree_view_column_get_fixed_width( (GtkTreeViewColumn *)m_column );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDataViewCtrl
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user