ClanLib  2.3.7
listview.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 // (Note, enum moved here because of problems with gcc not allowing "enum CL_ListViewDisplayMode;")
37 {
43 };
44 
45 #include "../api_gui.h"
46 #include "../gui_component.h"
47 #include "listview_item.h"
48 #include "listview_selected_item.h"
49 #include "listview_column_header.h"
50 #include "listview_icon_list.h"
51 
52 class CL_ListViewHeader;
53 class CL_ListView_Impl;
55 class CL_InputEvent;
56 
61 {
64 
65 public:
66 
71 
72  virtual ~CL_ListView();
73 
77 
78 public:
80 
84  static CL_ListView *get_named_item(CL_GUIComponent *reference_component, const CL_StringRef &id);
85 
89  int get_scroll_position();
90 
94  int get_scroll_max_position();
95 
99  CL_ListViewHeader *get_header() const;
100 
104  CL_ListViewItem get_document_item() const;
105 
109  bool get_select_whole_row() const;
110 
114  CL_ListViewIconList get_icon_list() const;
115 
117  CL_ListViewSelection get_selected_items() const;
118 
123  CL_ListViewItem get_selected_item();
124 
126  CL_Size get_preferred_size() const;
127 
131  CL_ListViewDisplayMode get_display_mode() const;
132 
136 
137 public:
138 
142  CL_ListViewItem create_item();
143 
147  void set_scroll_position(int pos);
148 
152  void on_process_message(CL_GUIMessage &msg);
153 
155  void set_select_whole_row(bool value);
156 
158  void set_multi_select(bool value);
159 
163  void set_display_mode(CL_ListViewDisplayMode mode);
164 
166  void show_detail_icon(bool enable = true);
167 
169  void show_detail_opener(bool enable = true);
170 
172  void clear();
173 
175  void clear_selection();
176 
181  void set_selected(CL_ListViewItem &item, bool selected=true);
182 
184  CL_ListViewItem find(const CL_StringRef &col_id, const CL_StringRef &str, bool recursive=true);
185 
187  CL_ListViewItem find(int id, bool recursive=true);
188 
190  CL_ListViewItem find(CL_SharedPtr<CL_ListViewItemUserData> userdata, bool recursive=true);
191 
195 
196 public:
198  CL_Callback_v1<CL_ListViewSelection> &func_selection_changed();
199 
201  CL_Callback_v1<const CL_ListViewItem &> &func_item_doubleclick();
202 
206 
207  CL_Callback_v1<CL_InputEvent> &func_key_pressed();
208 
209  CL_Callback_v1<CL_InputEvent> &func_key_released();
210 
213  CL_Callback_v1<CL_Point> &func_mouse_right_up();
214 
218 
219 private:
220  CL_SharedPtr<CL_ListView_Impl> impl;
221 
222  friend class CL_ListViewRenderer;
224 };
225