Compiles now..

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37658 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2006-02-21 18:44:13 +00:00
parent 64ffb88849
commit 1557c77b9f

View File

@@ -21,9 +21,8 @@
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
#include <gobject/gvaluecollector.h> #include <gobject/gvaluecollector.h>
#include "gtktreemodel.h" #include <gtk/gtktreemodel.h>
#include "gtktreedatalist.h" #include <gtk/gtktreednd.h>
#include "gtktreednd.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
@@ -77,8 +76,9 @@ struct _GtkWxListStoreClass
}; };
static GtkWxListStore *wxgtk_list_store_new ();
static void wxgtk_list_store_init (GtkWxListStore *list_store); static void wxgtk_list_store_init (GtkWxListStore *list_store);
static void wxgtk_list_store_class_init (GtkWxListStoreClass *class); static void wxgtk_list_store_class_init (GtkWxListStoreClass *klass);
static void wxgtk_list_store_tree_model_init (GtkTreeModelIface *iface); static void wxgtk_list_store_tree_model_init (GtkTreeModelIface *iface);
static void wxgtk_list_store_finalize (GObject *object); static void wxgtk_list_store_finalize (GObject *object);
static GtkTreeModelFlags wxgtk_list_store_get_flags (GtkTreeModel *tree_model); static GtkTreeModelFlags wxgtk_list_store_get_flags (GtkTreeModel *tree_model);
@@ -147,7 +147,7 @@ wxgtk_list_store_get_type (void)
}; };
list_store_type = g_type_register_static (G_TYPE_OBJECT, "GtkWxListStore", list_store_type = g_type_register_static (G_TYPE_OBJECT, "GtkWxListStore",
&list_store_info, 0); &list_store_info, (GTypeFlags)0 );
g_type_add_interface_static (list_store_type, g_type_add_interface_static (list_store_type,
GTK_TYPE_TREE_MODEL, GTK_TYPE_TREE_MODEL,
@@ -157,12 +157,19 @@ wxgtk_list_store_get_type (void)
return list_store_type; return list_store_type;
} }
static GtkWxListStore *
wxgtk_list_store_new()
{
GtkWxListStore *retval = (GtkWxListStore *) g_object_new (GTK_TYPE_WX_LIST_STORE, NULL);
return retval;
}
static void static void
wxgtk_list_store_class_init (GtkWxListStoreClass *class) wxgtk_list_store_class_init (GtkWxListStoreClass *klass)
{ {
GObjectClass *object_class; GObjectClass *object_class;
parent_class = g_type_class_peek_parent (class); parent_class = (GObjectClass*) g_type_class_peek_parent (klass);
object_class = (GObjectClass*) class; object_class = (GObjectClass*) klass;
object_class->finalize = wxgtk_list_store_finalize; object_class->finalize = wxgtk_list_store_finalize;
} }
@@ -187,13 +194,13 @@ static void
wxgtk_list_store_init (GtkWxListStore *list_store) wxgtk_list_store_init (GtkWxListStore *list_store)
{ {
list_store->model = NULL; list_store->model = NULL;
list_store->stamp = g_random_init(); list_store->stamp = g_random_int();
} }
static void static void
wxgtk_list_store_finalize (GObject *object) wxgtk_list_store_finalize (GObject *object)
{ {
GtkWxListStore *list_store = GTK_LIST_STORE (object); /* GtkWxListStore *list_store = GTK_WX_LIST_STORE (object); */
/* we need to sort out, which class deletes what */ /* we need to sort out, which class deletes what */
/* delete model; */ /* delete model; */
@@ -212,7 +219,7 @@ wxgtk_list_store_finalize (GObject *object)
static GtkTreeModelFlags static GtkTreeModelFlags
wxgtk_list_store_get_flags (GtkTreeModel *tree_model) wxgtk_list_store_get_flags (GtkTreeModel *tree_model)
{ {
g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), 0); g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), (GtkTreeModelFlags)0 );
// GTK+ list store uses a linked list for storing the // GTK+ list store uses a linked list for storing the
// items and a pointer to a child is used as the member // items and a pointer to a child is used as the member
@@ -240,13 +247,12 @@ wxgtk_list_store_get_column_type (GtkTreeModel *tree_model,
GtkWxListStore *list_store = (GtkWxListStore *) tree_model; GtkWxListStore *list_store = (GtkWxListStore *) tree_model;
g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), G_TYPE_INVALID); g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), G_TYPE_INVALID);
GType gtype = G_TYPE_STRING; GType gtype = G_TYPE_INVALID;
#if 0 wxString wxtype = list_store->model->GetColType( (size_t) index );
wxString wxtype = list_store->model->GetColType( index );
// convert wxtype to GType if (wxtype == wxT("string"))
gtype = .. gtype = G_TYPE_STRING;
#endif
return gtype; return gtype;
} }
@@ -260,9 +266,9 @@ wxgtk_list_store_get_iter (GtkTreeModel *tree_model,
g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), FALSE); g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), FALSE);
g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE); g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
i = gtk_tree_path_get_indices (path)[0]; size_t i = (size_t)gtk_tree_path_get_indices (path)[0];
if (i >= list_store->model->GetCount()) if (i >= list_store->model->GetNumberOfRows())
return FALSE; return FALSE;
iter->stamp = list_store->stamp; iter->stamp = list_store->stamp;
@@ -276,14 +282,12 @@ static GtkTreePath *
wxgtk_list_store_get_path (GtkTreeModel *tree_model, wxgtk_list_store_get_path (GtkTreeModel *tree_model,
GtkTreeIter *iter) GtkTreeIter *iter)
{ {
GtkWxListStore *list_store = (GtkListStore *) tree_model;
g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), NULL); g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), NULL);
g_return_val_if_fail (iter->stamp == GTK_WX_LIST_STORE (tree_model)->stamp, NULL); g_return_val_if_fail (iter->stamp == GTK_WX_LIST_STORE (tree_model)->stamp, NULL);
GtkTreePath *retval = gtk_tree_path_new (); GtkTreePath *retval = gtk_tree_path_new ();
// user_data is just the index // user_data is just the index
int i = (int) item->user_data; int i = (int) iter->user_data;
gtk_tree_path_append_index (retval, i); gtk_tree_path_append_index (retval, i);
return retval; return retval;
} }
@@ -294,11 +298,20 @@ wxgtk_list_store_get_value (GtkTreeModel *tree_model,
gint column, gint column,
GValue *value) GValue *value)
{ {
GtkWxListStore *list_store = (GtkListStore *) tree_model; GtkWxListStore *list_store = (GtkWxListStore *) tree_model;
g_return_if_fail (GTK_IS_WX_LIST_STORE (tree_model) ); g_return_if_fail (GTK_IS_WX_LIST_STORE (tree_model) );
g_value_init( value, G_TYPE_STRING ); wxDataViewListModel *model = list_store->model;
g_value_set_string( value, "Hello" ); wxString mtype = model->GetColType( (size_t) column );
if (mtype == wxT("string"))
{
g_value_init( value, G_TYPE_STRING );
wxVariant variant = model->GetValue( (size_t) column, (size_t) iter->user_data );
g_value_set_string( value, wxGTK_CONV(variant.GetString()) );
}
else
{
}
#if 0 #if 0
GtkTreeDataList *list; GtkTreeDataList *list;
@@ -327,7 +340,7 @@ wxgtk_list_store_iter_next (GtkTreeModel *tree_model,
GtkTreeIter *iter) GtkTreeIter *iter)
{ {
g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), FALSE); g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), FALSE);
GtkWxListStore *list_store = (GtkListStore *) tree_model; GtkWxListStore *list_store = (GtkWxListStore *) tree_model;
g_return_val_if_fail (list_store->stamp == iter->stamp, FALSE); g_return_val_if_fail (list_store->stamp == iter->stamp, FALSE);
@@ -336,7 +349,7 @@ wxgtk_list_store_iter_next (GtkTreeModel *tree_model,
if (n == -1) if (n == -1)
return FALSE; return FALSE;
if (n >= (int) list_store->model->GetRowCount()) if (n >= (int) list_store->model->GetNumberOfRows())
return FALSE; return FALSE;
iter->user_data = (gpointer) n++; iter->user_data = (gpointer) n++;
@@ -350,7 +363,7 @@ wxgtk_list_store_iter_children (GtkTreeModel *tree_model,
GtkTreeIter *parent) GtkTreeIter *parent)
{ {
g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), FALSE); g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), FALSE);
GtkWxListStore *list_store = (GtkListStore *) tree_model; GtkWxListStore *list_store = (GtkWxListStore *) tree_model;
// this is a list, nodes have no children // this is a list, nodes have no children
if (parent) if (parent)
@@ -374,10 +387,10 @@ wxgtk_list_store_iter_n_children (GtkTreeModel *tree_model,
GtkTreeIter *iter) GtkTreeIter *iter)
{ {
g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), -1); g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), -1);
GtkWxListStore *list_store = (GtkListStore *) tree_model; GtkWxListStore *list_store = (GtkWxListStore *) tree_model;
if (iter == NULL) if (iter == NULL)
return (gint) list_store->model->GetRowCount(); return (gint) list_store->model->GetNumberOfRows();
g_return_val_if_fail (list_store->stamp == iter->stamp, -1); g_return_val_if_fail (list_store->stamp == iter->stamp, -1);
@@ -391,7 +404,7 @@ wxgtk_list_store_iter_nth_child (GtkTreeModel *tree_model,
gint n) gint n)
{ {
g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), FALSE); g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), FALSE);
GtkWxListStore *list_store = (GtkListStore *) tree_model; GtkWxListStore *list_store = (GtkWxListStore *) tree_model;
if (parent) if (parent)
return FALSE; return FALSE;
@@ -399,7 +412,7 @@ wxgtk_list_store_iter_nth_child (GtkTreeModel *tree_model,
if (n < 0) if (n < 0)
return FALSE; return FALSE;
if (n >= (gint) list_store->model->GetRowCount()) if (n >= (gint) list_store->model->GetNumberOfRows())
return FALSE; return FALSE;
iter->stamp = list_store->stamp; iter->stamp = list_store->stamp;
@@ -469,17 +482,15 @@ bool wxDataViewCtrl::AppendStringColumn( const wxString &label )
return true; return true;
} }
bool wxDataViewCtrl::AssociateModel( wxDataViewStore *model ) bool wxDataViewCtrl::AssociateModel( wxDataViewModel *model )
{ {
if (!wxDataViewCtrlBase::AssociateModel( model )) if (!wxDataViewCtrlBase::AssociateModel( model ))
return false; return false;
// Right now we only have the GTK+ port's GtkWxListStore *wxmodel = wxgtk_list_store_new();
// list store variant, so cast to that... wxmodel->model = (wxDataViewListModel*) model;
wxDataViewListStore *liststore = (wxDataViewListStore*) store; gtk_tree_view_set_model( GTK_TREE_VIEW(m_widget), GTK_TREE_MODEL(wxmodel) );
gtk_tree_view_set_model( GTK_TREE_VIEW(m_widget), GTK_TREE_MODEL(liststore->GetGtkListStore()) );
return true; return true;
} }