X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/03e11df5470fd64d9d9a669d0b50b84c2d714736..6ff68ce9ad2f2b1bc97f45ffefdf6add1fcb7eef:/src/mac/carbon/treectrl.cpp diff --git a/src/mac/carbon/treectrl.cpp b/src/mac/carbon/treectrl.cpp index 67ccc4f022..7977dabef9 100644 --- a/src/mac/carbon/treectrl.cpp +++ b/src/mac/carbon/treectrl.cpp @@ -1,27 +1,24 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: treectrl.cpp +// Name: src/mac/carbon/treectrl.cpp // Purpose: wxTreeCtrl. See also Robert's generic wxTreeCtrl. -// Author: AUTHOR +// Author: Stefan Csomor // Modified by: -// Created: ??/??/98 +// Created: 1998-01-01 // RCS-ID: $Id$ -// Copyright: (c) AUTHOR -// Licence: wxWindows licence +// Copyright: (c) Stefan Csomor +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "treectrl.h" -#endif +#include "wx/wxprec.h" #include "wx/stubs/textctrl.h" #include "wx/treebase.h" #include "wx/stubs/treectrl.h" -#if !USE_SHARED_LIBRARY + IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject) -#endif wxTreeCtrl::wxTreeCtrl() { @@ -30,39 +27,40 @@ wxTreeCtrl::wxTreeCtrl() m_textCtrl = NULL; } -bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, - long style, const wxValidator& validator, const wxString& name) +bool wxTreeCtrl::Create(wxWindow *parent, + wxWindowID id, const wxPoint& pos, const wxSize& size, + long style, const wxValidator& wxVALIDATOR_PARAM(validator), + const wxString& name) { - SetName(name); - SetValidator(validator); - m_imageListNormal = NULL; m_imageListState = NULL; m_textCtrl = NULL; - m_windowStyle = style; - + SetName(name); +#if wxUSE_VALIDATORS + SetValidator(validator); +#endif SetParent(parent); - m_windowId = (id == -1) ? NewControlId() : id; + m_windowStyle = style; + + m_windowId = (id == wxID_ANY) ? NewControlId() : id; - if (parent) parent->AddChild(this); + if (parent) + parent->AddChild(this); - // TODO create tree control + // TODO: create tree control - return FALSE; + return false; } wxTreeCtrl::~wxTreeCtrl() { - if (m_textCtrl) - { - delete m_textCtrl; - } + delete m_textCtrl; } // Attributes -int wxTreeCtrl::GetCount() const +unsigned int wxTreeCtrl::GetCount() const { // TODO return 0; @@ -81,27 +79,21 @@ void wxTreeCtrl::SetIndent(int indent) wxImageList *wxTreeCtrl::GetImageList(int which) const { - if ( which == wxIMAGE_LIST_NORMAL ) - { - return m_imageListNormal; - } - else if ( which == wxIMAGE_LIST_STATE ) - { - return m_imageListState; - } - return NULL; + if ( which == wxIMAGE_LIST_NORMAL ) + return m_imageListNormal; + else if ( which == wxIMAGE_LIST_STATE ) + return m_imageListState; + + return NULL; } void wxTreeCtrl::SetImageList(wxImageList *imageList, int which) { if ( which == wxIMAGE_LIST_NORMAL ) - { m_imageListNormal = imageList; - } else if ( which == wxIMAGE_LIST_STATE ) - { m_imageListState = imageList; - } + // TODO } @@ -114,7 +106,7 @@ long wxTreeCtrl::GetNextItem(long item, int code) const bool wxTreeCtrl::ItemHasChildren(long item) const { // TODO - return FALSE; + return false; } long wxTreeCtrl::GetChild(long item) const @@ -123,7 +115,7 @@ long wxTreeCtrl::GetChild(long item) const return 0; } -long wxTreeCtrl::GetParent(long item) const +long wxTreeCtrl::GetItemParent(long item) const { // TODO return 0; @@ -156,20 +148,20 @@ long wxTreeCtrl::GetRootItem() const bool wxTreeCtrl::GetItem(wxTreeItem& info) const { // TODO - return FALSE; + return false; } bool wxTreeCtrl::SetItem(wxTreeItem& info) { // TODO - return FALSE; + return false; } int wxTreeCtrl::GetItemState(long item, long stateMask) const { wxTreeItem info; - info.m_mask = wxTREE_MASK_STATE ; + info.m_mask = wxTREE_MASK_STATE; info.m_stateMask = stateMask; info.m_itemId = item; @@ -183,7 +175,7 @@ bool wxTreeCtrl::SetItemState(long item, long state, long stateMask) { wxTreeItem info; - info.m_mask = wxTREE_MASK_STATE ; + info.m_mask = wxTREE_MASK_STATE; info.m_state = state; info.m_stateMask = stateMask; info.m_itemId = item; @@ -195,13 +187,14 @@ bool wxTreeCtrl::SetItemImage(long item, int image, int selImage) { wxTreeItem info; - info.m_mask = wxTREE_MASK_IMAGE ; + info.m_mask = wxTREE_MASK_IMAGE; info.m_image = image; if ( selImage > -1) { info.m_selectedImage = selImage; info.m_mask |= wxTREE_MASK_SELECTED_IMAGE; } + info.m_itemId = item; return SetItem(info); @@ -211,11 +204,12 @@ wxString wxTreeCtrl::GetItemText(long item) const { wxTreeItem info; - info.m_mask = wxTREE_MASK_TEXT ; + info.m_mask = wxTREE_MASK_TEXT; info.m_itemId = item; if (!GetItem(info)) - return wxString(""); + return wxEmptyString; + return info.m_text; } @@ -223,7 +217,7 @@ void wxTreeCtrl::SetItemText(long item, const wxString& str) { wxTreeItem info; - info.m_mask = wxTREE_MASK_TEXT ; + info.m_mask = wxTREE_MASK_TEXT; info.m_itemId = item; info.m_text = str; @@ -234,11 +228,12 @@ long wxTreeCtrl::GetItemData(long item) const { wxTreeItem info; - info.m_mask = wxTREE_MASK_DATA ; + info.m_mask = wxTREE_MASK_DATA; info.m_itemId = item; if (!GetItem(info)) return 0; + return info.m_data; } @@ -246,7 +241,7 @@ bool wxTreeCtrl::SetItemData(long item, long data) { wxTreeItem info; - info.m_mask = wxTREE_MASK_DATA ; + info.m_mask = wxTREE_MASK_DATA; info.m_itemId = item; info.m_data = data; @@ -256,10 +251,10 @@ bool wxTreeCtrl::SetItemData(long item, long data) bool wxTreeCtrl::GetItemRect(long item, wxRect& rect, bool textOnly) const { // TODO - return FALSE; + return false; } -wxTextCtrl* wxTreeCtrl::GetEditControl() const +wxTextCtrl * wxTreeCtrl::GetEditControl() const { return m_textCtrl; } @@ -268,56 +263,61 @@ wxTextCtrl* wxTreeCtrl::GetEditControl() const bool wxTreeCtrl::DeleteItem(long item) { // TODO - return FALSE; + return false; } bool wxTreeCtrl::ExpandItem(long item, int action) { // TODO - switch ( action ) - { + switch ( action ) + { case wxTREE_EXPAND_EXPAND: - break; + break; case wxTREE_EXPAND_COLLAPSE: - break; + break; case wxTREE_EXPAND_COLLAPSE_RESET: - break; + break; case wxTREE_EXPAND_TOGGLE: - break; + break; default: - wxFAIL_MSG("unknown action in wxTreeCtrl::ExpandItem"); - } - - bool bOk = FALSE; // TODO expand item - - // May not send messages, so emulate them - if ( bOk ) { - wxTreeEvent event(wxEVT_NULL, m_windowId); - event.m_item.m_itemId = item; - event.m_item.m_mask = - event.m_item.m_stateMask = 0xffff; // get all - GetItem(event.m_item); - - bool bIsExpanded = (event.m_item.m_state & wxTREE_STATE_EXPANDED) != 0; - - event.m_code = action; - event.SetEventObject(this); + wxFAIL_MSG(wxT("unknown action in wxTreeCtrl::ExpandItem"); + } - // @@@ return values of {EXPAND|COLLAPS}ING event handler is discarded - event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDING - : wxEVT_COMMAND_TREE_ITEM_COLLAPSING); - GetEventHandler()->ProcessEvent(event); + // TODO: expand item + bool bOk = false; - event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDED - : wxEVT_COMMAND_TREE_ITEM_COLLAPSED); - GetEventHandler()->ProcessEvent(event); - } + // May not send messages, so emulate them + if ( bOk ) + { + wxTreeEvent event(wxEVT_NULL, m_windowId); + event.m_item.m_itemId = item; + event.m_item.m_mask = event.m_item.m_stateMask = 0xFFFF; // get all + GetItem(event.m_item); + + bool bIsExpanded = (event.m_item.m_state & wxTREE_STATE_EXPANDED) != 0; + + event.m_code = action; + event.SetEventObject(this); + + // @@@ return values of {EXPAND|COLLAPS}ING event handler is discarded + event.SetEventType( + bIsExpanded + ? wxEVT_COMMAND_TREE_ITEM_EXPANDING + : wxEVT_COMMAND_TREE_ITEM_COLLAPSING); + GetEventHandler()->ProcessEvent(event); + + event.SetEventType( + bIsExpanded + ? wxEVT_COMMAND_TREE_ITEM_EXPANDED + : wxEVT_COMMAND_TREE_ITEM_COLLAPSED); + GetEventHandler()->ProcessEvent(event); + } - return bOk; + return bOk; } long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter) @@ -326,8 +326,8 @@ long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter) return 0; } -long wxTreeCtrl::InsertItem(long parent, const wxString& label, int image, int selImage, - long insertAfter) +long wxTreeCtrl::InsertItem(long parent, const wxString& label, + int image, int selImage, long insertAfter) { wxTreeItem info; info.m_text = label; @@ -348,22 +348,22 @@ long wxTreeCtrl::InsertItem(long parent, const wxString& label, int image, int s bool wxTreeCtrl::SelectItem(long item) { // TODO - return FALSE; + return false; } bool wxTreeCtrl::ScrollTo(long item) { // TODO - return FALSE; + return false; } bool wxTreeCtrl::DeleteAllItems() { // TODO - return FALSE; + return false; } -wxTextCtrl* wxTreeCtrl::EditLabel(long item, wxClassInfo* textControlClass) +wxTextCtrl * wxTreeCtrl::EditLabel(long item, wxClassInfo* textControlClass) { // TODO return NULL; @@ -373,7 +373,7 @@ wxTextCtrl* wxTreeCtrl::EditLabel(long item, wxClassInfo* textControlClass) bool wxTreeCtrl::EndEditLabel(bool cancel) { // TODO - return FALSE; + return false; } long wxTreeCtrl::HitTest(const wxPoint& point, int& flags) @@ -385,13 +385,13 @@ long wxTreeCtrl::HitTest(const wxPoint& point, int& flags) bool wxTreeCtrl::SortChildren(long item) { // TODO - return FALSE; + return false; } bool wxTreeCtrl::EnsureVisible(long item) { // TODO - return FALSE; + return false; } // Tree item structure @@ -410,10 +410,9 @@ wxTreeItem::wxTreeItem() // Tree event IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxCommandEvent) -wxTreeEvent::wxTreeEvent(wxEventType commandType, int id): - wxCommandEvent(commandType, id) +wxTreeEvent::wxTreeEvent(wxEventType commandType, int id) + : wxCommandEvent(commandType, id) { m_code = 0; m_oldItem = 0; } -