Setup notifiers from datamodel to generic
wxDataViewCtrl. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38263 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
3d9d7cc4f7
commit
a0f3af5fb6
@ -37,6 +37,82 @@
|
||||
|
||||
class wxDataViewCtrl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDataViewHeaderWindow
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxDataViewHeaderWindow: public wxWindow
|
||||
{
|
||||
public:
|
||||
wxDataViewHeaderWindow( wxDataViewCtrl *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint &pos = wxDefaultPosition,
|
||||
const wxSize &size = wxDefaultSize,
|
||||
const wxString &name = wxT("wxdataviewctrlheaderwindow") );
|
||||
~wxDataViewHeaderWindow();
|
||||
|
||||
void SetOwner( wxDataViewCtrl* owner ) { m_owner = owner; }
|
||||
wxDataViewCtrl *GetOwner() { return m_owner; }
|
||||
|
||||
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()
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDataViewMainWindow
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxDataViewMainWindow: public wxWindow
|
||||
{
|
||||
public:
|
||||
wxDataViewMainWindow( wxDataViewCtrl *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint &pos = wxDefaultPosition,
|
||||
const wxSize &size = wxDefaultSize,
|
||||
const wxString &name = wxT("wxdataviewctrlmainwindow") );
|
||||
~wxDataViewMainWindow();
|
||||
|
||||
// notifications from wxDataViewListModel
|
||||
bool RowAppended();
|
||||
bool RowPrepended();
|
||||
bool RowInserted( size_t before );
|
||||
bool RowDeleted( size_t row );
|
||||
bool RowChanged( size_t row );
|
||||
bool ValueChanged( size_t col, size_t row );
|
||||
bool RowsReordered( size_t *new_order );
|
||||
bool Cleared();
|
||||
|
||||
void SetOwner( wxDataViewCtrl* owner ) { m_owner = owner; }
|
||||
wxDataViewCtrl *GetOwner() { return m_owner; }
|
||||
|
||||
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
|
||||
// ---------------------------------------------------------
|
||||
@ -44,91 +120,28 @@ class wxDataViewCtrl;
|
||||
class wxGenericDataViewListModelNotifier: public wxDataViewListModelNotifier
|
||||
{
|
||||
public:
|
||||
wxGenericDataViewListModelNotifier( wxDataViewListModel *wx_model );
|
||||
|
||||
virtual bool RowAppended();
|
||||
virtual bool RowPrepended();
|
||||
virtual bool RowInserted( size_t before );
|
||||
virtual bool RowDeleted( size_t row );
|
||||
virtual bool RowChanged( size_t row );
|
||||
virtual bool ValueChanged( size_t col, size_t row );
|
||||
virtual bool RowsReordered( size_t *new_order );
|
||||
virtual bool Cleared();
|
||||
|
||||
wxDataViewListModel *m_wx_model;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxGenericDataViewListModelNotifier
|
||||
// ---------------------------------------------------------
|
||||
|
||||
wxGenericDataViewListModelNotifier::wxGenericDataViewListModelNotifier(
|
||||
wxDataViewListModel *wx_model )
|
||||
{
|
||||
m_wx_model = wx_model;
|
||||
}
|
||||
|
||||
bool wxGenericDataViewListModelNotifier::RowAppended()
|
||||
{
|
||||
size_t pos = m_wx_model->GetNumberOfRows()-1;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxGenericDataViewListModelNotifier::RowPrepended()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxGenericDataViewListModelNotifier::RowInserted( size_t before )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxGenericDataViewListModelNotifier::RowDeleted( size_t row )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxGenericDataViewListModelNotifier::RowChanged( size_t row )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxGenericDataViewListModelNotifier::ValueChanged( size_t model_col, size_t model_row )
|
||||
{
|
||||
wxNode *node = GetOwner()->m_viewingColumns.GetFirst();
|
||||
while (node)
|
||||
{
|
||||
wxDataViewViewingColumn* viewing_column = (wxDataViewViewingColumn*) node->GetData();
|
||||
if (viewing_column->m_modelColumn == model_col)
|
||||
{
|
||||
wxGenericDataViewListModelNotifier( wxDataViewMainWindow *mainWindow )
|
||||
{ m_mainWindow = mainWindow; }
|
||||
|
||||
}
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
virtual bool RowAppended()
|
||||
{ return m_mainWindow->RowAppended(); }
|
||||
virtual bool RowPrepended()
|
||||
{ return m_mainWindow->RowPrepended(); }
|
||||
virtual bool RowInserted( size_t before )
|
||||
{ return m_mainWindow->RowInserted( before ); }
|
||||
virtual bool RowDeleted( size_t row )
|
||||
{ return m_mainWindow->RowDeleted( row ); }
|
||||
virtual bool RowChanged( size_t row )
|
||||
{ return m_mainWindow->RowChanged( row ); }
|
||||
virtual bool ValueChanged( size_t col, size_t row )
|
||||
{ return m_mainWindow->ValueChanged( col, row ); }
|
||||
virtual bool RowsReordered( size_t *new_order )
|
||||
{ return m_mainWindow->RowsReordered( new_order ); }
|
||||
virtual bool Cleared()
|
||||
{ return m_mainWindow->Cleared(); }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxGenericDataViewListModelNotifier::RowsReordered( size_t *new_order )
|
||||
{
|
||||
wxNode *node = GetOwner()->m_viewingColumns.GetFirst();
|
||||
while (node)
|
||||
{
|
||||
wxDataViewViewingColumn* viewing_column = (wxDataViewViewingColumn*) node->GetData();
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxGenericDataViewListModelNotifier::Cleared()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
wxDataViewMainWindow *m_mainWindow;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewCell
|
||||
@ -412,32 +425,6 @@ void wxDataViewColumn::SetTitle( const wxString &title )
|
||||
// wxDataViewHeaderWindow
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxDataViewHeaderWindow: public wxWindow
|
||||
{
|
||||
public:
|
||||
wxDataViewHeaderWindow( wxDataViewCtrl *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint &pos = wxDefaultPosition,
|
||||
const wxSize &size = wxDefaultSize,
|
||||
const wxString &name = wxT("wxdataviewctrlheaderwindow") );
|
||||
~wxDataViewHeaderWindow();
|
||||
|
||||
void SetOwner( wxDataViewCtrl* owner ) { m_owner = owner; }
|
||||
wxDataViewCtrl *GetOwner() { return m_owner; }
|
||||
|
||||
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()
|
||||
};
|
||||
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxDataViewHeaderWindow, wxWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDataViewHeaderWindow,wxWindow)
|
||||
@ -530,38 +517,6 @@ void wxDataViewHeaderWindow::OnSetFocus( wxFocusEvent &event )
|
||||
// wxDataViewMainWindow
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxDataViewMainWindow: public wxWindow
|
||||
{
|
||||
public:
|
||||
wxDataViewMainWindow( wxDataViewCtrl *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint &pos = wxDefaultPosition,
|
||||
const wxSize &size = wxDefaultSize,
|
||||
const wxString &name = wxT("wxdataviewctrlmainwindow") );
|
||||
~wxDataViewMainWindow();
|
||||
|
||||
void SetOwner( wxDataViewCtrl* owner ) { m_owner = owner; }
|
||||
wxDataViewCtrl *GetOwner() { return m_owner; }
|
||||
|
||||
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()
|
||||
};
|
||||
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxDataViewMainWindow, wxWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDataViewMainWindow,wxWindow)
|
||||
@ -586,6 +541,46 @@ wxDataViewMainWindow::~wxDataViewMainWindow()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxDataViewMainWindow::RowAppended()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxDataViewMainWindow::RowPrepended()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxDataViewMainWindow::RowInserted( size_t before )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxDataViewMainWindow::RowDeleted( size_t row )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxDataViewMainWindow::RowChanged( size_t row )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxDataViewMainWindow::ValueChanged( size_t col, size_t row )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxDataViewMainWindow::RowsReordered( size_t *new_order )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxDataViewMainWindow::Cleared()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxDataViewMainWindow::UpdateDisplay()
|
||||
{
|
||||
m_dirty = true;
|
||||
@ -740,7 +735,7 @@ bool wxDataViewCtrl::AssociateModel( wxDataViewListModel *model )
|
||||
if (!wxDataViewCtrlBase::AssociateModel( model ))
|
||||
return false;
|
||||
|
||||
m_notifier = new wxGenericDataViewListModelNotifier( model );
|
||||
m_notifier = new wxGenericDataViewListModelNotifier( m_clientArea );
|
||||
|
||||
model->AddNotifier( m_notifier );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user