00001
00002
00003 #ifndef _LIBGNOMEUIMM_ICON_LIST_H
00004 #define _LIBGNOMEUIMM_ICON_LIST_H
00005
00006
00007 #include <glibmm.h>
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <libgnomeuimm/icon-textitem.h>
00035 #include <libgnomecanvasmm/canvas.h>
00036 #include <libgnomecanvasmm/pixbuf.h>
00037 #include <gtkmm/container.h>
00038 #include <glibmm/helperlist.h>
00039 #include <libgnomeui/gnome-icon-list.h>
00040
00041
00042 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00043 typedef struct _GnomeIconList GnomeIconList;
00044 typedef struct _GnomeIconListClass GnomeIconListClass;
00045 #endif
00046
00047
00048 namespace Gnome
00049 {
00050
00051 namespace UI
00052 { class IconList_Class; }
00053
00054 }
00055 namespace Gnome
00056 {
00057
00058 namespace UI
00059 {
00060
00061 namespace IconList_Helpers
00062 {
00063
00064
00065 class SelectionList : public Glib::HelperList< int, int, Glib::List_Iterator< int > >
00066 {
00067 public:
00068 SelectionList();
00069 explicit SelectionList(GnomeIconList* gparent);
00070 SelectionList(const SelectionList& src);
00071 virtual ~SelectionList() {}
00072
00073 SelectionList& operator=(const SelectionList& src);
00074
00075 typedef Glib::HelperList< int, int, Glib::List_Iterator< int > > type_base;
00076
00077 GnomeIconList* gparent();
00078 const GnomeIconList* gparent() const;
00079
00080 virtual GList*& glist() const;
00081
00082 virtual void erase(iterator start, iterator stop);
00083 virtual iterator erase(iterator);
00084 virtual void remove(const_reference);
00085
00087 reference operator[](size_type l) const;
00088
00089 public:
00090 iterator insert(iterator position, element_type& e);
00091
00092 template <class InputIterator>
00093 inline void insert(iterator position, InputIterator first, InputIterator last)
00094 {
00095 for(;first != last; ++first)
00096 position = insert(position, *first);
00097 }
00098
00099 inline void push_front(element_type& e)
00100 { insert(begin(), e); }
00101 inline void push_back(element_type& e)
00102 { insert(end(), e); }
00103
00104
00105 protected:
00106 mutable GList* glist_;
00107 };
00108
00109
00110 }
00111
00112
00113 class Group;
00114
00115
00116 class IconList : public Gnome::Canvas::Canvas
00117 {
00118 public:
00119 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00120 typedef IconList CppObjectType;
00121 typedef IconList_Class CppClassType;
00122 typedef GnomeIconList BaseObjectType;
00123 typedef GnomeIconListClass BaseClassType;
00124 #endif
00125
00126 virtual ~IconList();
00127
00128 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00129
00130 private:
00131 friend class IconList_Class;
00132 static CppClassType iconlist_class_;
00133
00134
00135 IconList(const IconList&);
00136 IconList& operator=(const IconList&);
00137
00138 protected:
00139 explicit IconList(const Glib::ConstructParams& construct_params);
00140 explicit IconList(GnomeIconList* castitem);
00141
00142 #endif
00143
00144 public:
00145 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00146 static GType get_type() G_GNUC_CONST;
00147 static GType get_base_type() G_GNUC_CONST;
00148 #endif
00149
00151 GnomeIconList* gobj() { return reinterpret_cast<GnomeIconList*>(gobject_); }
00152
00154 const GnomeIconList* gobj() const { return reinterpret_cast<GnomeIconList*>(gobject_); }
00155
00156
00157 public:
00158
00159
00160 protected:
00161
00162
00163
00164 virtual void on_select_icon(int num, GdkEvent* event);
00165 virtual void on_unselect_icon(int num, GdkEvent* event);
00166 virtual void on_focus_icon(int num);
00167 virtual bool on_text_changed(int num, const char* new_text);
00168 virtual void on_move_cursor(Gtk::DirectionType dir, bool clear_selection);
00169 virtual void on_toggle_cursor_selection();
00170
00171
00172 private:
00173
00174
00175 public:
00176
00177 explicit IconList(guint icon_width = 80, bool is_editable = false);
00178
00179
00180 void set_hadjustment(Gtk::Adjustment& hadj);
00181
00182 void set_vadjustment(Gtk::Adjustment& vadj);
00183
00184 void freeze();
00185
00186 void thaw();
00187
00188 void insert(int pos, const Glib::ustring& icon_filename, const Glib::ustring& text);
00189
00190 void insert(int idx, const Glib::RefPtr<Gdk::Pixbuf>& im, const Glib::ustring& icon_filename, const Glib::ustring& text);
00191
00192 int append(const Glib::ustring& icon_filename, const Glib::ustring& text);
00193
00194 int append(const Glib::RefPtr<Gdk::Pixbuf>& im, const Glib::ustring& icon_filename, const Glib::ustring& text);
00195
00196 void clear();
00197
00198 void remove(int pos);
00199
00200 guint get_num_icons() const;
00201
00202 Gtk::SelectionMode get_selection_mode() const;
00203
00204 void set_selection_mode(Gtk::SelectionMode mode);
00205
00206 void select_icon(int idx);
00207
00208 void unselect_icon(int idx);
00209
00210 int select_all();
00211
00212 int unselect_all();
00213
00214 void focus_icon(gint idx);
00215
00216 void set_icon_width (int w);
00217
00218 void set_row_spacing(int spacing);
00219
00220 void set_col_spacing(int spacing);
00221
00222 void set_text_spacing(int spacing);
00223
00224 void set_icon_border(int spacing);
00225
00226 void set_separators(const Glib::ustring& sep);
00227
00228 Glib::ustring get_icon_filename(int idx) const;
00229
00230 int find_icon_from_filename(const Glib::ustring& filename) const;
00231
00232 void set_icon_data(int pos, gpointer data);
00233
00234
00235 int find_icon_from_data(gpointer data) const;
00236
00237 gpointer get_icon_data(int pos);
00238
00239 void moveto(int pos, double yalign);
00240
00241 Gtk::Visibility icon_is_visible(int pos);
00242
00243 int get_icon_at(int x, int y) const;
00244
00245 int get_items_per_line() const;
00246
00247
00248 IconTextItem* get_icon_text_item(int idx);
00249
00250 Gnome::Canvas::Pixbuf* get_icon_pixbuf_item(int idx);
00251
00252 typedef IconList_Helpers::SelectionList SelectionList;
00253 SelectionList& selection();
00254 const SelectionList& selection() const;
00255
00256
00257 Glib::SignalProxy2< void,int,GdkEvent* > signal_select_icon();
00258 ;
00259
00260
00261 Glib::SignalProxy2< void,int,GdkEvent* > signal_unselect_icon();
00262 ;
00263
00264
00265 Glib::SignalProxy1< void,int > signal_focus_icon();
00266 ;
00267
00268
00269 Glib::SignalProxy2< bool,int,const char* > signal_text_changed();
00270 ;
00271
00272
00273
00274
00275 Glib::SignalProxy2< void,Gtk::DirectionType,bool > signal_move_cursor();
00276
00277
00278 Glib::SignalProxy0< void > signal_toggle_cursor_selection();
00279
00280
00281 protected:
00282 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00283 mutable SelectionList selection_proxy_;
00284 #endif
00285
00286
00287 };
00288
00289 }
00290 }
00291
00292
00293 namespace Glib
00294 {
00300 Gnome::UI::IconList* wrap(GnomeIconList* object, bool take_copy = false);
00301 }
00302
00303
00304 #endif
00305