listview.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 namespace clan
34 {
35 // (Note, enum moved here because of problems with gcc not allowing "enum ListViewDisplayMode;")
37 {
43 };
44 }
45 
46 #include "../api_gui.h"
47 #include "../gui_component.h"
48 #include "listview_item.h"
49 #include "listview_selected_item.h"
50 #include "listview_column_header.h"
51 #include "listview_icon_list.h"
52 
53 namespace clan
54 {
57 
58 class ListViewHeader;
59 class ListView_Impl;
60 class ListViewIconList;
61 class InputEvent;
62 
64 class CL_API_GUI ListView : public GUIComponent
65 {
68 
69 public:
70 
74  ListView(GUIComponent *parent);
75 
76  virtual ~ListView();
77 
81 
82 public:
84 
88  static ListView *get_named_item(GUIComponent *reference_component, const std::string &id);
89 
93  int get_scroll_position();
94 
98  int get_scroll_max_position();
99 
103  ListViewHeader *get_header() const;
104 
108  ListViewItem get_document_item() const;
109 
113  bool get_select_whole_row() const;
114 
118  ListViewIconList get_icon_list() const;
119 
121  ListViewSelection get_selected_items() const;
122 
127  ListViewItem get_selected_item();
128 
130  Size get_css_size() const;
131 
135  ListViewDisplayMode get_display_mode() const;
136 
140 
141 public:
142 
146  ListViewItem create_item();
147 
151  void set_scroll_position(int pos);
152 
156  void on_process_message(std::shared_ptr<GUIMessage> &msg);
157 
159  void set_select_whole_row(bool value);
160 
162  void set_multi_select(bool value);
163 
167  void set_display_mode(ListViewDisplayMode mode);
168 
170  void show_detail_icon(bool enable = true);
171 
173  void show_detail_opener(bool enable = true);
174 
176  void clear();
177 
179  void clear_selection();
180 
185  void set_selected(ListViewItem &item, bool selected=true);
186 
188  ListViewItem find(const std::string &col_id, const std::string &str, bool recursive=true);
189 
191  ListViewItem find(int id, bool recursive=true);
192 
194  ListViewItem find(std::shared_ptr<ListViewItemUserData> userdata, bool recursive=true);
195 
199 
200 public:
202  Callback_v1<ListViewSelection> &func_selection_changed();
203 
205  Callback_v1<const ListViewItem &> &func_item_doubleclick();
206 
210 
211  Callback_v1<InputEvent&> &func_key_pressed();
212 
213  Callback_v1<InputEvent&> &func_key_released();
214 
217  Callback_v1<Point> &func_mouse_right_up();
218 
220  Callback_v1<const ListViewItem &> &func_item_opened();
221 
223  Callback_v1<const ListViewItem &> &func_item_closed();
224 
226  Callback_v0 &func_begin_drag();
227 
231 
232 private:
233  std::shared_ptr<ListView_Impl> impl;
234 
235  friend class ListViewRenderer;
237 };
238 
239 }
240 
ListView selection.
Definition: listview_selected_item.h:114
Definition: listview.h:42
ListView item.
Definition: listview_item.h:50
List view component.
Definition: listview.h:64
Definition: listview.h:40
GUI base component class.
Definition: gui_component.h:80
ListViewDisplayMode
Definition: listview.h:36
Definition: listview.h:41
Definition: listview.h:38
GUIComponent * get_named_item(const std::string &id)
Find child component with the specified component ID name.
ListViewHeader component.
Definition: listview_header.h:48
Callback_v1.
Definition: callback_v1.h:156
ListView icon list.
Definition: listview_icon_list.h:45
Callback_2.
Definition: callback_2.h:156
2D (width,height) size structure - Integer
Definition: size.h:157
Definition: listview.h:39
Callback_v0.
Definition: callback_v0.h:152