]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/treegtk.cpp
Added missing wx_aui.dsp file
[wxWidgets.git] / src / gtk / treegtk.cpp
index d1adda4004ea2dcb0cc7cd1943dd36655a099f3f..cd72f0589d9c2f4d8fbadee56dbfa1ff3fc8e37c 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        treectrl.cpp
+// Name:        src/gtk/treectrl.cpp
 // Purpose:     wxTreeCtrl
 // Author:      Denis Pershin
 // Modified by:
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-#pragma hdrstop
+    #pragma hdrstop
 #endif
 
 #ifndef WX_PRECOMP
-#include "wx/wx.h"
+    #include "wx/wx.h"
+    #include "wx/log.h"
+    #include "wx/textctrl.h"
 #endif
 
 #include "wx/gtk/treectrl.h"
-#include "wx/textctrl.h"
-#include "wx/log.h"
 
 #include <gtk/gtk.h>
 
@@ -103,7 +103,7 @@ bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos,
   if (y < 0)
     y = 0;
 
-  m_needParent = TRUE;
+  m_needParent = true;
 
 printf("precreate\n");
   PreCreation( parent, id, pos, size, style, name );
@@ -133,9 +133,9 @@ printf("postcreate\n");
 
   gtk_widget_realize(GTK_WIDGET(m_tree));
 
-  Show(TRUE);
+  Show(true);
 
-  return TRUE;
+  return true;
 }
 
 wxTreeCtrl::~wxTreeCtrl(void) {
@@ -152,12 +152,14 @@ static void gtk_treectrl_count_callback (GtkWidget *widget, gpointer data) {
     gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_count_callback, data);
 }
 
-size_t wxTreeCtrl::GetCount() const {
-  int count = 0;
+unsigned int wxTreeCtrl::GetCount() const
+{
+    int count = 0;
+
+    if (m_anchor != NULL)
+        gtk_treectrl_count_callback(GTK_WIDGET(m_anchor), &count);
 
-  if (m_anchor != NULL)
-    gtk_treectrl_count_callback(GTK_WIDGET(m_anchor), &count);
-  return count;
+    return (unsigned int)count;
 }
 
 unsigned int wxTreeCtrl::GetIndent() const {
@@ -184,16 +186,17 @@ void wxTreeCtrl::SetStateImageList(wxImageList *imageList) {
   m_imageListState = imageList;
 }
 
-wxString wxTreeCtrl::GetItemText(const wxTreeItemId &item) const {
-  char *t;
+wxString wxTreeCtrl::GetItemText(const wxTreeItemId &item) const
+{
+    char *t;
 
-  if (!item.IsOk())
-    return wxString("");
+    if (!item.IsOk())
+        return wxEmptyString;
 
-  GtkLabel *l = GTK_LABEL(gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "w_label"));
-  gtk_label_get(l, &t);
+    GtkLabel *l = GTK_LABEL(gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "w_label"));
+    gtk_label_get(l, &t);
 
-  return t;
+    return t;
 }
 
 int wxTreeCtrl::GetItemImage(const wxTreeItemId& item) const {
@@ -222,7 +225,7 @@ void wxTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text) {
     return;
 
   GtkLabel *l = GTK_LABEL(gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "w_label"));
-  gtk_label_set(l, text);
+  gtk_label_set_text(l, text);
 }
 
 void wxTreeCtrl::SetItemImage(const wxTreeItemId& item, int image) {
@@ -534,16 +537,14 @@ printf("m_tree = %p\n", m_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 );
-
-  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 );
+  g_signal_connect (item, "select",
+                    G_CALLBACK (gtk_treeitem_select_callback), this);
+  g_signal_connect (item, "deselect",
+                    G_CALLBACK (gtk_treeitem_select_callback), this);
+  g_signal_connect (item, "expand",
+                    G_CALLBACK (gtk_treeitem_expand_callback), this);
+  g_signal_connect (item, "collapse",
+                    G_CALLBACK (gtk_treeitem_collapse_callback), this);
 
   return item;
 }
@@ -667,7 +668,7 @@ void wxTreeCtrl::EndEditLabel(const wxTreeItemId& item, bool discardChanges) {
 #warning "Need to implement EndEditLabel"
 /*
   GtkLabel *m_label = (GtkLabel *)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)m_editItem), "w_label");
-  gtk_label_set(m_label, m_textCtrl->GetValue());
+  gtk_label_set_text(m_label, m_textCtrl->GetValue());
 
   gtk_object_remove_data(GTK_OBJECT((GtkTreeItem *)m_editItem), "w_edit");
 
@@ -716,7 +717,7 @@ long wxTreeCtrl::GetChild(long item) const {
   GtkTreeItem *next = NULL;
 
   p = findGtkTreeItem(item);
-  GList *list = gtk_container_children(GTK_CONTAINER(p));
+  GList *list = gtk_container_get_children(GTK_CONTAINER(p));
   next = GTK_TREE_ITEM(list->data);
 
   if (next != NULL)
@@ -728,7 +729,7 @@ long wxTreeCtrl::GetChild(long item) const {
 long wxTreeCtrl::GetFirstVisibleItem(void) const {
   GtkTreeItem *next = NULL;
 
-  GList *list = gtk_container_children(GTK_CONTAINER(m_anchor));
+  GList *list = gtk_container_get_children(GTK_CONTAINER(m_anchor));
   next = GTK_TREE_ITEM(list->data);
 //  gtk_container_foreach(GTK_CONTAINER(m_anchor), gtk_treectrl_next_visible_callback, &next);
 
@@ -738,49 +739,54 @@ long wxTreeCtrl::GetFirstVisibleItem(void) const {
   return (-1);
 }
 
-long wxTreeCtrl::GetNextVisibleItem(long item) const {
-  GtkTreeItem *p;
-  GtkTreeItem *next = NULL;
+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);
+    p = findGtkTreeItem(item);
+    GList *list = gtk_container_get_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");
+    if (next != NULL)
+        return (long)gtk_object_get_data(GTK_OBJECT(next), "id");
 
-  return (-1);
+    return wxNOT_FOUND;
 }
 
-bool wxTreeCtrl::GetItem(wxTreeItem& info) const {
-  GtkTreeItem *p;
+bool wxTreeCtrl::GetItem(wxTreeItem& info) const
+{
+    GtkTreeItem *p;
 
-  p = findGtkTreeItem(info.m_itemId);
+    p = findGtkTreeItem(info.m_itemId);
 
-  if (p == NULL) {
-    wxLogSysError("TreeCtrl::GetItem failed");
-    return FALSE;
-  }
+    if (p == NULL)
+    {
+        wxLogSysError("TreeCtrl::GetItem failed");
+        return false;
+    }
 
-  wxConvertFromGtkTreeItem(info, p);
+    wxConvertFromGtkTreeItem(info, p);
 
-  return TRUE;
+    return true;
 }
 
-bool wxTreeCtrl::SetItem(wxTreeItem& info) {
-  GtkTreeItem *p;
+bool wxTreeCtrl::SetItem(wxTreeItem& info)
+{
+    GtkTreeItem *p;
 
-  p = findGtkTreeItem(info.m_itemId);
+    p = findGtkTreeItem(info.m_itemId);
 
-  if (p == NULL) {
-    wxLogSysError("TreeCtrl::SetItem failed");
-    return FALSE;
-  }
+    if (p == NULL)
+    {
+        wxLogSysError("TreeCtrl::SetItem failed");
+        return false;
+    }
 
-  wxConvertToGtkTreeItem(this, info, &p);
+    wxConvertToGtkTreeItem(this, info, &p);
 
-  return TRUE;
+    return true;
 }
 
 int wxTreeCtrl::GetItemState(long item, long stateMask) const {
@@ -796,30 +802,32 @@ int wxTreeCtrl::GetItemState(long item, long stateMask) const {
   return info.m_state;
 }
 
-bool wxTreeCtrl::SetItemState(long item, long state, long stateMask) {
-  wxTreeItem info;
+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;
+    info.m_mask = wxTREE_MASK_STATE ;
+    info.m_state = state;
+    info.m_stateMask = stateMask;
+    info.m_itemId = item;
 
-  return SetItem(info);
+    return SetItem(info);
 }
 */
 
 // Operations
 /*
-bool wxTreeCtrl::DeleteChildren(long item) {
-  GtkTreeItem *p;
+bool wxTreeCtrl::DeleteChildren(long item)
+{
+    GtkTreeItem *p;
 
-  p = findGtkTreeItem(item);
-  if (p == NULL)
-    return FALSE;
+    p = findGtkTreeItem(item);
+    if (p == NULL)
+        return false;
 
-  gtk_tree_item_remove_subtree(GTK_TREE_ITEM(p));
+    gtk_tree_item_remove_subtree(GTK_TREE_ITEM(p));
 
-  return TRUE;
+    return true;
 }
 */
 
@@ -856,16 +864,14 @@ long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter) {
 
   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 );
-
-  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 );
+  g_signal_connect (item, "select",
+                    G_CALLBACK (gtk_treeitem_select_callback), this);
+  g_signal_connect (item, "deselect",
+                    G_CALLBACK (gtk_treeitem_select_callback), this);
+  g_signal_connect (item, "expand",
+                    G_CALLBACK (gtk_treeitem_expand_callback), this);
+  g_signal_connect (item, "collapse",
+                    G_CALLBACK (gtk_treeitem_collapse_callback), this);
 
   return info.m_itemId;
 }