listview_item.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 ** Harry Storbacka
28 */
29 
30 
31 #pragma once
32 
33 #include "../api_gui.h"
34 
35 namespace clan
36 {
39 
40 class ListViewColumnData;
41 class ListViewItem_Impl;
42 
44 {
45 public:
46  virtual ~ListViewItemUserData() { }
47 };
48 
50 class CL_API_GUI ListViewItem
51 {
54 
55 public:
57  ListViewItem();
58 
59  ~ListViewItem();
60 
64 
65 public:
66 
68  bool is_null() const { return !impl; }
69 
71  void throw_if_null() const;
72 
76  bool is_item() const;
77 
83  ListViewColumnData get_column(const std::string &column_id);
84 
88  ListViewItem get_parent();
89 
93  ListViewItem get_next_sibling();
94 
98  ListViewItem get_prev_sibling();
99 
103  ListViewItem get_first_child();
104 
108  ListViewItem get_last_child();
109 
113  ListViewItem get_document_item();
114 
118  int get_parent_count();
119 
126  int get_child_count(bool recursive=false, bool recurse_only_into_open_items=false);
127 
131  bool has_children() const;
132 
136  bool is_open() const;
137 
141  bool is_selected() const;
142 
146  bool is_editable() const;
147 
149  int get_icon() const;
150 
152  int get_id() const;
153 
157  std::shared_ptr<ListViewItemUserData> get_userdata() const;
158 
159  bool operator==(ListViewItem &other) const;
160 
161  bool operator!=(ListViewItem &other) const;
162 
163  std::vector<int> get_overlay_icons();
164 
168 
169 public:
170 
176  ListViewItem append_child(ListViewItem &item);
177 
179  ListViewItem remove();
180 
182  void remove_children();
183 
188  void set_column_text(const std::string &column_id, const std::string &text);
189 
193  void set_open(bool open);
194 
198  void set_icon(int icon_index);
199 
201  void set_id(int id);
202 
206  void add_overlay_icon(int icon_index);
207 
211  void remove_overlay_icon(int icon_index);
212 
216  void set_editable(bool editable);
217 
221  void set_userdata(std::shared_ptr<ListViewItemUserData> ptr);
222 
226 
227 public:
228  Callback_v1<Rect> &func_render_icon();
229 
233 
234 private:
235 
239  ListViewItem(const std::shared_ptr<ListViewItem_Impl> &impl);
240 
241  std::shared_ptr<ListViewItem_Impl> impl;
242 
243  friend class ListView;
244  friend class ListView_Impl;
245  friend class ListViewSelection;
246  friend class ListViewLayout;
248 };
249 
250 }
251 
ListView selection.
Definition: listview_selected_item.h:114
ListView item.
Definition: listview_item.h:50
List view component.
Definition: listview.h:64
bool is_null() const
Returns true if this object is invalid.
Definition: listview_item.h:68
Definition: listview_item.h:43
Callback_v1.
Definition: callback_v1.h:156
virtual ~ListViewItemUserData()
Definition: listview_item.h:46
ListView column data.
Definition: listview_column_data.h:43