Debian Codegraph @

gtk/gtkmm/listviewtext.h

raw symbols SCIP
1 /* Copyright (C) 2006 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 #ifndef _GTKMM_LISTVIEW_TEXT_H
18 #define _GTKMM_LISTVIEW_TEXT_H
19
20 #include <gtkmm/treeview.h>
21 #include <gtkmm/liststore.h>
22
23 #include <vector>
24
25 namespace Gtk
26 {
27
28 /** A simple listbox which presents some lines of information in columns and lets the user select some of them.
29 *
30 * This is a convenience class, based on Gtk::TreeView, which allows only text values and does not allow child items.
31 * In most cases you will actually need the functionality offered by a real Gtk::TreeView with your own type-safe
32 * Gtk::TreeModel::ColumnRecord.
33 *
34 * @ingroup Widgets
35 * @ingroup Containers
36 * @ingroup TreeView
37 *
38 * @newin{2,10}
39 */
40 class GTKMM_API ListViewText : public Gtk::TreeView
41 {
42 public:
43
44 ListViewText(guint columns_count, bool editable = false, Gtk::SelectionMode mode = Gtk::SELECTION_SINGLE);
45 ~ListViewText() noexcept override;
46
47 /** Adds a title to column @a column.
48 * @param column the column number.
49 * @param title the title for column @a column.
50 */
51 void set_column_title(guint column, const Glib::ustring& title);
52
53 /** Gets the title of column @a column.
54 * @param column the column number.
55 * @return the title of column @a column.
56 */
57 Glib::ustring get_column_title(guint column) const;
58
59 /** Add a new row at the end of the list
60 * @param column_one_value the new text for the new row, column 0
61 * @return the number of the row added
62 */
63 guint append(const Glib::ustring& column_one_value = Glib::ustring());
64
65 /** Insert a new row at the beginning of the list
66 * @param column_one_value the new text for the new row, column 0
67 */
68 void prepend(const Glib::ustring& column_one_value = Glib::ustring());
69
70 /** Insert a new row at an arbitrary position in the list
71 * @param row The row number
72 * @param column_one_value the new text for the new row, column 0
73 */
74 void insert(guint row, const Glib::ustring& column_one_value = Glib::ustring());
75
76 /// Discard all row:
77 void clear_items();
78
79 /** Obtain the value of an existing cell from the list.
80 * @param row the number of the row in the listbox.
81 * @param column the number of the column in the row.
82 * @return the value of that cell, if it exists.
83 */
84 Glib::ustring get_text(guint row, guint column = 0) const;
85
86 /** Change an existing value of cell of the list.
87 * @param row the number of the row in the list.
88 * @param column the number of the column in the row.
89 * @param value the new contents of that row and column.
90 */
91 void set_text(guint row, guint column, const Glib::ustring& value);
92
93 /** Change an existing value of a column 0 of a row of the list
94 * @param row the number of the row in the list.
95 * @param value the new contents of column 0 of the row.
96 */
97 void set_text(guint row, const Glib::ustring& value);
98
99 /// @return the number of rows in the listbox
100 guint size() const;
101
102 /// @return the number of columns in the listbox
103 guint get_num_columns() const;
104
105 typedef std::vector<int> SelectionList;
106
107 /** Returns a vector of the indexes of the selected rows
108 * @return a SelectionList with the selection results
109 */
110 SelectionList get_selected();
111
112 protected:
113
114 class TextModelColumns : public Gtk::TreeModel::ColumnRecord
115 {
116 public:
117 TextModelColumns(guint columns_count);
118 ~TextModelColumns() noexcept;
119
120 guint get_num_columns() const;
121
122 Gtk::TreeModelColumn<Glib::ustring>* m_columns;
123
124 protected:
125 guint m_columns_count;
126 };
127
128 Glib::RefPtr<Gtk::ListStore> m_model;
129 TextModelColumns m_model_columns;
130 };
131
132 } //namespace Gtk
133
134 #endif //_GTKMM_LISTVIEW_TEXT_H