/////////////////////////////////////////////////////////////////////////////
// Name: treectrl.cpp
-// Purpose:
+// Purpose: wxTreeCtrl
// Author: Denis Pershin
+// Modified by:
// Created: 07/05/98
-// Id: $Id$
-// Copyright: (c) 1998 Denis Pershin and Julian Smart
+// RCS-ID: $Id$
+// Copyright: (c) Denis Pershin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#pragma implementation "treectrl.h"
#endif
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+
#include "wx/gtk/treectrl.h"
-#include "wx/settings.h"
#include "wx/log.h"
-#ifdef wxUSE_GDK_IMLIB
-#include "../gdk_imlib/gdk_imlib.h"
-#endif
+#include <gtk/gtk.h>
-//-----------------------------------------------------------------------------
-// wxTreeItem
-//-----------------------------------------------------------------------------
+static void wxConvertToGtkTreeItem(wxTreeCtrl *owner, wxTreeItem& info, GtkTreeItem **gtkItem);
+static void wxConvertFromGtkTreeItem(wxTreeItem& info, GtkTreeItem *gtkItem);
+static void gtk_treectrl_count_callback (GtkWidget *widget, gpointer data);
+// static void gtk_treectrl_next_callback (GtkWidget *widget, gpointer data);
+// static void gtk_treectrl_next_visible_callback (GtkWidget *widget, gpointer data);
+// static void gtk_treectrl_next_selected_callback (GtkWidget *widget, gpointer data);
-// clicked
+static void gtk_treeitem_expand_callback(GtkWidget *WXUNUSED(widget), wxTreeItem *treeitem);
+static void gtk_treeitem_collapse_callback( GtkWidget *WXUNUSED(widget), wxTreeItem *treeitem);
+static void gtk_treeitem_select_callback( GtkWidget *WXUNUSED(widget), wxTreeItem *treeitem);
-void gtk_treeitem_expand_callback(GtkWidget *WXUNUSED(widget), wxTreeItem *treeitem) {
- if (treeitem->ignore)
+static void gtk_treeitem_expand_callback(GtkWidget *widget, wxTreeItem *treeitem)
+{
+ wxTreeCtrl *owner = (wxTreeCtrl *)gtk_object_get_data(GTK_OBJECT(widget), "owner");
+ if (owner == NULL)
return;
- treeitem->SendExpanding(treeitem->m_owner);
- treeitem->SendExpand(treeitem->m_owner);
+
+ long id = (long)gtk_object_get_data(GTK_OBJECT(widget), "id");
+ owner->SendExpanding(id);
+ owner->SendExpanded(id);
};
-void gtk_treeitem_collapse_callback( GtkWidget *WXUNUSED(widget), wxTreeItem *treeitem) {
- if (treeitem->ignore)
+static void gtk_treeitem_collapse_callback(GtkWidget *widget, wxTreeItem *treeitem)
+{
+ wxTreeCtrl *owner = (wxTreeCtrl *)gtk_object_get_data(GTK_OBJECT(widget), "owner");
+ if (owner == NULL)
return;
- treeitem->SendCollapsing(treeitem->m_owner);
- treeitem->SendCollapse(treeitem->m_owner);
+
+ long id = (long)gtk_object_get_data(GTK_OBJECT(widget), "id");
+ owner->SendCollapsing(id);
+ owner->SendCollapsed(id);
};
-void gtk_treeitem_select_callback( GtkWidget *WXUNUSED(widget), wxTreeItem *treeitem) {
- treeitem->SendSelChanging(treeitem->m_owner);
- treeitem->m_state |= wxTREE_STATE_SELECTED;
- treeitem->SendSelChanged(treeitem->m_owner);
+static void gtk_treeitem_select_callback(GtkWidget *widget, wxTreeItem *treeitem)
+{
+ wxTreeCtrl *owner = (wxTreeCtrl *)gtk_object_get_data(GTK_OBJECT(widget), "owner");
+ if (owner == NULL)
+ return;
+
+ long id = (long)gtk_object_get_data(GTK_OBJECT(widget), "id");
+ owner->SendSelChanging(id);
+ owner->SendSelChanged(id);
}
-void gtk_treeitem_deselect_callback( GtkWidget *WXUNUSED(widget), wxTreeItem *treeitem) {
- treeitem->SendSelChanging(treeitem->m_owner);
- treeitem->m_state &= !wxTREE_STATE_SELECTED;
- treeitem->SendSelChanged(treeitem->m_owner);
+#if !USE_SHARED_LIBRARY
+ IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl)
+ IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject)
+#endif
+
+wxTreeCtrl::wxTreeCtrl()
+{
+ m_imageListNormal = NULL;
+ m_imageListState = NULL;
+ m_textCtrl = NULL;
+ m_curitemId = 1;
}
-IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject)
+bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
+ long style, const wxValidator& validator, const wxString& name)
+{
+ m_imageListNormal = NULL;
+ m_imageListState = NULL;
+ m_textCtrl = NULL;
+ m_curitemId = 1;
-wxTreeItem::wxTreeItem() {
- m_mask = 0;
- m_itemId = 0;
- m_state = 0;
- m_stateMask = 0;
- m_image = -1;
- m_children = 0;
- m_selectedImage = -1;
- m_tree = NULL;
- m_parentwidget = NULL;
- m_widget = NULL;
- m_data = 0;
- m_owner = 0;
- expand_handler = 0;
- collapse_handler = 0;
-};
+ int x = pos.x;
+ int y = pos.y;
+ int width = size.x;
+ int height = size.y;
-wxTreeItem::wxTreeItem(GtkWidget *parent, const wxTreeItem &item) {
- m_mask = item.m_mask;
- m_text = item.m_text;
- m_itemId = item.m_itemId;
- m_state = item.m_state;
- m_stateMask = item.m_stateMask;
- m_image = item.m_image;
- m_tree = NULL;
- m_owner = 0;
- m_selectedImage = item.m_selectedImage;
- m_children = item.m_children;
- m_childlist = item.m_childlist;
- m_data = item.m_data;
- m_parentwidget = parent;
- expand_handler = 0;
- collapse_handler = 0;
-
- Create();
-}
-
-void wxTreeItem::Create() {
- wxASSERT(m_parentwidget != NULL);
-
- m_widget = GTK_TREE_ITEM(gtk_tree_item_new_with_label ((char *)(const char *)m_text));
- gtk_container_add (GTK_CONTAINER(m_parentwidget), GTK_WIDGET(m_widget));
- gtk_widget_show(GTK_WIDGET(m_widget));
-
- ignore = FALSE;
-
- gtk_signal_connect(GTK_OBJECT(m_widget), "select",
- GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this );
-
- gtk_signal_connect(GTK_OBJECT(m_widget), "deselect",
- GTK_SIGNAL_FUNC(gtk_treeitem_deselect_callback), (gpointer)this );
-
- if (expand_handler == 0)
- expand_handler = gtk_signal_connect(GTK_OBJECT(m_widget), "expand",
- GTK_SIGNAL_FUNC(gtk_treeitem_expand_callback), (gpointer)this );
-
- if (collapse_handler == 0)
- collapse_handler = gtk_signal_connect( GTK_OBJECT(m_widget), "collapse",
- GTK_SIGNAL_FUNC(gtk_treeitem_collapse_callback), (gpointer)this );
-
- if ((m_mask & wxTREE_MASK_CHILDREN) != 0)
- AddSubtree();
-}
-
-wxTreeItem::~wxTreeItem() {
- if (m_owner != NULL)
- SendDelete(m_owner);
- DeleteChildren();
- if ((m_widget != NULL) && (m_parentwidget != NULL))
- gtk_container_remove(GTK_CONTAINER(m_parentwidget),
- GTK_WIDGET(m_widget));
-// if (m_tree != NULL) {
-// gtk_widget_destroy(GTK_WIDGET(m_tree));
-// m_tree = NULL;
-// }
-
-// if (m_widget != NULL)
-// gtk_widget_destroy(GTK_WIDGET(m_widget));
-}
-
-void wxTreeItem::AddSubtree() {
- if (m_widget == NULL)
- return;
+ m_windowStyle = style;
+
+ SetParent(parent);
+
+ if (width <= 0)
+ width = 100;
+ if (height <= 0)
+ height = 30;
+ if (x < 0)
+ x = 0;
+ if (y < 0)
+ y = 0;
+
+ m_needParent = TRUE;
+
+ PreCreation( parent, id, pos, size, style, name );
+
+ m_widget = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(m_widget),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
m_tree = GTK_TREE(gtk_tree_new());
- gtk_tree_item_set_subtree(GTK_TREE_ITEM(m_widget), GTK_WIDGET(m_tree));
+
+ gtk_container_add(GTK_CONTAINER(m_widget), GTK_WIDGET(m_tree));
gtk_widget_show(GTK_WIDGET(m_tree));
- ignore = TRUE;
- gtk_tree_item_expand(m_widget);
- gtk_tree_item_collapse(m_widget);
- ignore = FALSE;
+ wxSystemSettings settings;
+ SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW));
+ SetForegroundColour(parent->GetForegroundColour());
+
+ SetName(name);
+ SetValidator(validator);
+
+ PostCreation();
+
+ gtk_widget_realize(GTK_WIDGET(m_tree));
+
+ Show(TRUE);
+
+ return TRUE;
}
-void wxTreeItem::AddChild(wxTreeItem *child) {
- wxASSERT(child != NULL);
+wxTreeCtrl::~wxTreeCtrl()
+{
+ wxDELETE(m_textCtrl);
+}
+
+// Attributes
+static void gtk_treectrl_count_callback (GtkWidget *widget, gpointer data)
+{
+ int count = (*((int *)data));
- m_childlist.Append(child);
+ count++;
+ if (GTK_IS_CONTAINER(widget))
+ gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_count_callback, data);
}
-bool wxTreeItem::HasChildren() {
- return (m_childlist.Number() != 0);
+int wxTreeCtrl::GetCount() const
+{
+ int count = 0;
+
+ if (m_anchor != NULL)
+ gtk_container_foreach(GTK_CONTAINER(m_anchor), gtk_treectrl_count_callback, &count);
+ return count;
}
-void wxTreeItem::DeleteChildren() {
- wxTreeItem *item;
-
- long no = GetChildrenNumber();
- for (long i=0; i<no; i++)
- if ((item = GetChild(i)) != 0)
- delete item;
- m_childlist.Clear();
-
- if ((no == 0) && (m_widget != NULL))
- gtk_tree_item_remove_subtree(m_widget);
+int wxTreeCtrl::GetIndent() const
+{
+ return m_tree->indent_value;
+}
- m_tree = NULL;
-
- if ((m_mask & wxTREE_MASK_CHILDREN) != 0)
- if (m_widget != NULL)
- if (m_widget->subtree == 0)
- AddSubtree();
-}
-
-int wxTreeItem::NumberOfVisibleDescendents() {
- wxTreeItem *item;
- long no = GetChildrenNumber();
- long num = 0;
- for (long i=0; i<no; i++)
- if ((item = GetChild(i)) != 0)
- num += item->NumberOfVisibleDescendents();
+void wxTreeCtrl::SetIndent(int indent)
+{
+ m_tree->indent_value = 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;
+}
+
+void wxTreeCtrl::SetImageList(wxImageList *imageList, int which)
+{
+ if (which == wxIMAGE_LIST_NORMAL)
+ m_imageListNormal = imageList;
+ else
+ if (which == wxIMAGE_LIST_STATE)
+ m_imageListState = imageList;
+}
+
+long wxTreeCtrl::GetNextItem(long item, int code) const
+{
+ switch (code) {
+ case wxTREE_NEXT_CARET:
+// flag = TVGN_CARET;
+ break;
+ case wxTREE_NEXT_CHILD:
+// flag = TVGN_CHILD;
+ break;
+ case wxTREE_NEXT_DROPHILITE:
+// flag = TVGN_DROPHILITE;
+ break;
+ case wxTREE_NEXT_FIRSTVISIBLE:
+// flag = TVGN_FIRSTVISIBLE;
+ break;
+ case wxTREE_NEXT_NEXT:
+// flag = TVGN_NEXT;
+ break;
+ case wxTREE_NEXT_NEXTVISIBLE:
+// flag = TVGN_NEXTVISIBLE;
+ break;
+ case wxTREE_NEXT_PARENT:
+// flag = TVGN_PARENT;
+ break;
+ case wxTREE_NEXT_PREVIOUS:
+// flag = TVGN_PREVIOUS;
+ break;
+ case wxTREE_NEXT_PREVIOUSVISIBLE:
+// flag = TVGN_PREVIOUSVISIBLE;
+ break;
+ case wxTREE_NEXT_ROOT:
+// flag = TVGN_ROOT;
+ break;
+
+ default :
+ break;
+ }
+// return (long) TreeView_GetNextItem( (HWND) GetHWND(), (HTREEITEM) item, flag);
+ return 0;
+}
+
+bool wxTreeCtrl::ItemHasChildren(long item) const
+{
+ GtkTreeItem *p;
+ int count = 0;
+
+ p = findGtkTreeItem(item);
- num+=no;
+ gtk_container_foreach(GTK_CONTAINER(p), gtk_treectrl_count_callback, &count);
- return num;
+ return (count != 0);
}
-wxTreeItem *wxTreeItem::FindItem(long itemId) const {
- if (m_itemId == itemId) return (wxTreeItem*)(this);
- wxNode *node = m_childlist.First();
- while (node) {
- wxTreeItem *item = (wxTreeItem*)node->Data();
- wxTreeItem *res = item->FindItem( itemId );
- if (res) return (wxTreeItem*)(res);
- node = node->Next();
- };
- return NULL;
-};
+static GtkTreeItem *findItem(GtkTreeItem *p, long id)
+{
+ GtkTreeItem *q;
-wxTreeItem *wxTreeItem::FindItem(GtkTreeItem *item) const {
- if (m_widget == item)
- return (wxTreeItem*)(this);
- wxNode *node = m_childlist.First();
- while (node) {
- wxTreeItem *i = (wxTreeItem*)node->Data();
- wxTreeItem *res = i->FindItem(item);
- if (res) return (wxTreeItem*)(res);
- node = node->Next();
- };
- return NULL;
-};
+ if (((long)gtk_object_get_data(GTK_OBJECT(p), "id")) == id)
+ return p;
-void wxTreeItem::PrepareEvent(wxTreeEvent &event) {
- event.m_item.m_itemId = m_itemId;
- event.m_item.m_state = m_state;
- event.m_item.m_text = m_text;
- event.m_item.m_image = m_image;
- event.m_item.m_selectedImage = m_selectedImage;
- event.m_item.m_children = (GetChildrenNumber() > 0);
- event.m_item.m_data = m_data;
- event.m_oldItem = 0;
- event.m_code = 0;
-// event.m_pointDrag.x = 0;
-// event.m_pointDrag.y = 0;
-};
+ if (p->subtree == NULL)
+ return NULL;
-void wxTreeItem::SendDelete(wxWindow *target) {
- wxTreeEvent event(wxEVT_COMMAND_TREE_DELETE_ITEM, target->GetId());
- PrepareEvent(event);
- event.SetEventObject(target);
- target->ProcessEvent(event);
-};
+ GtkTree *tree = GTK_TREE(p->subtree);
-void wxTreeItem::SendExpand(wxWindow *target) {
- wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_EXPANDED, target->GetId());
- PrepareEvent(event);
- event.SetEventObject(target);
- target->ProcessEvent(event);
-};
+ GList *list = gtk_container_children(GTK_CONTAINER(tree));
+ guint len = g_list_length(list);
-void wxTreeItem::SendExpanding(wxWindow *target) {
- wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_EXPANDING, target->GetId());
- PrepareEvent(event);
- event.SetEventObject(target);
- target->ProcessEvent(event);
-};
+ for (guint i=0; i<len;i++) {
+ GList *l = g_list_nth(list, i);
+ if (!GTK_IS_TREE_ITEM(l->data))
+ continue;
+ q = GTK_TREE_ITEM(l->data);
+ GtkTreeItem *ret = findItem(q, id);
+ if (ret != NULL)
+ return ret;
+ }
-void wxTreeItem::SendCollapse(wxWindow *target) {
- wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_COLLAPSED, target->GetId());
- PrepareEvent(event);
- event.SetEventObject(target);
- target->ProcessEvent(event);
-};
+ return NULL;
+}
-void wxTreeItem::SendCollapsing(wxWindow *target) {
- wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_COLLAPSING, target->GetId());
- PrepareEvent(event);
- event.SetEventObject(target);
- target->ProcessEvent(event);
-};
+GtkTreeItem *wxTreeCtrl::findGtkTreeItem(long id) const
+{
+ return findItem(m_anchor, id);
+}
-void wxTreeItem::SendSelChanged(wxWindow *target) {
- wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGED, target->GetId());
- PrepareEvent(event);
- event.SetEventObject(target);
- target->ProcessEvent(event);
-};
+long wxTreeCtrl::GetChild(long item) const
+{
+ GtkTreeItem *p;
+ GtkTreeItem *next = NULL;
-void wxTreeItem::SendSelChanging(wxWindow *target) {
- wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, target->GetId());
- PrepareEvent(event);
- event.SetEventObject(target);
- target->ProcessEvent(event);
-};
+ p = findGtkTreeItem(item);
+ GList *list = gtk_container_children(GTK_CONTAINER(p));
+ next = GTK_TREE_ITEM(list->data);;
-//-----------------------------------------------------------------------------
-// wxTreeCtrl
-//-----------------------------------------------------------------------------
+ if (next != NULL)
+ return (long)gtk_object_get_data(GTK_OBJECT(next), "id");
+
+ return (-1);
+}
-IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxScrolledWindow)
+long wxTreeCtrl::GetParent(long item) const
+{
+ GtkTreeItem *p;
-wxTreeCtrl::wxTreeCtrl() {
- m_current = NULL;
- m_lastId = 0;
- m_isCreated = FALSE;
- m_imageList = NULL;
- m_smallImageList = NULL;
-};
+ p = findGtkTreeItem(item);
+ if (p != NULL)
+ return (long)gtk_object_get_data(GTK_OBJECT(p), "parent");
-wxTreeCtrl::wxTreeCtrl(wxWindow *parent, wxWindowID id,
- const wxPoint& pos, const wxSize& size,
- long style, const wxString& name ) {
- m_current = NULL;
- m_lastId = 0;
- m_isCreated = FALSE;
- m_imageList = NULL;
- m_smallImageList = NULL;
- Create( parent, id, pos, size, style, name );
-};
+ return (-1);
+}
-wxTreeCtrl::~wxTreeCtrl() {
- DeleteAllItems();
-};
+long wxTreeCtrl::GetFirstVisibleItem() const
+{
+ GtkTreeItem *next = NULL;
-bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos, const wxSize& size,
- long style, const wxString& name ) {
- m_needParent = TRUE;
+ GList *list = gtk_container_children(GTK_CONTAINER(m_anchor));
+ next = GTK_TREE_ITEM(list->data);;
+// gtk_container_foreach(GTK_CONTAINER(m_anchor), gtk_treectrl_next_visible_callback, &next);
+
+ if (next != NULL)
+ return (long)gtk_object_get_data(GTK_OBJECT(next), "id");
- PreCreation( parent, id, pos, size, style, name );
-
- m_widget = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(m_widget),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-
- m_tree = GTK_TREE(gtk_tree_new());
+ return (-1);
+}
+
+long wxTreeCtrl::GetNextVisibleItem(long item) const
+{
+ GtkTreeItem *p;
+ GtkTreeItem *next = NULL;
+
+ p = findGtkTreeItem(item);
+ GList *list = gtk_container_children(GTK_CONTAINER(p));
+ next = GTK_TREE_ITEM(list->data);;
+// gtk_container_foreach(GTK_CONTAINER(p), gtk_treectrl_next_visible_callback, &next);
+
+ if (next != NULL)
+ return (long)gtk_object_get_data(GTK_OBJECT(next), "id");
-/*
- gtk_signal_connect( GTK_OBJECT(m_tree), "selection_changed",
- GTK_SIGNAL_FUNC(gtk_treectrl_selection_changed_callback), (gpointer)this);
- gtk_signal_connect( GTK_OBJECT(m_tree), "select_child",
- GTK_SIGNAL_FUNC(gtk_treectrl_select_child_callback), (gpointer)this);
- gtk_signal_connect( GTK_OBJECT(m_tree), "unselect_child",
- GTK_SIGNAL_FUNC(gtk_treectrl_unselect_child_callback), (gpointer)this);
-*/
+ return (-1);
+}
- gtk_container_add(GTK_CONTAINER(m_widget), GTK_WIDGET(m_tree));
- gtk_widget_show(GTK_WIDGET(m_tree));
+long wxTreeCtrl::GetSelection() const
+{
+ GtkTreeItem *next = NULL;
- PostCreation();
+ GList *list = gtk_container_children(GTK_CONTAINER(m_anchor));
+ next = GTK_TREE_ITEM(list->data);;
+// gtk_container_foreach(GTK_CONTAINER(m_anchor), gtk_treectrl_next_selected_callback, &next);
- gtk_widget_realize(GTK_WIDGET(m_tree));
+ if (next != NULL)
+ return (long)gtk_object_get_data(GTK_OBJECT(next), "id");
- Show(TRUE);
+ return (-1);
+}
+
+long wxTreeCtrl::GetRootItem() const
+{
+ return (long)gtk_object_get_data(GTK_OBJECT(m_anchor), "id");
+}
+
+bool wxTreeCtrl::GetItem(wxTreeItem& info) const
+{
+ GtkTreeItem *p;
+
+ p = findGtkTreeItem(info.m_itemId);
+
+ if (p == NULL) {
+ wxLogError("TreeCtrl::GetItem failed.");
+ return FALSE;
+ }
+
+ wxConvertFromGtkTreeItem(info, p);
return TRUE;
-};
+}
-int wxTreeCtrl::GetCount() const
+bool wxTreeCtrl::SetItem(wxTreeItem& info)
{
- if (!m_anchor) return 0;
- return m_anchor->NumberOfVisibleDescendents();
-};
+ GtkTreeItem *p;
-long wxTreeCtrl::InsertItem(long parent, const wxString& label,
- int image, int selImage, long insertAfter) {
- wxTreeItem item;
- if (!label.IsNull() || (label == "")) {
- item.m_text = label;
- item.m_mask |= wxTREE_MASK_TEXT;
- };
-
- if (image >= 0) {
- item.m_image = image;
- item.m_mask |= wxTREE_MASK_IMAGE;
- };
-
- if (selImage >= 0) {
- item.m_selectedImage = selImage;
- item.m_mask |= wxTREE_MASK_SELECTED_IMAGE;
- };
-
- return InsertItem(parent, item, insertAfter);
-};
+ p = findGtkTreeItem(info.m_itemId);
-long wxTreeCtrl::InsertItem( long parent, wxTreeItem &info, long WXUNUSED(insertAfter) ) {
- int oldMask = info.m_mask;
- long ret = 0;
- wxTreeItem *p = NULL;
- wxTreeItem *new_child;
+ if (p == NULL) {
+ wxLogError("TreeCtrl::SetItem failed.");
+ return FALSE;
+ }
- if (parent == 0) {
- if (m_anchor)
- return -1;
- } else {
- p = FindItem(parent);
- if (!p) return -1;
- };
-
- if ((info.m_mask & wxTREE_MASK_HANDLE) == 0) {
- m_lastId++;
- info.m_itemId = m_lastId;
- info.m_mask |= wxTREE_MASK_HANDLE;
- ret = m_lastId;
- } else
- ret = info.m_itemId;
-
- if (p) {
- if (p->m_tree == NULL)
- p->AddSubtree();
-
- new_child = new wxTreeItem(GTK_WIDGET(p->m_tree), info);
- p->AddChild(new_child);
-gtk_widget_draw_default(GTK_WIDGET(m_tree));
- } else {
- new_child = new wxTreeItem(GTK_WIDGET(m_tree), info);
- m_anchor = new_child;
+ wxConvertToGtkTreeItem(this, info, &p);
+
+ return TRUE;
+}
+
+int wxTreeCtrl::GetItemState(long item, long stateMask) const
+{
+ wxTreeItem info;
+
+ info.m_mask = wxTREE_MASK_STATE ;
+ info.m_stateMask = stateMask;
+ info.m_itemId = item;
+
+ if (!GetItem(info))
+ return 0;
+
+ return info.m_state;
+}
+
+bool wxTreeCtrl::SetItemState(long item, long state, long stateMask)
+{
+ wxTreeItem info;
+
+ info.m_mask = wxTREE_MASK_STATE ;
+ info.m_state = state;
+ info.m_stateMask = stateMask;
+ info.m_itemId = item;
+
+ return SetItem(info);
+}
+
+bool wxTreeCtrl::SetItemImage(long item, int image, int selImage)
+{
+ wxTreeItem info;
+
+ 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);
+}
+
+wxString wxTreeCtrl::GetItemText(long item) const
+{
+ wxTreeItem info;
+
+ info.m_mask = wxTREE_MASK_TEXT ;
+ info.m_itemId = item;
-/* Disabled until wxImageList q solved >>> seems it solved */
+ if (!GetItem(info))
+ return wxString("");
+ return info.m_text;
+}
+
+void wxTreeCtrl::SetItemText(long item, const wxString& str)
+{
+ wxTreeItem info;
+
+ info.m_mask = wxTREE_MASK_TEXT ;
+ info.m_itemId = item;
+ info.m_text = str;
+
+ SetItem(info);
+}
+
+long wxTreeCtrl::GetItemData(long item) const
+{
+ wxTreeItem info;
+
+ info.m_mask = wxTREE_MASK_DATA ;
+ info.m_itemId = item;
+
+ if (!GetItem(info))
+ return 0;
+ return info.m_data;
+}
+
+bool wxTreeCtrl::SetItemData(long item, long data)
+{
+ wxTreeItem info;
+
+ info.m_mask = wxTREE_MASK_DATA ;
+ info.m_itemId = item;
+ info.m_data = data;
+
+ return SetItem(info);
+}
+
+bool wxTreeCtrl::GetItemRect(long item, wxRectangle& rect, bool textOnly) const
+{
/*
- wxBitmap *bmp;
- if ((new_child->m_mask & wxTREE_MASK_IMAGE) != 0) {
- if (m_imageList != NULL) {
-// if ((bmp = m_imageList->GetBitmap(new_child->m_image)) != NULL) {
- if ((bmp = m_imageList->GetBitmap(0)) != NULL) {
- if (bmp->Ok()) {
- GdkBitmap *mask = NULL;
- if (bmp->GetMask()) mask = bmp->GetMask()->GetBitmap();
- GtkWidget *pixmap = gtk_pixmap_new(bmp->GetPixmap(), mask);
-
-gtk_widget_unref(new_child->m_widget->plus_pix_widget);
-gtk_container_remove(GTK_CONTAINER(new_child->m_widget->pixmaps_box),
- new_child->m_widget->plus_pix_widget);
-gtk_container_add(GTK_CONTAINER(new_child->m_widget->pixmaps_box),
- pixmap);
- gtk_widget_show(pixmap);
- GTK_TREE_ITEM(new_child->m_widget)->plus_pix_widget = pixmap;
- }
- }
+ RECT rect2;
- if ((bmp = m_imageList->GetBitmap(1)) != NULL) {
- if (bmp->Ok()) {
- GdkBitmap *mask = NULL;
- if (bmp->GetMask()) mask = bmp->GetMask()->GetBitmap();
- GtkWidget *pixmap = gtk_pixmap_new(bmp->GetPixmap(), mask);
-
-gtk_widget_unref(new_child->m_widget->minus_pix_widget);
-//gtk_container_remove(GTK_CONTAINER(new_child->m_widget->pixmaps_box),
-// new_child->m_widget->plus_pix_widget);
-//gtk_container_add(GTK_CONTAINER(new_child->m_widget->pixmaps_box),
-// pixmap);
- gtk_widget_show(pixmap);
- GTK_TREE_ITEM(new_child->m_widget)->minus_pix_widget = pixmap;
- }
- }
- }
- }
+ *(HTREEITEM*)& rect2 = (HTREEITEM) item;
+ bool success = (::SendMessage((HWND) GetHWND(), TVM_GETITEMRECT, (WPARAM)textOnly,
+ (LPARAM)&rect2) != 0);
+
+ rect.x = rect2.left;
+ rect.y = rect2.top;
+ rect.width = rect2.right - rect2.left;
+ rect.height = rect2.bottom - rect2.left;
+ return success;
*/
+ wxFAIL_MSG("Not implemented");
- new_child->m_owner = this;
+ return FALSE;
+}
- info.m_mask = oldMask;
- return ret;
-};
+wxTextCtrl* wxTreeCtrl::GetEditControl() const
+{
+ return m_textCtrl;
+}
+
+// Operations
+bool wxTreeCtrl::DeleteItem(long item)
+{
+ GtkTreeItem *p;
+ p = findGtkTreeItem(item);
+ if (p == NULL)
+ return FALSE;
-bool wxTreeCtrl::ExpandItem( long item, int action ) {
- wxTreeItem *i = FindItem( item );
- if (!i)
+ GtkTreeItem *parent = GTK_TREE_ITEM(GTK_WIDGET(p)->parent);
+ if (parent == NULL)
+ return FALSE;
+
+ gtk_container_remove(GTK_CONTAINER(parent), GTK_WIDGET(p));
+
+ return TRUE;
+}
+
+bool wxTreeCtrl::DeleteChildren(long item)
+{
+ GtkTreeItem *p;
+
+ p = findGtkTreeItem(item);
+ if (p == NULL)
+ return FALSE;
+
+ gtk_tree_item_remove_subtree(GTK_TREE_ITEM(p));
+
+ return TRUE;
+}
+
+bool wxTreeCtrl::ExpandItem(long item, int action)
+{
+ GtkTreeItem *p;
+
+ p = findGtkTreeItem(item);
+
+ if (p == NULL)
return FALSE;
switch (action) {
case wxTREE_EXPAND_EXPAND:
- gtk_tree_item_expand(GTK_TREE_ITEM(i->m_widget));
+ gtk_tree_item_expand(GTK_TREE_ITEM(p));
break;
- case wxTREE_EXPAND_COLLAPSE_RESET:
case wxTREE_EXPAND_COLLAPSE:
- gtk_tree_item_collapse(GTK_TREE_ITEM(i->m_widget));
+ gtk_tree_item_collapse(GTK_TREE_ITEM(p));
+ break;
+
+ case wxTREE_EXPAND_COLLAPSE_RESET:
+ gtk_tree_item_collapse(GTK_TREE_ITEM(p));
+ gtk_tree_item_remove_subtree(GTK_TREE_ITEM(p));
break;
case wxTREE_EXPAND_TOGGLE:
- if ((i->GetState() & wxTREE_STATE_EXPANDED) == 0)
- gtk_tree_item_expand(GTK_TREE_ITEM(i->m_widget));
+ if (p->expanded)
+ gtk_tree_item_collapse(GTK_TREE_ITEM(p));
else
- gtk_tree_item_collapse(GTK_TREE_ITEM(i->m_widget));
+ gtk_tree_item_expand(GTK_TREE_ITEM(p));
break;
+
+ default:
+ wxFAIL_MSG("unknown action in wxTreeCtrl::ExpandItem");
}
return TRUE;
-};
+}
-void wxTreeCtrl::DeleteItem( long item )
+long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter)
{
- wxTreeItem *pItem = FindItem( item );
- wxCHECK_RET( pItem != NULL, "wxTreeCtrl::DeleteItem: no such pItem." );
+ GtkTreeItem *p;
+ GtkTreeItem *item = NULL;
+
+ info.m_itemId = m_curitemId;
+ m_curitemId++;
+
+ wxConvertToGtkTreeItem(this, info, &item);
+
+ if (parent != 0) {
+ p = findGtkTreeItem(parent);
+ if (p->subtree == NULL) {
+ GtkTree *tree = GTK_TREE(gtk_tree_new());
+ gtk_tree_item_set_subtree(GTK_TREE_ITEM(p), GTK_WIDGET(tree));
+ gtk_widget_show(GTK_WIDGET(tree));
+ p->expanded = 1;
+ }
+
+ gtk_container_add(GTK_CONTAINER(p->subtree), GTK_WIDGET(item));
+ } else {
+ m_anchor = item;
+ gtk_container_add(GTK_CONTAINER(m_tree), GTK_WIDGET(item));
+ }
+
+ if ((info.m_mask & wxTREE_MASK_CHILDREN) != 0) {
+ GtkTree *tree = GTK_TREE(gtk_tree_new());
+ gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), GTK_WIDGET(tree));
+ gtk_widget_show(GTK_WIDGET(tree));
+ }
+
+ gtk_widget_show(GTK_WIDGET(item));
+
+ gtk_signal_connect(GTK_OBJECT(item), "select",
+ GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this );
+
+ gtk_signal_connect(GTK_OBJECT(item), "deselect",
+ GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this );
-// pItem->m_parent->m_childlist.DeleteObject(pItem);
+ gtk_signal_connect(GTK_OBJECT(item), "expand",
+ GTK_SIGNAL_FUNC(gtk_treeitem_expand_callback), (gpointer)this );
+ gtk_signal_connect(GTK_OBJECT(item), "collapse",
+ GTK_SIGNAL_FUNC(gtk_treeitem_collapse_callback), (gpointer)this );
+
+ return info.m_itemId;
}
-void wxTreeCtrl::DeleteChildren( long item )
-{
- wxTreeItem *pItem = FindItem( item );
- wxCHECK_RET( pItem != NULL, "wxTreeCtrl::DeleteChildren: no such pItem." );
+long wxTreeCtrl::InsertItem(long parent, const wxString& label, int image,
+ int selImage, long insertAfter) {
+
+ wxTreeItem info;
+ info.m_text = label;
+ info.m_mask = wxTREE_MASK_TEXT;
+ if (image > -1) {
+ info.m_mask |= wxTREE_MASK_IMAGE | wxTREE_MASK_SELECTED_IMAGE;
+ info.m_image = image;
+ if (selImage == -1)
+ info.m_selectedImage = image;
+ else
+ info.m_selectedImage = selImage;
+ }
- pItem->DeleteChildren();
+ return InsertItem(parent, info, insertAfter);
}
-bool wxTreeCtrl::DeleteAllItems()
+bool wxTreeCtrl::SelectItem(long item)
{
- delete m_anchor;
- m_anchor = NULL;
- return TRUE;
-};
+ GtkTreeItem *p;
-/*
-bool wxTreeCtrl::GetItem( wxTreeItem &info ) const
-{
- wxTreeItem *i = FindItem( info.m_itemId );
- if (!i) return FALSE;
- i->GetItem( info );
+ p = findGtkTreeItem(item);
+ if (p == NULL)
+ return FALSE;
+
+ gtk_tree_item_select(p);
return TRUE;
-};
-*/
+}
-long wxTreeCtrl::GetItemData( long item ) const
+bool wxTreeCtrl::ScrollTo(long item)
{
- wxTreeItem *i = FindItem( item );
- if (!i) return 0;
- return i->m_data;
-};
+ wxFAIL_MSG("Not implemented");
-wxString wxTreeCtrl::GetItemText( long item ) const
-{
- wxTreeItem *i = FindItem( item );
- if (!i) return "";
- return i->m_text;
-};
+ return FALSE; // Still unimplemented
+}
-int wxTreeCtrl::GetItemImage(long item) const
+bool wxTreeCtrl::DeleteAllItems()
{
- wxTreeItem *i = FindItem( item );
- return i == 0 ? -1 : i->GetImage();
+ gtk_tree_item_remove_subtree(m_anchor);
+ return TRUE;
}
-long wxTreeCtrl::GetParent( long item ) const
+wxTextCtrl* wxTreeCtrl::EditLabel(long item, wxClassInfo* textControlClass)
{
- wxTreeItem *i = FindItem( item );
- if (!i) return -1;
+ wxASSERT( (textControlClass->IsKindOf(CLASSINFO(wxTextCtrl))) );
+
/*
- i = i->m_parent;
- if (!i) return -1;
- return i->m_parent->m_itemId;
-*/
- return -1;
-};
+ HWND hWnd = (HWND) TreeView_EditLabel((HWND) GetHWND(), item);
-long wxTreeCtrl::GetRootItem() const
-{
- if (m_anchor) return m_anchor->m_itemId;
- return -1;
-};
+ if (m_textCtrl)
+ {
+ m_textCtrl->UnsubclassWin();
+ m_textCtrl->SetHWND(0);
+ delete m_textCtrl;
+ m_textCtrl = NULL;
+ }
-/*
-long wxTreeCtrl::GetSelection() const
+ m_textCtrl = (wxTextCtrl*) textControlClass->CreateObject();
+ m_textCtrl->SetHWND((WXHWND) hWnd);
+ m_textCtrl->SubclassWin((WXHWND) hWnd);
+
+*/
+ wxFAIL_MSG("Not implemented");
+
+ return m_textCtrl;
+}
+
+// End label editing, optionally cancelling the edit
+bool wxTreeCtrl::EndEditLabel(bool cancel)
{
- return m_current ? m_current->GetItemId() : -1;
-};
+/*
+ bool success = (TreeView_EndEditLabelNow((HWND) GetHWND(), cancel) != 0);
-bool wxTreeCtrl::SelectItem(long itemId)
+ if (m_textCtrl)
+ {
+ m_textCtrl->UnsubclassWin();
+ m_textCtrl->SetHWND(0);
+ delete m_textCtrl;
+ m_textCtrl = NULL;
+ }
+ return success;
+*/
+ wxFAIL_MSG("Not implemented");
+
+ return FALSE;
+}
+
+long wxTreeCtrl::HitTest(const wxPoint& point, int& flags)
{
- wxTreeItem *pItem = FindItem(itemId);
- if ( !pItem ) {
- wxLogDebug("Can't select an item %d which doesn't exist.", itemId);
+/*
+ TV_HITTESTINFO hitTestInfo;
+ hitTestInfo.pt.x = (int) point.x;
+ hitTestInfo.pt.y = (int) point.y;
- return FALSE;
- }
+ TreeView_HitTest((HWND) GetHWND(), & hitTestInfo);
- SelectItem(pItem);
+ flags = 0;
+ if ( hitTestInfo.flags & TVHT_ABOVE )
+ flags |= wxTREE_HITTEST_ABOVE;
+ if ( hitTestInfo.flags & TVHT_BELOW )
+ flags |= wxTREE_HITTEST_BELOW;
+ if ( hitTestInfo.flags & TVHT_NOWHERE )
+ flags |= wxTREE_HITTEST_NOWHERE;
+ if ( hitTestInfo.flags & TVHT_ONITEMBUTTON )
+ flags |= wxTREE_HITTEST_ONITEMBUTTON;
+ if ( hitTestInfo.flags & TVHT_ONITEMICON )
+ flags |= wxTREE_HITTEST_ONITEMICON;
+ if ( hitTestInfo.flags & TVHT_ONITEMINDENT )
+ flags |= wxTREE_HITTEST_ONITEMINDENT;
+ if ( hitTestInfo.flags & TVHT_ONITEMLABEL )
+ flags |= wxTREE_HITTEST_ONITEMLABEL;
+ if ( hitTestInfo.flags & TVHT_ONITEMRIGHT )
+ flags |= wxTREE_HITTEST_ONITEMRIGHT;
+ if ( hitTestInfo.flags & TVHT_ONITEMSTATEICON )
+ flags |= wxTREE_HITTEST_ONITEMSTATEICON;
+ if ( hitTestInfo.flags & TVHT_TOLEFT )
+ flags |= wxTREE_HITTEST_TOLEFT;
+ if ( hitTestInfo.flags & TVHT_TORIGHT )
+ flags |= wxTREE_HITTEST_TORIGHT;
+
+ return (long) hitTestInfo.hItem ;
+*/
+ wxFAIL_MSG("Not implemented");
- return TRUE;
-};
+ return 0;
+}
-void wxTreeCtrl::SelectItem(wxTreeItem *item, bool bDoEvents )
+/*
+wxImageList *wxTreeCtrl::CreateDragImage(long item)
{
- if (m_current != item)
- {
- if (m_current)
- {
- m_current->SetHilight( FALSE );
-// RefreshLine( m_current );
- };
- m_current = item;
- m_current->SetHilight( TRUE );
-// RefreshLine( m_current );
-
- if (bDoEvents) m_current->SendSelected( this );
- }
}
*/
-bool wxTreeCtrl::ItemHasChildren( long item ) const
+bool wxTreeCtrl::SortChildren(long item)
{
- wxTreeItem *i = FindItem( item );
- if (!i) return FALSE;
- return i->HasChildren();
-};
+ wxFAIL_MSG("Not implemented");
-void wxTreeCtrl::SetIndent( int indent )
-{
- m_indent = indent;
- Refresh();
-};
+ return FALSE; // Still unimplemented
+}
-int wxTreeCtrl::GetIndent() const
+bool wxTreeCtrl::EnsureVisible(long item)
{
- return m_indent;
-};
+ wxFAIL_MSG("Not implemented");
-/*
-bool wxTreeCtrl::SetItem( wxTreeItem &info )
+ return FALSE; // Still unimplemented
+}
+
+void wxTreeCtrl::SendExpanding(long item)
{
- wxTreeItem *i = FindItem( info.m_itemId );
- if (!i) return FALSE;
- wxClientDC dc(this);
- i->SetItem( info, &dc );
- Refresh();
- return TRUE;
-};
+ wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_EXPANDING, GetId());
+ event.SetEventObject(this);
+ ProcessEvent(event);
+}
-bool wxTreeCtrl::SetItemData( long item, long data )
+void wxTreeCtrl::SendExpanded(long item)
{
- wxTreeItem *i = FindItem( item );
- if (!i) return FALSE;
- i->m_data = data;
- return TRUE;
-};
+ wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_EXPANDED, GetId());
+ event.SetEventObject(this);
+ ProcessEvent(event);
+}
-bool wxTreeCtrl::SetItemText( long item, const wxString &text )
+void wxTreeCtrl::SendCollapsing(long item)
{
- wxTreeItem *i = FindItem( item );
- if (!i) return FALSE;
- wxClientDC dc(this);
- i->SetText( text, &dc );
- return TRUE;
-};
+ wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_COLLAPSING, GetId());
+ event.SetEventObject(this);
+ ProcessEvent(event);
+}
-void wxTreeCtrl::SetItemImage(long item, int image, int imageSel) const
+void wxTreeCtrl::SendCollapsed(long item)
{
- wxTreeItem *i = FindItem( item );
- if ( i != 0 ) {
- i->SetImage(image);
- i->SetSelectedImage(imageSel);
- }
+ wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_COLLAPSED, GetId());
+ event.SetEventObject(this);
+ ProcessEvent(event);
}
-long wxTreeCtrl::HitTest( const wxPoint& point, int &flags )
+void wxTreeCtrl::SendSelChanging(long item)
{
- flags = 0;
- if (!m_anchor) return -1;
- return m_anchor->HitTest( point, flags );
-};
-*/
+ wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGED, GetId());
+ event.SetEventObject(this);
+ ProcessEvent(event);
+}
-wxImageList *wxTreeCtrl::GetImageList( int which ) const
+void wxTreeCtrl::SendSelChanged(long item)
{
- if (which == wxIMAGE_LIST_NORMAL) return m_imageList;
- return m_smallImageList;
-};
+ wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, GetId());
+ event.SetEventObject(this);
+ ProcessEvent(event);
+}
-void wxTreeCtrl::SetImageList( wxImageList *imageList, int which )
+// Tree item structure
+wxTreeItem::wxTreeItem()
{
- if (which == wxIMAGE_LIST_NORMAL)
- {
- if (m_imageList) delete m_imageList;
- m_imageList = imageList;
- }
- else
- {
- if (m_smallImageList) delete m_smallImageList;
- m_smallImageList = imageList;
- };
-};
+ m_mask = 0;
+ m_itemId = 0;
+ m_state = 0;
+ m_stateMask = 0;
+ m_image = -1;
+ m_selectedImage = -1;
+ m_children = 0;
+ m_data = 0;
+}
-wxTreeItem *wxTreeCtrl::FindItem( long itemId ) const {
- if (!m_anchor) return NULL;
- return m_anchor->FindItem( itemId );
- return 0;
-};
+// If getFullInfo is TRUE, we explicitly query for more info if we haven't got it all.
-wxTreeItem *wxTreeCtrl::FindItem(GtkTreeItem *item) const {
- if (!m_anchor) return NULL;
- return m_anchor->FindItem(item);
- return 0;
-};
+static void wxConvertFromGtkTreeItem(wxTreeItem& info, GtkTreeItem *gtkItem)
+{
+ GtkLabel *l;
+ char *t;
+
+ info.m_data = (long)gtk_object_get_data(GTK_OBJECT(gtkItem), "data");
+ info.m_itemId = (long)gtk_object_get_data(GTK_OBJECT(gtkItem), "id");
+ info.m_image = (int)gtk_object_get_data(GTK_OBJECT(gtkItem), "image");
+ info.m_selectedImage = (int)gtk_object_get_data(GTK_OBJECT(gtkItem), "selectedImage");
+
+ info.m_mask = 0;
+ info.m_state = 0;
+ info.m_stateMask = 0;
+ l = GTK_LABEL(gtk_object_get_data(GTK_OBJECT(gtkItem), "label"));
+ gtk_label_get(l, &t);
+ info.m_text = t;
+}
-//-----------------------------------------------------------------------------
-// wxTreeEvent
-//-----------------------------------------------------------------------------
+static void wxConvertToGtkTreeItem(wxTreeCtrl *owner, wxTreeItem& info, GtkTreeItem **gtkItem)
+{
+ GtkTreeItem *item = (*gtkItem);
-IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent,wxCommandEvent)
+ if (item == NULL) {
+ item = GTK_TREE_ITEM(gtk_tree_item_new());
-wxTreeEvent::wxTreeEvent( wxEventType commandType, int id ) :
- wxCommandEvent( commandType, id )
-{
- m_code = 0;
- m_oldItem = 0;
-};
+ GtkHBox *m_box = GTK_HBOX(gtk_hbox_new(FALSE, 0));
+ gtk_container_add (GTK_CONTAINER (item), GTK_WIDGET(m_box));
-/* Bunch of old code might be useful */
-/*
- wxBitmap *bmp;
+ gtk_object_set_data(GTK_OBJECT(item), "box", m_box);
- if ((bmp = m_imageList->GetItem(0))->Ok()) {
- GdkBitmap *mask = NULL;
- if (bmp->GetMask()) mask = bmp->GetMask()->GetBitmap();
- GtkWidget *pixmap = gtk_pixmap_new( bmp->GetPixmap(), mask );
+ const wxBitmap *bmp;
+ const wxImageList *list;
+ if (owner != NULL)
+ if ((list = owner->GetImageList(wxIMAGE_LIST_NORMAL)) != NULL)
+ if ((bmp = list->GetBitmap(info.m_image)) != NULL)
+ if (bmp->Ok()) {
+ GdkBitmap *mask = NULL;
+ if (bmp->GetMask())
+ mask = bmp->GetMask()->GetBitmap();
+ GtkPixmap *m_image_widget = GTK_PIXMAP(gtk_pixmap_new(bmp->GetPixmap(), mask));
+ gtk_misc_set_alignment (GTK_MISC (m_image_widget), 0.0, 0.5);
+ gtk_box_pack_start(GTK_BOX(m_box), GTK_WIDGET(m_image_widget), FALSE, FALSE, 0);
+ gtk_object_set_data(GTK_OBJECT(item), "image", m_image_widget);
+ gtk_widget_show (GTK_WIDGET(m_image_widget));
+ }
- gtk_widget_set_parent(pixmap, GTK_WIDGET(new_child->m_widget));
- gtk_widget_show(pixmap);
- GTK_TREE_ITEM(new_child->m_widget)->pixmaps_box = pixmap;
- }
+ GtkLabel *m_label_widget = GTK_LABEL(gtk_label_new ((char *)(const char *)info.m_text));
+ gtk_misc_set_alignment (GTK_MISC (m_label_widget), 0.5, 0.5);
+
+ gtk_box_pack_start(GTK_BOX(m_box), GTK_WIDGET(m_label_widget), FALSE, FALSE, 0);
+ gtk_object_set_data(GTK_OBJECT(item), "label", m_label_widget);
- if ((bmp = m_imageList->GetItem(1))->Ok()) {
- GdkBitmap *mask = NULL;
- if (bmp->GetMask()) mask = bmp->GetMask()->GetBitmap();
- GtkWidget *pixmap = gtk_pixmap_new( bmp->GetPixmap(), mask );
+ gtk_widget_show (GTK_WIDGET(m_label_widget));
- gtk_widget_set_parent(pixmap, GTK_WIDGET(new_child->m_widget));
- gtk_widget_show(pixmap);
- GTK_TREE_ITEM(new_child->m_widget)->plus_pix_widget = pixmap;
+ gtk_widget_show(GTK_WIDGET(m_box));
+ gtk_object_set_data(GTK_OBJECT(item), "id", (gpointer)info.m_itemId);
+ gtk_object_set_data(GTK_OBJECT(item), "owner", owner);
+ (*gtkItem) = item;
}
+}
- if ((bmp = m_imageList->GetItem(2))->Ok()) {
- GdkBitmap *mask = NULL;
- if (bmp->GetMask()) mask = bmp->GetMask()->GetBitmap();
- GtkWidget *pixmap = gtk_pixmap_new( bmp->GetPixmap(), mask );
+// Tree event
+IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxCommandEvent)
- gtk_widget_set_parent(pixmap, GTK_WIDGET(new_child->m_widget));
- gtk_widget_show(pixmap);
- GTK_TREE_ITEM(new_child->m_widget)->minus_pix_widget = pixmap;
- }
+wxTreeEvent::wxTreeEvent(wxEventType commandType, int id)
+ : wxCommandEvent(commandType, id)
+{
+ m_code = 0;
+ m_oldItem = 0;
+}
- if (p)
- if (p->m_childlist.Number() == 1) {
- gtk_tree_item_collapse(GTK_TREE_ITEM(p->m_widget));
- gtk_tree_item_expand(GTK_TREE_ITEM(p->m_widget));
- }
-*/