Update to wxDataViewCtrl from Hartwig

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50038 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2007-11-17 21:20:27 +00:00
parent 40d2fe77c1
commit 594d5596ee
5 changed files with 217 additions and 151 deletions

View File

@@ -468,8 +468,8 @@ public:
const wxBitmap &GetBitmap() const { return m_bitmap; }
unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); }
wxDataViewCtrl *GetOwner() { return m_owner; }
wxDataViewRenderer* GetRenderer() { return m_renderer; }
wxDataViewCtrl *GetOwner() const { return m_owner; }
wxDataViewRenderer* GetRenderer() const { return m_renderer; }
protected:
wxDataViewRenderer *m_renderer;
@@ -909,7 +909,7 @@ public:
virtual unsigned int GetColumnCount() const
{ return 1; };
virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const
{ return "wxDataViewIconText"; }
{ return wxT("wxDataViewIconText"); }
wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const;
wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const;

View File

@@ -10,15 +10,19 @@
#ifndef _WX_MACCARBONDATAVIEWCTRL_H_
#define _WX_MACCARBONDATAVIEWCTRL_H_
typedef void* DataBrowserItemDataRef;
// --------------------------------------------------------
// Type definitions to mask native types
// --------------------------------------------------------
typedef void* WXDataBrowserItemDataRef;
typedef unsigned long WXDataBrowserPropertyType;
typedef wxUint32 WXDataBrowserPropertyID;
typedef wxUint32 WXDataBrowserPropertyID;
// ---------------------------------------------------------
// wxDataViewRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewRendererBase
class WXDLLIMPEXP_ADV wxDataViewRenderer : public wxDataViewRendererBase
{
public:
//
@@ -56,7 +60,7 @@ public:
//
// implementation
//
DataBrowserItemDataRef GetDataReference(void) const
WXDataBrowserItemDataRef GetDataReference(void) const
{
return this->m_dataReference;
}
@@ -65,12 +69,12 @@ public:
return this->m_value;
}
virtual WXDataBrowserPropertyType GetPropertyType() const = 0;
virtual WXDataBrowserPropertyType GetPropertyType(void) const = 0;
virtual bool Render(void) = 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(DataBrowserItemDataRef const& newDataReference)
void SetDataReference(WXDataBrowserItemDataRef const& newDataReference)
{
this->m_dataReference = newDataReference;
}
@@ -79,7 +83,7 @@ private:
//
// variables
//
DataBrowserItemDataRef m_dataReference; // data reference of the data browser; the data will be assigned to this reference during rendering
WXDataBrowserItemDataRef m_dataReference; // data reference of the data browser; the data will be assigned to this reference during rendering
int m_alignment; // contains the alignment flags
@@ -186,7 +190,7 @@ public:
virtual bool Render(void); // declared in wxDataViewRenderer but will not be used here, therefore calling this function will
// return 'true' without having done anything
virtual WXDataBrowserPropertyType GetPropertyType() const;
virtual WXDataBrowserPropertyType GetPropertyType(void) const;
void SetDC(wxDC* newDCPtr); // this method takes ownership of the pointer
@@ -225,7 +229,7 @@ public:
//
// implementation
//
virtual WXDataBrowserPropertyType GetPropertyType() const;
virtual WXDataBrowserPropertyType GetPropertyType(void) const;
protected:
private:
@@ -268,7 +272,7 @@ public:
//
// implementation
//
virtual WXDataBrowserPropertyType GetPropertyType() const;
virtual WXDataBrowserPropertyType GetPropertyType(void) const;
protected:
private:
@@ -292,7 +296,7 @@ public:
//
// implementation
//
virtual WXDataBrowserPropertyType GetPropertyType() const;
virtual WXDataBrowserPropertyType GetPropertyType(void) const;
protected:
private:
@@ -316,7 +320,7 @@ public:
//
// implementation
//
virtual WXDataBrowserPropertyType GetPropertyType() const;
virtual WXDataBrowserPropertyType GetPropertyType(void) const;
protected:
private:
@@ -341,7 +345,7 @@ public:
//
// implementation
//
virtual WXDataBrowserPropertyType GetPropertyType() const;
virtual WXDataBrowserPropertyType GetPropertyType(void) const;
protected:
private:
@@ -365,7 +369,7 @@ public:
//
// implementation
//
virtual WXDataBrowserPropertyType GetPropertyType() const;
virtual WXDataBrowserPropertyType GetPropertyType(void) const;
protected:
private:
@@ -521,6 +525,7 @@ public:
virtual wxDataViewColumn* GetColumn(unsigned int pos) const;
virtual unsigned int GetColumnCount(void) 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);

View File

@@ -705,7 +705,7 @@ static const char *small1_xpm[] = {
void MyFrame::OnTestTreeCtrl(wxCommandEvent& WXUNUSED(event) )
{
wxDialog dialog( this, -1, "Test wxDataViewTreeStore" );
wxDialog dialog( this, -1, wxString(wxT("Test wxDataViewTreeStore")));
wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );

View File

@@ -9,33 +9,24 @@
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef wxUSE_GENERICDATAVIEWCTRL
#include <limits>
#include "wx/wxprec.h"
#if wxUSE_DATAVIEWCTRL
#if !defined(wxUSE_GENERICDATAVIEWCTRL) || wxUSE_GENERICDATAVIEWCTRL == 0
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/toplevel.h"
#include "wx/font.h"
#include "wx/settings.h"
#endif
#include "wx/dataview.h"
#include "wx/utils.h"
#include "wx/mac/private.h"
#include "wx/mac/carbon/databrow.h"
#include "wx/mac/private.h"
#include "wx/mac/uma.h"
#include <limits>
#if defined(__MWERKS__) && wxUSE_UNICODE
#if __MWERKS__ < 0x4100
#include <wtime.h>
#endif
#endif
// ============================================================================
// wxMacDataBrowserTableViewControl
// ============================================================================
@@ -134,6 +125,7 @@ wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* pee
flags |= kDataBrowserSelectOnlyOne;
(void) this->SetSelectionFlags(flags);
} /* if */
OptionBits attributes; // variable definition
if (this->GetAttributes(&attributes) == noErr) // get default settings
@@ -144,6 +136,7 @@ wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* pee
attributes &= ~kDataBrowserAttributeListViewDrawColumnDividers;
(void) this->SetAttributes(attributes);
} /* if */
if ((style & wxDV_NO_HEADER) != 0)
this->SetHeaderButtonHeight(0);
} /* wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow*, wxPoint const&, wxSize const&, long) */
@@ -938,4 +931,3 @@ void wxMacDataViewDataBrowserListViewControl::DataBrowserItemNotificationProc(Da
#endif // wxUSE_GENERICDATAVIEWCTRL
#endif // wxUSE_DATAVIEWCTRL

View File

@@ -22,8 +22,6 @@
#ifndef WX_PRECOMP
#include "wx/timer.h"
#include "wx/settings.h"
#include "wx/dcclient.h"
#endif
#include "wx/icon.h"
@@ -113,6 +111,67 @@ static DataBrowserItemID* CreateDataBrowserItemIDArray(size_t& noOfEntries, wxDa
return itemIDs;
} /* CreateDataBrowserItemIDArray(size_t&, wxDataViewItemArray const&) */
static bool InitializeColumnDescription(DataBrowserListViewColumnDesc& columnDescription, wxDataViewColumn const* columnPtr, DataBrowserPropertyID columnPropertyID, wxMacCFStringHolder const& title)
{
// set properties for the column:
columnDescription.propertyDesc.propertyID = columnPropertyID;
columnDescription.propertyDesc.propertyType = columnPtr->GetRenderer()->GetPropertyType();
columnDescription.propertyDesc.propertyFlags = kDataBrowserListViewSelectionColumn; // make the column selectable
if (columnPtr->IsSortable())
columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewSortableColumn;
#if 0
if (columnPtr->IsMovable())
columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewMovableColumn;
#endif
if (columnPtr->GetRenderer()->GetMode() == wxDATAVIEW_CELL_EDITABLE)
columnDescription.propertyDesc.propertyFlags |= kDataBrowserPropertyIsEditable;
if ((columnDescription.propertyDesc.propertyType == kDataBrowserTextType) ||
(columnDescription.propertyDesc.propertyType == kDataBrowserIconAndTextType) ||
(columnDescription.propertyDesc.propertyType == kDataBrowserDateTimeType))
columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn; // enables generally the possibility to have user input for the mentioned types
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton;
#endif
// set header's properties:
columnDescription.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
if (columnPtr->IsResizeable())
{
columnDescription.headerBtnDesc.minimumWidth = 0;
columnDescription.headerBtnDesc.maximumWidth = 30000; // 32767 is the theoretical maximum though but 30000 looks nicer
} /* if */
else
{
columnDescription.headerBtnDesc.minimumWidth = columnPtr->GetWidth();
columnDescription.headerBtnDesc.maximumWidth = columnPtr->GetWidth();
} /* if */
columnDescription.headerBtnDesc.titleOffset = 0;
columnDescription.headerBtnDesc.titleString = ::CFStringCreateCopy(kCFAllocatorDefault,title);
columnDescription.headerBtnDesc.initialOrder = kDataBrowserOrderIncreasing; // choose one of the orders as "undefined" is not supported anyway (s. ControlDefs.h in the HIToolbox framework)
columnDescription.headerBtnDesc.btnFontStyle.flags = kControlUseFontMask | kControlUseJustMask;
switch (columnPtr->GetAlignment())
{
case wxALIGN_CENTER:
case wxALIGN_CENTER_HORIZONTAL:
columnDescription.headerBtnDesc.btnFontStyle.just = teCenter;
break;
case wxALIGN_LEFT:
columnDescription.headerBtnDesc.btnFontStyle.just = teFlushLeft;
break;
case wxALIGN_RIGHT:
columnDescription.headerBtnDesc.btnFontStyle.just = teFlushRight;
break;
default:
columnDescription.headerBtnDesc.btnFontStyle.just = teFlushDefault;
} /* switch */
columnDescription.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
columnDescription.headerBtnDesc.btnFontStyle.style = normal;
columnDescription.headerBtnDesc.btnContentInfo.contentType = kControlContentIconRef;
if (columnPtr->GetBitmap().Ok())
columnDescription.headerBtnDesc.btnContentInfo.u.iconRef = columnPtr->GetBitmap().GetBitmapData()->GetIconRef();
// done:
return true;
} /* InitializeColumnDescription(DataBrowserListViewColumnDesc&, wxDataViewColumn const*, DataBrowserPropertyID, wxMacCFStringHolder const&) */
//-----------------------------------------------------------------------------
// local function pointers
//-----------------------------------------------------------------------------
@@ -384,9 +443,7 @@ wxDataViewCustomRenderer::~wxDataViewCustomRenderer(void)
void wxDataViewCustomRenderer::RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state )
{
wxDataViewCtrl *view = GetOwner()->GetOwner();
wxColour col = (state & wxDATAVIEW_CELL_SELECTED) ?
wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) :
view->GetForegroundColour();
wxColour col = (state & wxDATAVIEW_CELL_SELECTED) ? wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) : view->GetForegroundColour();
dc->SetTextForeground(col);
dc->DrawText( text, cell.x + xoffset, cell.y + ((cell.height - dc->GetCharHeight()) / 2));
}
@@ -413,10 +470,10 @@ void wxDataViewCustomRenderer::SetDC(wxDC* newDCPtr)
this->m_DCPtr = newDCPtr;
} /* wxDataViewCustomRenderer::SetDC(wxDC*) */
WXDataBrowserPropertyType wxDataViewCustomRenderer::GetPropertyType() const
WXDataBrowserPropertyType wxDataViewCustomRenderer::GetPropertyType(void) const
{
return kDataBrowserCustomType;
}
return kDataBrowserCustomType;
} /* wxDataViewCustomRenderer::GetPropertyType(void) const */
IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer, wxDataViewRenderer)
@@ -442,13 +499,35 @@ bool wxDataViewTextRenderer::Render(void)
return false;
} /* wxDataViewTextRenderer::Render(void) */
WXDataBrowserPropertyType wxDataViewTextRenderer::GetPropertyType() const
WXDataBrowserPropertyType wxDataViewTextRenderer::GetPropertyType(void) const
{
return kDataBrowserTextType;
}
return kDataBrowserTextType;
} /* wxDataViewTextRenderer::GetPropertyType(void) const */
IMPLEMENT_CLASS(wxDataViewTextRenderer,wxDataViewRenderer)
// ---------------------------------------------------------
// wxDataViewTextRendererAttr
// ---------------------------------------------------------
#pragma mark -
wxDataViewTextRendererAttr::wxDataViewTextRendererAttr(wxString const& varianttype, wxDataViewCellMode mode, int align)
:wxDataViewTextRenderer(varianttype,mode,align)
{
} /* wxDataViewTextRendererAttr::wxDataViewTextRendererAttr(wxString const&, wxDataViewCellMode, int) */
IMPLEMENT_CLASS(wxDataViewTextRendererAttr,wxDataViewTextRenderer)
// ---------------------------------------------------------
// wxDataViewTextRendererAttr
// ---------------------------------------------------------
wxDataViewTextRendererAttr::wxDataViewTextRendererAttr(wxString const& varianttype, wxDataViewCellMode mode, int align)
:wxDataViewTextRenderer(varianttype,mode,align)
{
}
IMPLEMENT_CLASS(wxDataViewTextRendererAttr,wxDataViewTextRenderer)
// ---------------------------------------------------------
// wxDataViewBitmapRenderer
// ---------------------------------------------------------
@@ -474,10 +553,10 @@ bool wxDataViewBitmapRenderer::Render(void)
return false;
} /* wxDataViewBitmapRenderer::Render(void) */
WXDataBrowserPropertyType wxDataViewBitmapRenderer::GetPropertyType() const
WXDataBrowserPropertyType wxDataViewBitmapRenderer::GetPropertyType(void) const
{
return kDataBrowserIconType;
}
return kDataBrowserIconType;
} /* wxDataViewBitmapRenderer::GetPropertyType(void) const */
IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer)
@@ -509,10 +588,10 @@ bool wxDataViewIconTextRenderer::Render(void)
return false;
} /* wxDataViewIconTextRenderer::Render(void) */
WXDataBrowserPropertyType wxDataViewIconTextRenderer::GetPropertyType() const
WXDataBrowserPropertyType wxDataViewIconTextRenderer::GetPropertyType(void) const
{
return kDataBrowserIconAndTextType;
}
return kDataBrowserIconAndTextType;
} /* wxDataViewIconTextRenderer::GetPropertyType(void) const */
IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer,wxDataViewRenderer)
@@ -534,10 +613,10 @@ bool wxDataViewToggleRenderer::Render(void)
return false;
} /* wxDataViewToggleRenderer::Render(void) */
WXDataBrowserPropertyType wxDataViewToggleRenderer::GetPropertyType() const
WXDataBrowserPropertyType wxDataViewToggleRenderer::GetPropertyType(void) const
{
return kDataBrowserCheckboxType;
}
return kDataBrowserCheckboxType;
} /* wxDataViewToggleRenderer::GetPropertyType(void) const */
IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer)
@@ -560,10 +639,10 @@ bool wxDataViewProgressRenderer::Render(void)
return false;
} /* wxDataViewProgressRenderer::Render(void) */
WXDataBrowserPropertyType wxDataViewProgressRenderer::GetPropertyType() const
WXDataBrowserPropertyType wxDataViewProgressRenderer::GetPropertyType(void) const
{
return kDataBrowserProgressBarType;
}
return kDataBrowserProgressBarType;
} /* wxDataViewProgressRenderer::GetPropertyType(void) const */
IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer,wxDataViewRenderer)
@@ -584,10 +663,10 @@ bool wxDataViewDateRenderer::Render(void)
return false;
} /* wxDataViewDateRenderer::Render(void) */
WXDataBrowserPropertyType wxDataViewDateRenderer::GetPropertyType() const
WXDataBrowserPropertyType wxDataViewDateRenderer::GetPropertyType(void) const
{
return kDataBrowserDateTimeType;
}
return kDataBrowserDateTimeType;
} /* wxDataViewDateRenderer::GetPropertyType(void) const */
IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer,wxDataViewRenderer)
@@ -871,108 +950,51 @@ bool wxDataViewCtrl::AssociateModel(wxDataViewModel* model)
return true;
} /* wxDataViewCtrl::AssociateModel(wxDataViewModel*) */
bool wxDataViewCtrl::AppendColumn(wxDataViewColumn* dataViewColumnPtr)
bool wxDataViewCtrl::AppendColumn(wxDataViewColumn* columnPtr)
{
DataBrowserListViewColumnDesc columnDescription;
DataBrowserPropertyID NewPropertyID;
wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
wxMacCFStringHolder title(columnPtr->GetTitle(),this->m_font.Ok() ? this->m_font.GetEncoding() : wxLocale::GetSystemEncoding());
// first, some error checking:
wxCHECK_MSG(MacDataViewListCtrlPtr != NULL, false,_("m_peer is not or incorrectly initialized"));
wxCHECK_MSG(dataViewColumnPtr != NULL, false,_("Column pointer must not be NULL."));
wxCHECK_MSG(dataViewColumnPtr->GetRenderer() != NULL, false,_("Column does not have a renderer."));
wxCHECK_MSG(this->GetModel() != NULL, false,_("No model associated with control."));
wxCHECK_MSG((dataViewColumnPtr->GetModelColumn() >= 0) &&
(dataViewColumnPtr->GetModelColumn() < this->GetModel()->GetColumnCount()),false,_("Column's model column has no equivalent in the associated model."));
if ((MacDataViewListCtrlPtr->GetFreePropertyID(&NewPropertyID) == noErr) && this->wxDataViewCtrlBase::AppendColumn(dataViewColumnPtr))
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,kDataBrowserListViewAppendColumn) == 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)
{
// insert column into hash map:
this->m_ColumnPointers.insert(ColumnPointerHashMapType::value_type(NewPropertyID,dataViewColumnPtr));
// variable definitions:
DataBrowserListViewColumnDesc columnDescription;
wxMacCFStringHolder cfTitle(dataViewColumnPtr->GetTitle(),(this->m_font.Ok() ? this->m_font.GetEncoding() : wxLocale::GetSystemEncoding()));
// initialize column description:
dataViewColumnPtr->SetPropertyID(NewPropertyID);
columnDescription.propertyDesc.propertyID = NewPropertyID;
columnDescription.propertyDesc.propertyType = DataBrowserPropertyType(dataViewColumnPtr->GetRenderer()->GetPropertyType());
columnDescription.propertyDesc.propertyFlags = kDataBrowserListViewSelectionColumn; // make the column selectable
if (dataViewColumnPtr->IsSortable())
columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewSortableColumn;
#if 0
if (dataViewColumnPtr->IsMovable())
columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewMovableColumn;
#endif
if (dataViewColumnPtr->GetRenderer()->GetMode() == wxDATAVIEW_CELL_EDITABLE)
columnDescription.propertyDesc.propertyFlags |= kDataBrowserPropertyIsEditable;
if ((columnDescription.propertyDesc.propertyType == kDataBrowserTextType) ||
(columnDescription.propertyDesc.propertyType == kDataBrowserIconAndTextType) ||
(columnDescription.propertyDesc.propertyType == kDataBrowserDateTimeType))
columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton;
#endif
columnDescription.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
if (dataViewColumnPtr->IsResizeable())
{
columnDescription.headerBtnDesc.minimumWidth = 0;
columnDescription.headerBtnDesc.maximumWidth = 30000;
} /* if */
else
{
columnDescription.headerBtnDesc.minimumWidth = dataViewColumnPtr->GetWidth();
columnDescription.headerBtnDesc.maximumWidth = dataViewColumnPtr->GetWidth();
} /* if */
columnDescription.headerBtnDesc.titleOffset = 0;
columnDescription.headerBtnDesc.titleString = cfTitle; // we cannot directly use the wxMacCFStringHolder constructor call because then the CFStringRef is released
// having called 'AddColumn' where the title (CFStringRef) is going to be used
columnDescription.headerBtnDesc.initialOrder = kDataBrowserOrderIncreasing;
columnDescription.headerBtnDesc.btnFontStyle.flags = kControlUseFontMask | kControlUseJustMask;
switch (dataViewColumnPtr->GetAlignment())
{
case wxALIGN_CENTER:
case wxALIGN_CENTER_HORIZONTAL:
columnDescription.headerBtnDesc.btnFontStyle.just = teCenter;
break;
case wxALIGN_LEFT:
columnDescription.headerBtnDesc.btnFontStyle.just = teFlushLeft;
break;
case wxALIGN_RIGHT:
columnDescription.headerBtnDesc.btnFontStyle.just = teFlushRight;
break;
default:
columnDescription.headerBtnDesc.btnFontStyle.just = teFlushDefault;
} /* switch */
columnDescription.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
columnDescription.headerBtnDesc.btnFontStyle.style = normal;
columnDescription.headerBtnDesc.btnContentInfo.contentType = kControlContentIconRef;
if (dataViewColumnPtr->GetBitmap().Ok())
columnDescription.headerBtnDesc.btnContentInfo.u.iconRef = dataViewColumnPtr->GetBitmap().GetBitmapData()->GetIconRef();
// add column:
wxCHECK_MSG(MacDataViewListCtrlPtr->AddColumn(&columnDescription,kDataBrowserListViewAppendColumn) == noErr,false,_("Column could not be added."));
// final adjustments for the layout:
wxCHECK_MSG(MacDataViewListCtrlPtr->SetColumnWidth(NewPropertyID,dataViewColumnPtr->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(dataViewColumnPtr);
this->AddChildrenLevel(wxDataViewItem());
} /* if */
else
MacDataViewListCtrlPtr->UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,NewPropertyID);
// done:
return true;
this->SetExpanderColumn(columnPtr);
this->AddChildrenLevel(wxDataViewItem());
} /* if */
else
return false;
MacDataViewListCtrlPtr->UpdateItems(kDataBrowserNoItem,0,NULL,kDataBrowserItemNoProperty,NewPropertyID);
// done:
return true;
} /* wxDataViewCtrl::AppendColumn(wxDataViewColumn*) */
bool wxDataViewCtrl::ClearColumns(void)
@@ -1044,6 +1066,53 @@ 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));
wxMacCFStringHolder title(columnPtr->GetTitle(),this->m_font.Ok() ? this->m_font.GetEncoding() : wxLocale::GetSystemEncoding());
// 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));