X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0bdfa38835fa13d142bbe56595123989c798bf31..ff58644a54af11b74b8e9b33a00de8496c531566:/src/gtk/dataview.cpp?ds=sidebyside diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 673814770e..0ecca2c7f1 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -1080,7 +1080,7 @@ gtk_wx_cell_renderer_render (GtkCellRenderer *renderer, rect.y += cell_area->y; rect.width -= renderer->xpad * 2; rect.height -= renderer->ypad * 2; - + GdkRectangle dummy; if (gdk_rectangle_intersect (expose_area, &rect, &dummy)) { @@ -1468,8 +1468,21 @@ wxDataViewCellMode wxDataViewRenderer::GetMode() const return ret; } -void wxDataViewRenderer::SetAlignment( int align ) +void wxDataViewRenderer::GtkUpdateAlignment() { + int align = m_alignment; + + // query alignment from column ? + if (align == -1) + { + // None there yet + if (GetOwner() == NULL) + return; + + align = GetOwner()->GetAlignment(); + align |= wxALIGN_CENTRE_VERTICAL; + } + // horizontal alignment: gfloat xalign = 0.0; @@ -1499,40 +1512,16 @@ void wxDataViewRenderer::SetAlignment( int align ) g_value_unset( &gvalue2 ); } -int wxDataViewRenderer::GetAlignment() const +void wxDataViewRenderer::SetAlignment( int align ) { - int ret = 0; - GValue gvalue; - - // horizontal alignment: - - g_object_get( G_OBJECT(m_renderer), "xalign", &gvalue, NULL ); - float xalign = g_value_get_float( &gvalue ); - if (xalign < 0.5) - ret |= wxALIGN_LEFT; - else if (xalign == 0.5) - ret |= wxALIGN_CENTER_HORIZONTAL; - else - ret |= wxALIGN_RIGHT; - g_value_unset( &gvalue ); - - - // vertical alignment: - - g_object_get( G_OBJECT(m_renderer), "yalign", &gvalue, NULL ); - float yalign = g_value_get_float( &gvalue ); - if (yalign < 0.5) - ret |= wxALIGN_TOP; - else if (yalign == 0.5) - ret |= wxALIGN_CENTER_VERTICAL; - else - ret |= wxALIGN_BOTTOM; - g_value_unset( &gvalue ); - - return ret; + m_alignment = align; + GtkUpdateAlignment(); } - +int wxDataViewRenderer::GetAlignment() const +{ + return m_alignment; +} // --------------------------------------------------------- // wxDataViewTextRenderer @@ -2262,7 +2251,7 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column), wxDataViewModel *wx_model = tree_model->internal->GetDataViewModel(); - if (!wx_model->IsIndexListModel()) + if (!wx_model->IsVirtualListModel()) { if (wx_model->IsContainer( item )) @@ -2564,6 +2553,9 @@ void wxDataViewColumn::SetAlignment( wxAlignment align ) xalign = 0.5; gtk_tree_view_column_set_alignment( column, xalign ); + + if (m_renderer && m_renderer->GetAlignment() == -1) + m_renderer->GtkUpdateAlignment(); } wxAlignment wxDataViewColumn::GetAlignment() const @@ -2649,7 +2641,16 @@ void wxDataViewColumn::SetWidth( int width ) { if (width < 0) { +#if 1 + gtk_tree_view_column_set_sizing( GTK_TREE_VIEW_COLUMN(m_column), GTK_TREE_VIEW_COLUMN_FIXED ); + + // TODO find a better calculation + gtk_tree_view_column_set_fixed_width( GTK_TREE_VIEW_COLUMN(m_column), wxDVC_DEFAULT_WIDTH ); +#else + // this is unpractical for large numbers of items and disables + // user resizing, which is totally unexpected gtk_tree_view_column_set_sizing( GTK_TREE_VIEW_COLUMN(m_column), GTK_TREE_VIEW_COLUMN_AUTOSIZE ); +#endif } else { @@ -2743,7 +2744,7 @@ wxDataViewCtrlInternal::wxDataViewCtrlInternal( wxDataViewCtrl *owner, m_sort_column = -1; m_dataview_sort_column = NULL; - if (!m_wx_model->IsIndexListModel()) + if (!m_wx_model->IsVirtualListModel()) InitTree(); } @@ -2862,13 +2863,13 @@ bool wxDataViewCtrlInternal::Cleared() void wxDataViewCtrlInternal::Resort() { - if (!m_wx_model->IsIndexListModel()) + if (!m_wx_model->IsVirtualListModel()) m_root->Resort(); } bool wxDataViewCtrlInternal::ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) { - if (!m_wx_model->IsIndexListModel()) + if (!m_wx_model->IsVirtualListModel()) { wxGtkTreeModelNode *parent_node = FindNode( parent ); if (m_wx_model->IsContainer( item )) @@ -2882,7 +2883,7 @@ bool wxDataViewCtrlInternal::ItemAdded( const wxDataViewItem &parent, const wxDa bool wxDataViewCtrlInternal::ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) { - if (!m_wx_model->IsIndexListModel()) + if (!m_wx_model->IsVirtualListModel()) { wxGtkTreeModelNode *parent_node = FindNode( parent ); parent_node->DeleteChild( item.GetID() ); @@ -2919,7 +2920,7 @@ bool wxDataViewCtrlInternal::ValueChanged( const wxDataViewItem &item, unsigned GtkTreeModelFlags wxDataViewCtrlInternal::get_flags() { - if (m_wx_model->IsIndexListModel()) + if (m_wx_model->IsVirtualListModel()) return GTK_TREE_MODEL_LIST_ONLY; else return GTK_TREE_MODEL_ITERS_PERSIST; @@ -2927,7 +2928,7 @@ GtkTreeModelFlags wxDataViewCtrlInternal::get_flags() gboolean wxDataViewCtrlInternal::get_iter( GtkTreeIter *iter, GtkTreePath *path ) { - if (m_wx_model->IsIndexListModel()) + if (m_wx_model->IsVirtualListModel()) { wxDataViewIndexListModel *wx_model = (wxDataViewIndexListModel*) m_wx_model; @@ -2987,7 +2988,7 @@ GtkTreePath *wxDataViewCtrlInternal::get_path( GtkTreeIter *iter ) { GtkTreePath *retval = gtk_tree_path_new (); - if (m_wx_model->IsIndexListModel()) + if (m_wx_model->IsVirtualListModel()) { // user_data is just the index int i = (wxUIntPtr) iter->user_data; @@ -3014,7 +3015,7 @@ GtkTreePath *wxDataViewCtrlInternal::get_path( GtkTreeIter *iter ) gboolean wxDataViewCtrlInternal::iter_next( GtkTreeIter *iter ) { - if (m_wx_model->IsIndexListModel()) + if (m_wx_model->IsVirtualListModel()) { wxDataViewIndexListModel *wx_model = (wxDataViewIndexListModel*) m_wx_model; @@ -3048,7 +3049,7 @@ gboolean wxDataViewCtrlInternal::iter_next( GtkTreeIter *iter ) gboolean wxDataViewCtrlInternal::iter_children( GtkTreeIter *iter, GtkTreeIter *parent ) { - if (m_wx_model->IsIndexListModel()) + if (m_wx_model->IsVirtualListModel()) { // this is a list, nodes have no children if (parent) @@ -3081,7 +3082,7 @@ gboolean wxDataViewCtrlInternal::iter_children( GtkTreeIter *iter, GtkTreeIter * gboolean wxDataViewCtrlInternal::iter_has_child( GtkTreeIter *iter ) { - if (m_wx_model->IsIndexListModel()) + if (m_wx_model->IsVirtualListModel()) { // this is a list, nodes have no children return FALSE; @@ -3104,7 +3105,7 @@ gboolean wxDataViewCtrlInternal::iter_has_child( GtkTreeIter *iter ) gint wxDataViewCtrlInternal::iter_n_children( GtkTreeIter *iter ) { - if (m_wx_model->IsIndexListModel()) + if (m_wx_model->IsVirtualListModel()) { wxDataViewIndexListModel *wx_model = (wxDataViewIndexListModel*) m_wx_model; @@ -3131,7 +3132,7 @@ gint wxDataViewCtrlInternal::iter_n_children( GtkTreeIter *iter ) gboolean wxDataViewCtrlInternal::iter_nth_child( GtkTreeIter *iter, GtkTreeIter *parent, gint n ) { - if (m_wx_model->IsIndexListModel()) + if (m_wx_model->IsVirtualListModel()) { wxDataViewIndexListModel *wx_model = (wxDataViewIndexListModel*) m_wx_model; @@ -3172,7 +3173,7 @@ gboolean wxDataViewCtrlInternal::iter_nth_child( GtkTreeIter *iter, GtkTreeIter gboolean wxDataViewCtrlInternal::iter_parent( GtkTreeIter *iter, GtkTreeIter *child ) { - if (m_wx_model->IsIndexListModel()) + if (m_wx_model->IsVirtualListModel()) { return FALSE; }