| 1 | /* Copyright (C) 2002 The gtkmm Development Team |
| 2 | * |
| 3 | * This library is free software; you can redistribute it and/or |
| 4 | * modify it under the terms of the GNU Lesser General Public |
| 5 | * License as published by the Free Software Foundation; either |
| 6 | * version 2.1 of the License, or(at your option) any later version. |
| 7 | * |
| 8 | * This library is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | * Lesser General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU Lesser General Public |
| 14 | * License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 | */ |
| 16 | |
| 17 | #include <gtkmm/treemodelcolumn.h> |
| 18 | |
| 19 | |
| 20 | namespace Gtk |
| 21 | { |
| 22 | |
| 23 | /**** Gtk::TreeModelColumnRecord *******************************************/ |
| 24 | |
| 25 | TreeModelColumnRecord::TreeModelColumnRecord() |
| 26 | : |
| 27 | column_types_ () |
| 28 | {} |
| 29 | |
| 30 | TreeModelColumnRecord::~TreeModelColumnRecord() noexcept |
| 31 | {} |
| 32 | |
| 33 | void TreeModelColumnRecord::add(TreeModelColumnBase& column) |
| 34 | { |
| 35 | g_return_if_fail(column.index_ == -1); //Check that it hasn't been set before. |
| 36 | |
| 37 | column.index_ = column_types_.size(); |
| 38 | column_types_.push_back(column.type_); |
| 39 | } |
| 40 | |
| 41 | unsigned int TreeModelColumnRecord::size() const |
| 42 | { |
| 43 | return column_types_.size(); |
| 44 | } |
| 45 | |
| 46 | const GType* TreeModelColumnRecord::types() const |
| 47 | { |
| 48 | g_return_val_if_fail(!column_types_.empty(), 0); |
| 49 | |
| 50 | // According to Josuttis' book, &vector.front() to get a builtin array is |
| 51 | // quasi-standard. It should work fine with any std::vector implementation. |
| 52 | return &column_types_.front(); |
| 53 | } |
| 54 | |
| 55 | /**** Gtk::TreeModelColumnBase *********************************************/ |
| 56 | |
| 57 | TreeModelColumnBase::TreeModelColumnBase(GType g_type) |
| 58 | : |
| 59 | type_ (g_type), |
| 60 | index_ (-1) //default to an invalid index. |
| 61 | {} |
| 62 | |
| 63 | } // namespace Gtk |