listview.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 **    Harry Storbacka
00028 */
00029 
00032 
00033 #pragma once
00034 
00035 // (Note, enum moved here because of problems with gcc not allowing "enum CL_ListViewDisplayMode;")
00036 enum CL_ListViewDisplayMode
00037 {
00038         listview_mode_thumbnails,
00039         listview_mode_tiles,
00040         listview_mode_icons,
00041         listview_mode_list,
00042         listview_mode_details
00043 };
00044 
00045 #include "../api_gui.h"
00046 #include "../gui_component.h"
00047 #include "listview_item.h"
00048 #include "listview_selected_item.h"
00049 #include "listview_column_header.h"
00050 #include "listview_icon_list.h"
00051 
00052 class CL_ListViewHeader;
00053 class CL_ListView_Impl;
00054 class CL_ListViewIconList;
00055 class CL_InputEvent;
00056 
00060 class CL_API_GUI CL_ListView : public CL_GUIComponent
00061 {
00064 
00065 public:
00066 
00070         CL_ListView(CL_GUIComponent *parent);
00071 
00072         virtual ~CL_ListView();
00073 
00077 
00078 public:
00079         using CL_GUIComponent::get_named_item;
00080 
00084         static CL_ListView *get_named_item(CL_GUIComponent *reference_component, const CL_StringRef &id);
00085 
00089         int get_scroll_position();
00090 
00094         int get_scroll_max_position();
00095         
00099         CL_ListViewHeader *get_header() const;
00100 
00104         CL_ListViewItem get_document_item() const;
00105 
00109         bool get_select_whole_row() const;
00110 
00114         CL_ListViewIconList get_icon_list() const;
00115 
00117         CL_ListViewSelection get_selected_items() const;
00118 
00123         CL_ListViewItem get_selected_item();
00124 
00126         CL_Size get_preferred_size() const;
00127 
00131         CL_ListViewDisplayMode get_display_mode() const;
00132 
00136 
00137 public:
00138 
00142         CL_ListViewItem create_item();
00143 
00147         void set_scroll_position(int pos);
00148 
00152         void on_process_message(CL_GUIMessage &msg);
00153 
00155         void set_select_whole_row(bool value);
00156 
00158         void set_multi_select(bool value);
00159 
00163         void set_display_mode(CL_ListViewDisplayMode mode);
00164 
00166         void show_detail_icon(bool enable = true);
00167 
00169         void show_detail_opener(bool enable = true);
00170 
00172         void clear();
00173 
00175         void clear_selection();
00176 
00181         void set_selected(CL_ListViewItem &item, bool selected=true);
00182 
00184         CL_ListViewItem find(const CL_StringRef &col_id, const CL_StringRef &str, bool recursive=true);
00185 
00187         CL_ListViewItem find(int id, bool recursive=true);
00188 
00190         CL_ListViewItem find(CL_SharedPtr<CL_ListViewItemUserData> userdata, bool recursive=true);
00191 
00195 
00196 public:
00198         CL_Callback_v1<CL_ListViewSelection> &func_selection_changed();
00199 
00201         CL_Callback_v1<const CL_ListViewItem &> &func_item_doubleclick();
00202 
00205         CL_Callback_2<bool, CL_ListViewItem, CL_String &> &func_item_edited();
00206 
00207         CL_Callback_v1<CL_InputEvent> &func_key_pressed();
00208 
00209         CL_Callback_v1<CL_InputEvent> &func_key_released();
00210 
00213         CL_Callback_v1<CL_Point> &func_mouse_right_up();
00214 
00218 
00219 private:
00220         CL_SharedPtr<CL_ListView_Impl> impl;
00221 
00222         friend class CL_ListViewRenderer;
00224 };
00225