/* Copyright (C) 1998-2002 The gtkmm Development Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see . */ #include #include namespace Gtk { TreeStore::TreeStore(const TreeModelColumnRecord& columns) : _CONSTRUCT() { gtk_tree_store_set_column_types(gobj(), columns.size(), const_cast(columns.types())); } void TreeStore::set_column_types(const TreeModelColumnRecord& columns) { gtk_tree_store_set_column_types(gobj(), columns.size(), const_cast(columns.types())); } TreeModel::iterator TreeStore::erase(const iterator& iter) { g_assert(iter.get_gobject_if_not_end() != nullptr); iterator next (iter); ++next; auto tmp = *iter.gobj(); gtk_tree_store_remove(gobj(), &tmp); return next; } TreeModel::iterator TreeStore::insert(const iterator& iter) { iterator new_pos (this); gtk_tree_store_insert_before( gobj(), new_pos.gobj(), const_cast(iter.get_parent_gobject_if_end()), const_cast(iter.get_gobject_if_not_end())); if(new_pos.gobj()->stamp == 0) new_pos.setup_end_iterator(iter); return new_pos; } TreeModel::iterator TreeStore::insert_after(const iterator& iter) { iterator new_pos (this); gtk_tree_store_insert_after( gobj(), new_pos.gobj(), const_cast(iter.get_parent_gobject_if_end()), const_cast(iter.get_gobject_if_not_end())); if(new_pos.gobj()->stamp == 0) new_pos.setup_end_iterator(iter); return new_pos; } TreeModel::iterator TreeStore::prepend() { iterator new_pos (this); gtk_tree_store_prepend(gobj(), new_pos.gobj(), nullptr); return new_pos; } TreeModel::iterator TreeStore::prepend(const TreeNodeChildren& node) { iterator new_pos (this); gtk_tree_store_prepend( gobj(), new_pos.gobj(), const_cast(node.get_parent_gobject())); return new_pos; } TreeModel::iterator TreeStore::append() { iterator new_pos (this); gtk_tree_store_append(gobj(), new_pos.gobj(), nullptr); return new_pos; } TreeModel::iterator TreeStore::append(const TreeNodeChildren& node) { iterator new_pos (this); gtk_tree_store_append( gobj(), new_pos.gobj(), const_cast(node.get_parent_gobject())); return new_pos; } void TreeStore::move(const iterator& source, const iterator& destination) { gtk_tree_store_move_before(gobj(), const_cast(source.get_gobject_if_not_end()), const_cast(destination.get_gobject_if_not_end())); } void TreeStore::reorder(const TreeNodeChildren& node, const std::vector& new_order) { gtk_tree_store_reorder(gobj(), const_cast(node.get_parent_gobject()), const_cast(Glib::ArrayHandler::vector_to_array(new_order).data ())); } void TreeStore::set_value_impl(const iterator& row, int column, const Glib::ValueBase& value) { gtk_tree_store_set_value( gobj(), const_cast(row.gobj()), column, const_cast(value.gobj())); } } // namespace Gtk