listview_item.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 #include "../api_gui.h"
00036 
00037 class CL_ListViewColumnData;
00038 class CL_ListViewItem_Impl;
00039 
00040 class CL_ListViewItemUserData
00041 {
00042 public:
00043         virtual ~CL_ListViewItemUserData() { }
00044 };
00045 
00049 class CL_API_GUI CL_ListViewItem
00050 {
00053 
00054 public:
00056         CL_ListViewItem();
00057 
00058         ~CL_ListViewItem();
00059 
00063 
00064 public:
00065 
00067         bool is_null() const { return !impl; }
00068 
00070         void throw_if_null() const;
00071 
00075         bool is_item() const;
00076 
00082         CL_ListViewColumnData get_column(const CL_StringRef &column_id);
00083 
00087         CL_ListViewItem get_parent();
00088 
00092         CL_ListViewItem get_next_sibling();
00093 
00097         CL_ListViewItem get_prev_sibling();
00098 
00102         CL_ListViewItem get_first_child();
00103 
00107         CL_ListViewItem get_last_child();
00108 
00112         CL_ListViewItem get_document_item();
00113 
00117         int get_parent_count();
00118 
00125         int get_child_count(bool recursive=false, bool recurse_only_into_open_items=false);
00126 
00130         bool has_children() const;
00131 
00135         bool is_open() const;
00136 
00140         bool is_selected() const;
00141 
00145         bool is_editable() const;
00146 
00148         int get_icon() const;
00149 
00151         int get_id() const;
00152 
00156         CL_SharedPtr<CL_ListViewItemUserData> get_userdata() const;
00157 
00158         bool operator==(CL_ListViewItem &other) const;
00159 
00160         bool operator!=(CL_ListViewItem &other) const;
00161 
00162         std::vector<int> get_overlay_icons();
00163 
00167 
00168 public:
00169 
00175         CL_ListViewItem append_child(CL_ListViewItem &item);
00176 
00178         CL_ListViewItem remove();
00179 
00181         void remove_children();
00182 
00187         void set_column_text(const CL_StringRef &column_id, const CL_StringRef &text);
00188 
00192         void set_open(bool open);
00193 
00197         void set_icon(int icon_index);
00198 
00200         void set_id(int id);
00201 
00205         void add_overlay_icon(int icon_index);
00206 
00210         void remove_overlay_icon(int icon_index);
00211 
00215         void set_editable(bool editable);
00216 
00220         void set_userdata(CL_SharedPtr<CL_ListViewItemUserData> ptr);
00221 
00225 
00226 public:
00227         CL_Callback_v1<CL_Rect> &func_render_icon();
00228 
00232 
00233 private:
00234 
00238         CL_ListViewItem(const CL_SharedPtr<CL_ListViewItem_Impl> &impl);
00239 
00240         CL_SharedPtr<CL_ListViewItem_Impl> impl;
00241 
00242         friend class CL_ListView;
00243         friend class CL_ListView_Impl;
00244         friend class CL_ListViewSelection;
00245         friend class CL_ListViewLayout;
00247 };
00248