build fixes and cleanup

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58245 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2009-01-20 17:50:51 +00:00
parent 02f07b1980
commit 8c2654ce3d
5 changed files with 119 additions and 129 deletions

View File

@@ -16,23 +16,22 @@
#if wxUSE_DATAVIEWCTRL #if wxUSE_DATAVIEWCTRL
#include "wx/control.h"
#include "wx/textctrl.h" #include "wx/textctrl.h"
#include "wx/headercol.h" #include "wx/headercol.h"
#include "wx/variant.h" #include "wx/variant.h"
#include "wx/dynarray.h" #include "wx/dynarray.h"
#include "wx/icon.h" #include "wx/icon.h"
#include "wx/imaglist.h"
#include "wx/weakref.h" #include "wx/weakref.h"
#include "wx/vector.h" #include "wx/vector.h"
#include "wx/dataobj.h"
class WXDLLIMPEXP_FWD_CORE wxImageList;
#if !(defined(__WXGTK20__) || defined(__WXMAC__)) || defined(__WXUNIVERSAL__) #if !(defined(__WXGTK20__) || defined(__WXMAC__)) || defined(__WXUNIVERSAL__)
// #if !(defined(__WXMAC__)) || defined(__WXUNIVERSAL__) // #if !(defined(__WXMAC__)) || defined(__WXUNIVERSAL__)
#define wxHAS_GENERIC_DATAVIEWCTRL #define wxHAS_GENERIC_DATAVIEWCTRL
#endif #endif
class WXDLLIMPEXP_FWD_CORE wxDataFormat;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDataViewCtrl flags // wxDataViewCtrl flags
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -713,7 +712,7 @@ public:
const wxDataViewColumn *column = NULL ) = 0; const wxDataViewColumn *column = NULL ) = 0;
virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0; virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0;
virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0; virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0;
virtual bool EnableDragSource( const wxDataFormat &format ); virtual bool EnableDragSource( const wxDataFormat &format );
virtual bool EnableDropTarget( const wxDataFormat &format ); virtual bool EnableDropTarget( const wxDataFormat &format );
@@ -787,7 +786,7 @@ public:
// For drag operations // For drag operations
void SetDataObject( wxDataObject *obj ) { m_dataObject = obj; } void SetDataObject( wxDataObject *obj ) { m_dataObject = obj; }
wxDataObject *GetDataObject() const { return m_dataObject; } wxDataObject *GetDataObject() const { return m_dataObject; }
// For drop operations // For drop operations
void SetDataFormat( const wxDataFormat &format ) { m_dataFormat = format; } void SetDataFormat( const wxDataFormat &format ) { m_dataFormat = format; }
wxDataFormat GetDataFormat() const { return m_dataFormat; } wxDataFormat GetDataFormat() const { return m_dataFormat; }
@@ -805,9 +804,9 @@ protected:
wxVariant m_value; wxVariant m_value;
wxDataViewColumn *m_column; wxDataViewColumn *m_column;
wxPoint m_pos; wxPoint m_pos;
wxDataObject *m_dataObject; wxDataObject *m_dataObject;
wxDataFormat m_dataFormat; wxDataFormat m_dataFormat;
void* m_dataBuffer; void* m_dataBuffer;
size_t m_dataSize; size_t m_dataSize;
@@ -954,9 +953,9 @@ public:
{ if (m_data) delete m_data; m_data = data; } { if (m_data) delete m_data; m_data = data; }
wxClientData *GetData() const wxClientData *GetData() const
{ return m_data; } { return m_data; }
wxVector<wxVariant> m_values; wxVector<wxVariant> m_values;
private: private:
wxClientData *m_data; wxClientData *m_data;
}; };
@@ -971,7 +970,7 @@ public:
void PrependColumn( const wxString &varianttype ); void PrependColumn( const wxString &varianttype );
void InsertColumn( unsigned int pos, const wxString &varianttype ); void InsertColumn( unsigned int pos, const wxString &varianttype );
void AppendColumn( const wxString &varianttype ); void AppendColumn( const wxString &varianttype );
void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL );
void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL ); void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL );
void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL ); void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL );
@@ -990,7 +989,7 @@ public:
virtual bool SetValueByRow( const wxVariant &value, virtual bool SetValueByRow( const wxVariant &value,
unsigned int row, unsigned int col ); unsigned int row, unsigned int col );
public: public:
wxVector<wxDataViewListStoreLine*> m_data; wxVector<wxDataViewListStoreLine*> m_data;
wxArrayString m_cols; wxArrayString m_cols;
@@ -1021,7 +1020,7 @@ public:
bool AppendColumn( wxDataViewColumn *column, const wxString &varianttype ); bool AppendColumn( wxDataViewColumn *column, const wxString &varianttype );
bool PrependColumn( wxDataViewColumn *column, const wxString &varianttype ); bool PrependColumn( wxDataViewColumn *column, const wxString &varianttype );
bool InsertColumn( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype ); bool InsertColumn( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype );
// overridden from base class // overridden from base class
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 );

View File

@@ -431,6 +431,7 @@ public:
virtual bool IsExpanded( const wxDataViewItem & item ) const; virtual bool IsExpanded( const wxDataViewItem & item ) const;
virtual bool EnableDragSource( const wxDataFormat &format ); virtual bool EnableDragSource( const wxDataFormat &format );
virtual bool EnableDropTarget( const wxDataFormat &format );
static wxVisualAttributes static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);

View File

@@ -20,14 +20,14 @@
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
#include "wx/dataview.h"
#include "wx/datetime.h" #include "wx/datetime.h"
#include "wx/splitter.h" #include "wx/splitter.h"
#include "wx/aboutdlg.h" #include "wx/aboutdlg.h"
#include "wx/choicdlg.h" #include "wx/choicdlg.h"
#include "wx/numdlg.h" #include "wx/numdlg.h"
#include "wx/dataview.h"
#include "wx/spinctrl.h" #include "wx/spinctrl.h"
#include "wx/menu.h" #include "wx/imaglist.h"
#ifndef __WXMSW__ #ifndef __WXMSW__
#include "../sample.xpm" #include "../sample.xpm"
@@ -65,9 +65,6 @@ static const char *small1_xpm[] = {
}; };
#define DEFAULT_ALIGN wxALIGN_LEFT
#define DATAVIEW_DEFAULT_STYLE (wxDV_MULTIPLE|wxDV_HORIZ_RULES|wxDV_VERT_RULES)
// ------------------------------------- // -------------------------------------
// MyMusicModel // MyMusicModel
// ------------------------------------- // -------------------------------------
@@ -668,7 +665,7 @@ public:
void OnRightClick( wxMouseEvent &event ); void OnRightClick( wxMouseEvent &event );
void OnGoto( wxCommandEvent &event); void OnGoto( wxCommandEvent &event);
void OnAddMany( wxCommandEvent &event); void OnAddMany( wxCommandEvent &event);
void OnBeginDrag( wxDataViewEvent &event ); void OnBeginDrag( wxDataViewEvent &event );
void OnDropPossible( wxDataViewEvent &event ); void OnDropPossible( wxDataViewEvent &event );
void OnDrop( wxDataViewEvent &event ); void OnDrop( wxDataViewEvent &event );
@@ -767,7 +764,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_DATAVIEW_COLUMN_SORTED(ID_MUSIC_CTRL, MyFrame::OnSorted) EVT_DATAVIEW_COLUMN_SORTED(ID_MUSIC_CTRL, MyFrame::OnSorted)
EVT_DATAVIEW_ITEM_CONTEXT_MENU(ID_MUSIC_CTRL, MyFrame::OnContextMenu) EVT_DATAVIEW_ITEM_CONTEXT_MENU(ID_MUSIC_CTRL, MyFrame::OnContextMenu)
EVT_DATAVIEW_ITEM_BEGIN_DRAG( ID_MUSIC_CTRL, MyFrame::OnBeginDrag ) EVT_DATAVIEW_ITEM_BEGIN_DRAG( ID_MUSIC_CTRL, MyFrame::OnBeginDrag )
EVT_DATAVIEW_ITEM_DROP_POSSIBLE( ID_MUSIC_CTRL, MyFrame::OnDropPossible ) EVT_DATAVIEW_ITEM_DROP_POSSIBLE( ID_MUSIC_CTRL, MyFrame::OnDropPossible )
EVT_DATAVIEW_ITEM_DROP( ID_MUSIC_CTRL, MyFrame::OnDrop ) EVT_DATAVIEW_ITEM_DROP( ID_MUSIC_CTRL, MyFrame::OnDrop )
@@ -795,7 +792,7 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
SetMenuBar(menu_bar); SetMenuBar(menu_bar);
CreateStatusBar(); CreateStatusBar();
wxPanel *panel = new wxPanel( this, -1 ); wxPanel *panel = new wxPanel( this, -1 );
wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
@@ -809,7 +806,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() );
m_musicCtrl->EnableDragSource( wxDF_TEXT ); m_musicCtrl->EnableDragSource( wxDF_TEXT );
m_musicCtrl->EnableDropTarget( wxDF_TEXT ); m_musicCtrl->EnableDropTarget( wxDF_TEXT );
@@ -901,25 +898,25 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
bottom_sizer->Add( m_log, 1, wxGROW ); bottom_sizer->Add( m_log, 1, wxGROW );
// wxDataViewListCtrl // wxDataViewListCtrl
wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( panel, -1, wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( panel, -1,
wxDefaultPosition, wxSize(100,200) ); wxDefaultPosition, wxSize(100,200) );
listctrl->AppendToggleColumn( wxT("Toggle") ); listctrl->AppendToggleColumn( wxT("Toggle") );
listctrl->AppendTextColumn( wxT("Text") ); listctrl->AppendTextColumn( wxT("Text") );
wxVector<wxVariant> data; wxVector<wxVariant> data;
data.push_back( true ); data.push_back( true );
data.push_back( "row 1" ); data.push_back( "row 1" );
listctrl->AppendItem( data ); listctrl->AppendItem( data );
data.clear(); data.clear();
data.push_back( false ); data.push_back( false );
data.push_back( "row 3" ); data.push_back( "row 3" );
listctrl->AppendItem( data ); listctrl->AppendItem( data );
bottom_sizer->Add( listctrl, 1 ); bottom_sizer->Add( listctrl, 1 );
// wxDataViewTreeCtrl // wxDataViewTreeCtrl
@@ -930,9 +927,9 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
treectrl2->SetImageList( ilist ); treectrl2->SetImageList( ilist );
wxDataViewItem parent2 = treectrl2->AppendContainer( wxDataViewItem(0),wxT("Root 1"), 0 ); wxDataViewItem parent2 = treectrl2->AppendContainer( wxDataViewItem(0),wxT("Root 1"), 0 );
wxDataViewItem child2 = treectrl2->AppendItem( parent2, wxT("Child 1"), 0 ); treectrl2->AppendItem( parent2, wxT("Child 1"), 0 );
child2 = treectrl2->AppendItem( parent2, wxT("Child 2"), 0 ); treectrl2->AppendItem( parent2, wxT("Child 2"), 0 );
child2 = treectrl2->AppendItem( parent2, wxT("Child 3, very long, long, long, long"), 0 ); treectrl2->AppendItem( parent2, wxT("Child 3, very long, long, long, long"), 0 );
bottom_sizer->Add( treectrl2, 1 ); bottom_sizer->Add( treectrl2, 1 );
@@ -1006,9 +1003,9 @@ void MyFrame::OnActivated( wxDataViewEvent &event )
wxString title = m_music_model->GetTitle( event.GetItem() ); wxString title = m_music_model->GetTitle( event.GetItem() );
wxLogMessage(wxT("wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, Item: %s"), title ); wxLogMessage(wxT("wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, Item: %s"), title );
if (m_musicCtrl->IsExpanded( event.GetItem() )) if (m_musicCtrl->IsExpanded( event.GetItem() ))
wxLogMessage(wxT("Item: %s is expanded"), title ); wxLogMessage(wxT("Item: %s is expanded"), title );
} }
void MyFrame::OnSelectionChanged( wxDataViewEvent &event ) void MyFrame::OnSelectionChanged( wxDataViewEvent &event )
@@ -1163,14 +1160,14 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
void MyFrame::OnBeginDrag( wxDataViewEvent &event ) void MyFrame::OnBeginDrag( wxDataViewEvent &event )
{ {
wxDataViewItem item( event.GetItem() ); wxDataViewItem item( event.GetItem() );
// only allow drags for item, not containers // only allow drags for item, not containers
if (m_music_model->IsContainer( item ) ) if (m_music_model->IsContainer( item ) )
{ {
event.Veto(); event.Veto();
return; return;
} }
MyMusicModelNode *node = (MyMusicModelNode*) item.GetID(); MyMusicModelNode *node = (MyMusicModelNode*) item.GetID();
wxTextDataObject *obj = new wxTextDataObject; wxTextDataObject *obj = new wxTextDataObject;
obj->SetText( node->m_title ); obj->SetText( node->m_title );
@@ -1180,11 +1177,11 @@ void MyFrame::OnBeginDrag( wxDataViewEvent &event )
void MyFrame::OnDropPossible( wxDataViewEvent &event ) void MyFrame::OnDropPossible( wxDataViewEvent &event )
{ {
wxDataViewItem item( event.GetItem() ); wxDataViewItem item( event.GetItem() );
// only allow drags for item, not containers // only allow drags for item, not containers
if (m_music_model->IsContainer( item ) ) if (m_music_model->IsContainer( item ) )
event.Veto(); event.Veto();
if (event.GetDataFormat() != wxDF_TEXT) if (event.GetDataFormat() != wxDF_TEXT)
event.Veto(); event.Veto();
} }
@@ -1192,23 +1189,23 @@ void MyFrame::OnDropPossible( wxDataViewEvent &event )
void MyFrame::OnDrop( wxDataViewEvent &event ) void MyFrame::OnDrop( wxDataViewEvent &event )
{ {
wxDataViewItem item( event.GetItem() ); wxDataViewItem item( event.GetItem() );
// only allow drops for item, not containers // only allow drops for item, not containers
if (m_music_model->IsContainer( item ) ) if (m_music_model->IsContainer( item ) )
{ {
event.Veto(); event.Veto();
return; return;
} }
if (event.GetDataFormat() != wxDF_TEXT) if (event.GetDataFormat() != wxDF_TEXT)
{ {
event.Veto(); event.Veto();
return; return;
} }
wxTextDataObject obj; wxTextDataObject obj;
obj.SetData( wxDF_TEXT, event.GetDataSize(), event.GetDataBuffer() ); obj.SetData( wxDF_TEXT, event.GetDataSize(), event.GetDataBuffer() );
wxLogMessage(wxT("Text dropped: %s"), obj.GetText() ); wxLogMessage(wxT("Text dropped: %s"), obj.GetText() );
} }

View File

@@ -18,20 +18,17 @@
#if wxUSE_DATAVIEWCTRL #if wxUSE_DATAVIEWCTRL
#include "wx/dataview.h" #include "wx/dataview.h"
#include "wx/spinctrl.h"
#include "wx/choice.h"
#include "wx/weakref.h"
#include "wx/vector.h"
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/dc.h" #include "wx/dc.h"
#include "wx/settings.h" #include "wx/settings.h"
#include "wx/log.h" #include "wx/log.h"
#include "wx/icon.h"
#include "wx/crt.h" #include "wx/crt.h"
#endif #endif
#include "wx/spinctrl.h"
#include "wx/imaglist.h"
const char wxDataViewCtrlNameStr[] = "dataviewCtrl"; const char wxDataViewCtrlNameStr[] = "dataviewCtrl";
@@ -909,11 +906,11 @@ bool wxDataViewCtrlBase::EnableDropTarget( const wxDataFormat &WXUNUSED(format)
void wxDataViewCtrlBase::ExpandAncestors( const wxDataViewItem & item ) void wxDataViewCtrlBase::ExpandAncestors( const wxDataViewItem & item )
{ {
if (!m_model) return; if (!m_model) return;
if (!item.IsOk()) return; if (!item.IsOk()) return;
wxVector<wxDataViewItem> parentChain; wxVector<wxDataViewItem> parentChain;
// at first we get all the parents of the selected item // at first we get all the parents of the selected item
wxDataViewItem parent = m_model->GetParent(item); wxDataViewItem parent = m_model->GetParent(item);
while (parent.IsOk()) while (parent.IsOk())
@@ -921,7 +918,7 @@ void wxDataViewCtrlBase::ExpandAncestors( const wxDataViewItem & item )
parentChain.push_back(parent); parentChain.push_back(parent);
parent = m_model->GetParent(parent); parent = m_model->GetParent(parent);
} }
// then we expand the parents, starting at the root // then we expand the parents, starting at the root
while (!parentChain.empty()) while (!parentChain.empty())
{ {
@@ -1408,13 +1405,13 @@ wxString wxDataViewListStore::GetColumnType( unsigned int pos ) const
{ {
return m_cols[pos]; return m_cols[pos];
} }
void wxDataViewListStore::AppendItem( const wxVector<wxVariant> &values, wxClientData *data ) void wxDataViewListStore::AppendItem( const wxVector<wxVariant> &values, wxClientData *data )
{ {
wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data ); wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data );
line->m_values = values; line->m_values = values;
m_data.push_back( line ); m_data.push_back( line );
RowAppended(); RowAppended();
} }
@@ -1423,7 +1420,7 @@ void wxDataViewListStore::PrependItem( const wxVector<wxVariant> &values, wxClie
wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data ); wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data );
line->m_values = values; line->m_values = values;
m_data.insert( m_data.begin(), line ); m_data.insert( m_data.begin(), line );
RowPrepended(); RowPrepended();
} }
@@ -1432,7 +1429,7 @@ void wxDataViewListStore::InsertItem( unsigned int row, const wxVector<wxVarian
wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data ); wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data );
line->m_values = values; line->m_values = values;
m_data.insert( m_data.begin()+row, line ); m_data.insert( m_data.begin()+row, line );
RowInserted( row ); RowInserted( row );
} }
@@ -1440,7 +1437,7 @@ void wxDataViewListStore::DeleteItem( unsigned row )
{ {
wxVector<wxDataViewListStoreLine*>::iterator it = m_data.begin() + row; wxVector<wxDataViewListStoreLine*>::iterator it = m_data.begin() + row;
m_data.erase( it ); m_data.erase( it );
RowDeleted( row ); RowDeleted( row );
} }
@@ -1452,7 +1449,7 @@ void wxDataViewListStore::DeleteAllItems()
wxDataViewListStoreLine* line = *it; wxDataViewListStoreLine* line = *it;
delete line; delete line;
} }
Reset( 0 ); Reset( 0 );
} }
@@ -1466,7 +1463,7 @@ bool wxDataViewListStore::SetValueByRow( const wxVariant &value, unsigned int ro
{ {
wxDataViewListStoreLine *line = m_data[row]; wxDataViewListStoreLine *line = m_data[row];
line->m_values[col] = value; line->m_values[col] = value;
return true; return true;
} }
@@ -1539,18 +1536,18 @@ bool wxDataViewListCtrl::AppendColumn( wxDataViewColumn *col )
{ {
return AppendColumn( col, "string" ); return AppendColumn( col, "string" );
} }
wxDataViewColumn *wxDataViewListCtrl::AppendTextColumn( const wxString &label, wxDataViewColumn *wxDataViewListCtrl::AppendTextColumn( const wxString &label,
wxDataViewCellMode mode, int width, wxAlignment align, int flags ) wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{ {
GetStore()->AppendColumn( wxT("string") ); GetStore()->AppendColumn( wxT("string") );
wxDataViewColumn *ret = new wxDataViewColumn( label, wxDataViewColumn *ret = new wxDataViewColumn( label,
new wxDataViewTextRenderer( wxT("string"), mode ), new wxDataViewTextRenderer( wxT("string"), mode ),
GetStore()->GetColumnCount()-1, width, align, flags ); GetStore()->GetColumnCount()-1, width, align, flags );
wxDataViewCtrl::AppendColumn( ret ); wxDataViewCtrl::AppendColumn( ret );
return ret; return ret;
} }
@@ -1558,13 +1555,13 @@ wxDataViewColumn *wxDataViewListCtrl::AppendToggleColumn( const wxString &label,
wxDataViewCellMode mode, int width, wxAlignment align, int flags ) wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{ {
GetStore()->AppendColumn( wxT("bool") ); GetStore()->AppendColumn( wxT("bool") );
wxDataViewColumn *ret = new wxDataViewColumn( label, wxDataViewColumn *ret = new wxDataViewColumn( label,
new wxDataViewToggleRenderer( wxT("bool"), mode ), new wxDataViewToggleRenderer( wxT("bool"), mode ),
GetStore()->GetColumnCount()-1, width, align, flags ); GetStore()->GetColumnCount()-1, width, align, flags );
wxDataViewCtrl::AppendColumn( ret ); wxDataViewCtrl::AppendColumn( ret );
return ret; return ret;
} }
@@ -1572,13 +1569,13 @@ wxDataViewColumn *wxDataViewListCtrl::AppendProgressColumn( const wxString &labe
wxDataViewCellMode mode, int width, wxAlignment align, int flags ) wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{ {
GetStore()->AppendColumn( wxT("long") ); GetStore()->AppendColumn( wxT("long") );
wxDataViewColumn *ret = new wxDataViewColumn( label, wxDataViewColumn *ret = new wxDataViewColumn( label,
new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ), new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ),
GetStore()->GetColumnCount()-1, width, align, flags ); GetStore()->GetColumnCount()-1, width, align, flags );
wxDataViewCtrl::AppendColumn( ret ); wxDataViewCtrl::AppendColumn( ret );
return ret; return ret;
} }
@@ -1586,13 +1583,13 @@ wxDataViewColumn *wxDataViewListCtrl::AppendIconTextColumn( const wxString &labe
wxDataViewCellMode mode, int width, wxAlignment align, int flags ) wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{ {
GetStore()->AppendColumn( wxT("wxDataViewIconText") ); GetStore()->AppendColumn( wxT("wxDataViewIconText") );
wxDataViewColumn *ret = new wxDataViewColumn( label, wxDataViewColumn *ret = new wxDataViewColumn( label,
new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode ), new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode ),
GetStore()->GetColumnCount()-1, width, align, flags ); GetStore()->GetColumnCount()-1, width, align, flags );
wxDataViewCtrl::AppendColumn( ret ); wxDataViewCtrl::AppendColumn( ret );
return ret; return ret;
} }
@@ -1738,11 +1735,11 @@ wxDataViewTreeStore::InsertContainer(const wxDataViewItem& parent,
{ {
wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent ); wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent );
if (!parent_node) return wxDataViewItem(0); if (!parent_node) return wxDataViewItem(0);
wxDataViewTreeStoreNode *previous_node = FindNode( previous ); wxDataViewTreeStoreNode *previous_node = FindNode( previous );
int pos = parent_node->GetChildren().IndexOf( previous_node ); int pos = parent_node->GetChildren().IndexOf( previous_node );
if (pos == wxNOT_FOUND) return wxDataViewItem(0); if (pos == wxNOT_FOUND) return wxDataViewItem(0);
wxDataViewTreeStoreContainerNode *node = wxDataViewTreeStoreContainerNode *node =
new wxDataViewTreeStoreContainerNode( parent_node, text, icon, expanded, data ); new wxDataViewTreeStoreContainerNode( parent_node, text, icon, expanded, data );
parent_node->GetChildren().Insert( (size_t) pos, node ); parent_node->GetChildren().Insert( (size_t) pos, node );
@@ -2054,9 +2051,9 @@ wxDataViewItem wxDataViewTreeCtrl::AppendItem( const wxDataViewItem& parent,
icon = m_imageList->GetIcon( iconIndex ); icon = m_imageList->GetIcon( iconIndex );
wxDataViewItem res = GetStore()->AppendItem( parent, text, icon, data ); wxDataViewItem res = GetStore()->AppendItem( parent, text, icon, data );
GetStore()->ItemAdded( parent, res ); GetStore()->ItemAdded( parent, res );
return res; return res;
} }
@@ -2068,9 +2065,9 @@ wxDataViewItem wxDataViewTreeCtrl::PrependItem( const wxDataViewItem& parent,
icon = m_imageList->GetIcon( iconIndex ); icon = m_imageList->GetIcon( iconIndex );
wxDataViewItem res = GetStore()->PrependItem( parent, text, icon, data ); wxDataViewItem res = GetStore()->PrependItem( parent, text, icon, data );
GetStore()->ItemAdded( parent, res ); GetStore()->ItemAdded( parent, res );
return res; return res;
} }
@@ -2082,9 +2079,9 @@ wxDataViewItem wxDataViewTreeCtrl::InsertItem( const wxDataViewItem& parent, con
icon = m_imageList->GetIcon( iconIndex ); icon = m_imageList->GetIcon( iconIndex );
wxDataViewItem res = GetStore()->InsertItem( parent, previous, text, icon, data ); wxDataViewItem res = GetStore()->InsertItem( parent, previous, text, icon, data );
GetStore()->ItemAdded( parent, res ); GetStore()->ItemAdded( parent, res );
return res; return res;
} }
@@ -2100,9 +2097,9 @@ wxDataViewItem wxDataViewTreeCtrl::PrependContainer( const wxDataViewItem& paren
expanded = m_imageList->GetIcon( expandedIndex ); expanded = m_imageList->GetIcon( expandedIndex );
wxDataViewItem res = GetStore()->PrependContainer( parent, text, icon, expanded, data ); wxDataViewItem res = GetStore()->PrependContainer( parent, text, icon, expanded, data );
GetStore()->ItemAdded( parent, res ); GetStore()->ItemAdded( parent, res );
return res; return res;
} }
@@ -2118,9 +2115,9 @@ wxDataViewItem wxDataViewTreeCtrl::AppendContainer( const wxDataViewItem& parent
expanded = m_imageList->GetIcon( expandedIndex ); expanded = m_imageList->GetIcon( expandedIndex );
wxDataViewItem res = GetStore()->AppendContainer( parent, text, icon, expanded, data ); wxDataViewItem res = GetStore()->AppendContainer( parent, text, icon, expanded, data );
GetStore()->ItemAdded( parent, res ); GetStore()->ItemAdded( parent, res );
return res; return res;
} }
@@ -2136,16 +2133,16 @@ wxDataViewItem wxDataViewTreeCtrl::InsertContainer( const wxDataViewItem& parent
expanded = m_imageList->GetIcon( expandedIndex ); expanded = m_imageList->GetIcon( expandedIndex );
wxDataViewItem res = GetStore()->InsertContainer( parent, previous, text, icon, expanded, data ); wxDataViewItem res = GetStore()->InsertContainer( parent, previous, text, icon, expanded, data );
GetStore()->ItemAdded( parent, res ); GetStore()->ItemAdded( parent, res );
return res; return res;
} }
void wxDataViewTreeCtrl::SetItemText( const wxDataViewItem& item, const wxString &text ) void wxDataViewTreeCtrl::SetItemText( const wxDataViewItem& item, const wxString &text )
{ {
GetStore()->SetItemText(item,text); GetStore()->SetItemText(item,text);
// notify control // notify control
GetStore()->ValueChanged( item, 0 ); GetStore()->ValueChanged( item, 0 );
} }
@@ -2153,7 +2150,7 @@ void wxDataViewTreeCtrl::SetItemText( const wxDataViewItem& item, const wxString
void wxDataViewTreeCtrl::SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ) void wxDataViewTreeCtrl::SetItemIcon( const wxDataViewItem& item, const wxIcon &icon )
{ {
GetStore()->SetItemIcon(item,icon); GetStore()->SetItemIcon(item,icon);
// notify control // notify control
GetStore()->ValueChanged( item, 0 ); GetStore()->ValueChanged( item, 0 );
} }
@@ -2161,7 +2158,7 @@ void wxDataViewTreeCtrl::SetItemIcon( const wxDataViewItem& item, const wxIcon &
void wxDataViewTreeCtrl::SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ) void wxDataViewTreeCtrl::SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon )
{ {
GetStore()->SetItemExpandedIcon(item,icon); GetStore()->SetItemExpandedIcon(item,icon);
// notify control // notify control
GetStore()->ValueChanged( item, 0 ); GetStore()->ValueChanged( item, 0 );
} }
@@ -2171,7 +2168,7 @@ void wxDataViewTreeCtrl::DeleteItem( const wxDataViewItem& item )
wxDataViewItem parent_item = GetStore()->GetParent( item ); wxDataViewItem parent_item = GetStore()->GetParent( item );
GetStore()->DeleteItem(item); GetStore()->DeleteItem(item);
// notify control // notify control
GetStore()->ItemDeleted( parent_item, item ); GetStore()->ItemDeleted( parent_item, item );
} }
@@ -2198,7 +2195,7 @@ void wxDataViewTreeCtrl::DeleteChildren( const wxDataViewItem& item )
void wxDataViewTreeCtrl::DeleteAllItems() void wxDataViewTreeCtrl::DeleteAllItems()
{ {
GetStore()->DeleteAllItems(); GetStore()->DeleteAllItems();
GetStore()->Cleared(); GetStore()->Cleared();
} }
@@ -2210,7 +2207,7 @@ void wxDataViewTreeCtrl::OnExpanded( wxDataViewEvent &event )
if (!container) return; if (!container) return;
container->SetExpanded( true ); container->SetExpanded( true );
GetStore()->ItemChanged( event.GetItem() ); GetStore()->ItemChanged( event.GetItem() );
} }
@@ -2222,7 +2219,7 @@ void wxDataViewTreeCtrl::OnCollapsed( wxDataViewEvent &event )
if (!container) return; if (!container) return;
container->SetExpanded( false ); container->SetExpanded( false );
GetStore()->ItemChanged( event.GetItem() ); GetStore()->ItemChanged( event.GetItem() );
} }

View File

@@ -20,10 +20,7 @@
#include "wx/log.h" #include "wx/log.h"
#include "wx/dcclient.h" #include "wx/dcclient.h"
#include "wx/sizer.h" #include "wx/sizer.h"
#include "wx/icon.h"
#include "wx/list.h"
#include "wx/settings.h" #include "wx/settings.h"
#include "wx/dataobj.h"
#include "wx/crt.h" #include "wx/crt.h"
#endif #endif
@@ -39,9 +36,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxDataViewCtrlInternal; static wxDataViewCtrlInternal *gs_internal = NULL;
wxDataViewCtrlInternal *g_internal = NULL;
class wxGtkTreeModelNode; class wxGtkTreeModelNode;
@@ -56,7 +51,7 @@ typedef struct _GtkWxTreeModel GtkWxTreeModel;
WX_DECLARE_LIST(wxDataViewItem, ItemList); WX_DECLARE_LIST(wxDataViewItem, ItemList);
WX_DEFINE_LIST(ItemList) WX_DEFINE_LIST(ItemList)
class wxDataViewCtrlInternal class WXDLLIMPEXP_ADV wxDataViewCtrlInternal
{ {
public: public:
wxDataViewCtrlInternal( wxDataViewCtrl *owner, wxDataViewModel *wx_model, GtkWxTreeModel *gtk_model ); wxDataViewCtrlInternal( wxDataViewCtrl *owner, wxDataViewModel *wx_model, GtkWxTreeModel *gtk_model );
@@ -74,10 +69,10 @@ public:
gboolean iter_parent( GtkTreeIter *iter, GtkTreeIter *child ); gboolean iter_parent( GtkTreeIter *iter, GtkTreeIter *child );
// dnd iface // dnd iface
bool EnableDragSource( const wxDataFormat &format ); bool EnableDragSource( const wxDataFormat &format );
bool EnableDropTarget( const wxDataFormat &format ); bool EnableDropTarget( const wxDataFormat &format );
gboolean row_draggable( GtkTreeDragSource *drag_source, GtkTreePath *path ); gboolean row_draggable( GtkTreeDragSource *drag_source, GtkTreePath *path );
gboolean drag_data_delete( GtkTreeDragSource *drag_source, GtkTreePath* path ); gboolean drag_data_delete( GtkTreeDragSource *drag_source, GtkTreePath* path );
gboolean drag_data_get( GtkTreeDragSource *drag_source, GtkTreePath *path, gboolean drag_data_get( GtkTreeDragSource *drag_source, GtkTreePath *path,
@@ -128,11 +123,11 @@ private:
GtkSortType m_sort_order; GtkSortType m_sort_order;
wxDataViewColumn *m_dataview_sort_column; wxDataViewColumn *m_dataview_sort_column;
int m_sort_column; int m_sort_column;
GtkTargetEntry m_dragSourceTargetEntry; GtkTargetEntry m_dragSourceTargetEntry;
wxCharBuffer m_dragSourceTargetEntryTarget; wxCharBuffer m_dragSourceTargetEntryTarget;
wxDataObject *m_dragDataObject; wxDataObject *m_dragDataObject;
GtkTargetEntry m_dropTargetTargetEntry; GtkTargetEntry m_dropTargetTargetEntry;
wxCharBuffer m_dropTargetTargetEntryTarget; wxCharBuffer m_dropTargetTargetEntryTarget;
wxDataObject *m_dropDataObject; wxDataObject *m_dropDataObject;
@@ -143,10 +138,11 @@ private:
// wxGtkTreeModelNode // wxGtkTreeModelNode
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static
int LINKAGEMODE wxGtkTreeModelChildCmp( void** id1, void** id2 ) int LINKAGEMODE wxGtkTreeModelChildCmp( void** id1, void** id2 )
{ {
int ret = g_internal->GetDataViewModel()->Compare( *id1, *id2, int ret = gs_internal->GetDataViewModel()->Compare( *id1, *id2,
g_internal->GetSortColumn(), (g_internal->GetSortOrder() == GTK_SORT_ASCENDING) ); gs_internal->GetSortColumn(), (gs_internal->GetSortOrder() == GTK_SORT_ASCENDING) );
return ret; return ret;
} }
@@ -186,7 +182,7 @@ public:
if (m_internal->IsSorted() || m_internal->GetDataViewModel()->HasDefaultCompare()) if (m_internal->IsSorted() || m_internal->GetDataViewModel()->HasDefaultCompare())
{ {
g_internal = m_internal; gs_internal = m_internal;
m_children.Sort( &wxGtkTreeModelChildCmp ); m_children.Sort( &wxGtkTreeModelChildCmp );
return m_children.Index( id ); return m_children.Index( id );
} }
@@ -200,7 +196,7 @@ public:
if (m_internal->IsSorted() || m_internal->GetDataViewModel()->HasDefaultCompare()) if (m_internal->IsSorted() || m_internal->GetDataViewModel()->HasDefaultCompare())
{ {
g_internal = m_internal; gs_internal = m_internal;
m_children.Sort( &wxGtkTreeModelChildCmp ); m_children.Sort( &wxGtkTreeModelChildCmp );
return m_children.Index( id ); return m_children.Index( id );
} }
@@ -2836,7 +2832,7 @@ void wxGtkTreeModelNode::Resort()
wxGtkTreeModelChildren temp; wxGtkTreeModelChildren temp;
WX_APPEND_ARRAY( temp, m_children ); WX_APPEND_ARRAY( temp, m_children );
g_internal = m_internal; gs_internal = m_internal;
m_children.Sort( &wxGtkTreeModelChildCmp ); m_children.Sort( &wxGtkTreeModelChildCmp );
gint *new_order = new gint[child_count]; gint *new_order = new gint[child_count];
@@ -2884,7 +2880,7 @@ wxDataViewCtrlInternal::wxDataViewCtrlInternal( wxDataViewCtrl *owner,
m_sort_order = GTK_SORT_ASCENDING; m_sort_order = GTK_SORT_ASCENDING;
m_sort_column = -1; m_sort_column = -1;
m_dataview_sort_column = NULL; m_dataview_sort_column = NULL;
m_dragDataObject = NULL; m_dragDataObject = NULL;
m_dropDataObject = NULL; m_dropDataObject = NULL;
@@ -2895,7 +2891,7 @@ wxDataViewCtrlInternal::wxDataViewCtrlInternal( wxDataViewCtrl *owner,
wxDataViewCtrlInternal::~wxDataViewCtrlInternal() wxDataViewCtrlInternal::~wxDataViewCtrlInternal()
{ {
g_object_unref( m_gtk_model ); g_object_unref( m_gtk_model );
delete m_dragDataObject; delete m_dragDataObject;
delete m_dropDataObject; delete m_dropDataObject;
} }
@@ -2935,14 +2931,14 @@ bool wxDataViewCtrlInternal::EnableDragSource( const wxDataFormat &format )
{ {
wxGtkString atom_str( gdk_atom_name( format ) ); wxGtkString atom_str( gdk_atom_name( format ) );
m_dragSourceTargetEntryTarget = wxCharBuffer( atom_str ); m_dragSourceTargetEntryTarget = wxCharBuffer( atom_str );
m_dragSourceTargetEntry.target = m_dragSourceTargetEntryTarget.data(); m_dragSourceTargetEntry.target = m_dragSourceTargetEntryTarget.data();
m_dragSourceTargetEntry.flags = 0; m_dragSourceTargetEntry.flags = 0;
m_dragSourceTargetEntry.info = static_cast<guint>(-1); m_dragSourceTargetEntry.info = static_cast<guint>(-1);
gtk_tree_view_enable_model_drag_source( GTK_TREE_VIEW(m_owner->GtkGetTreeView() ), gtk_tree_view_enable_model_drag_source( GTK_TREE_VIEW(m_owner->GtkGetTreeView() ),
GDK_BUTTON1_MASK, &m_dragSourceTargetEntry, 1, (GdkDragAction) GDK_ACTION_COPY ); GDK_BUTTON1_MASK, &m_dragSourceTargetEntry, 1, (GdkDragAction) GDK_ACTION_COPY );
return true; return true;
} }
@@ -2950,14 +2946,14 @@ bool wxDataViewCtrlInternal::EnableDropTarget( const wxDataFormat &format )
{ {
wxGtkString atom_str( gdk_atom_name( format ) ); wxGtkString atom_str( gdk_atom_name( format ) );
m_dropTargetTargetEntryTarget = wxCharBuffer( atom_str ); m_dropTargetTargetEntryTarget = wxCharBuffer( atom_str );
m_dropTargetTargetEntry.target = m_dragSourceTargetEntryTarget.data(); m_dropTargetTargetEntry.target = m_dragSourceTargetEntryTarget.data();
m_dropTargetTargetEntry.flags = 0; m_dropTargetTargetEntry.flags = 0;
m_dropTargetTargetEntry.info = static_cast<guint>(-1); m_dropTargetTargetEntry.info = static_cast<guint>(-1);
gtk_tree_view_enable_model_drag_dest( GTK_TREE_VIEW(m_owner->GtkGetTreeView() ), gtk_tree_view_enable_model_drag_dest( GTK_TREE_VIEW(m_owner->GtkGetTreeView() ),
&m_dropTargetTargetEntry, 1, (GdkDragAction) GDK_ACTION_COPY ); &m_dropTargetTargetEntry, 1, (GdkDragAction) GDK_ACTION_COPY );
return true; return true;
} }
@@ -2965,7 +2961,7 @@ gboolean wxDataViewCtrlInternal::row_draggable( GtkTreeDragSource *WXUNUSED(drag
GtkTreePath *path ) GtkTreePath *path )
{ {
delete m_dragDataObject; delete m_dragDataObject;
GtkTreeIter iter; GtkTreeIter iter;
if (!get_iter( &iter, path )) return FALSE; if (!get_iter( &iter, path )) return FALSE;
wxDataViewItem item( (void*) iter.user_data ); wxDataViewItem item( (void*) iter.user_data );
@@ -2976,16 +2972,16 @@ gboolean wxDataViewCtrlInternal::row_draggable( GtkTreeDragSource *WXUNUSED(drag
event.SetModel( m_wx_model ); event.SetModel( m_wx_model );
if (!m_owner->HandleWindowEvent( event )) if (!m_owner->HandleWindowEvent( event ))
return FALSE; return FALSE;
if (!event.IsAllowed()) if (!event.IsAllowed())
return FALSE; return FALSE;
wxDataObject *obj = event.GetDataObject(); wxDataObject *obj = event.GetDataObject();
if (!obj) if (!obj)
return FALSE; return FALSE;
m_dragDataObject = obj; m_dragDataObject = obj;
return TRUE; return TRUE;
} }
@@ -3009,14 +3005,14 @@ gboolean wxDataViewCtrlInternal::drag_data_get( GtkTreeDragSource *WXUNUSED(drag
size_t size = m_dragDataObject->GetDataSize( selection_data->target ); size_t size = m_dragDataObject->GetDataSize( selection_data->target );
if (size == 0) if (size == 0)
return FALSE; return FALSE;
void *buf = malloc( size ); void *buf = malloc( size );
gboolean res = FALSE; gboolean res = FALSE;
if (m_dragDataObject->GetDataHere( selection_data->target, buf )) if (m_dragDataObject->GetDataHere( selection_data->target, buf ))
{ {
res = TRUE; res = TRUE;
gtk_selection_data_set( selection_data, selection_data->target, gtk_selection_data_set( selection_data, selection_data->target,
8, (const guchar*) buf, size ); 8, (const guchar*) buf, size );
} }
@@ -3034,7 +3030,7 @@ wxDataViewCtrlInternal::drag_data_received(GtkTreeDragDest *WXUNUSED(drag_dest),
GtkTreeIter iter; GtkTreeIter iter;
if (!get_iter( &iter, path )) return FALSE; if (!get_iter( &iter, path )) return FALSE;
wxDataViewItem item( (void*) iter.user_data ); wxDataViewItem item( (void*) iter.user_data );
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_DROP, m_owner->GetId() ); wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_DROP, m_owner->GetId() );
event.SetEventObject( m_owner ); event.SetEventObject( m_owner );
event.SetItem( item ); event.SetItem( item );
@@ -3044,7 +3040,7 @@ wxDataViewCtrlInternal::drag_data_received(GtkTreeDragDest *WXUNUSED(drag_dest),
event.SetDataBuffer( selection_data->data ); event.SetDataBuffer( selection_data->data );
if (!m_owner->HandleWindowEvent( event )) if (!m_owner->HandleWindowEvent( event ))
return FALSE; return FALSE;
if (!event.IsAllowed()) if (!event.IsAllowed())
return FALSE; return FALSE;
@@ -3059,7 +3055,7 @@ wxDataViewCtrlInternal::row_drop_possible(GtkTreeDragDest *WXUNUSED(drag_dest),
GtkTreeIter iter; GtkTreeIter iter;
if (!get_iter( &iter, path )) return FALSE; if (!get_iter( &iter, path )) return FALSE;
wxDataViewItem item( (void*) iter.user_data ); wxDataViewItem item( (void*) iter.user_data );
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE, m_owner->GetId() ); wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE, m_owner->GetId() );
event.SetEventObject( m_owner ); event.SetEventObject( m_owner );
event.SetItem( item ); event.SetItem( item );
@@ -3067,10 +3063,10 @@ wxDataViewCtrlInternal::row_drop_possible(GtkTreeDragDest *WXUNUSED(drag_dest),
event.SetDataFormat( selection_data->target ); event.SetDataFormat( selection_data->target );
if (!m_owner->HandleWindowEvent( event )) if (!m_owner->HandleWindowEvent( event ))
return FALSE; return FALSE;
if (!event.IsAllowed()) if (!event.IsAllowed())
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
@@ -4126,7 +4122,7 @@ bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const
GtkTreePath *path = m_internal->get_path( &iter ); GtkTreePath *path = m_internal->get_path( &iter );
bool res = gtk_tree_view_row_expanded( GTK_TREE_VIEW(m_treeview), path ); bool res = gtk_tree_view_row_expanded( GTK_TREE_VIEW(m_treeview), path );
gtk_tree_path_free( path ); gtk_tree_path_free( path );
return res; return res;
} }