Added InsertColumn( pos, col ), some reformating

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53684 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 2008-05-21 08:47:21 +00:00
parent 47e1c61bb7
commit 19723525ce
9 changed files with 189 additions and 172 deletions

View File

@ -698,6 +698,7 @@ public:
virtual bool PrependColumn( wxDataViewColumn *col );
virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
virtual bool AppendColumn( wxDataViewColumn *col );
virtual unsigned int GetColumnCount() const = 0;

View File

@ -414,8 +414,10 @@ public:
const wxValidator& validator = wxDefaultValidator );
virtual bool AssociateModel( wxDataViewModel *model );
virtual bool AppendColumn( wxDataViewColumn *col );
virtual bool PrependColumn( wxDataViewColumn *col );
virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
virtual void DoSetExpanderColumn();
virtual void DoSetIndent();

View File

@ -376,6 +376,8 @@ public:
virtual bool PrependColumn( wxDataViewColumn *col );
virtual bool AppendColumn( wxDataViewColumn *col );
virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
virtual unsigned int GetColumnCount() const;
virtual wxDataViewColumn* GetColumn( unsigned int pos ) const;
virtual bool DeleteColumn( wxDataViewColumn *column );

View File

@ -33,11 +33,11 @@ public:
//
// inherited methods from wxDataViewRendererBase
//
virtual int GetAlignment(void) const
virtual int GetAlignment() const
{
return this->m_alignment;
}
virtual wxDataViewCellMode GetMode(void) const
virtual wxDataViewCellMode GetMode() const
{
return this->m_mode;
}
@ -60,18 +60,18 @@ public:
//
// implementation
//
WXDataBrowserItemDataRef GetDataReference(void) const
WXDataBrowserItemDataRef GetDataReference() const
{
return this->m_dataReference;
}
wxVariant const& GetValue(void) const
wxVariant const& GetValue() const
{
return this->m_value;
}
virtual WXDataBrowserPropertyType GetPropertyType(void) const = 0;
virtual WXDataBrowserPropertyType GetPropertyType() const = 0;
virtual bool Render(void) = 0; // a call to the appropriate data browser function filling the data reference with the stored datum;
virtual bool Render() = 0; // a call to the appropriate data browser function filling the data reference with the stored datum;
// returns 'true' if the data value could be rendered, 'false' otherwise
void SetDataReference(WXDataBrowserItemDataRef const& newDataReference)
@ -109,7 +109,7 @@ public:
//
wxDataViewCustomRenderer(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
virtual ~wxDataViewCustomRenderer(void);
virtual ~wxDataViewCustomRenderer();
void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state );
@ -146,15 +146,15 @@ public:
//
// device context handling
//
virtual wxDC* GetDC(void); // creates a device context and keeps it
virtual wxDC* GetDC(); // creates a device context and keeps it
//
// implementation
//
virtual bool Render(void); // declared in wxDataViewRenderer but will not be used here, therefore calling this function will
virtual bool Render(); // declared in wxDataViewRenderer but will not be used here, therefore calling this function will
// return 'true' without having done anything
virtual WXDataBrowserPropertyType GetPropertyType(void) const;
virtual WXDataBrowserPropertyType GetPropertyType() const;
void SetDC(wxDC* newDCPtr); // this method takes ownership of the pointer
@ -188,12 +188,12 @@ public:
//
// inherited functions from wxDataViewRenderer
//
virtual bool Render(void);
virtual bool Render();
//
// implementation
//
virtual WXDataBrowserPropertyType GetPropertyType(void) const;
virtual WXDataBrowserPropertyType GetPropertyType() const;
protected:
private:
@ -231,12 +231,12 @@ public:
//
// inherited functions from wxDataViewRenderer
//
virtual bool Render(void);
virtual bool Render();
//
// implementation
//
virtual WXDataBrowserPropertyType GetPropertyType(void) const;
virtual WXDataBrowserPropertyType GetPropertyType() const;
protected:
private:
@ -255,12 +255,12 @@ public:
//
// inherited functions from wxDataViewRenderer
//
virtual bool Render(void);
virtual bool Render();
//
// implementation
//
virtual WXDataBrowserPropertyType GetPropertyType(void) const;
virtual WXDataBrowserPropertyType GetPropertyType() const;
protected:
private:
@ -279,12 +279,12 @@ public:
//
// inherited functions from wxDataViewRenderer
//
virtual bool Render(void);
virtual bool Render();
//
// implementation
//
virtual WXDataBrowserPropertyType GetPropertyType(void) const;
virtual WXDataBrowserPropertyType GetPropertyType() const;
protected:
private:
@ -304,12 +304,12 @@ public:
//
// inherited functions from wxDataViewRenderer
//
virtual bool Render(void);
virtual bool Render();
//
// implementation
//
virtual WXDataBrowserPropertyType GetPropertyType(void) const;
virtual WXDataBrowserPropertyType GetPropertyType() const;
protected:
private:
@ -328,12 +328,12 @@ public:
//
// inherited functions from wxDataViewRenderer
//
virtual bool Render(void);
virtual bool Render();
//
// implementation
//
virtual WXDataBrowserPropertyType GetPropertyType(void) const;
virtual WXDataBrowserPropertyType GetPropertyType() const;
protected:
private:
@ -358,48 +358,48 @@ public:
//
// inherited methods from wxDataViewColumnBase
//
virtual wxAlignment GetAlignment(void) const
virtual wxAlignment GetAlignment() const
{
return this->m_alignment;
}
virtual int GetFlags(void) const
virtual int GetFlags() const
{
return this->m_flags;
}
virtual int GetMaxWidth(void) const
virtual int GetMaxWidth() const
{
return this->m_maxWidth;
}
virtual int GetMinWidth(void) const
virtual int GetMinWidth() const
{
return this->m_minWidth;
}
virtual wxString GetTitle(void) const
virtual wxString GetTitle() const
{
return this->m_title;
}
virtual int GetWidth(void) const
virtual int GetWidth() const
{
return this->m_width;
}
virtual bool IsHidden(void) const
virtual bool IsHidden() const
{
return false; // not implemented
}
virtual bool IsReorderable(void) const
virtual bool IsReorderable() const
{
return ((this->m_flags & wxDATAVIEW_COL_REORDERABLE) != 0);
}
virtual bool IsResizeable(void) const
virtual bool IsResizeable() const
{
return ((this->m_flags & wxDATAVIEW_COL_RESIZABLE) != 0);
}
virtual bool IsSortable(void) const
virtual bool IsSortable() const
{
return ((this->m_flags & wxDATAVIEW_COL_SORTABLE) != 0);
}
virtual bool IsSortOrderAscending(void) const
virtual bool IsSortOrderAscending() const
{
return this->m_ascending;
}
@ -465,7 +465,7 @@ class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase
{
public:
// Constructors / destructor:
wxDataViewCtrl(void)
wxDataViewCtrl()
{
this->Init();
}
@ -480,7 +480,7 @@ public:
bool Create(wxWindow *parent, wxWindowID id, wxPoint const& pos=wxDefaultPosition, wxSize const& size=wxDefaultSize, long style=0,
wxValidator const& validator=wxDefaultValidator);
virtual wxControl* GetMainWindow(void) // should disappear as it is not of any use for the native implementation
virtual wxControl* GetMainWindow() // should disappear as it is not of any use for the native implementation
{
return this;
}
@ -489,34 +489,36 @@ public:
virtual bool AssociateModel(wxDataViewModel* model);
virtual bool AppendColumn(wxDataViewColumn* columnPtr);
virtual bool ClearColumns(void);
virtual bool PrependColumn(wxDataViewColumn* columnPtr);
virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
virtual bool ClearColumns();
virtual bool DeleteColumn(wxDataViewColumn* columnPtr);
virtual wxDataViewColumn* GetColumn(unsigned int pos) const;
virtual unsigned int GetColumnCount(void) const;
virtual unsigned int GetColumnCount() const;
virtual int GetColumnPosition(wxDataViewColumn const* columnPtr) const;
virtual bool PrependColumn(wxDataViewColumn* columnPtr);
virtual void Collapse(wxDataViewItem const& item);
virtual void EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr=NULL);
virtual void Expand(wxDataViewItem const& item);
virtual wxDataViewColumn* GetSortingColumn(void) const;
virtual wxDataViewColumn* GetSortingColumn() const;
virtual unsigned int GetCount(void) const;
virtual unsigned int GetCount() const;
virtual wxRect GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const;
virtual wxDataViewItem GetSelection(void) const;
virtual wxDataViewItem GetSelection() const;
virtual int GetSelections(wxDataViewItemArray& sel) const;
virtual void HitTest(wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const;
virtual bool IsSelected(wxDataViewItem const& item) const;
virtual void SelectAll(void);
virtual void SelectAll();
virtual void Select(wxDataViewItem const& item);
virtual void SetSelections(wxDataViewItemArray const& sel);
virtual void Unselect(wxDataViewItem const& item);
virtual void UnselectAll(void);
virtual void UnselectAll();
//
// implementation
@ -526,24 +528,24 @@ public:
void AddChildrenLevel(wxDataViewItem const& parentItem);
// finishes editing of custom items; if no custom item is currently edited the method does nothing
void FinishCustomItemEditing(void);
void FinishCustomItemEditing();
// returns a pointer to a column;
// in case the pointer cannot be found NULL is returned:
wxDataViewColumn* GetColumnPtr(WXDataBrowserPropertyID propertyID) const;
// returns the current being rendered item of the customized renderer (this item is only valid during editing)
wxDataViewItem const& GetCustomRendererItem(void) const
wxDataViewItem const& GetCustomRendererItem() const
{
return this->m_CustomRendererItem;
}
// returns a pointer to a customized renderer (this pointer is only valid during editing)
wxDataViewCustomRenderer* GetCustomRendererPtr(void) const
wxDataViewCustomRenderer* GetCustomRendererPtr() const
{
return this->m_CustomRendererPtr;
}
// checks if currently a delete process is running:
bool IsDeleting(void) const
bool IsDeleting() const
{
return this->m_Deleting;
}
@ -556,7 +558,7 @@ public:
{
this->m_cgContext = context;
}
void* MacGetDrawingContext(void) const
void* MacGetDrawingContext() const
{
return this->m_cgContext;
}
@ -587,8 +589,8 @@ public:
protected:
// inherited methods from wxDataViewCtrlBase:
virtual void DoSetExpanderColumn(void);
virtual void DoSetIndent(void);
virtual void DoSetExpanderColumn();
virtual void DoSetIndent();
// event handling:
void OnSize(wxSizeEvent &event);
@ -598,7 +600,7 @@ private:
WX_DECLARE_HASH_MAP(WXDataBrowserPropertyID,wxDataViewColumn*,wxIntegerHash,wxIntegerEqual,ColumnPointerHashMapType);
// initializing of local variables:
void Init(void);
void Init();
///
// variables

View File

@ -687,17 +687,19 @@ public:
class wxDataViewCtrl : public wxControl
{
public:
//@{
/**
Default Constructor.
*/
wxDataViewCtrl();
/**
Constructor. Calls Create().
*/
wxDataViewCtrl();
wxDataViewCtrl(wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator);
//@}
/**
Destructor.
@ -705,13 +707,24 @@ public:
~wxDataViewCtrl();
/**
Add a wxDataViewColumn to the control. Returns
@e @true on success.
Appends a wxDataViewColumn to the control. Returns @true on success.
Note that there is a number of short cut methods which implicitly create
a wxDataViewColumn and a wxDataViewRenderer for it (see below).
*/
virtual bool AppendColumn(wxDataViewColumn* col);
/**
Prepends a wxDataViewColumn to the control. Returns @true on success.
Note that there is a number of short cut methods which implicitly create
a wxDataViewColumn and a wxDataViewRenderer for it.
*/
virtual bool PrependColumn(wxDataViewColumn* col);
/**
Inserts a wxDataViewColumn to the control. Returns @true on success.
*/
virtual bool InsertColumn(unsigned int pos, wxDataViewColumn* col);
//@{
/**
Appends a column for rendering a bitmap. Returns the wxDataViewColumn

View File

@ -1205,6 +1205,13 @@ wxDataViewCtrlBase::PrependColumn( wxDataViewColumn *col )
return true;
}
bool
wxDataViewCtrlBase::InsertColumn( unsigned int WXUNUSED(pos), wxDataViewColumn *col )
{
col->SetOwner( (wxDataViewCtrl*) this );
return true;
}
// ---------------------------------------------------------
// wxDataViewEvent
// ---------------------------------------------------------

View File

@ -4183,6 +4183,16 @@ bool wxDataViewCtrl::PrependColumn( wxDataViewColumn *col )
return true;
}
bool wxDataViewCtrl::InsertColumn( unsigned int pos, wxDataViewColumn *col )
{
if (!wxDataViewCtrlBase::InsertColumn(pos,col))
return false;
m_cols.Insert( pos, col );
OnColumnChange();
return true;
}
void wxDataViewCtrl::OnColumnChange()
{
if (m_headerArea)

View File

@ -3783,6 +3783,28 @@ bool wxDataViewCtrl::PrependColumn( wxDataViewColumn *col )
return true;
}
bool wxDataViewCtrl::InsertColumn( unsigned int pos, wxDataViewColumn *col )
{
if (!wxDataViewCtrlBase::InsertColumn(pos,col))
return false;
m_cols.Insert( pos, col );
#ifdef __WXGTK26__
if (!gtk_check_version(2,6,0))
{
if (gtk_tree_view_column_get_sizing( GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) ) !=
GTK_TREE_VIEW_COLUMN_FIXED)
gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE );
}
#endif
gtk_tree_view_insert_column( GTK_TREE_VIEW(m_treeview),
GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()), pos );
return true;
}
unsigned int wxDataViewCtrl::GetColumnCount() const
{
return m_cols.GetCount();

View File

@ -468,7 +468,7 @@ public:
return false;
} /* ValueChanged(wxDataViewItem const&, unsigned int) */
virtual bool Cleared(void)
virtual bool Cleared()
{
bool noFailureFlag = (this->m_dataViewControlPtr->RemoveItems() == noErr);
wxDataViewItem item;
@ -476,9 +476,9 @@ public:
GetOwner()->GetChildren( item, array );
ItemsAdded( item, array );
return noFailureFlag;
} /* Cleared(void) */
} /* Cleared() */
virtual void Resort(void)
virtual void Resort()
{
this->m_dataViewControlPtr->Resort();
}
@ -544,11 +544,11 @@ wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const& varianttype,
{
} /* wxDataViewCustomRenderer::wxDataViewCustomRenderer(wxString const&, wxDataViewCellMode) */
wxDataViewCustomRenderer::~wxDataViewCustomRenderer(void)
wxDataViewCustomRenderer::~wxDataViewCustomRenderer()
{
if (this->m_DCPtr != NULL)
delete this->m_DCPtr;
} /* wxDataViewCustomRenderer::~wxDataViewCustomRenderer(void) */
} /* wxDataViewCustomRenderer::~wxDataViewCustomRenderer() */
void wxDataViewCustomRenderer::RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state )
{
@ -559,7 +559,7 @@ void wxDataViewCustomRenderer::RenderText( const wxString &text, int xoffset, wx
dc->DrawText( text, cell.x + xoffset, cell.y + ((cell.height - dc->GetCharHeight()) / 2));
}
wxDC* wxDataViewCustomRenderer::GetDC(void)
wxDC* wxDataViewCustomRenderer::GetDC()
{
if (this->m_DCPtr == NULL)
{
@ -568,12 +568,12 @@ wxDC* wxDataViewCustomRenderer::GetDC(void)
this->m_DCPtr = new wxWindowDC(this->GetOwner()->GetOwner());
} /* if */
return this->m_DCPtr;
} /* wxDataViewCustomRenderer::GetDC(void) */
} /* wxDataViewCustomRenderer::GetDC() */
bool wxDataViewCustomRenderer::Render(void)
bool wxDataViewCustomRenderer::Render()
{
return true;
} /* wxDataViewCustomRenderer::Render(void) */
} /* wxDataViewCustomRenderer::Render() */
void wxDataViewCustomRenderer::SetDC(wxDC* newDCPtr)
{
@ -581,10 +581,10 @@ void wxDataViewCustomRenderer::SetDC(wxDC* newDCPtr)
this->m_DCPtr = newDCPtr;
} /* wxDataViewCustomRenderer::SetDC(wxDC*) */
WXDataBrowserPropertyType wxDataViewCustomRenderer::GetPropertyType(void) const
WXDataBrowserPropertyType wxDataViewCustomRenderer::GetPropertyType() const
{
return kDataBrowserCustomType;
} /* wxDataViewCustomRenderer::GetPropertyType(void) const */
} /* wxDataViewCustomRenderer::GetPropertyType() const */
IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer, wxDataViewRenderer)
@ -597,7 +597,7 @@ wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const& varianttype, wxDa
{
} /* wxDataViewTextRenderer::wxDataViewTextRenderer(wxString const&, wxDataViewCellMode, int) */
bool wxDataViewTextRenderer::Render(void)
bool wxDataViewTextRenderer::Render()
{
wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Text renderer cannot render value; value type: ")) << this->GetValue().GetType());
@ -608,12 +608,12 @@ bool wxDataViewTextRenderer::Render(void)
wxMacCFStringHolder cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
#endif
return (::SetDataBrowserItemDataText(this->GetDataReference(),cfString) == noErr);
} /* wxDataViewTextRenderer::Render(void) */
} /* wxDataViewTextRenderer::Render() */
WXDataBrowserPropertyType wxDataViewTextRenderer::GetPropertyType(void) const
WXDataBrowserPropertyType wxDataViewTextRenderer::GetPropertyType() const
{
return kDataBrowserTextType;
} /* wxDataViewTextRenderer::GetPropertyType(void) const */
} /* wxDataViewTextRenderer::GetPropertyType() const */
IMPLEMENT_CLASS(wxDataViewTextRenderer,wxDataViewRenderer)
@ -637,7 +637,7 @@ wxDataViewBitmapRenderer::wxDataViewBitmapRenderer(wxString const& varianttype,
{
}
bool wxDataViewBitmapRenderer::Render(void)
bool wxDataViewBitmapRenderer::Render()
// This method returns 'true' if
// - the passed bitmap is valid and it could be assigned to the native data browser;
// - the passed bitmap is invalid (or is not initialized); this case simulates a non-existing bitmap.
@ -657,12 +657,12 @@ bool wxDataViewBitmapRenderer::Render(void)
#endif
else
return true;
} /* wxDataViewBitmapRenderer::Render(void) */
} /* wxDataViewBitmapRenderer::Render() */
WXDataBrowserPropertyType wxDataViewBitmapRenderer::GetPropertyType(void) const
WXDataBrowserPropertyType wxDataViewBitmapRenderer::GetPropertyType() const
{
return kDataBrowserIconType;
} /* wxDataViewBitmapRenderer::GetPropertyType(void) const */
} /* wxDataViewBitmapRenderer::GetPropertyType() const */
IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer)
@ -675,7 +675,7 @@ wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(wxString const& variantty
{
}
bool wxDataViewIconTextRenderer::Render(void)
bool wxDataViewIconTextRenderer::Render()
{
wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Icon & text renderer cannot render value; value type: ")) << this->GetValue().GetType());
@ -695,12 +695,12 @@ bool wxDataViewIconTextRenderer::Render(void)
if (::SetDataBrowserItemDataIcon(this->GetDataReference(),MAC_WXHICON(iconText.GetIcon().GetHICON())) != noErr)
return false;
return (::SetDataBrowserItemDataText(this->GetDataReference(),cfString) == noErr);
} /* wxDataViewIconTextRenderer::Render(void) */
} /* wxDataViewIconTextRenderer::Render() */
WXDataBrowserPropertyType wxDataViewIconTextRenderer::GetPropertyType(void) const
WXDataBrowserPropertyType wxDataViewIconTextRenderer::GetPropertyType() const
{
return kDataBrowserIconAndTextType;
} /* wxDataViewIconTextRenderer::GetPropertyType(void) const */
} /* wxDataViewIconTextRenderer::GetPropertyType() const */
IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer,wxDataViewRenderer)
@ -714,16 +714,16 @@ wxDataViewToggleRenderer::wxDataViewToggleRenderer(wxString const& varianttype,
{
}
bool wxDataViewToggleRenderer::Render(void)
bool wxDataViewToggleRenderer::Render()
{
wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Toggle renderer cannot render value; value type: ")) << this->GetValue().GetType());
return (::SetDataBrowserItemDataButtonValue(this->GetDataReference(),this->GetValue().GetBool()) == noErr);
} /* wxDataViewToggleRenderer::Render(void) */
} /* wxDataViewToggleRenderer::Render() */
WXDataBrowserPropertyType wxDataViewToggleRenderer::GetPropertyType(void) const
WXDataBrowserPropertyType wxDataViewToggleRenderer::GetPropertyType() const
{
return kDataBrowserCheckboxType;
} /* wxDataViewToggleRenderer::GetPropertyType(void) const */
} /* wxDataViewToggleRenderer::GetPropertyType() const */
IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer)
@ -736,18 +736,18 @@ wxDataViewProgressRenderer::wxDataViewProgressRenderer(wxString const& label, wx
{
}
bool wxDataViewProgressRenderer::Render(void)
bool wxDataViewProgressRenderer::Render()
{
wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Progress renderer cannot render value type; value type: ")) << this->GetValue().GetType());
return ((::SetDataBrowserItemDataMinimum(this->GetDataReference(), 0) == noErr) &&
(::SetDataBrowserItemDataMaximum(this->GetDataReference(),100) == noErr) &&
(::SetDataBrowserItemDataValue (this->GetDataReference(),this->GetValue().GetLong()) == noErr));
} /* wxDataViewProgressRenderer::Render(void) */
} /* wxDataViewProgressRenderer::Render() */
WXDataBrowserPropertyType wxDataViewProgressRenderer::GetPropertyType(void) const
WXDataBrowserPropertyType wxDataViewProgressRenderer::GetPropertyType() const
{
return kDataBrowserProgressBarType;
} /* wxDataViewProgressRenderer::GetPropertyType(void) const */
} /* wxDataViewProgressRenderer::GetPropertyType() const */
IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer,wxDataViewRenderer)
@ -760,16 +760,16 @@ wxDataViewDateRenderer::wxDataViewDateRenderer(wxString const& varianttype, wxDa
{
}
bool wxDataViewDateRenderer::Render(void)
bool wxDataViewDateRenderer::Render()
{
wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Date renderer cannot render value; value type: ")) << this->GetValue().GetType());
return (::SetDataBrowserItemDataDateTime(this->GetDataReference(),this->GetValue().GetDateTime().Subtract(wxDateTime(1,wxDateTime::Jan,1904)).GetSeconds().GetLo()) == noErr);
} /* wxDataViewDateRenderer::Render(void) */
} /* wxDataViewDateRenderer::Render() */
WXDataBrowserPropertyType wxDataViewDateRenderer::GetPropertyType(void) const
WXDataBrowserPropertyType wxDataViewDateRenderer::GetPropertyType() const
{
return kDataBrowserDateTimeType;
} /* wxDataViewDateRenderer::GetPropertyType(void) const */
} /* wxDataViewDateRenderer::GetPropertyType() const */
IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer,wxDataViewRenderer)
@ -1079,13 +1079,13 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn,wxDataViewColumnBase)
// wxDataViewCtrl
//-----------------------------------------------------------------------------
#pragma mark -
void wxDataViewCtrl::Init(void)
void wxDataViewCtrl::Init()
{
this->m_CustomRendererPtr = NULL;
this->m_Deleting = false;
this->m_macIsUserPane = false;
this->m_cgContext = NULL;
} /* wxDataViewCtrl::Init(void) */
} /* wxDataViewCtrl::Init() */
bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator )
{
@ -1127,9 +1127,19 @@ bool wxDataViewCtrl::AssociateModel(wxDataViewModel* model)
model->AddNotifier(new wxMacDataViewModelNotifier(dynamic_cast<wxMacDataViewDataBrowserListViewControl*>(this->m_peer)));
return true;
} /* wxDataViewCtrl::AssociateModel(wxDataViewModel*) */
}
bool wxDataViewCtrl::AppendColumn(wxDataViewColumn* columnPtr)
{
return InsertColumn( kDataBrowserListViewAppendColumn, columnPtr );
}
bool wxDataViewCtrl::PrependColumn(wxDataViewColumn* columnPtr)
{
return InsertColumn( 0, columnPtr );
}
bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr)
{
DataBrowserListViewColumnDesc columnDescription;
@ -1161,7 +1171,7 @@ bool wxDataViewCtrl::AppendColumn(wxDataViewColumn* columnPtr)
this->m_ColumnPointers.insert(ColumnPointerHashMapType::value_type(NewPropertyID,columnPtr)).second,false,_("Could not add column to internal structures."));
// create a column description and add column to the native control:
wxCHECK_MSG(::InitializeColumnDescription(columnDescription,columnPtr,NewPropertyID,title), false,_("Column description could not be initialized."));
wxCHECK_MSG(MacDataViewListCtrlPtr->AddColumn(&columnDescription,kDataBrowserListViewAppendColumn) == noErr,false,_("Column could not be added."));
wxCHECK_MSG(MacDataViewListCtrlPtr->AddColumn(&columnDescription,pos) == noErr,false,_("Column could not be added."));
// final adjustments for the layout:
wxCHECK_MSG(MacDataViewListCtrlPtr->SetColumnWidth(NewPropertyID,columnPtr->GetWidth()) == noErr,false,_("Column width could not be set."));
@ -1178,9 +1188,9 @@ bool wxDataViewCtrl::AppendColumn(wxDataViewColumn* columnPtr)
MacDataViewListCtrlPtr->UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,NewPropertyID);
// done:
return true;
} /* wxDataViewCtrl::AppendColumn(wxDataViewColumn*) */
}
bool wxDataViewCtrl::ClearColumns(void)
bool wxDataViewCtrl::ClearColumns()
{
wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
@ -1192,7 +1202,7 @@ bool wxDataViewCtrl::ClearColumns(void)
this->m_ColumnPointers.erase(this->m_ColumnPointers.begin());
} /* while */
return true;
} /* wxDataViewCtrl::ClearColumns(void) */
}
bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn* columnPtr)
{
@ -1229,10 +1239,10 @@ wxDataViewColumn* wxDataViewCtrl::GetColumn(unsigned int pos) const
return NULL;
} /* wxDataViewCtrl::GetColumn(unsigned int pos) const */
unsigned int wxDataViewCtrl::GetColumnCount(void) const
unsigned int wxDataViewCtrl::GetColumnCount() const
{
return this->m_ColumnPointers.size();
} /* wxDataViewCtrl::GetColumnCount(void) const */
} /* wxDataViewCtrl::GetColumnCount() const */
int wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const* columnPtr) const
{
@ -1249,57 +1259,6 @@ int wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const* columnPtr) const
return wxNOT_FOUND;
} /* wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const*) const */
bool wxDataViewCtrl::PrependColumn(wxDataViewColumn* columnPtr)
{
DataBrowserListViewColumnDesc columnDescription;
DataBrowserPropertyID NewPropertyID;
wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
#if wxCHECK_VERSION(2,9,0)
wxCFStringRef title(columnPtr->GetTitle(),this->m_font.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding());
#else
wxMacCFStringHolder title(columnPtr->GetTitle(),this->m_font.Ok() ? this->GetFont().GetEncoding() : wxLocale::GetSystemEncoding());
#endif
// first, some error checking:
wxCHECK_MSG(MacDataViewListCtrlPtr != NULL, false,_("m_peer is not or incorrectly initialized"));
wxCHECK_MSG(columnPtr != NULL, false,_("Column pointer must not be NULL."));
wxCHECK_MSG(columnPtr->GetRenderer() != NULL, false,_("Column does not have a renderer."));
wxCHECK_MSG(this->GetModel() != NULL, false,_("No model associated with control."));
wxCHECK_MSG((columnPtr->GetModelColumn() >= 0) &&
(columnPtr->GetModelColumn() < this->GetModel()->GetColumnCount()),false,_("Column's model column has no equivalent in the associated model."));
// try to get new ID for the column:
wxCHECK_MSG(MacDataViewListCtrlPtr->GetFreePropertyID(&NewPropertyID) == noErr,false,_("Cannot create new column's ID. Probably max. number of columns reached."));
// full column variable initialization:
columnPtr->SetPropertyID(NewPropertyID);
// add column to wxWidget's internal structure:
wxCHECK_MSG(this->wxDataViewCtrlBase::AppendColumn(columnPtr) &&
this->m_ColumnPointers.insert(ColumnPointerHashMapType::value_type(NewPropertyID,columnPtr)).second,false,_("Could not add column to internal structures."));
// create a column description and add column to the native control:
wxCHECK_MSG(::InitializeColumnDescription(columnDescription,columnPtr,NewPropertyID,title),false,_("Column description could not be initialized."));
wxCHECK_MSG(MacDataViewListCtrlPtr->AddColumn(&columnDescription,0) == noErr, false,_("Column could not be added."));
// final adjustments for the layout:
wxCHECK_MSG(MacDataViewListCtrlPtr->SetColumnWidth(NewPropertyID,columnPtr->GetWidth()) == noErr,false,_("Column width could not be set."));
// make sure that the data is up-to-date...
// if the newly appended column is the first column add the initial data to the control and mark the column as an expander column,
// otherwise ask the control to 'update' the data in the newly appended column:
if (this->GetColumnCount() == 1)
{
this->SetExpanderColumn(columnPtr);
this->AddChildrenLevel(wxDataViewItem());
} /* if */
else
MacDataViewListCtrlPtr->UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,NewPropertyID);
// done:
return true;
} /* wxDataViewCtrl::PrependColumn(wxDataViewColumn*) */
void wxDataViewCtrl::Collapse(wxDataViewItem const& item)
{
wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
@ -1332,7 +1291,7 @@ void wxDataViewCtrl::Expand(wxDataViewItem const& item)
MacDataViewListCtrlPtr->OpenContainer(reinterpret_cast<DataBrowserItemID>(item.GetID()));
} /* wxDataViewCtrl::Expand(wxDataViewItem const&) */
wxDataViewColumn* wxDataViewCtrl::GetSortingColumn(void) const
wxDataViewColumn* wxDataViewCtrl::GetSortingColumn() const
{
DataBrowserPropertyID propertyID;
@ -1343,16 +1302,16 @@ wxDataViewColumn* wxDataViewCtrl::GetSortingColumn(void) const
return this->GetColumnPtr(propertyID);
else
return NULL;
} /* wxDataViewCtrl::GetSortingColumn(void) const */
} /* wxDataViewCtrl::GetSortingColumn() const */
unsigned int wxDataViewCtrl::GetCount(void) const
unsigned int wxDataViewCtrl::GetCount() const
{
ItemCount noOfItems;
wxCHECK_MSG(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer)->GetItemCount(&noOfItems) == noErr,0,_("Could not determine number of items"));
return noOfItems;
} /* wxDataViewCtrl::GetCount(void) const */
} /* wxDataViewCtrl::GetCount() const */
wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const
{
@ -1377,7 +1336,7 @@ wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn
return wxRect();
} /* wxDataViewCtrl::GetItemRect(wxDataViewItem const&, unsigned int) const */
wxDataViewItem wxDataViewCtrl::GetSelection(void) const
wxDataViewItem wxDataViewCtrl::GetSelection() const
{
wxArrayDataBrowserItemID itemIDs;
@ -1388,7 +1347,7 @@ wxDataViewItem wxDataViewCtrl::GetSelection(void) const
return wxDataViewItem(reinterpret_cast<void*>(itemIDs[0]));
else
return wxDataViewItem();
} /* wxDataViewCtrl::GetSelection(void) const */
} /* wxDataViewCtrl::GetSelection() const */
int wxDataViewCtrl::GetSelections(wxDataViewItemArray& sel) const
{
@ -1421,7 +1380,7 @@ bool wxDataViewCtrl::IsSelected(wxDataViewItem const& item) const
return MacDataViewListCtrlPtr->IsItemSelected(reinterpret_cast<DataBrowserItemID>(item.GetID()));
} /* wxDataViewCtrl::IsSelected(wxDataViewItem const&) const */
void wxDataViewCtrl::SelectAll(void)
void wxDataViewCtrl::SelectAll()
{
DataBrowserItemID* itemIDPtr;
@ -1439,7 +1398,7 @@ void wxDataViewCtrl::SelectAll(void)
MacDataViewListCtrlPtr->SetSelectedItems(NoOfItems,itemIDPtr,kDataBrowserItemsAssign);
HUnlock(handle);
DisposeHandle(handle);
} /* wxDataViewCtrl::SelectAll(void) */
} /* wxDataViewCtrl::SelectAll() */
void wxDataViewCtrl::Select(wxDataViewItem const& item)
{
@ -1481,7 +1440,7 @@ void wxDataViewCtrl::Unselect(wxDataViewItem const& item)
} /* if */
} /* wxDataViewCtrl::Unselect(wxDataViewItem const&) */
void wxDataViewCtrl::UnselectAll(void)
void wxDataViewCtrl::UnselectAll()
{
DataBrowserItemID* itemIDPtr;
@ -1499,7 +1458,7 @@ void wxDataViewCtrl::UnselectAll(void)
MacDataViewListCtrlPtr->SetSelectedItems(NoOfItems,itemIDPtr,kDataBrowserItemsRemove);
HUnlock(handle);
DisposeHandle(handle);
} /* wxDataViewCtrl::UnselectAll(void) */
} /* wxDataViewCtrl::UnselectAll() */
// data handling:
void wxDataViewCtrl::AddChildrenLevel(wxDataViewItem const& parentItem)
@ -1517,17 +1476,17 @@ void wxDataViewCtrl::AddChildrenLevel(wxDataViewItem const& parentItem)
#else
(void) this->GetModel()->ItemsAdded(parentItem,items);
#endif
} /* wxDataViewCtrl::AddChildrenLevel(wxDataViewItem const&) */
}
void wxDataViewCtrl::FinishCustomItemEditing(void)
void wxDataViewCtrl::FinishCustomItemEditing()
{
if (this->GetCustomRendererItem().IsOk())
{
this->GetCustomRendererPtr()->FinishEditing();
this->SetCustomRendererItem(wxDataViewItem());
this->SetCustomRendererPtr (NULL);
} /* if */
} /* wxDataViewCtrl::FinishCustomItemEditing(void) */
}
}
wxDataViewColumn* wxDataViewCtrl::GetColumnPtr(WXDataBrowserPropertyID propertyID) const
{
@ -1538,10 +1497,10 @@ wxDataViewColumn* wxDataViewCtrl::GetColumnPtr(WXDataBrowserPropertyID propertyI
return Result->second;
else
return NULL;
} /* wxDataViewCtrl::GetColumnPtr(DataBrowserPropertyID) const */
}
// inherited methods from wxDataViewCtrlBase
void wxDataViewCtrl::DoSetExpanderColumn(void)
void wxDataViewCtrl::DoSetExpanderColumn()
{
if (this->GetExpanderColumn() != NULL)
{
@ -1549,16 +1508,15 @@ void wxDataViewCtrl::DoSetExpanderColumn(void)
wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
(void) MacDataViewListCtrlPtr->SetDisclosureColumn(this->GetExpanderColumn()->GetPropertyID(),false); // second parameter explicitely passed to ensure that arrow is centered
} /* if */
} /* wxDataViewCtrl::DoSetExpanderColumn(void) */
}
}
void wxDataViewCtrl::DoSetIndent(void)
void wxDataViewCtrl::DoSetIndent()
{
wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
(void) MacDataViewListCtrlPtr->SetIndent(static_cast<float>(this->GetIndent()));
} /* wxDataViewCtrl::DoSetIndent(void) */
}
// event handling:
void wxDataViewCtrl::OnSize(wxSizeEvent& event)