ClanLib  2.3.7
listview_item.h
Go to the documentation of this file.
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2011 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 
32 
33 #pragma once
34 
35 #include "../api_gui.h"
36 
38 class CL_ListViewItem_Impl;
39 
41 {
42 public:
44 };
45 
50 {
53 
54 public:
57 
58  ~CL_ListViewItem();
59 
63 
64 public:
65 
67  bool is_null() const { return !impl; }
68 
70  void throw_if_null() const;
71 
75  bool is_item() const;
76 
82  CL_ListViewColumnData get_column(const CL_StringRef &column_id);
83 
87  CL_ListViewItem get_parent();
88 
92  CL_ListViewItem get_next_sibling();
93 
97  CL_ListViewItem get_prev_sibling();
98 
102  CL_ListViewItem get_first_child();
103 
107  CL_ListViewItem get_last_child();
108 
112  CL_ListViewItem get_document_item();
113 
117  int get_parent_count();
118 
125  int get_child_count(bool recursive=false, bool recurse_only_into_open_items=false);
126 
130  bool has_children() const;
131 
135  bool is_open() const;
136 
140  bool is_selected() const;
141 
145  bool is_editable() const;
146 
148  int get_icon() const;
149 
151  int get_id() const;
152 
156  CL_SharedPtr<CL_ListViewItemUserData> get_userdata() const;
157 
158  bool operator==(CL_ListViewItem &other) const;
159 
160  bool operator!=(CL_ListViewItem &other) const;
161 
162  std::vector<int> get_overlay_icons();
163 
167 
168 public:
169 
175  CL_ListViewItem append_child(CL_ListViewItem &item);
176 
178  CL_ListViewItem remove();
179 
181  void remove_children();
182 
187  void set_column_text(const CL_StringRef &column_id, const CL_StringRef &text);
188 
192  void set_open(bool open);
193 
197  void set_icon(int icon_index);
198 
200  void set_id(int id);
201 
205  void add_overlay_icon(int icon_index);
206 
210  void remove_overlay_icon(int icon_index);
211 
215  void set_editable(bool editable);
216 
220  void set_userdata(CL_SharedPtr<CL_ListViewItemUserData> ptr);
221 
225 
226 public:
227  CL_Callback_v1<CL_Rect> &func_render_icon();
228 
232 
233 private:
234 
238  CL_ListViewItem(const CL_SharedPtr<CL_ListViewItem_Impl> &impl);
239 
240  CL_SharedPtr<CL_ListViewItem_Impl> impl;
241 
242  friend class CL_ListView;
243  friend class CL_ListView_Impl;
244  friend class CL_ListViewSelection;
245  friend class CL_ListViewLayout;
247 };
248