X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a881f34e499feadfef915b9d4c80e45a73ba37d4..b18e2046af6c8eaf6e867ba18dd9410dbd7dfcf7:/src/osx/carbon/dataview.cpp diff --git a/src/osx/carbon/dataview.cpp b/src/osx/carbon/dataview.cpp index bf7479c4cf..997d24de1e 100644 --- a/src/osx/carbon/dataview.cpp +++ b/src/osx/carbon/dataview.cpp @@ -133,7 +133,8 @@ static bool InitializeColumnDescription(DataBrowserListViewColumnDesc& columnDes } if (columnPtr->IsSortable()) columnDescription.propertyDesc.propertyFlags |= kDataBrowserListViewSortableColumn; - if (columnPtr->GetRenderer()->GetMode() == wxDATAVIEW_CELL_EDITABLE) + if ((columnPtr->GetRenderer()->GetMode() == wxDATAVIEW_CELL_EDITABLE) || + (columnPtr->GetRenderer()->GetMode() == wxDATAVIEW_CELL_ACTIVATABLE)) columnDescription.propertyDesc.propertyFlags |= kDataBrowserPropertyIsEditable; if ((columnDescription.propertyDesc.propertyType == kDataBrowserCustomType) || (columnDescription.propertyDesc.propertyType == kDataBrowserDateTimeType) || @@ -489,7 +490,7 @@ void wxDataViewRenderer::SetMode(wxDataViewCellMode mode) DataBrowserPropertyFlags flags; verify_noerr(macDataViewListCtrlPtr->GetPropertyFlags(dataViewColumnPtr->GetPropertyID(),&flags)); - if (mode == wxDATAVIEW_CELL_EDITABLE) + if ((mode == wxDATAVIEW_CELL_EDITABLE) || (mode == wxDATAVIEW_CELL_ACTIVATABLE)) flags |= kDataBrowserPropertyIsEditable; else flags &= ~kDataBrowserPropertyIsEditable; @@ -620,7 +621,7 @@ IMPLEMENT_CLASS(wxDataViewBitmapRenderer,wxDataViewRenderer) // --------------------------------------------------------- // wxDataViewIconTextRenderer // --------------------------------------------------------- -wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align) +wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(wxString const& varianttype, wxDataViewCellMode mode, int WXUNUSED(align)) :wxDataViewRenderer(varianttype,mode) { } @@ -652,7 +653,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewIconTextRenderer,wxDataViewRenderer) // --------------------------------------------------------- // wxDataViewToggleRenderer // --------------------------------------------------------- -wxDataViewToggleRenderer::wxDataViewToggleRenderer(wxString const& varianttype, wxDataViewCellMode mode, int align) +wxDataViewToggleRenderer::wxDataViewToggleRenderer(wxString const& varianttype, wxDataViewCellMode mode, int WXUNUSED(align)) :wxDataViewRenderer(varianttype,mode) { } @@ -673,7 +674,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer,wxDataViewRenderer) // --------------------------------------------------------- // wxDataViewProgressRenderer // --------------------------------------------------------- -wxDataViewProgressRenderer::wxDataViewProgressRenderer(wxString const& label, wxString const& varianttype, wxDataViewCellMode mode, int align) +wxDataViewProgressRenderer::wxDataViewProgressRenderer(wxString const& WXUNUSED(label), wxString const& varianttype, wxDataViewCellMode mode, int align) :wxDataViewRenderer(varianttype,mode,align) { } @@ -1027,14 +1028,22 @@ bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, return true; } +wxSize wxDataViewCtrl::DoGetBestSize() const +{ + wxSize best = wxControl::DoGetBestSize(); + best.y = 80; + + return best; +} + /*static*/ -wxVisualAttributes wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant variant) +wxVisualAttributes wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) { wxVisualAttributes attr; attr.colFg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ); attr.colBg = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX ); - attr.font.MacCreateFromThemeFont(kThemeViewsFont); + //attr.font.CreateSystemFont(wxOSX_SYSTEM_FONT_VIEWS); return attr; } @@ -1051,12 +1060,12 @@ bool wxDataViewCtrl::AssociateModel(wxDataViewModel* model) bool wxDataViewCtrl::AppendColumn(wxDataViewColumn* columnPtr) { - return InsertColumn( kDataBrowserListViewAppendColumn, columnPtr ); + return wxDataViewCtrl::InsertColumn( GetColumnCount(), columnPtr ); } bool wxDataViewCtrl::PrependColumn(wxDataViewColumn* columnPtr) { - return InsertColumn( 0, columnPtr ); + return wxDataViewCtrl::InsertColumn( 0, columnPtr ); } bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr) @@ -1083,7 +1092,7 @@ bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr) // full column variable initialization: columnPtr->SetPropertyID(NewPropertyID); // add column to wxWidget's internal structure: - wxCHECK_MSG(this->wxDataViewCtrlBase::AppendColumn(columnPtr) && + wxCHECK_MSG(this->wxDataViewCtrlBase::InsertColumn(pos,columnPtr) && 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.")); @@ -1183,7 +1192,7 @@ void wxDataViewCtrl::Collapse(wxDataViewItem const& item) void wxDataViewCtrl::EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) { - wxDataViewCtrlBase::EnsureVisible(item,columnPtr); + ExpandAncestors(item); if (item.IsOk()) { @@ -1296,7 +1305,7 @@ int wxDataViewCtrl::GetSelections(wxDataViewItemArray& sel) const return static_cast(NoOfSelectedItems); } -void wxDataViewCtrl::HitTest(wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const +void wxDataViewCtrl::HitTest(wxPoint const& WXUNUSED(point), wxDataViewItem& item, wxDataViewColumn*& columnPtr) const { item = wxDataViewItem(); columnPtr = NULL; @@ -1334,6 +1343,8 @@ void wxDataViewCtrl::Select(wxDataViewItem const& item) { if (item.IsOk()) { + ExpandAncestors(item); + DataBrowserItemID itemID(reinterpret_cast(item.GetID())); wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(m_peer)); @@ -1343,18 +1354,31 @@ void wxDataViewCtrl::Select(wxDataViewItem const& item) void wxDataViewCtrl::SetSelections(wxDataViewItemArray const& sel) { - size_t const NoOfSelections = sel.GetCount(); + size_t const NoOfSelections = sel.GetCount(); - DataBrowserItemID* itemIDs; + wxDataViewItem last_parent; - wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(m_peer)); + size_t i; + for (i = 0; i < NoOfSelections; i++) + { + wxDataViewItem item = sel[i]; + wxDataViewItem parent = GetModel()->GetParent( item ); + if (parent) + { + if (parent != last_parent) + ExpandAncestors(item); + } + last_parent = parent; + } + DataBrowserItemID* itemIDs; + wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(m_peer)); - itemIDs = new DataBrowserItemID[NoOfSelections]; - for (size_t i=0; i(sel[i].GetID()); - MacDataViewListCtrlPtr->SetSelectedItems(NoOfSelections,itemIDs,kDataBrowserItemsAssign); - delete[] itemIDs; + itemIDs = new DataBrowserItemID[NoOfSelections]; + for (i=0; i(sel[i].GetID()); + MacDataViewListCtrlPtr->SetSelectedItems(NoOfSelections,itemIDs,kDataBrowserItemsAssign); + delete[] itemIDs; } void wxDataViewCtrl::Unselect(wxDataViewItem const& item) @@ -1445,6 +1469,56 @@ void wxDataViewCtrl::DoSetIndent() } // event handling: +void wxDataViewCtrl::OnMouse(wxMouseEvent& event) +{ + event.Skip(); + + if (GetModel() == NULL) + return; + + wxMacDataViewDataBrowserListViewControlPointer MacDataViewListCtrlPtr(dynamic_cast(m_peer)); + + int NoOfChildren; + wxDataViewItemArray items; + NoOfChildren = GetModel()->GetChildren( wxDataViewItem(), items); + if (NoOfChildren == 0) + return; + wxDataViewItem firstChild = items[0]; + + UInt16 headerHeight = 0; + MacDataViewListCtrlPtr->GetHeaderButtonHeight(&headerHeight); + + + if (event.GetY() < headerHeight) + { + unsigned int col_count = GetColumnCount(); + unsigned int col; + for (col = 0; col < col_count; col++) + { + wxDataViewColumn *column = GetColumn( col ); + if (column->IsHidden()) + continue; + + Rect itemrect; + ::GetDataBrowserItemPartBounds( MacDataViewListCtrlPtr->GetControlRef(), + reinterpret_cast(firstChild.GetID()), column->GetPropertyID(), + kDataBrowserPropertyEnclosingPart, &itemrect ); + + if (abs( event.GetX() - itemrect.right) < 3) + { + if (column->GetFlags() & wxDATAVIEW_COL_RESIZABLE) + SetCursor( wxCursor( wxCURSOR_SIZEWE ) ); + else + SetCursor( *wxSTANDARD_CURSOR ); + return; + } + } + + } + + SetCursor( *wxSTANDARD_CURSOR ); +} + void wxDataViewCtrl::OnSize(wxSizeEvent& event) { unsigned int const NoOfColumns = this->GetColumnCount(); @@ -1482,6 +1556,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl,wxDataViewCtrlBase) BEGIN_EVENT_TABLE(wxDataViewCtrl,wxDataViewCtrlBase) EVT_SIZE(wxDataViewCtrl::OnSize) + EVT_MOTION(wxDataViewCtrl::OnMouse) END_EVENT_TABLE() #endif // !wxUSE_GENERICDATAVIEWCTRL