#include "wx/mac/carbon/databrow.h"
#ifndef WX_PRECOMP
- #include "wx/timer.h"
- #include "wx/settings.h"
- #include "wx/dcclient.h"
+ #include "wx/timer.h"
+ #include "wx/settings.h"
+ #include "wx/dcclient.h"
+ #include "wx/icon.h"
#endif
-#include "wx/icon.h"
#include "wx/renderer.h"
//-----------------------------------------------------------------------------
DataViewEvent.SetColumn(columnIndex);
DataViewEvent.SetDataViewColumn(DataViewCtrlPtr->GetColumn(columnIndex));
// finally sent the equivalent wxWidget event:
+#if wxCHECK_VERSION(2,9,0)
+ DataViewCtrlPtr->HandleWindowEvent(DataViewEvent);
+#else
DataViewCtrlPtr->GetEventHandler()->ProcessEvent(DataViewEvent);
+#endif
return ::CallNextEventHandler(handler,EventReference);
} /* if */
else
return itemIDs;
} /* CreateDataBrowserItemIDArray(size_t&, wxDataViewItemArray const&) */
+#if wxCHECK_VERSION(2,9,0)
+static bool InitializeColumnDescription(DataBrowserListViewColumnDesc& columnDescription, wxDataViewColumn const* columnPtr, DataBrowserPropertyID columnPropertyID, wxCFStringRef const& title)
+#else
+static bool InitializeColumnDescription(DataBrowserListViewColumnDesc& columnDescription, wxDataViewColumn const* columnPtr, DataBrowserPropertyID columnPropertyID, wxMacCFStringHolder const& title)
+#endif
+{
+ // 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->IsReorderable())
+ columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewMovableColumn;
+ 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 */
+ if (columnPtr->IsSortable())
+ columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewSortableColumn;
+ if (columnPtr->GetRenderer()->GetMode() == wxDATAVIEW_CELL_EDITABLE)
+ columnDescription.propertyDesc.propertyFlags |= kDataBrowserPropertyIsEditable;
+ if ((columnDescription.propertyDesc.propertyType == kDataBrowserCustomType) ||
+ (columnDescription.propertyDesc.propertyType == kDataBrowserDateTimeType) ||
+ (columnDescription.propertyDesc.propertyType == kDataBrowserIconAndTextType) ||
+ (columnDescription.propertyDesc.propertyType == kDataBrowserTextType))
+ 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;
+ 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())
+#if wxCHECK_VERSION(2,9,0)
+ columnDescription.headerBtnDesc.btnContentInfo.u.iconRef = columnPtr->GetBitmap().GetIconRef();
+#else
+ columnDescription.headerBtnDesc.btnContentInfo.u.iconRef = columnPtr->GetBitmap().GetBitmapData()->GetIconRef();
+#endif
+ // done:
+ return true;
+} /* InitializeColumnDescription(DataBrowserListViewColumnDesc&, wxDataViewColumn const*, DataBrowserPropertyID, wxMacCFStringHolder const&) */
+
//-----------------------------------------------------------------------------
// local function pointers
//-----------------------------------------------------------------------------
dataViewEvent.SetEventObject(dataViewCtrlPtr);
dataViewEvent.SetItem(item);
// sent the equivalent wxWidget event:
+#if wxCHECK_VERSION(2,9,0)
+ dataViewCtrlPtr->HandleWindowEvent(dataViewEvent);
+#else
dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
+#endif
// done
return true;
} /* if */
for (size_t i=0; i<noOfEntries; ++i)
{
dataViewEvent.SetItem(reinterpret_cast<void*>(itemIDs[i]));
+#if wxCHECK_VERSION(2,9,0)
+ dataViewCtrlPtr->HandleWindowEvent(dataViewEvent);
+#else
dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
+#endif
} /* for */
} /* if */
// release allocated array space:
dataViewEvent.SetColumn(col);
dataViewEvent.SetItem(item);
// send the equivalent wxWidget event:
+#if wxCHECK_VERSION(2,9,0)
+ dataViewCtrlPtr->HandleWindowEvent(dataViewEvent);
+#else
dataViewCtrlPtr->GetEventHandler()->ProcessEvent(dataViewEvent);
+#endif
// done
return true;
} /* if */
virtual bool Cleared(void)
{
- return (this->m_dataViewControlPtr->RemoveItems() == noErr);
+ bool noFailureFlag = (this->m_dataViewControlPtr->RemoveItems() == noErr);
+ wxDataViewItem item;
+ wxDataViewItemArray array;
+ GetOwner()->GetChildren( item, array );
+ ItemsAdded( item, array );
+ return noFailureFlag;
} /* Cleared(void) */
virtual void Resort(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));
}
{
if ((GetOwner() == NULL) || (GetOwner()->GetOwner() == NULL))
return NULL;
- this->m_DCPtr = new wxClientDC(this->GetOwner()->GetOwner());
+ this->m_DCPtr = new wxWindowDC(this->GetOwner()->GetOwner());
} /* if */
return this->m_DCPtr;
} /* wxDataViewCustomRenderer::GetDC(void) */
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)
bool wxDataViewTextRenderer::Render(void)
{
- if (this->GetValue().GetType() == this->GetVariantType())
- {
- // variable definition:
- wxMacCFStringHolder cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
+ wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Text renderer cannot render value; value type: ")) << this->GetValue().GetType());
- return (::SetDataBrowserItemDataText(this->GetDataReference(),cfString) == noErr);
- } /* if */
- else
- return false;
+ // variable definition:
+#if wxCHECK_VERSION(2,9,0)
+ wxCFStringRef cfString(this->GetValue().GetString(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
+#else
+ 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) */
-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)
+
// ---------------------------------------------------------
// wxDataViewBitmapRenderer
// ---------------------------------------------------------
}
bool wxDataViewBitmapRenderer::Render(void)
+ // 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.
+ // In all other cases the method returns 'false'.
{
- if (this->GetValue().GetType() == this->GetVariantType())
- {
- wxBitmap bitmap;
-
- bitmap << this->GetValue();
- if (bitmap.Ok())
- return (::SetDataBrowserItemDataIcon(this->GetDataReference(),bitmap.GetBitmapData()->GetIconRef()) == noErr);
- else
- return true;
- } /* if */
+ wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Bitmap renderer cannot render value; value type: ")) << this->GetValue().GetType());
+
+ // variable definition:
+ wxBitmap bitmap;
+
+ bitmap << this->GetValue();
+ if (bitmap.Ok())
+#if wxCHECK_VERSION(2,9,0)
+ return (::SetDataBrowserItemDataIcon(this->GetDataReference(),bitmap.GetIconRef()) == noErr);
+#else
+ return (::SetDataBrowserItemDataIcon(this->GetDataReference(),bitmap.GetBitmapData()->GetIconRef()) == noErr);
+#endif
else
- return false;
+ return true;
} /* wxDataViewBitmapRenderer::Render(void) */
-WXDataBrowserPropertyType wxDataViewBitmapRenderer::GetPropertyType() const
+WXDataBrowserPropertyType wxDataViewBitmapRenderer::GetPropertyType(void) const
{
- return kDataBrowserIconType;
-}
+ return kDataBrowserIconType;
+} /* wxDataViewBitmapRenderer::GetPropertyType(void) const */
IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer)
bool wxDataViewIconTextRenderer::Render(void)
{
- if (this->GetValue().GetType() == this->GetVariantType())
- {
- // variable definition:
- wxDataViewIconText iconText;
-
- iconText << this->GetValue();
+ wxCHECK_MSG(this->GetValue().GetType() == this->GetVariantType(),false,wxString(_("Icon & text renderer cannot render value; value type: ")) << this->GetValue().GetType());
- // variable definition:
- wxMacCFStringHolder cfString(iconText.GetText(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
-
- return ((::SetDataBrowserItemDataIcon(this->GetDataReference(),MAC_WXHICON(iconText.GetIcon().GetHICON())) == noErr) &&
- (::SetDataBrowserItemDataText(this->GetDataReference(),cfString) == noErr));
- } /* if */
- else
- return false;
+ // variable definition:
+ wxDataViewIconText iconText;
+
+ iconText << this->GetValue();
+
+ // variable definition:
+#if wxCHECK_VERSION(2,9,0)
+ wxCFStringRef cfString(iconText.GetText(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
+#else
+ wxMacCFStringHolder cfString(iconText.GetText(),(this->GetView()->GetFont().Ok() ? this->GetView()->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
+#endif
+
+ if (iconText.GetIcon().IsOk())
+ if (::SetDataBrowserItemDataIcon(this->GetDataReference(),MAC_WXHICON(iconText.GetIcon().GetHICON())) != noErr)
+ return false;
+ return (::SetDataBrowserItemDataText(this->GetDataReference(),cfString) == noErr);
} /* 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)
bool wxDataViewToggleRenderer::Render(void)
{
- if (this->GetValue().GetType() == this->GetVariantType())
- return (::SetDataBrowserItemDataButtonValue(this->GetDataReference(),this->GetValue().GetBool()) == noErr);
- else
- return false;
+ 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) */
-WXDataBrowserPropertyType wxDataViewToggleRenderer::GetPropertyType() const
+WXDataBrowserPropertyType wxDataViewToggleRenderer::GetPropertyType(void) const
{
- return kDataBrowserCheckboxType;
-}
+ return kDataBrowserCheckboxType;
+} /* wxDataViewToggleRenderer::GetPropertyType(void) const */
IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer)
bool wxDataViewProgressRenderer::Render(void)
{
- if (this->GetValue().GetType() == this->GetVariantType())
- return ((::SetDataBrowserItemDataMinimum(this->GetDataReference(), 0) == noErr) &&
- (::SetDataBrowserItemDataMaximum(this->GetDataReference(),100) == noErr) &&
- (::SetDataBrowserItemDataValue (this->GetDataReference(),this->GetValue().GetLong()) == noErr));
- else
- return false;
+ 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) */
-WXDataBrowserPropertyType wxDataViewProgressRenderer::GetPropertyType() const
+WXDataBrowserPropertyType wxDataViewProgressRenderer::GetPropertyType(void) const
{
- return kDataBrowserProgressBarType;
-}
+ return kDataBrowserProgressBarType;
+} /* wxDataViewProgressRenderer::GetPropertyType(void) const */
IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer,wxDataViewRenderer)
bool wxDataViewDateRenderer::Render(void)
{
- if (this->GetValue().GetType() == this->GetVariantType())
- return (::SetDataBrowserItemDataDateTime(this->GetDataReference(),this->GetValue().GetDateTime().Subtract(wxDateTime(1,wxDateTime::Jan,1904)).GetSeconds().GetLo()) == noErr);
- else
- return false;
+ 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) */
-WXDataBrowserPropertyType wxDataViewDateRenderer::GetPropertyType() const
+WXDataBrowserPropertyType wxDataViewDateRenderer::GetPropertyType(void) const
{
- return kDataBrowserDateTimeType;
-}
+ return kDataBrowserDateTimeType;
+} /* wxDataViewDateRenderer::GetPropertyType(void) const */
IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer,wxDataViewRenderer)
// ---------------------------------------------------------
#pragma mark -
wxDataViewColumn::wxDataViewColumn(wxString const &title, wxDataViewRenderer *cell, unsigned int model_column, int width, wxAlignment align, int flags)
- :wxDataViewColumnBase(title,cell,model_column,width,wxALIGN_CENTER,flags), m_ascending(true),
+ :wxDataViewColumnBase(title,cell,model_column,width,align,flags), m_ascending(true),
m_flags(flags & ~(wxDATAVIEW_COL_HIDDEN)), m_maxWidth(30000), m_minWidth(0), m_width(width >= 0 ? width : wxDVC_DEFAULT_WIDTH),
m_alignment(align), m_title(title)
{
} /* wxDataViewColumn::wxDataViewColumn(wxString const &title, wxDataViewRenderer*, unsigned int, int, wxAlignment, int) */
wxDataViewColumn::wxDataViewColumn(wxBitmap const& bitmap, wxDataViewRenderer *cell, unsigned int model_column, int width, wxAlignment align, int flags)
- :wxDataViewColumnBase(bitmap,cell,model_column,width,wxALIGN_CENTER,flags), m_ascending(true),
+ :wxDataViewColumnBase(bitmap,cell,model_column,width,align,flags), m_ascending(true),
m_flags(flags & ~(wxDATAVIEW_COL_HIDDEN)), m_maxWidth(30000), m_minWidth(0), m_width(width >= 0 ? width : wxDVC_DEFAULT_WIDTH),
m_alignment(align)
{
wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
if (this->GetBitmap().Ok())
+#if wxCHECK_VERSION(2,9,0)
+ headerDescription.btnContentInfo.u.iconRef = this->GetBitmap().GetIconRef();
+#else
headerDescription.btnContentInfo.u.iconRef = this->GetBitmap().GetBitmapData()->GetIconRef();
+#endif
else
headerDescription.btnContentInfo.u.iconRef = NULL;
wxCHECK_RET(macDataViewListCtrlPtr->SetHeaderDesc(this->GetPropertyID(),&headerDescription) == noErr,_("Could not set icon."));
void wxDataViewColumn::SetFlags(int flags)
{
- this->SetHidden ((flags & wxDATAVIEW_COL_HIDDEN) != 0);
- this->SetResizeable((flags & wxDATAVIEW_COL_RESIZABLE) != 0);
- this->SetSortable ((flags & wxDATAVIEW_COL_SORTABLE) != 0);
+ this->SetHidden ((flags & wxDATAVIEW_COL_HIDDEN) != 0);
+ this->SetReorderable((flags & wxDATAVIEW_COL_REORDERABLE) != 0);
+ this->SetResizeable ((flags & wxDATAVIEW_COL_RESIZABLE) != 0);
+ this->SetSortable ((flags & wxDATAVIEW_COL_SORTABLE) != 0);
} /* wxDataViewColumn::SetFlags(int) */
void wxDataViewColumn::SetMaxWidth(int maxWidth)
} /* if */
} /* wxDataViewColumn::SetMaxWidth(int) */
+void wxDataViewColumn::SetReorderable(bool reorderable)
+{
+ // first set the internal flag of the column:
+ if (reorderable)
+ this->m_flags |= wxDATAVIEW_COL_REORDERABLE;
+ else
+ this->m_flags &= ~wxDATAVIEW_COL_REORDERABLE;
+ // if the column is associated with a control change also immediately the flags of the control:
+ wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner()); // variable definition and initialization
+
+ if (dataViewCtrlPtr != NULL)
+ {
+ // variable definition and initialization:
+ DataBrowserPropertyFlags flags;
+ wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
+
+ wxCHECK_RET(macDataViewListCtrlPtr != NULL, _("Valid pointer to native data view control does not exist"));
+ wxCHECK_RET(macDataViewListCtrlPtr->GetPropertyFlags(this->GetPropertyID(),&flags) == noErr,_("Could not get property flags."));
+ if (reorderable)
+ flags |= kDataBrowserListViewMovableColumn;
+ else
+ flags &= ~kDataBrowserListViewMovableColumn;
+ wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(this->GetPropertyID(),flags) == noErr,_("Could not set property flags."));
+ } /* if */
+} /* wxDataViewColumn::SetReorderable(bool) */
+
void wxDataViewColumn::SetResizeable(bool WXUNUSED(resizeable))
{
} /* wxDataViewColumn::SetResizeable(bool) */
void wxDataViewColumn::SetSortable(bool sortable)
{
- // variable definition and initialization:
- wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner());
-
+ // first set the internal flag of the column:
+ if (sortable)
+ this->m_flags |= wxDATAVIEW_COL_SORTABLE;
+ else
+ this->m_flags &= ~wxDATAVIEW_COL_SORTABLE;
+ // if the column is associated with a control change also immediately the flags of the control:
+ wxDataViewCtrl* dataViewCtrlPtr(this->GetOwner()); // variable definition and initialization
+
if (dataViewCtrlPtr != NULL)
{
// variable definition and initialization:
+ DataBrowserPropertyFlags flags;
wxMacDataViewDataBrowserListViewControlPointer macDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(dataViewCtrlPtr->GetPeer()));
- if (macDataViewListCtrlPtr != NULL)
- {
- // variable definition and initialization:
- DataBrowserPropertyFlags flags;
-
- wxCHECK_RET(macDataViewListCtrlPtr->GetPropertyFlags(this->GetPropertyID(),&flags) == noErr,_("Could not get property flags."));
- if (sortable)
- {
- this->m_flags |= wxDATAVIEW_COL_SORTABLE;
- flags |= kDataBrowserListViewSortableColumn;
- } /* if */
- else
- {
- this->m_flags &= ~wxDATAVIEW_COL_SORTABLE;
- flags &= ~kDataBrowserPropertyIsEditable;
- } /* if */
- wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(this->GetPropertyID(),flags) == noErr,_("Could not set property flags."));
- } /* if */
+ wxCHECK_RET(macDataViewListCtrlPtr != NULL, _("Valid pointer to native data view control does not exist"));
+ wxCHECK_RET(macDataViewListCtrlPtr->GetPropertyFlags(this->GetPropertyID(),&flags) == noErr,_("Could not get property flags."));
+ if (sortable)
+ flags |= kDataBrowserListViewSortableColumn;
+ else
+ flags &= ~kDataBrowserListViewSortableColumn;
+ wxCHECK_RET(macDataViewListCtrlPtr->SetPropertyFlags(this->GetPropertyID(),flags) == noErr,_("Could not set property flags."));
} /* if */
} /* wxDataViewColumn::SetSortable(bool) */
{
// variable definition and initialization:
DataBrowserListViewHeaderDesc headerDescription;
+#if wxCHECK_VERSION(2,9,0)
+ wxCFStringRef cfTitle(title,(dataViewCtrlPtr->GetFont().Ok() ? dataViewCtrlPtr->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
+#else
wxMacCFStringHolder cfTitle(title,(dataViewCtrlPtr->GetFont().Ok() ? dataViewCtrlPtr->GetFont().GetEncoding() : wxLocale::GetSystemEncoding()));
+#endif
wxCHECK_RET(macDataViewListCtrlPtr->GetHeaderDesc(this->GetPropertyID(),&headerDescription) == noErr,_("Could not get header description."));
headerDescription.titleString = cfTitle;
#pragma mark -
void wxDataViewCtrl::Init(void)
{
- this->m_Deleting = false;
- this->m_macIsUserPane = false;
- this->m_cgContext = NULL;
+ this->m_CustomRendererPtr = NULL;
+ this->m_Deleting = false;
+ this->m_macIsUserPane = false;
+ this->m_cgContext = NULL;
} /* wxDataViewCtrl::Init(void) */
bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator )
InstallControlEventHandler(this->m_peer->GetControlRef(),GetwxMacDataViewCtrlEventHandlerUPP(),GetEventTypeCount(eventList),eventList,this,NULL);
+ ::SetDataBrowserTableViewHiliteStyle( this->m_peer->GetControlRef(), kDataBrowserTableViewFillHilite );
+
+ ::SetDataBrowserTableViewGeometry( this->m_peer->GetControlRef(), true, false );
+
return true;
} /* wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator) */
+/*static*/
+wxVisualAttributes wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
+{
+ wxVisualAttributes attr;
+
+ attr.colFg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
+ attr.colBg = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX );
+ attr.font.MacCreateFromThemeFont(kThemeViewsFont);
+
+ return attr;
+}
+
bool wxDataViewCtrl::AssociateModel(wxDataViewModel* model)
{
if (!wxDataViewCtrlBase::AssociateModel(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));
-
- // 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))
- {
- // 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;
+#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
- 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;
+ // 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,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)
+ {
+ 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)
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));
#endif
} /* wxDataViewCtrl::AddChildrenLevel(wxDataViewItem const&) */
+void wxDataViewCtrl::FinishCustomItemEditing(void)
+{
+ if (this->GetCustomRendererItem().IsOk())
+ {
+ this->GetCustomRendererPtr()->FinishEditing();
+ this->SetCustomRendererItem(wxDataViewItem());
+ this->SetCustomRendererPtr (NULL);
+ } /* if */
+} /* wxDataViewCtrl::FinishCustomItemEditing(void) */
+
wxDataViewColumn* wxDataViewCtrl::GetColumnPtr(WXDataBrowserPropertyID propertyID) const
{
// variable definition:
// variable definition and initialization:
wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
- (void) MacDataViewListCtrlPtr->SetDisclosureColumn(this->GetExpanderColumn()->GetPropertyID());
+ (void) MacDataViewListCtrlPtr->SetDisclosureColumn(this->GetExpanderColumn()->GetPropertyID(),false); // second parameter explicitely passed to ensure that arrow is centered
} /* if */
} /* wxDataViewCtrl::DoSetExpanderColumn(void) */
dataViewCustomRendererPtr->SetDC(NULL); // reset DC because DC has changed
} /* if */
} /* for */
+
+ wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast<wxMacDataViewDataBrowserListViewControlPointer>(this->m_peer));
+ ControlRef ref = MacDataViewListCtrlPtr->GetControlRef();
+ if (NoOfColumns == 1)
+ {
+ ::SetDataBrowserHasScrollBars( ref, false, true );
+ ::AutoSizeDataBrowserListViewColumns( ref );
+ }
+ if (NoOfColumns > 1)
+ {
+ ::SetDataBrowserHasScrollBars( ref, true, true );
+ }
+
event.Skip();
} /* wxDataViewCtrl::OnSize(wxSizeEvent&) */