#endif
// ----------------------------------------------------------------------------
-// wxDataViewCtrl flags
+// wxDataViewCtrl flags
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
extern WXDLLEXPORT_DATA(const wxChar) wxDataViewCtrlNameStr[];
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewModel
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class wxDataViewModel: public wxObject
{
public:
wxDataViewModel() { }
virtual ~wxDataViewModel() { }
-
+
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewModel)
};
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewListModelNotifier
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class wxDataViewListModelNotifier: public wxObject
public:
wxDataViewListModelNotifier() { }
virtual ~wxDataViewListModelNotifier() { }
-
+
virtual bool RowAppended() = 0;
virtual bool RowPrepended() = 0;
virtual bool RowInserted( size_t before ) = 0;
virtual bool ValueChanged( size_t col, size_t row ) = 0;
virtual bool RowsReordered( size_t *new_order ) = 0;
virtual bool Cleared() = 0;
-
+
void SetOwner( wxDataViewListModel *owner ) { m_owner = owner; }
wxDataViewListModel *GetOwner() { return m_owner; }
-
+
private:
wxDataViewListModel *m_owner;
};
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewListModel
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class wxDataViewViewingColumn: public wxObject
{
m_viewColumn = view_column;
m_modelColumn = model_column;
}
-
+
wxDataViewColumn *m_viewColumn;
size_t m_modelColumn;
};
virtual bool RowsReordered( size_t *new_order );
virtual bool Cleared();
- // Used internally
+ // Used internally
virtual void AddViewingColumn( wxDataViewColumn *view_column, size_t model_column );
virtual void RemoveViewingColumn( wxDataViewColumn *column );
-
+
virtual void AddNotifier( wxDataViewListModelNotifier *notifier );
virtual void RemoveNotifier( wxDataViewListModelNotifier *notifier );
-
+
wxList m_notifiers;
wxList m_viewingColumns;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel)
};
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewSortedListModel
-// ---------------------------------------------------------
+// ---------------------------------------------------------
typedef int (wxCALLBACK *wxDataViewListModelCompare)
(size_t row1, size_t row2, size_t col, wxDataViewListModel* model );
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewSortedListModel)
};
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewCellBase
-// ---------------------------------------------------------
+// ---------------------------------------------------------
enum wxDataViewCellMode
{
public:
wxDataViewCellBase( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
- virtual bool SetValue( const wxVariant &value ) { return true; }
- virtual bool GetValue( wxVariant &value ) { return true; }
- virtual bool Validate( wxVariant &value ) { return true; }
-
+ virtual bool SetValue( const wxVariant& WXUNUSED(value) ) { return true; }
+ virtual bool GetValue( wxVariant& WXUNUSED(value) ) { return true; }
+ virtual bool Validate( wxVariant& WXUNUSED(value) ) { return true; }
+
wxString GetVariantType() { return m_variantType; }
wxDataViewCellMode GetMode() { return m_mode; }
-
+
void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
wxDataViewColumn* GetOwner() { return m_owner; }
-
+
protected:
wxDataViewCellMode m_mode;
wxString m_variantType;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCellBase)
};
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewColumnBase
-// ---------------------------------------------------------
+// ---------------------------------------------------------
enum wxDataViewColumnFlags
{
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; }
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
};
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewCtrlBase
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class wxDataViewCtrlBase: public wxControl
{
public:
wxDataViewCtrlBase();
~wxDataViewCtrlBase();
-
+
virtual bool AssociateModel( wxDataViewListModel *model );
wxDataViewListModel* GetModel();
-
+
virtual bool AppendTextColumn( const wxString &label, size_t model_column );
virtual bool AppendToggleColumn( const wxString &label, size_t model_column );
virtual bool AppendProgressColumn( const wxString &label, size_t model_column );
virtual bool AppendDateColumn( const wxString &label, size_t model_column );
- virtual bool AppendColumn( wxDataViewColumn *col );
+ virtual bool AppendColumn( wxDataViewColumn *col );
virtual size_t GetNumberOfColumns();
virtual bool DeleteColumn( size_t pos );
virtual bool ClearColumns();
virtual wxDataViewColumn* GetColumn( size_t pos );
-
+
private:
wxDataViewListModel *m_model;
wxList m_cols;
#include "wx/control.h"
#include "wx/scrolwin.h"
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// classes
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataViewCtrl;
class WXDLLIMPEXP_CORE wxDataViewMainWindow;
class WXDLLIMPEXP_CORE wxDataViewHeaderWindow;
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewCell
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class wxDataViewCell: public wxDataViewCellBase
{
virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
virtual wxSize GetSize() = 0;
-
- virtual bool Activate( wxRect cell,
- wxDataViewListModel *model, size_t col, size_t row )
- { return false; }
-
- virtual bool LeftClick( wxPoint cursor, wxRect cell,
- wxDataViewListModel *model, size_t col, size_t row )
- { return false; }
- virtual bool RightClick( wxPoint cursor, wxRect cell,
- wxDataViewListModel *model, size_t col, size_t row )
- { return false; }
- virtual bool StartDrag( wxPoint cursor, wxRect cell,
- wxDataViewListModel *model, size_t col, size_t row )
+
+ virtual bool Activate( wxRect WXUNUSED(cell),
+ wxDataViewListModel *WXUNUSED(model),
+ size_t WXUNUSED(col),
+ size_t WXUNUSED(row) )
{ return false; }
-
+
+ virtual bool LeftClick( wxPoint WXUNUSED(cursor),
+ wxRect WXUNUSED(cell),
+ wxDataViewListModel *WXUNUSED(model),
+ size_t WXUNUSED(col),
+ size_t WXUNUSED(row) )
+ { return false; }
+ virtual bool RightClick( wxPoint WXUNUSED(cursor),
+ wxRect WXUNUSED(cell),
+ wxDataViewListModel *WXUNUSED(model),
+ size_t WXUNUSED(col),
+ size_t WXUNUSED(row) )
+ { return false; }
+ virtual bool StartDrag( wxPoint WXUNUSED(cursor),
+ wxRect WXUNUSED(cell),
+ wxDataViewListModel *WXUNUSED(model),
+ size_t WXUNUSED(col),
+ size_t WXUNUSED(row) )
+ { return false; }
+
// Create DC on request
virtual wxDC *GetDC();
-
+
private:
wxDC *m_dc;
-
+
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCell)
};
-
-// ---------------------------------------------------------
+
+// ---------------------------------------------------------
// wxDataViewCustomCell
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class wxDataViewCustomCell: public wxDataViewCell
{
public:
- wxDataViewCustomCell( const wxString &varianttype = wxT("string"),
+ wxDataViewCustomCell( const wxString &varianttype = wxT("string"),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
-
+
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomCell)
};
-
-// ---------------------------------------------------------
+
+// ---------------------------------------------------------
// wxDataViewTextCell
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class wxDataViewTextCell: public wxDataViewCustomCell
{
public:
- wxDataViewTextCell( const wxString &varianttype = wxT("string"),
+ wxDataViewTextCell( const wxString &varianttype = wxT("string"),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
bool SetValue( const wxVariant &value );
bool GetValue( wxVariant &value );
-
+
bool Render( wxRect cell, wxDC *dc, int state );
wxSize GetSize();
-
+
private:
wxString m_text;
-
+
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextCell)
};
-
-// ---------------------------------------------------------
+
+// ---------------------------------------------------------
// wxDataViewToggleCell
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class wxDataViewToggleCell: public wxDataViewCustomCell
{
public:
- wxDataViewToggleCell( const wxString &varianttype = wxT("bool"),
+ wxDataViewToggleCell( const wxString &varianttype = wxT("bool"),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
bool SetValue( const wxVariant &value );
bool GetValue( wxVariant &value );
-
+
bool Render( wxRect cell, wxDC *dc, int state );
bool Activate( wxRect cell, wxDataViewListModel *model, size_t col, size_t row );
wxSize GetSize();
-
+
private:
bool m_toggle;
-
+
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleCell)
};
-
-// ---------------------------------------------------------
+
+// ---------------------------------------------------------
// wxDataViewProgressCell
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class wxDataViewProgressCell: public wxDataViewCustomCell
{
public:
- wxDataViewProgressCell( const wxString &label = wxEmptyString,
- const wxString &varianttype = wxT("long"),
+ wxDataViewProgressCell( const wxString &label = wxEmptyString,
+ const wxString &varianttype = wxT("long"),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
~wxDataViewProgressCell();
-
+
bool SetValue( const wxVariant &value );
-
+
virtual bool Render( wxRect cell, wxDC *dc, int state );
virtual wxSize GetSize();
-
+
private:
wxString m_label;
int m_value;
-
+
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressCell)
};
-
-// ---------------------------------------------------------
+
+// ---------------------------------------------------------
// wxDataViewDateCell
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class wxDataViewDateCell: public wxDataViewCustomCell
{
public:
- wxDataViewDateCell( const wxString &varianttype = wxT("datetime"),
+ wxDataViewDateCell( const wxString &varianttype = wxT("datetime"),
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE );
-
+
bool SetValue( const wxVariant &value );
-
+
virtual bool Render( wxRect cell, wxDC *dc, int state );
virtual wxSize GetSize();
virtual bool Activate( wxRect cell,
wxDataViewListModel *model, size_t col, size_t row );
-
+
private:
wxDateTime m_date;
-
+
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateCell)
};
-
-// ---------------------------------------------------------
+
+// ---------------------------------------------------------
// wxDataViewColumn
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase
{
virtual ~wxDataViewColumn();
virtual void SetTitle( const wxString &title );
-
+
void SetWidth( int width ) { m_width = width; }
int GetWidth() { return m_width; }
-
+
private:
int m_width;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
};
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewCtrl
-// ---------------------------------------------------------
+// ---------------------------------------------------------
-class WXDLLIMPEXP_CORE wxDataViewCtrl: public wxDataViewCtrlBase,
+class WXDLLIMPEXP_CORE wxDataViewCtrl: public wxDataViewCtrlBase,
public wxScrollHelperNative
{
public:
{
Init();
}
-
+
wxDataViewCtrl( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator )
+ const wxValidator& validator = wxDefaultValidator )
: wxScrollHelperNative(this)
{
Create(parent, id, pos, size, style, validator );
virtual bool AssociateModel( wxDataViewListModel *model );
virtual bool AppendColumn( wxDataViewColumn *col );
-
+
private:
friend class wxDataViewMainWindow;
friend class wxDataViewHeaderWindow;
wxDataViewListModelNotifier *m_notifier;
wxDataViewMainWindow *m_clientArea;
wxDataViewHeaderWindow *m_headerArea;
-
+
private:
void OnSize( wxSizeEvent &event );
-
+
// we need to return a special WM_GETDLGCODE value to process just the
// arrows but let the other navigation characters through
#ifdef __WXMSW__
m_colour = value.GetString();
return true;
}
- bool Render( wxRect rect, wxDC *dc, int state )
+ bool Render( wxRect rect, wxDC *dc, int WXUNUSED(state) )
{
dc->SetPen( *wxBLACK_PEN );
if (m_colour == wxT("red"))
{
return wxSize(20,8);
}
- bool Activate( wxRect rect,
- wxDataViewListModel *model, size_t col, size_t row )
+ bool Activate( wxRect WXUNUSED(rect),
+ wxDataViewListModel *WXUNUSED(model),
+ size_t WXUNUSED(col),
+ size_t WXUNUSED(row) )
{
return false;
}
virtual size_t GetNumberOfRows() { return m_list.GetCount(); }
virtual size_t GetNumberOfCols() { return 2; }
- virtual wxString GetColType( size_t col ) { return wxT("string"); }
+ virtual wxString GetColType( size_t WXUNUSED(col) ) { return wxT("string"); }
virtual void GetValue( wxVariant &variant, size_t col, size_t row )
{
if (col == 0)
// Left wxDataViewCtrl
- dataview_left = new wxDataViewCtrl( this, -1 );
+ dataview_left = new wxDataViewCtrl( this, wxID_ANY );
MyTextModel *model = new MyTextModel;
dataview_left->AssociateModel( model );
dataview_left->AppendDateColumn( wxT("date"), 6 );
// Right wxDataViewCtrl using the same model
- dataview_right = new wxDataViewCtrl( this, -1 );
+ dataview_right = new wxDataViewCtrl( this, wxID_ANY );
dataview_right->AssociateModel( model );
text_cell = new wxDataViewTextCell( wxT("string"), wxDATAVIEW_CELL_EDITABLE );
// Left wxDataViewCtrl
- dataview_left = new wxDataViewCtrl( this, -1 );
+ dataview_left = new wxDataViewCtrl( this, wxID_ANY );
MyUnsortedTextModel *model = new MyUnsortedTextModel;
dataview_left->AssociateModel( model );
dataview_left->AppendTextColumn( wxT("second"), 1 );
// Right wxDataViewCtrl using the sorting model
- dataview_right = new wxDataViewCtrl( this, -1 );
+ dataview_right = new wxDataViewCtrl( this, wxID_ANY );
wxDataViewSortedListModel *sorted_model =
new wxDataViewSortedListModel( model );
dataview_right->AssociateModel( sorted_model );
dialog.ShowModal();
}
-void MySortingFrame::OnAppendRowLeft(wxCommandEvent& event)
+void MySortingFrame::OnAppendRowLeft(wxCommandEvent& WXUNUSED(event))
{
}
-void MySortingFrame::OnPrependRowLeft(wxCommandEvent& event)
+void MySortingFrame::OnPrependRowLeft(wxCommandEvent& WXUNUSED(event))
{
}
-void MySortingFrame::OnInsertRowLeft(wxCommandEvent& event)
+void MySortingFrame::OnInsertRowLeft(wxCommandEvent& WXUNUSED(event))
{
}
-void MySortingFrame::OnDeleteRowLeft(wxCommandEvent& event)
+void MySortingFrame::OnDeleteRowLeft(wxCommandEvent& WXUNUSED(event))
{
}
-void MySortingFrame::OnEditRowLeft(wxCommandEvent& event)
+void MySortingFrame::OnEditRowLeft(wxCommandEvent& WXUNUSED(event))
{
}
-void MySortingFrame::OnAppendRowRight(wxCommandEvent& event)
+void MySortingFrame::OnAppendRowRight(wxCommandEvent& WXUNUSED(event))
{
}
-void MySortingFrame::OnPrependRowRight(wxCommandEvent& event)
+void MySortingFrame::OnPrependRowRight(wxCommandEvent& WXUNUSED(event))
{
}
-void MySortingFrame::OnInsertRowRight(wxCommandEvent& event)
+void MySortingFrame::OnInsertRowRight(wxCommandEvent& WXUNUSED(event))
{
}
-void MySortingFrame::OnDeleteRowRight(wxCommandEvent& event)
+void MySortingFrame::OnDeleteRowRight(wxCommandEvent& WXUNUSED(event))
{
}
-void MySortingFrame::OnEditRowRight(wxCommandEvent& event)
+void MySortingFrame::OnEditRowRight(wxCommandEvent& WXUNUSED(event))
{
}
#pragma hdrstop
#endif
-#include "wx/defs.h"
-
#if wxUSE_DATAVIEWCTRL
-#include "wx/object.h"
-#include "wx/dataview.h"
-#include "wx/log.h"
+#ifndef WX_PRECOMP
+ #include "wx/object.h"
+ #include "wx/log.h"
+#endif
+
#include "wx/image.h"
+#include "wx/dataview.h"
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewModel
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewModel, wxObject)
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewListModel
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewListModel, wxDataViewModel)
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
while (node)
{
wxDataViewViewingColumn* tmp = (wxDataViewViewingColumn*) node->GetData();
-
+
if (tmp->m_viewColumn == column)
{
m_viewingColumns.DeleteObject( tmp );
return;
}
-
+
node = node->GetNext();
}
}
m_notifiers.DeleteObject( notifier );
}
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewSortedListModelNotifier
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class wxDataViewSortedListModelNotifier: public wxDataViewListModelNotifier
{
public:
wxDataViewSortedListModelNotifier( wxDataViewSortedListModel *model )
{ m_model = model; }
-
+
virtual bool RowAppended() { return true; }
virtual bool RowPrepended() { return true; }
- virtual bool RowInserted( size_t before ) { return true; }
- virtual bool RowDeleted( size_t row ) { return true; }
- virtual bool RowChanged( size_t row ) { return true; }
+ virtual bool RowInserted( size_t WXUNUSED(before) ) { return true; }
+ virtual bool RowDeleted( size_t WXUNUSED(row) ) { return true; }
+ virtual bool RowChanged( size_t WXUNUSED(row) ) { return true; }
virtual bool ValueChanged( size_t col, size_t row )
{ return m_model->ChildValueChanged( col, row); }
- virtual bool RowsReordered( size_t *new_order ) { return true; }
+ virtual bool RowsReordered( size_t *WXUNUSED(new_order) ) { return true; }
virtual bool Cleared() { return true; }
-
+
wxDataViewSortedListModel *m_model;
};
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewSortedListModel compare function
-// ---------------------------------------------------------
+// ---------------------------------------------------------
int wxCALLBACK wxDataViewListModelSortedDefaultCompare
(size_t row1, size_t row2, size_t col, wxDataViewListModel* model )
return s_CmpFunc( row1, row2, s_CmpCol, s_CmpModel );
}
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewSortedListModel
// ---------------------------------------------------------
s_CmpCol = 0;
s_CmpModel = child;
s_CmpFunc = wxDataViewListModelSortedDefaultCompare;
-
+
m_notifierOnChild = new wxDataViewSortedListModelNotifier( this );
m_child->AddNotifier( m_notifierOnChild );
-
- Resort();
+
+ Resort();
}
wxDataViewSortedListModel::~wxDataViewSortedListModel()
{
size_t i;
size_t len = m_array.GetCount();
-
+
// Remove and readd sorted. Find out at which
// position it was and where it ended.
size_t start_pos = 0,end_pos = 0;
}
m_array.RemoveAt( start_pos );
m_array.Add( row );
-
+
for (i = 0; i < len; i++)
if (m_array[i] == row)
{
end_pos = i;
break;
}
-
+
if (end_pos == start_pos)
return wxDataViewListModel::ValueChanged( col, start_pos );
-
+
// Create an array where order[old] -> new_pos, so that
// if nothing changed order[0] -> 0 etc.
size_t *order = new size_t[ len ];
for (i = end_pos; i > start_pos; i--)
order[i] = order[i-1];
order[start_pos] = end_pos;
- }
-
+ }
+
wxDataViewListModel::RowsReordered( order );
-
+
delete [] order;
-
+
return true;
}
{
size_t child_row = m_array[row];
bool ret = m_child->SetValue( variant, col, child_row );
-
+
// Resort in ::ChildValueChanged() which gets reported back.
-
+
return ret;
}
{
// you can only append
bool ret = m_child->RowAppended();
-
+
// report RowInsrted
-
+
return ret;
}
{
// you can only append
bool ret = m_child->RowAppended();
-
+
// report RowInsrted
-
+
return ret;
}
-bool wxDataViewSortedListModel::RowInserted( size_t before )
+bool wxDataViewSortedListModel::RowInserted( size_t WXUNUSED(before) )
{
// you can only append
bool ret = m_child->RowAppended();
-
+
// report different RowInsrted
-
+
return ret;
}
bool wxDataViewSortedListModel::RowDeleted( size_t row )
{
size_t child_row = m_array[row];
-
+
bool ret = m_child->RowDeleted( child_row );
-
+
// Do nothing here as the change in the
// child model will be reported back.
-
+
return ret;
}
{
size_t child_row = m_array[row];
bool ret = m_child->RowChanged( child_row );
-
+
// Do nothing here as the change in the
// child model will be reported back.
-
+
return ret;
}
{
size_t child_row = m_array[row];
bool ret = m_child->ValueChanged( col, child_row );
-
+
// Do nothing here as the change in the
// child model will be reported back.
-
+
return ret;
}
-bool wxDataViewSortedListModel::RowsReordered( size_t *new_order )
+bool wxDataViewSortedListModel::RowsReordered( size_t *WXUNUSED(new_order) )
{
// We sort them ourselves.
bool wxDataViewSortedListModel::Cleared()
{
bool ret = m_child->Cleared();
-
+
wxDataViewListModel::Cleared();
-
+
return ret;
}
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewCellBase
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewCellBase, wxObject)
m_variantType = varianttype;
m_mode = mode;
}
-
-// ---------------------------------------------------------
+
+// ---------------------------------------------------------
// wxDataViewColumnBase
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject)
{
if (m_cell)
delete m_cell;
-
+
if (GetOwner())
{
GetOwner()->GetModel()->RemoveViewingColumn( (wxDataViewColumn*) this );
return m_title;
}
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewCtrlBase
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase, wxControl)
bool wxDataViewCtrlBase::AssociateModel( wxDataViewListModel *model )
{
m_model = model;
-
+
return true;
}
return m_cols.GetCount();
}
-bool wxDataViewCtrlBase::DeleteColumn( size_t pos )
+bool wxDataViewCtrlBase::DeleteColumn( size_t WXUNUSED(pos) )
{
return false;
}
/////////////////////////////////////////////////////////////////////////////
-// Name: datavgen.cpp
+// Name: src/generic/datavgen.cpp
// Purpose: wxDataViewCtrl generic implementation
// Author: Robert Roebling
// Id: $Id$
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
-#include "wx/defs.h"
-
#if wxUSE_DATAVIEWCTRL
#include "wx/dataview.h"
#ifdef wxUSE_GENERICDATAVIEWCTRL
+#ifndef WX_PRECOMP
+ #include "wx/sizer.h"
+ #include "wx/log.h"
+#endif
+
#include "wx/stockitem.h"
#include "wx/dcclient.h"
#include "wx/calctrl.h"
#include "wx/popupwin.h"
-#include "wx/sizer.h"
-#include "wx/log.h"
#include "wx/renderer.h"
#ifdef __WXMSW__
- #include <windows.h> // for DLGC_WANTARROWS
- #include "wx/msw/winundef.h"
+ #include "wx/msw/wrapwin.h"
#endif
//-----------------------------------------------------------------------------
void OnPaint( wxPaintEvent &event );
void OnMouse( wxMouseEvent &event );
void OnSetFocus( wxFocusEvent &event );
-
+
private:
wxDataViewCtrl *m_owner;
wxCursor *m_resizeCursor;
-
+
private:
DECLARE_DYNAMIC_CLASS(wxDataViewHeaderWindow)
DECLARE_EVENT_TABLE()
void OnPaint( wxPaintEvent &event );
void OnMouse( wxMouseEvent &event );
void OnSetFocus( wxFocusEvent &event );
-
+
void UpdateDisplay();
void RecalculateDisplay();
void OnInternalIdle();
-
+
void ScrollWindow( int dx, int dy, const wxRect *rect );
private:
wxDataViewCtrl *m_owner;
int m_lineHeight;
bool m_dirty;
-
+
private:
DECLARE_DYNAMIC_CLASS(wxDataViewMainWindow)
DECLARE_EVENT_TABLE()
};
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxGenericDataViewListModelNotifier
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class wxGenericDataViewListModelNotifier: public wxDataViewListModelNotifier
{
public:
wxGenericDataViewListModelNotifier( wxDataViewMainWindow *mainWindow )
{ m_mainWindow = mainWindow; }
-
+
virtual bool RowAppended()
{ return m_mainWindow->RowAppended(); }
virtual bool RowPrepended()
{ return m_mainWindow->RowsReordered( new_order ); }
virtual bool Cleared()
{ return m_mainWindow->Cleared(); }
-
+
wxDataViewMainWindow *m_mainWindow;
};
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewCell
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewCell, wxDataViewCellBase)
return NULL;
m_dc = new wxClientDC( GetOwner()->GetOwner() );
}
-
+
return m_dc;
}
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewCustomCell
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomCell, wxDataViewCell)
-wxDataViewCustomCell::wxDataViewCustomCell( const wxString &varianttype,
+wxDataViewCustomCell::wxDataViewCustomCell( const wxString &varianttype,
wxDataViewCellMode mode ) :
wxDataViewCell( varianttype, mode )
{
}
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewTextCell
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewTextCell, wxDataViewCustomCell)
bool wxDataViewTextCell::SetValue( const wxVariant &value )
{
m_text = value.GetString();
-
+
return true;
}
-bool wxDataViewTextCell::GetValue( wxVariant &value )
+bool wxDataViewTextCell::GetValue( wxVariant& WXUNUSED(value) )
{
return false;
}
-bool wxDataViewTextCell::Render( wxRect cell, wxDC *dc, int state )
+bool wxDataViewTextCell::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
{
dc->DrawText( m_text, cell.x, cell.y );
return wxSize(80,20);
}
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewToggleCell
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleCell, wxDataViewCustomCell)
-wxDataViewToggleCell::wxDataViewToggleCell( const wxString &varianttype,
+wxDataViewToggleCell::wxDataViewToggleCell( const wxString &varianttype,
wxDataViewCellMode mode ) :
wxDataViewCustomCell( varianttype, mode )
{
bool wxDataViewToggleCell::SetValue( const wxVariant &value )
{
m_toggle = value.GetBool();
-
+
return true;;
}
-bool wxDataViewToggleCell::GetValue( wxVariant &value )
+bool wxDataViewToggleCell::GetValue( wxVariant &WXUNUSED(value) )
{
return false;
}
-
-bool wxDataViewToggleCell::Render( wxRect cell, wxDC *dc, int state )
+
+bool wxDataViewToggleCell::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
{
// User wxRenderer here
-
+
if (GetMode() == wxDATAVIEW_CELL_ACTIVATABLE)
dc->SetPen( *wxBLACK_PEN );
else
dc->DrawLine( rect.x, rect.y, rect.x+rect.width, rect.y+rect.height );
dc->DrawLine( rect.x+rect.width, rect.y, rect.x, rect.y+rect.height );
}
-
+
return true;
}
-bool wxDataViewToggleCell::Activate( wxRect cell, wxDataViewListModel *model, size_t col, size_t row )
+bool wxDataViewToggleCell::Activate( wxRect WXUNUSED(cell), wxDataViewListModel *model, size_t col, size_t row )
{
bool value = !m_toggle;
wxVariant variant = value;
model->SetValue( variant, col, row );
- model->ValueChanged( col, row );
+ model->ValueChanged( col, row );
return true;
}
return wxSize(20,20);
}
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewProgressCell
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressCell, wxDataViewCustomCell)
-wxDataViewProgressCell::wxDataViewProgressCell( const wxString &label,
+wxDataViewProgressCell::wxDataViewProgressCell( const wxString &label,
const wxString &varianttype, wxDataViewCellMode mode ) :
- wxDataViewCustomCell( varianttype, mode )
+ wxDataViewCustomCell( varianttype, mode )
{
m_label = label;
m_value = 0;
bool wxDataViewProgressCell::SetValue( const wxVariant &value )
{
m_value = (long) value;
-
+
if (m_value < 0) m_value = 0;
if (m_value > 100) m_value = 100;
-
+
return true;
}
-
-bool wxDataViewProgressCell::Render( wxRect cell, wxDC *dc, int state )
+
+bool wxDataViewProgressCell::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
{
double pct = (double)m_value / 100.0;
wxRect bar = cell;
dc->SetBrush( *wxTRANSPARENT_BRUSH );
dc->SetPen( *wxBLACK_PEN );
dc->DrawRectangle( cell );
-
+
return true;
}
{
return wxSize(40,12);
}
-
-// ---------------------------------------------------------
+
+// ---------------------------------------------------------
// wxDataViewDateCell
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class wxDataViewDateCellPopupTransient: public wxPopupTransientWindow
{
-public:
+public:
wxDataViewDateCellPopupTransient( wxWindow* parent, wxDateTime *value,
wxDataViewListModel *model, size_t col, size_t row ) :
wxPopupTransientWindow( parent, wxBORDER_SIMPLE )
m_model = model;
m_col = col;
m_row = row;
- m_cal = new wxCalendarCtrl( this, -1, *value );
+ m_cal = new wxCalendarCtrl( this, wxID_ANY, *value );
wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
sizer->Add( m_cal, 1, wxGROW );
SetSizer( sizer );
sizer->Fit( this );
}
-
+
virtual void OnDismiss()
{
}
-
+
void OnCalendar( wxCalendarEvent &event );
-
+
wxCalendarCtrl *m_cal;
- wxDataViewListModel *m_model;
+ wxDataViewListModel *m_model;
size_t m_col;
size_t m_row;
-
+
private:
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(wxDataViewDateCellPopupTransient,wxPopupTransientWindow)
- EVT_CALENDAR( -1, wxDataViewDateCellPopupTransient::OnCalendar )
+ EVT_CALENDAR( wxID_ANY, wxDataViewDateCellPopupTransient::OnCalendar )
END_EVENT_TABLE()
void wxDataViewDateCellPopupTransient::OnCalendar( wxCalendarEvent &event )
wxDataViewCustomCell( varianttype, mode )
{
}
-
+
bool wxDataViewDateCell::SetValue( const wxVariant &value )
{
m_date = value.GetDateTime();
-
+
return true;
}
-bool wxDataViewDateCell::Render( wxRect cell, wxDC *dc, int state )
+bool wxDataViewDateCell::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
{
dc->SetFont( GetOwner()->GetOwner()->GetFont() );
wxString tmp = m_date.FormatDate();
return wxSize(x,y+d);
}
-bool wxDataViewDateCell::Activate( wxRect cell, wxDataViewListModel *model, size_t col, size_t row )
+bool wxDataViewDateCell::Activate( wxRect WXUNUSED(cell), wxDataViewListModel *model, size_t col, size_t row )
{
wxVariant variant;
model->GetValue( variant, col, row );
wxDateTime value = variant.GetDateTime();
- wxDataViewDateCellPopupTransient *popup = new wxDataViewDateCellPopupTransient(
+ wxDataViewDateCellPopupTransient *popup = new wxDataViewDateCellPopupTransient(
GetOwner()->GetOwner()->GetParent(), &value, model, col, row );
wxPoint pos = wxGetMousePosition();
popup->Move( pos );
return true;
}
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewColumn
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
-wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell,
+wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell,
size_t model_column, int flags ) :
wxDataViewColumnBase( title, cell, model_column, flags )
{
void wxDataViewColumn::SetTitle( const wxString &title )
{
wxDataViewColumnBase::SetTitle( title );
-
+
}
//-----------------------------------------------------------------------------
SetOwner( parent );
m_resizeCursor = new wxCursor( wxCURSOR_SIZEWE );
-
+
wxVisualAttributes attr = wxPanel::GetClassDefaultAttributes();
SetOwnForegroundColour( attr.colFg );
SetOwnBackgroundColour( attr.colBg );
delete m_resizeCursor;
}
-void wxDataViewHeaderWindow::OnPaint( wxPaintEvent &event )
+void wxDataViewHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
int w, h;
GetClientSize( &w, &h );
wxPaintDC dc( this );
-
+
int xpix;
m_owner->GetScrollPixelsPerUnit( &xpix, NULL );
// account for the horz scrollbar offset
dc.SetDeviceOrigin( -x * xpix, 0 );
-
+
dc.SetFont( GetFont() );
-
+
size_t cols = GetOwner()->GetNumberOfColumns();
size_t i;
int xpos = 0;
{
wxDataViewColumn *col = GetOwner()->GetColumn( i );
int width = col->GetWidth();
-
+
// the width of the rect to draw: make it smaller to fit entirely
// inside the column rect
#ifdef __WXMAC__
: (int)wxCONTROL_DISABLED
);
- dc.DrawText( col->GetTitle(), xpos+3, 3 );
-
+ dc.DrawText( col->GetTitle(), xpos+3, 3 );
+
xpos += width;
}
}
-void wxDataViewHeaderWindow::OnMouse( wxMouseEvent &event )
+void wxDataViewHeaderWindow::OnMouse( wxMouseEvent &WXUNUSED(event) )
{
}
wxWindow( parent, id, pos, size, 0, name )
{
SetOwner( parent );
-
+
// We need to calculate this smartly..
m_lineHeight = 20;
-
+
UpdateDisplay();
}
return false;
}
-bool wxDataViewMainWindow::RowInserted( size_t before )
+bool wxDataViewMainWindow::RowInserted( size_t WXUNUSED(before) )
{
return false;
}
-bool wxDataViewMainWindow::RowDeleted( size_t row )
+bool wxDataViewMainWindow::RowDeleted( size_t WXUNUSED(row) )
{
return false;
}
-bool wxDataViewMainWindow::RowChanged( size_t row )
+bool wxDataViewMainWindow::RowChanged( size_t WXUNUSED(row) )
{
return false;
}
-bool wxDataViewMainWindow::ValueChanged( size_t col, size_t row )
+bool wxDataViewMainWindow::ValueChanged( size_t WXUNUSED(col), size_t row )
{
wxRect rect( 0, row*m_lineHeight, 10000, m_lineHeight );
m_owner->CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
return true;
}
-bool wxDataViewMainWindow::RowsReordered( size_t *new_order )
+bool wxDataViewMainWindow::RowsReordered( size_t *WXUNUSED(new_order) )
{
return false;
}
void wxDataViewMainWindow::OnInternalIdle()
{
wxWindow::OnInternalIdle();
-
+
if (m_dirty)
{
RecalculateDisplay();
Refresh();
return;
}
-
+
int width = 0;
size_t cols = GetOwner()->GetNumberOfColumns();
size_t i;
wxDataViewColumn *col = GetOwner()->GetColumn( i );
width += col->GetWidth();
}
-
+
int height = model->GetNumberOfRows() * m_lineHeight;
SetVirtualSize( width, height );
GetOwner()->SetScrollRate( 10, m_lineHeight );
-
+
Refresh();
}
GetOwner()->m_headerArea->ScrollWindow( dx, 0 );
}
-void wxDataViewMainWindow::OnPaint( wxPaintEvent &event )
+void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
wxPaintDC dc( this );
wxRect update = GetUpdateRegion().GetBox();
m_owner->CalcUnscrolledPosition( update.x, update.y, &update.x, &update.y );
-
+
wxDataViewListModel *model = GetOwner()->GetModel();
-
+
size_t item_start = update.y / m_lineHeight;
size_t item_count = (update.height / m_lineHeight) + 1;
wxDataViewColumn *col = GetOwner()->GetColumn( i );
wxDataViewCell *cell = col->GetCell();
cell_rect.width = col->GetWidth();
-
+
size_t item;
for (item = item_start; item <= item_start+item_count; item++)
{
// for now: centre
item_rect.x = cell_rect.x + (cell_rect.width / 2) - (size.x / 2);
item_rect.y = cell_rect.y + (cell_rect.height / 2) - (size.y / 2);
-
+
item_rect.width = size.x;
item_rect.height= size.y;
cell->Render( item_rect, &dc, 0 );
}
-
+
cell_rect.x += cell_rect.width;
}
}
}
xpos += c->GetWidth();
}
- if (!col)
+ if (!col)
return;
wxDataViewCell *cell = col->GetCell();
-
+
size_t row = y / m_lineHeight;
-
+
wxDataViewListModel *model = GetOwner()->GetModel();
if (event.LeftDClick())
wxRect cell_rect( xpos, row * m_lineHeight, col->GetWidth(), m_lineHeight );
cell->Activate( cell_rect, model, col->GetModelColumn(), row );
}
-
+
return;
}
}
bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos, const wxSize& size,
+ const wxPoint& pos, const wxSize& size,
long style, const wxValidator& validator )
{
if (!wxControl::Create( parent, id, pos, size, style | wxScrolledWindowStyle|wxSUNKEN_BORDER, validator))
return false;
Init();
-
+
#ifdef __WXMAC__
MacSetClipChildren( true ) ;
#endif
- m_clientArea = new wxDataViewMainWindow( this, -1 );
- m_headerArea = new wxDataViewHeaderWindow( this, -1, wxDefaultPosition, wxSize(-1,25) );
-
+ m_clientArea = new wxDataViewMainWindow( this, wxID_ANY );
+ m_headerArea = new wxDataViewHeaderWindow( this, wxID_ANY, wxDefaultPosition, wxSize(wxDefaultCoord,25) );
+
SetTargetWindow( m_clientArea );
-
+
wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
sizer->Add( m_headerArea, 0, wxGROW );
sizer->Add( m_clientArea, 1, wxGROW );
}
#endif
-void wxDataViewCtrl::OnSize( wxSizeEvent &event )
+void wxDataViewCtrl::OnSize( wxSizeEvent &WXUNUSED(event) )
{
// We need to override OnSize so that our scrolled
// window a) does call Layout() to use sizers for
m_notifier = new wxGenericDataViewListModelNotifier( m_clientArea );
- model->AddNotifier( m_notifier );
+ model->AddNotifier( m_notifier );
m_clientArea->UpdateDisplay();
-
+
return true;
}
{
if (!wxDataViewCtrlBase::AppendColumn(col))
return false;
-
+
m_clientArea->UpdateDisplay();
-
+
return true;
}
-#endif
+#endif
// !wxUSE_GENERICDATAVIEWCTRL
-#endif
+#endif
// wxUSE_DATAVIEWCTRL