#elif defined(__WXMOTIF__)
#include "wx/generic/treectrl.h"
#elif defined(__WXGTK__)
-#include "wx/generic/treectrl.h"
+#include "wx/gtk/treectrl.h"
#elif defined(__WXQT__)
#include "wx/qt/treectrl.h"
#elif defined(__WXMAC__)
--- /dev/null
+/* XPM */
+static char *icon1_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"32 32 6 1",
+" c Black",
+". c Blue",
+"X c #00bf00",
+"o c Red",
+"O c Yellow",
+"+ c Gray100",
+/* pixels */
+" ",
+" oooooo +++++++++++++++++++++++ ",
+" oooooo +++++++++++++++++++++++ ",
+" oooooo +++++++++++++++++++++++ ",
+" oooooo +++++++++++++++++++++++ ",
+" oooooo +++++++++++++++++++++++ ",
+" oooooo +++++++++++++++++++++++ ",
+" oooooo +++++++++++++++++++++++ ",
+" ",
+" ++++++ ++++++++++++++++++ .... ",
+" ++++++ ++++++++++++++++++ .... ",
+" ++++++ +++++++XXX++++++++ .... ",
+" ++++++ ++++++X+XX++++++++ .... ",
+" ++++++ +++++X++XX++++++++ .... ",
+" ++++++ ++++++++XX++++++++ ",
+" ++++++ ++++++++XX++++++++ ++++ ",
+" ++++++ ++++++++XX++++++++ ++++ ",
+" ++++++ ++++++++XX++++++++ ++++ ",
+" ++++++ ++++++++XX++++++++ ++++ ",
+" ++++++ ++++++++XX++++++++ ++++ ",
+" ++++++ ++++++++++++++++++ ++++ ",
+" ++++++ ++++++++++++++++++ ++++ ",
+" ++++++ ++++++++++++++++++ ++++ ",
+" ++++++ ++++++++++++++++++ ++++ ",
+" ++++++ ++++ ",
+" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
+" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
+" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
+" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
+" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
+" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
+" "
+};
--- /dev/null
+/* XPM */
+static char *icon2_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"32 32 6 1",
+" c Black",
+". c Blue",
+"X c #00bf00",
+"o c Red",
+"O c Yellow",
+"+ c Gray100",
+/* pixels */
+" ",
+" oooooo +++++++++++++++++++++++ ",
+" oooooo +++++++++++++++++++++++ ",
+" oooooo +++++++++++++++++++++++ ",
+" oooooo +++++++++++++++++++++++ ",
+" oooooo +++++++++++++++++++++++ ",
+" oooooo +++++++++++++++++++++++ ",
+" oooooo +++++++++++++++++++++++ ",
+" ",
+" ++++++ ++++++++++++++++++ .... ",
+" ++++++ ++++++++++++++++++ .... ",
+" ++++++ ++++++++++++++++++ .... ",
+" ++++++ +++++XXXXXX+++++++ .... ",
+" ++++++ ++++X++++++X++++++ .... ",
+" ++++++ +++++++++++X++++++ ",
+" ++++++ ++++++++++X+++++++ ++++ ",
+" ++++++ ++++++++XX++++++++ ++++ ",
+" ++++++ +++++++XX+++++++++ ++++ ",
+" ++++++ ++++++X+++++++++++ ++++ ",
+" ++++++ +++++X++++++++++++ ++++ ",
+" ++++++ +++++XXXXXXXX+++++ ++++ ",
+" ++++++ ++++++++++++++++++ ++++ ",
+" ++++++ ++++++++++++++++++ ++++ ",
+" ++++++ ++++++++++++++++++ ++++ ",
+" ++++++ ++++ ",
+" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
+" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
+" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
+" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
+" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
+" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
+" "
+};
#include "wx/wx.h"
#endif
-#ifdef __WXGTK__
-#include "mondrian.xpm"
+#ifndef __WXMSW__
+ #include "icon1.xpm"
+ #include "icon2.xpm"
+ #include "mondrian.xpm"
#endif
#include "wx/treectrl.h"
IMPLEMENT_APP(MyApp)
// `Main program' equivalent, creating windows and returning main app frame
-bool MyApp::OnInit(void)
+bool MyApp::OnInit()
{
// Create the main frame window
MyFrame *frame = new MyFrame((wxFrame *) NULL, (char *) "wxTreeCtrl Test", 50, 50, 450, 340);
frame->SetBackgroundColour(wxColour(255, 255, 255));
// Give it an icon
-#ifdef __WXMSW__
- frame->SetIcon(wxIcon("mondrian"));
-#else
- frame->SetIcon(wxIcon(mondrian_xpm));
-#endif
+ frame->SetIcon(wxICON(mondrian));
// Make an image list containing small icons
m_imageListNormal = new wxImageList(16, 16, TRUE);
-#ifdef __WXMSW__
- wxIcon icon1("icon1", wxBITMAP_TYPE_ICO_RESOURCE);
- m_imageListNormal->Add(icon1);
- wxIcon icon2("icon2", wxBITMAP_TYPE_ICO_RESOURCE);
- m_imageListNormal->Add(icon2);
-#else
-#endif
+ m_imageListNormal->Add(wxICON(icon1));
+ m_imageListNormal->Add(wxICON(icon2));
// Make a menubar
wxMenu *file_menu = new wxMenu;
m_logWindow = (wxTextCtrl *) NULL;
}
-MyFrame::~MyFrame(void)
+MyFrame::~MyFrame()
{
delete wxGetApp().m_imageListNormal;
}
gtk/tbargtk.cpp \
gtk/textctrl.cpp \
gtk/timer.cpp \
+ gtk/treectrl.cpp \
gtk/utilsgtk.cpp \
gtk/utilsres.cpp \
gtk/window.cpp \
generic/splitter.cpp \
generic/statusbr.cpp \
generic/tabg.cpp \
- generic/textdlgg.cpp \
- generic/treectrl.cpp
+ generic/textdlgg.cpp
LIB_C_SRC=\
// Created: 07/05/98
// RCS-ID: $Id$
// Copyright: (c) Denis Pershin
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
static void gtk_treeitem_collapse_callback( GtkWidget *WXUNUSED(widget), wxTreeItem *treeitem);
static void gtk_treeitem_select_callback( GtkWidget *WXUNUSED(widget), wxTreeItem *treeitem);
-static void gtk_treeitem_expand_callback(GtkWidget *widget, wxTreeItem *treeitem) {
+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;
owner->SendExpanded(id);
};
-static void gtk_treeitem_collapse_callback(GtkWidget *widget, wxTreeItem *treeitem) {
+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;
owner->SendCollapsed(id);
};
-static void gtk_treeitem_select_callback(GtkWidget *widget, wxTreeItem *treeitem) {
+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;
}
#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl)
-IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject)
-
+ IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl)
+ IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject)
#endif
-wxTreeCtrl::wxTreeCtrl(void) {
+wxTreeCtrl::wxTreeCtrl()
+{
m_imageListNormal = NULL;
m_imageListState = NULL;
m_textCtrl = NULL;
m_widget = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(m_widget),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
m_tree = GTK_TREE(gtk_tree_new());
gtk_container_add(GTK_CONTAINER(m_widget), GTK_WIDGET(m_tree));
- gtk_widget_set_parent(GTK_WIDGET(m_tree), m_widget);
gtk_widget_show(GTK_WIDGET(m_tree));
wxSystemSettings settings;
return TRUE;
}
-wxTreeCtrl::~wxTreeCtrl(void) {
- if (m_textCtrl)
- delete m_textCtrl;
+wxTreeCtrl::~wxTreeCtrl()
+{
+ wxDELETE(m_textCtrl);
}
// Attributes
-static void gtk_treectrl_count_callback (GtkWidget *widget, gpointer data) {
+static void gtk_treectrl_count_callback (GtkWidget *widget, gpointer data)
+{
int count = (*((int *)data));
count++;
gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_count_callback, data);
}
-int wxTreeCtrl::GetCount(void) const {
+int wxTreeCtrl::GetCount() const
+{
int count = 0;
if (m_anchor != NULL)
return count;
}
-int wxTreeCtrl::GetIndent(void) const {
+int wxTreeCtrl::GetIndent() const
+{
return m_tree->indent_value;
}
-void wxTreeCtrl::SetIndent(int indent) {
+void wxTreeCtrl::SetIndent(int indent)
+{
m_tree->indent_value = indent;
}
-wxImageList *wxTreeCtrl::GetImageList(int which) const {
+wxImageList *wxTreeCtrl::GetImageList(int which) const
+{
if (which == wxIMAGE_LIST_NORMAL) {
return m_imageListNormal;
}
return NULL;
}
-void wxTreeCtrl::SetImageList(wxImageList *imageList, int which) {
+void wxTreeCtrl::SetImageList(wxImageList *imageList, int which)
+{
if (which == wxIMAGE_LIST_NORMAL)
m_imageListNormal = imageList;
else
m_imageListState = imageList;
}
-long wxTreeCtrl::GetNextItem(long item, int code) const {
+long wxTreeCtrl::GetNextItem(long item, int code) const
+{
switch (code) {
case wxTREE_NEXT_CARET:
// flag = TVGN_CARET;
return 0;
}
-bool wxTreeCtrl::ItemHasChildren(long item) const {
+bool wxTreeCtrl::ItemHasChildren(long item) const
+{
GtkTreeItem *p;
int count = 0;
return (count != 0);
}
-static GtkTreeItem *findItem(GtkTreeItem *p, long id) {
+static GtkTreeItem *findItem(GtkTreeItem *p, long id)
+{
GtkTreeItem *q;
if (((long)gtk_object_get_data(GTK_OBJECT(p), "id")) == id)
return NULL;
}
-GtkTreeItem *wxTreeCtrl::findGtkTreeItem(long id) const {
+GtkTreeItem *wxTreeCtrl::findGtkTreeItem(long id) const
+{
return findItem(m_anchor, id);
}
-long wxTreeCtrl::GetChild(long item) const {
+long wxTreeCtrl::GetChild(long item) const
+{
GtkTreeItem *p;
GtkTreeItem *next = NULL;
return (-1);
}
-long wxTreeCtrl::GetParent(long item) const {
+long wxTreeCtrl::GetParent(long item) const
+{
GtkTreeItem *p;
p = findGtkTreeItem(item);
return (-1);
}
-long wxTreeCtrl::GetFirstVisibleItem(void) const {
+long wxTreeCtrl::GetFirstVisibleItem() const
+{
GtkTreeItem *next = NULL;
GList *list = gtk_container_children(GTK_CONTAINER(m_anchor));
return (-1);
}
-long wxTreeCtrl::GetNextVisibleItem(long item) const {
+long wxTreeCtrl::GetNextVisibleItem(long item) const
+{
GtkTreeItem *p;
GtkTreeItem *next = NULL;
return (-1);
}
-long wxTreeCtrl::GetSelection(void) const {
+long wxTreeCtrl::GetSelection() const
+{
GtkTreeItem *next = NULL;
GList *list = gtk_container_children(GTK_CONTAINER(m_anchor));
return (-1);
}
-long wxTreeCtrl::GetRootItem(void) const {
+long wxTreeCtrl::GetRootItem() const
+{
return (long)gtk_object_get_data(GTK_OBJECT(m_anchor), "id");
}
-bool wxTreeCtrl::GetItem(wxTreeItem& info) const {
+bool wxTreeCtrl::GetItem(wxTreeItem& info) const
+{
GtkTreeItem *p;
p = findGtkTreeItem(info.m_itemId);
if (p == NULL) {
- wxLogSysError("TreeCtrl::GetItem failed");
+ wxLogError("TreeCtrl::GetItem failed.");
return FALSE;
}
return TRUE;
}
-bool wxTreeCtrl::SetItem(wxTreeItem& info) {
+bool wxTreeCtrl::SetItem(wxTreeItem& info)
+{
GtkTreeItem *p;
p = findGtkTreeItem(info.m_itemId);
if (p == NULL) {
- wxLogSysError("TreeCtrl::SetItem failed");
+ wxLogError("TreeCtrl::SetItem failed.");
return FALSE;
}
return TRUE;
}
-int wxTreeCtrl::GetItemState(long item, long stateMask) const {
+int wxTreeCtrl::GetItemState(long item, long stateMask) const
+{
wxTreeItem info;
info.m_mask = wxTREE_MASK_STATE ;
return info.m_state;
}
-bool wxTreeCtrl::SetItemState(long item, long state, long stateMask) {
+bool wxTreeCtrl::SetItemState(long item, long state, long stateMask)
+{
wxTreeItem info;
info.m_mask = wxTREE_MASK_STATE ;
return SetItem(info);
}
-bool wxTreeCtrl::SetItemImage(long item, int image, int selImage) {
+bool wxTreeCtrl::SetItemImage(long item, int image, int selImage)
+{
wxTreeItem info;
info.m_mask = wxTREE_MASK_IMAGE ;
return SetItem(info);
}
-wxString wxTreeCtrl::GetItemText(long item) const {
+wxString wxTreeCtrl::GetItemText(long item) const
+{
wxTreeItem info;
info.m_mask = wxTREE_MASK_TEXT ;
return info.m_text;
}
-void wxTreeCtrl::SetItemText(long item, const wxString& str) {
+void wxTreeCtrl::SetItemText(long item, const wxString& str)
+{
wxTreeItem info;
info.m_mask = wxTREE_MASK_TEXT ;
SetItem(info);
}
-long wxTreeCtrl::GetItemData(long item) const {
+long wxTreeCtrl::GetItemData(long item) const
+{
wxTreeItem info;
info.m_mask = wxTREE_MASK_DATA ;
return info.m_data;
}
-bool wxTreeCtrl::SetItemData(long item, long data) {
+bool wxTreeCtrl::SetItemData(long item, long data)
+{
wxTreeItem info;
info.m_mask = wxTREE_MASK_DATA ;
return SetItem(info);
}
-bool wxTreeCtrl::GetItemRect(long item, wxRectangle& rect, bool textOnly) const {
+bool wxTreeCtrl::GetItemRect(long item, wxRectangle& rect, bool textOnly) const
+{
/*
RECT rect2;
rect.height = rect2.bottom - rect2.left;
return success;
*/
+ wxFAIL_MSG("Not implemented");
+
return FALSE;
}
-wxTextCtrl* wxTreeCtrl::GetEditControl(void) const {
- return m_textCtrl;
+wxTextCtrl* wxTreeCtrl::GetEditControl() const
+{
+ return m_textCtrl;
}
// Operations
-bool wxTreeCtrl::DeleteItem(long item) {
+bool wxTreeCtrl::DeleteItem(long item)
+{
GtkTreeItem *p;
p = findGtkTreeItem(item);
return TRUE;
}
-bool wxTreeCtrl::DeleteChildren(long item) {
+bool wxTreeCtrl::DeleteChildren(long item)
+{
GtkTreeItem *p;
p = findGtkTreeItem(item);
return TRUE;
}
-bool wxTreeCtrl::ExpandItem(long item, int action) {
+bool wxTreeCtrl::ExpandItem(long item, int action)
+{
GtkTreeItem *p;
p = findGtkTreeItem(item);
return TRUE;
}
-long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter) {
+long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter)
+{
GtkTreeItem *p;
GtkTreeItem *item = NULL;
return InsertItem(parent, info, insertAfter);
}
-bool wxTreeCtrl::SelectItem(long item) {
+bool wxTreeCtrl::SelectItem(long item)
+{
GtkTreeItem *p;
p = findGtkTreeItem(item);
return TRUE;
}
-bool wxTreeCtrl::ScrollTo(long item) {
+bool wxTreeCtrl::ScrollTo(long item)
+{
+ wxFAIL_MSG("Not implemented");
+
return FALSE; // Still unimplemented
}
-bool wxTreeCtrl::DeleteAllItems(void) {
+bool wxTreeCtrl::DeleteAllItems()
+{
gtk_tree_item_remove_subtree(m_anchor);
return TRUE;
}
-wxTextCtrl* wxTreeCtrl::EditLabel(long item, wxClassInfo* textControlClass) {
+wxTextCtrl* wxTreeCtrl::EditLabel(long item, wxClassInfo* textControlClass)
+{
wxASSERT( (textControlClass->IsKindOf(CLASSINFO(wxTextCtrl))) );
/*
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) {
+bool wxTreeCtrl::EndEditLabel(bool cancel)
+{
/*
bool success = (TreeView_EndEditLabelNow((HWND) GetHWND(), cancel) != 0);
}
return success;
*/
+ wxFAIL_MSG("Not implemented");
+
return FALSE;
}
-long wxTreeCtrl::HitTest(const wxPoint& point, int& flags) {
+long wxTreeCtrl::HitTest(const wxPoint& point, int& flags)
+{
/*
TV_HITTESTINFO hitTestInfo;
hitTestInfo.pt.x = (int) point.x;
return (long) hitTestInfo.hItem ;
*/
+ wxFAIL_MSG("Not implemented");
+
return 0;
}
}
*/
-bool wxTreeCtrl::SortChildren(long item) {
+bool wxTreeCtrl::SortChildren(long item)
+{
+ wxFAIL_MSG("Not implemented");
+
return FALSE; // Still unimplemented
}
-bool wxTreeCtrl::EnsureVisible(long item) {
+bool wxTreeCtrl::EnsureVisible(long item)
+{
+ wxFAIL_MSG("Not implemented");
+
return FALSE; // Still unimplemented
}
-void wxTreeCtrl::SendExpanding(long item) {
+void wxTreeCtrl::SendExpanding(long item)
+{
wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_EXPANDING, GetId());
event.SetEventObject(this);
ProcessEvent(event);
}
-void wxTreeCtrl::SendExpanded(long item) {
+void wxTreeCtrl::SendExpanded(long item)
+{
wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_EXPANDED, GetId());
event.SetEventObject(this);
ProcessEvent(event);
}
-void wxTreeCtrl::SendCollapsing(long item) {
+void wxTreeCtrl::SendCollapsing(long item)
+{
wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_COLLAPSING, GetId());
event.SetEventObject(this);
ProcessEvent(event);
}
-void wxTreeCtrl::SendCollapsed(long item) {
+void wxTreeCtrl::SendCollapsed(long item)
+{
wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_COLLAPSED, GetId());
event.SetEventObject(this);
ProcessEvent(event);
}
-void wxTreeCtrl::SendSelChanging(long item) {
+void wxTreeCtrl::SendSelChanging(long item)
+{
wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGED, GetId());
event.SetEventObject(this);
ProcessEvent(event);
}
-void wxTreeCtrl::SendSelChanged(long item) {
+void wxTreeCtrl::SendSelChanged(long item)
+{
wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, GetId());
event.SetEventObject(this);
ProcessEvent(event);
}
// Tree item structure
-wxTreeItem::wxTreeItem(void) {
+wxTreeItem::wxTreeItem()
+{
m_mask = 0;
m_itemId = 0;
m_state = 0;
// If getFullInfo is TRUE, we explicitly query for more info if we haven't got it all.
-static void wxConvertFromGtkTreeItem(wxTreeItem& info, GtkTreeItem *gtkItem) {
+static void wxConvertFromGtkTreeItem(wxTreeItem& info, GtkTreeItem *gtkItem)
+{
GtkLabel *l;
char *t;
info.m_text = t;
}
-static void wxConvertToGtkTreeItem(wxTreeCtrl *owner, wxTreeItem& info, GtkTreeItem **gtkItem) {
+static void wxConvertToGtkTreeItem(wxTreeCtrl *owner, wxTreeItem& info, GtkTreeItem **gtkItem)
+{
GtkTreeItem *item = (*gtkItem);
if (item == NULL) {
gtk_widget_show(GTK_WIDGET(m_box));
gtk_object_set_data(GTK_OBJECT(item), "id", (gpointer)info.m_itemId);
-printf("owner = %p\n", owner);
gtk_object_set_data(GTK_OBJECT(item), "owner", owner);
(*gtkItem) = item;
}
// 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;
}
// Created: 07/05/98
// RCS-ID: $Id$
// Copyright: (c) Denis Pershin
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
static void gtk_treeitem_collapse_callback( GtkWidget *WXUNUSED(widget), wxTreeItem *treeitem);
static void gtk_treeitem_select_callback( GtkWidget *WXUNUSED(widget), wxTreeItem *treeitem);
-static void gtk_treeitem_expand_callback(GtkWidget *widget, wxTreeItem *treeitem) {
+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;
owner->SendExpanded(id);
};
-static void gtk_treeitem_collapse_callback(GtkWidget *widget, wxTreeItem *treeitem) {
+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;
owner->SendCollapsed(id);
};
-static void gtk_treeitem_select_callback(GtkWidget *widget, wxTreeItem *treeitem) {
+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;
}
#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl)
-IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject)
-
+ IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl)
+ IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject)
#endif
-wxTreeCtrl::wxTreeCtrl(void) {
+wxTreeCtrl::wxTreeCtrl()
+{
m_imageListNormal = NULL;
m_imageListState = NULL;
m_textCtrl = NULL;
m_widget = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(m_widget),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
m_tree = GTK_TREE(gtk_tree_new());
gtk_container_add(GTK_CONTAINER(m_widget), GTK_WIDGET(m_tree));
- gtk_widget_set_parent(GTK_WIDGET(m_tree), m_widget);
gtk_widget_show(GTK_WIDGET(m_tree));
wxSystemSettings settings;
return TRUE;
}
-wxTreeCtrl::~wxTreeCtrl(void) {
- if (m_textCtrl)
- delete m_textCtrl;
+wxTreeCtrl::~wxTreeCtrl()
+{
+ wxDELETE(m_textCtrl);
}
// Attributes
-static void gtk_treectrl_count_callback (GtkWidget *widget, gpointer data) {
+static void gtk_treectrl_count_callback (GtkWidget *widget, gpointer data)
+{
int count = (*((int *)data));
count++;
gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_count_callback, data);
}
-int wxTreeCtrl::GetCount(void) const {
+int wxTreeCtrl::GetCount() const
+{
int count = 0;
if (m_anchor != NULL)
return count;
}
-int wxTreeCtrl::GetIndent(void) const {
+int wxTreeCtrl::GetIndent() const
+{
return m_tree->indent_value;
}
-void wxTreeCtrl::SetIndent(int indent) {
+void wxTreeCtrl::SetIndent(int indent)
+{
m_tree->indent_value = indent;
}
-wxImageList *wxTreeCtrl::GetImageList(int which) const {
+wxImageList *wxTreeCtrl::GetImageList(int which) const
+{
if (which == wxIMAGE_LIST_NORMAL) {
return m_imageListNormal;
}
return NULL;
}
-void wxTreeCtrl::SetImageList(wxImageList *imageList, int which) {
+void wxTreeCtrl::SetImageList(wxImageList *imageList, int which)
+{
if (which == wxIMAGE_LIST_NORMAL)
m_imageListNormal = imageList;
else
m_imageListState = imageList;
}
-long wxTreeCtrl::GetNextItem(long item, int code) const {
+long wxTreeCtrl::GetNextItem(long item, int code) const
+{
switch (code) {
case wxTREE_NEXT_CARET:
// flag = TVGN_CARET;
return 0;
}
-bool wxTreeCtrl::ItemHasChildren(long item) const {
+bool wxTreeCtrl::ItemHasChildren(long item) const
+{
GtkTreeItem *p;
int count = 0;
return (count != 0);
}
-static GtkTreeItem *findItem(GtkTreeItem *p, long id) {
+static GtkTreeItem *findItem(GtkTreeItem *p, long id)
+{
GtkTreeItem *q;
if (((long)gtk_object_get_data(GTK_OBJECT(p), "id")) == id)
return NULL;
}
-GtkTreeItem *wxTreeCtrl::findGtkTreeItem(long id) const {
+GtkTreeItem *wxTreeCtrl::findGtkTreeItem(long id) const
+{
return findItem(m_anchor, id);
}
-long wxTreeCtrl::GetChild(long item) const {
+long wxTreeCtrl::GetChild(long item) const
+{
GtkTreeItem *p;
GtkTreeItem *next = NULL;
return (-1);
}
-long wxTreeCtrl::GetParent(long item) const {
+long wxTreeCtrl::GetParent(long item) const
+{
GtkTreeItem *p;
p = findGtkTreeItem(item);
return (-1);
}
-long wxTreeCtrl::GetFirstVisibleItem(void) const {
+long wxTreeCtrl::GetFirstVisibleItem() const
+{
GtkTreeItem *next = NULL;
GList *list = gtk_container_children(GTK_CONTAINER(m_anchor));
return (-1);
}
-long wxTreeCtrl::GetNextVisibleItem(long item) const {
+long wxTreeCtrl::GetNextVisibleItem(long item) const
+{
GtkTreeItem *p;
GtkTreeItem *next = NULL;
return (-1);
}
-long wxTreeCtrl::GetSelection(void) const {
+long wxTreeCtrl::GetSelection() const
+{
GtkTreeItem *next = NULL;
GList *list = gtk_container_children(GTK_CONTAINER(m_anchor));
return (-1);
}
-long wxTreeCtrl::GetRootItem(void) const {
+long wxTreeCtrl::GetRootItem() const
+{
return (long)gtk_object_get_data(GTK_OBJECT(m_anchor), "id");
}
-bool wxTreeCtrl::GetItem(wxTreeItem& info) const {
+bool wxTreeCtrl::GetItem(wxTreeItem& info) const
+{
GtkTreeItem *p;
p = findGtkTreeItem(info.m_itemId);
if (p == NULL) {
- wxLogSysError("TreeCtrl::GetItem failed");
+ wxLogError("TreeCtrl::GetItem failed.");
return FALSE;
}
return TRUE;
}
-bool wxTreeCtrl::SetItem(wxTreeItem& info) {
+bool wxTreeCtrl::SetItem(wxTreeItem& info)
+{
GtkTreeItem *p;
p = findGtkTreeItem(info.m_itemId);
if (p == NULL) {
- wxLogSysError("TreeCtrl::SetItem failed");
+ wxLogError("TreeCtrl::SetItem failed.");
return FALSE;
}
return TRUE;
}
-int wxTreeCtrl::GetItemState(long item, long stateMask) const {
+int wxTreeCtrl::GetItemState(long item, long stateMask) const
+{
wxTreeItem info;
info.m_mask = wxTREE_MASK_STATE ;
return info.m_state;
}
-bool wxTreeCtrl::SetItemState(long item, long state, long stateMask) {
+bool wxTreeCtrl::SetItemState(long item, long state, long stateMask)
+{
wxTreeItem info;
info.m_mask = wxTREE_MASK_STATE ;
return SetItem(info);
}
-bool wxTreeCtrl::SetItemImage(long item, int image, int selImage) {
+bool wxTreeCtrl::SetItemImage(long item, int image, int selImage)
+{
wxTreeItem info;
info.m_mask = wxTREE_MASK_IMAGE ;
return SetItem(info);
}
-wxString wxTreeCtrl::GetItemText(long item) const {
+wxString wxTreeCtrl::GetItemText(long item) const
+{
wxTreeItem info;
info.m_mask = wxTREE_MASK_TEXT ;
return info.m_text;
}
-void wxTreeCtrl::SetItemText(long item, const wxString& str) {
+void wxTreeCtrl::SetItemText(long item, const wxString& str)
+{
wxTreeItem info;
info.m_mask = wxTREE_MASK_TEXT ;
SetItem(info);
}
-long wxTreeCtrl::GetItemData(long item) const {
+long wxTreeCtrl::GetItemData(long item) const
+{
wxTreeItem info;
info.m_mask = wxTREE_MASK_DATA ;
return info.m_data;
}
-bool wxTreeCtrl::SetItemData(long item, long data) {
+bool wxTreeCtrl::SetItemData(long item, long data)
+{
wxTreeItem info;
info.m_mask = wxTREE_MASK_DATA ;
return SetItem(info);
}
-bool wxTreeCtrl::GetItemRect(long item, wxRectangle& rect, bool textOnly) const {
+bool wxTreeCtrl::GetItemRect(long item, wxRectangle& rect, bool textOnly) const
+{
/*
RECT rect2;
rect.height = rect2.bottom - rect2.left;
return success;
*/
+ wxFAIL_MSG("Not implemented");
+
return FALSE;
}
-wxTextCtrl* wxTreeCtrl::GetEditControl(void) const {
- return m_textCtrl;
+wxTextCtrl* wxTreeCtrl::GetEditControl() const
+{
+ return m_textCtrl;
}
// Operations
-bool wxTreeCtrl::DeleteItem(long item) {
+bool wxTreeCtrl::DeleteItem(long item)
+{
GtkTreeItem *p;
p = findGtkTreeItem(item);
return TRUE;
}
-bool wxTreeCtrl::DeleteChildren(long item) {
+bool wxTreeCtrl::DeleteChildren(long item)
+{
GtkTreeItem *p;
p = findGtkTreeItem(item);
return TRUE;
}
-bool wxTreeCtrl::ExpandItem(long item, int action) {
+bool wxTreeCtrl::ExpandItem(long item, int action)
+{
GtkTreeItem *p;
p = findGtkTreeItem(item);
return TRUE;
}
-long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter) {
+long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter)
+{
GtkTreeItem *p;
GtkTreeItem *item = NULL;
return InsertItem(parent, info, insertAfter);
}
-bool wxTreeCtrl::SelectItem(long item) {
+bool wxTreeCtrl::SelectItem(long item)
+{
GtkTreeItem *p;
p = findGtkTreeItem(item);
return TRUE;
}
-bool wxTreeCtrl::ScrollTo(long item) {
+bool wxTreeCtrl::ScrollTo(long item)
+{
+ wxFAIL_MSG("Not implemented");
+
return FALSE; // Still unimplemented
}
-bool wxTreeCtrl::DeleteAllItems(void) {
+bool wxTreeCtrl::DeleteAllItems()
+{
gtk_tree_item_remove_subtree(m_anchor);
return TRUE;
}
-wxTextCtrl* wxTreeCtrl::EditLabel(long item, wxClassInfo* textControlClass) {
+wxTextCtrl* wxTreeCtrl::EditLabel(long item, wxClassInfo* textControlClass)
+{
wxASSERT( (textControlClass->IsKindOf(CLASSINFO(wxTextCtrl))) );
/*
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) {
+bool wxTreeCtrl::EndEditLabel(bool cancel)
+{
/*
bool success = (TreeView_EndEditLabelNow((HWND) GetHWND(), cancel) != 0);
}
return success;
*/
+ wxFAIL_MSG("Not implemented");
+
return FALSE;
}
-long wxTreeCtrl::HitTest(const wxPoint& point, int& flags) {
+long wxTreeCtrl::HitTest(const wxPoint& point, int& flags)
+{
/*
TV_HITTESTINFO hitTestInfo;
hitTestInfo.pt.x = (int) point.x;
return (long) hitTestInfo.hItem ;
*/
+ wxFAIL_MSG("Not implemented");
+
return 0;
}
}
*/
-bool wxTreeCtrl::SortChildren(long item) {
+bool wxTreeCtrl::SortChildren(long item)
+{
+ wxFAIL_MSG("Not implemented");
+
return FALSE; // Still unimplemented
}
-bool wxTreeCtrl::EnsureVisible(long item) {
+bool wxTreeCtrl::EnsureVisible(long item)
+{
+ wxFAIL_MSG("Not implemented");
+
return FALSE; // Still unimplemented
}
-void wxTreeCtrl::SendExpanding(long item) {
+void wxTreeCtrl::SendExpanding(long item)
+{
wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_EXPANDING, GetId());
event.SetEventObject(this);
ProcessEvent(event);
}
-void wxTreeCtrl::SendExpanded(long item) {
+void wxTreeCtrl::SendExpanded(long item)
+{
wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_EXPANDED, GetId());
event.SetEventObject(this);
ProcessEvent(event);
}
-void wxTreeCtrl::SendCollapsing(long item) {
+void wxTreeCtrl::SendCollapsing(long item)
+{
wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_COLLAPSING, GetId());
event.SetEventObject(this);
ProcessEvent(event);
}
-void wxTreeCtrl::SendCollapsed(long item) {
+void wxTreeCtrl::SendCollapsed(long item)
+{
wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_COLLAPSED, GetId());
event.SetEventObject(this);
ProcessEvent(event);
}
-void wxTreeCtrl::SendSelChanging(long item) {
+void wxTreeCtrl::SendSelChanging(long item)
+{
wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGED, GetId());
event.SetEventObject(this);
ProcessEvent(event);
}
-void wxTreeCtrl::SendSelChanged(long item) {
+void wxTreeCtrl::SendSelChanged(long item)
+{
wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, GetId());
event.SetEventObject(this);
ProcessEvent(event);
}
// Tree item structure
-wxTreeItem::wxTreeItem(void) {
+wxTreeItem::wxTreeItem()
+{
m_mask = 0;
m_itemId = 0;
m_state = 0;
// If getFullInfo is TRUE, we explicitly query for more info if we haven't got it all.
-static void wxConvertFromGtkTreeItem(wxTreeItem& info, GtkTreeItem *gtkItem) {
+static void wxConvertFromGtkTreeItem(wxTreeItem& info, GtkTreeItem *gtkItem)
+{
GtkLabel *l;
char *t;
info.m_text = t;
}
-static void wxConvertToGtkTreeItem(wxTreeCtrl *owner, wxTreeItem& info, GtkTreeItem **gtkItem) {
+static void wxConvertToGtkTreeItem(wxTreeCtrl *owner, wxTreeItem& info, GtkTreeItem **gtkItem)
+{
GtkTreeItem *item = (*gtkItem);
if (item == NULL) {
gtk_widget_show(GTK_WIDGET(m_box));
gtk_object_set_data(GTK_OBJECT(item), "id", (gpointer)info.m_itemId);
-printf("owner = %p\n", owner);
gtk_object_set_data(GTK_OBJECT(item), "owner", owner);
(*gtkItem) = item;
}
// 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;
}