don't return hardcoded constants for empty renderers, introduce wxDVC_DEFAULT_RENDERER_SIZE.
Some code styling review (indentation, long line wrapping, etc) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59392 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -32,10 +32,6 @@ class WXDLLIMPEXP_FWD_CORE wxImageList;
|
|||||||
#define wxHAS_GENERIC_DATAVIEWCTRL
|
#define wxHAS_GENERIC_DATAVIEWCTRL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxDataViewCtrl flags
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxDataViewCtrl globals
|
// wxDataViewCtrl globals
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -49,6 +45,13 @@ class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier;
|
|||||||
|
|
||||||
extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr[];
|
extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr[];
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxDataViewCtrl flags
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// size of a wxDataViewRenderer without contents:
|
||||||
|
#define wxDVC_DEFAULT_RENDERER_SIZE 20
|
||||||
|
|
||||||
// the default width of new (text) columns:
|
// the default width of new (text) columns:
|
||||||
#define wxDVC_DEFAULT_WIDTH 80
|
#define wxDVC_DEFAULT_WIDTH 80
|
||||||
|
|
||||||
@@ -526,7 +529,8 @@ public:
|
|||||||
{ m_owner = owner; }
|
{ m_owner = owner; }
|
||||||
|
|
||||||
// getters:
|
// getters:
|
||||||
unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); }
|
unsigned int GetModelColumn() const
|
||||||
|
{ return static_cast<unsigned int>(m_model_column); }
|
||||||
wxDataViewCtrl *GetOwner() const { return m_owner; }
|
wxDataViewCtrl *GetOwner() const { return m_owner; }
|
||||||
wxDataViewRenderer* GetRenderer() const { return m_renderer; }
|
wxDataViewRenderer* GetRenderer() const { return m_renderer; }
|
||||||
|
|
||||||
@@ -566,11 +570,17 @@ public:
|
|||||||
wxDataViewCtrlBase();
|
wxDataViewCtrlBase();
|
||||||
virtual ~wxDataViewCtrlBase();
|
virtual ~wxDataViewCtrlBase();
|
||||||
|
|
||||||
|
// model
|
||||||
|
// -----
|
||||||
|
|
||||||
virtual bool AssociateModel( wxDataViewModel *model );
|
virtual bool AssociateModel( wxDataViewModel *model );
|
||||||
wxDataViewModel* GetModel();
|
wxDataViewModel* GetModel();
|
||||||
const wxDataViewModel* GetModel() const;
|
const wxDataViewModel* GetModel() const;
|
||||||
|
|
||||||
// short cuts
|
|
||||||
|
// column management
|
||||||
|
// -----------------
|
||||||
|
|
||||||
wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column,
|
wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column,
|
||||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||||
wxAlignment align = wxALIGN_NOT,
|
wxAlignment align = wxALIGN_NOT,
|
||||||
@@ -669,7 +679,6 @@ public:
|
|||||||
wxAlignment align = wxALIGN_CENTER,
|
wxAlignment align = wxALIGN_CENTER,
|
||||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||||
|
|
||||||
|
|
||||||
virtual bool PrependColumn( wxDataViewColumn *col );
|
virtual bool PrependColumn( wxDataViewColumn *col );
|
||||||
virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
|
virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
|
||||||
virtual bool AppendColumn( wxDataViewColumn *col );
|
virtual bool AppendColumn( wxDataViewColumn *col );
|
||||||
@@ -688,6 +697,10 @@ public:
|
|||||||
|
|
||||||
virtual wxDataViewColumn *GetSortingColumn() const = 0;
|
virtual wxDataViewColumn *GetSortingColumn() const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// items management
|
||||||
|
// ----------------
|
||||||
|
|
||||||
void SetIndent( int indent )
|
void SetIndent( int indent )
|
||||||
{ m_indent = indent ; DoSetIndent(); }
|
{ m_indent = indent ; DoSetIndent(); }
|
||||||
int GetIndent() const
|
int GetIndent() const
|
||||||
|
@@ -99,6 +99,7 @@ protected:
|
|||||||
return *(GetOwner()->GetColumn(idx));
|
return *(GetOwner()->GetColumn(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: currently unused
|
||||||
virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle)
|
virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle)
|
||||||
{
|
{
|
||||||
wxDataViewCtrl * const owner = GetOwner();
|
wxDataViewCtrl * const owner = GetOwner();
|
||||||
@@ -738,12 +739,8 @@ wxSize wxDataViewTextRenderer::GetSize() const
|
|||||||
{
|
{
|
||||||
const wxDataViewCtrl *view = GetView();
|
const wxDataViewCtrl *view = GetView();
|
||||||
if (!m_text.empty())
|
if (!m_text.empty())
|
||||||
{
|
return view->wxWindowBase::GetTextExtent( m_text );
|
||||||
int x,y;
|
return wxSize(wxDVC_DEFAULT_RENDERER_SIZE,wxDVC_DEFAULT_RENDERER_SIZE);
|
||||||
view->GetTextExtent( m_text, &x, &y );
|
|
||||||
return wxSize( x, y );
|
|
||||||
}
|
|
||||||
return wxSize(80,20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -844,7 +841,7 @@ wxSize wxDataViewBitmapRenderer::GetSize() const
|
|||||||
else if (m_icon.Ok())
|
else if (m_icon.Ok())
|
||||||
return wxSize( m_icon.GetWidth(), m_icon.GetHeight() );
|
return wxSize( m_icon.GetWidth(), m_icon.GetHeight() );
|
||||||
|
|
||||||
return wxSize(16,16);
|
return wxSize(wxDVC_DEFAULT_RENDERER_SIZE,wxDVC_DEFAULT_RENDERER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -1242,30 +1239,30 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual wxDragResult OnDragOver( wxCoord x, wxCoord y, wxDragResult def )
|
virtual wxDragResult OnDragOver( wxCoord x, wxCoord y, wxDragResult def )
|
||||||
{
|
{
|
||||||
wxDataFormat format = GetMatchingPair();
|
wxDataFormat format = GetMatchingPair();
|
||||||
if (format == wxDF_INVALID)
|
if (format == wxDF_INVALID)
|
||||||
return wxDragNone;
|
return wxDragNone;
|
||||||
return m_win->OnDragOver( format, x, y, def);
|
return m_win->OnDragOver( format, x, y, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool OnDrop( wxCoord x, wxCoord y )
|
virtual bool OnDrop( wxCoord x, wxCoord y )
|
||||||
{
|
{
|
||||||
wxDataFormat format = GetMatchingPair();
|
wxDataFormat format = GetMatchingPair();
|
||||||
if (format == wxDF_INVALID)
|
if (format == wxDF_INVALID)
|
||||||
return false;
|
return false;
|
||||||
return m_win->OnDrop( format, x, y );
|
return m_win->OnDrop( format, x, y );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual wxDragResult OnData( wxCoord x, wxCoord y, wxDragResult def )
|
virtual wxDragResult OnData( wxCoord x, wxCoord y, wxDragResult def )
|
||||||
{
|
{
|
||||||
wxDataFormat format = GetMatchingPair();
|
wxDataFormat format = GetMatchingPair();
|
||||||
if (format == wxDF_INVALID)
|
if (format == wxDF_INVALID)
|
||||||
return wxDragNone;
|
return wxDragNone;
|
||||||
if (!GetData())
|
if (!GetData())
|
||||||
return wxDragNone;
|
return wxDragNone;
|
||||||
return m_win->OnData( format, x, y, def );
|
return m_win->OnData( format, x, y, def );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnLeave()
|
virtual void OnLeave()
|
||||||
{ m_win->OnLeave(); }
|
{ m_win->OnLeave(); }
|
||||||
@@ -1304,7 +1301,6 @@ int LINKAGEMODE wxDataViewSelectionCmp( unsigned int row1, unsigned int row2 )
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IMPLEMENT_ABSTRACT_CLASS(wxDataViewMainWindow, wxWindow)
|
IMPLEMENT_ABSTRACT_CLASS(wxDataViewMainWindow, wxWindow)
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxDataViewMainWindow,wxWindow)
|
BEGIN_EVENT_TABLE(wxDataViewMainWindow,wxWindow)
|
||||||
@@ -1771,7 +1767,6 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
cell_rect.x = x_start;
|
cell_rect.x = x_start;
|
||||||
for (unsigned int i = col_start; i < col_last; i++)
|
for (unsigned int i = col_start; i < col_last; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
wxDataViewColumn *col = GetOwner()->GetColumnAt( i );
|
wxDataViewColumn *col = GetOwner()->GetColumnAt( i );
|
||||||
wxDataViewRenderer *cell = col->GetRenderer();
|
wxDataViewRenderer *cell = col->GetRenderer();
|
||||||
cell_rect.width = col->GetWidth();
|
cell_rect.width = col->GetWidth();
|
||||||
@@ -2592,18 +2587,20 @@ int wxDataViewMainWindow::GetLineStart( unsigned int row ) const
|
|||||||
if (column->IsHidden())
|
if (column->IsHidden())
|
||||||
continue; // skip it!
|
continue; // skip it!
|
||||||
|
|
||||||
if ((col != 0) && model->IsContainer(item) && !model->HasContainerColumns(item))
|
if ((col != 0) &&
|
||||||
|
model->IsContainer(item) &&
|
||||||
|
!model->HasContainerColumns(item))
|
||||||
continue; // skip it!
|
continue; // skip it!
|
||||||
|
|
||||||
const wxDataViewRenderer *renderer = column->GetRenderer();
|
|
||||||
wxVariant value;
|
wxVariant value;
|
||||||
model->GetValue( value, item, column->GetModelColumn() );
|
model->GetValue( value, item, column->GetModelColumn() );
|
||||||
wxDataViewRenderer *renderer2 = const_cast<wxDataViewRenderer*>(renderer);
|
|
||||||
renderer2->SetValue( value );
|
wxDataViewRenderer *renderer =
|
||||||
|
const_cast<wxDataViewRenderer*>(column->GetRenderer());
|
||||||
|
renderer->SetValue( value );
|
||||||
height = wxMax( height, renderer->GetSize().y );
|
height = wxMax( height, renderer->GetSize().y );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
start += height;
|
start += height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2628,14 +2625,14 @@ int wxDataViewMainWindow::GetLineAt( unsigned int y ) const
|
|||||||
unsigned int yy = 0;
|
unsigned int yy = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
const wxDataViewTreeNode* node = GetTreeNodeByRow(row);
|
const wxDataViewTreeNode* node = GetTreeNodeByRow(row);
|
||||||
if (!node)
|
if (!node)
|
||||||
{
|
{
|
||||||
// not really correct...
|
// not really correct...
|
||||||
return row + ((y-yy) / m_lineHeight);
|
return row + ((y-yy) / m_lineHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataViewItem item = node->GetItem();
|
wxDataViewItem item = node->GetItem();
|
||||||
|
|
||||||
if (node && !node->HasChildren())
|
if (node && !node->HasChildren())
|
||||||
{
|
{
|
||||||
@@ -2644,31 +2641,34 @@ int wxDataViewMainWindow::GetLineAt( unsigned int y ) const
|
|||||||
wxDELETE(node);
|
wxDELETE(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cols = GetOwner()->GetColumnCount();
|
unsigned int cols = GetOwner()->GetColumnCount();
|
||||||
unsigned int col;
|
unsigned int col;
|
||||||
int height = m_lineHeight;
|
int height = m_lineHeight;
|
||||||
for (col = 0; col < cols; col++)
|
for (col = 0; col < cols; col++)
|
||||||
{
|
{
|
||||||
const wxDataViewColumn *column = GetOwner()->GetColumn(col);
|
const wxDataViewColumn *column = GetOwner()->GetColumn(col);
|
||||||
if (column->IsHidden())
|
if (column->IsHidden())
|
||||||
continue; // skip it!
|
continue; // skip it!
|
||||||
|
|
||||||
if ((col != 0) && model->IsContainer(item) && !model->HasContainerColumns(item))
|
if ((col != 0) &&
|
||||||
|
model->IsContainer(item) &&
|
||||||
|
!model->HasContainerColumns(item))
|
||||||
continue; // skip it!
|
continue; // skip it!
|
||||||
|
|
||||||
const wxDataViewRenderer *renderer = column->GetRenderer();
|
|
||||||
wxVariant value;
|
wxVariant value;
|
||||||
model->GetValue( value, item, column->GetModelColumn() );
|
model->GetValue( value, item, column->GetModelColumn() );
|
||||||
wxDataViewRenderer *renderer2 = const_cast<wxDataViewRenderer*>(renderer);
|
|
||||||
renderer2->SetValue( value );
|
wxDataViewRenderer *renderer =
|
||||||
|
const_cast<wxDataViewRenderer*>(column->GetRenderer());
|
||||||
|
renderer->SetValue( value );
|
||||||
height = wxMax( height, renderer->GetSize().y );
|
height = wxMax( height, renderer->GetSize().y );
|
||||||
}
|
}
|
||||||
|
|
||||||
yy += height;
|
yy += height;
|
||||||
if (y < yy)
|
if (y < yy)
|
||||||
return row;
|
return row;
|
||||||
|
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2703,14 +2703,17 @@ int wxDataViewMainWindow::GetLineHeight( unsigned int row ) const
|
|||||||
if (column->IsHidden())
|
if (column->IsHidden())
|
||||||
continue; // skip it!
|
continue; // skip it!
|
||||||
|
|
||||||
if ((col != 0) && model->IsContainer(item) && !model->HasContainerColumns(item))
|
if ((col != 0) &&
|
||||||
|
model->IsContainer(item) &&
|
||||||
|
!model->HasContainerColumns(item))
|
||||||
continue; // skip it!
|
continue; // skip it!
|
||||||
|
|
||||||
const wxDataViewRenderer *renderer = column->GetRenderer();
|
|
||||||
wxVariant value;
|
wxVariant value;
|
||||||
model->GetValue( value, item, column->GetModelColumn() );
|
model->GetValue( value, item, column->GetModelColumn() );
|
||||||
wxDataViewRenderer *renderer2 = const_cast<wxDataViewRenderer*>(renderer);
|
|
||||||
renderer2->SetValue( value );
|
wxDataViewRenderer *renderer =
|
||||||
|
const_cast<wxDataViewRenderer*>(column->GetRenderer());
|
||||||
|
renderer->SetValue( value );
|
||||||
height = wxMax( height, renderer->GetSize().y );
|
height = wxMax( height, renderer->GetSize().y );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user