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
00148
00149 static GType get_base_type() G_GNUC_CONST;
00150 #endif
00151
00153 GnomeIconList* gobj() { return reinterpret_cast<GnomeIconList*>(gobject_); }
00154
00156 const GnomeIconList* gobj() const { return reinterpret_cast<GnomeIconList*>(gobject_); }
00157
00158
00159 public:
00160
00161 #ifdef GLIBMM_VFUNCS_ENABLED
00162 #endif //GLIBMM_VFUNCS_ENABLED
00163
00164 protected:
00165
00166 #ifdef GLIBMM_VFUNCS_ENABLED
00167 #endif //GLIBMM_VFUNCS_ENABLED
00168
00169
00170 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00171 virtual void on_select_icon(int num, GdkEvent* event);
00172 virtual void on_unselect_icon(int num, GdkEvent* event);
00173 virtual void on_focus_icon(int num);
00174 virtual bool on_text_changed(int num, const char* new_text);
00175 virtual void on_move_cursor(Gtk::DirectionType dir, bool clear_selection);
00176 virtual void on_toggle_cursor_selection();
00177 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00178
00179
00180 private:
00181
00182
00183 public:
00184
00185 explicit IconList(guint icon_width = 80, bool is_editable = false);
00186
00187
00188 void set_hadjustment(Gtk::Adjustment& hadj);
00189
00190 void set_vadjustment(Gtk::Adjustment& vadj);
00191
00192 void freeze();
00193
00194 void thaw();
00195
00196 void insert(int pos, const Glib::ustring& icon_filename, const Glib::ustring& text);
00197
00198 void insert(int idx, const Glib::RefPtr<Gdk::Pixbuf>& im, const Glib::ustring& icon_filename, const Glib::ustring& text);
00199
00200 int append(const Glib::ustring& icon_filename, const Glib::ustring& text);
00201
00202 int append(const Glib::RefPtr<Gdk::Pixbuf>& im, const Glib::ustring& icon_filename, const Glib::ustring& text);
00203
00204 void clear();
00205
00206 void remove(int pos);
00207
00208 guint get_num_icons() const;
00209
00210 Gtk::SelectionMode get_selection_mode() const;
00211
00212 void set_selection_mode(Gtk::SelectionMode mode);
00213
00214 void select_icon(int idx);
00215
00216 void unselect_icon(int idx);
00217
00218 int select_all();
00219
00220 int unselect_all();
00221
00222 void focus_icon(gint idx);
00223
00224 void set_icon_width (int w);
00225
00226 void set_row_spacing(int spacing);
00227
00228 void set_col_spacing(int spacing);
00229
00230 void set_text_spacing(int spacing);
00231
00232 void set_icon_border(int spacing);
00233
00234 void set_separators(const Glib::ustring& sep);
00235
00236 Glib::ustring get_icon_filename(int idx) const;
00237
00238 int find_icon_from_filename(const Glib::ustring& filename) const;
00239
00240 void set_icon_data(int pos, gpointer data);
00241
00242
00243 int find_icon_from_data(gpointer data) const;
00244
00245 gpointer get_icon_data(int pos);
00246
00247 void moveto(int pos, double yalign);
00248
00249 Gtk::Visibility icon_is_visible(int pos);
00250
00251 int get_icon_at(int x, int y) const;
00252
00253 int get_items_per_line() const;
00254
00255
00256 IconTextItem* get_icon_text_item(int idx);
00257
00258 Gnome::Canvas::Pixbuf* get_icon_pixbuf_item(int idx);
00259
00260 typedef IconList_Helpers::SelectionList SelectionList;
00261 SelectionList& selection();
00262 const SelectionList& selection() const;
00263
00264
00270 Glib::SignalProxy2< void,int,GdkEvent* > signal_select_icon();
00271 ;
00272
00278 Glib::SignalProxy2< void,int,GdkEvent* > signal_unselect_icon();
00279 ;
00280
00281
00287 Glib::SignalProxy1< void,int > signal_focus_icon();
00288 ;
00289
00290
00296 Glib::SignalProxy2< bool,int,const char* > signal_text_changed();
00297 ;
00298
00299
00300
00306 Glib::SignalProxy2< void,Gtk::DirectionType,bool > signal_move_cursor();
00307
00308
00314 Glib::SignalProxy0< void > signal_toggle_cursor_selection();
00315
00316
00317 protected:
00318 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00319 mutable SelectionList selection_proxy_;
00320 #endif
00321
00322
00323 };
00324
00325 }
00326 }
00327
00328
00329 namespace Glib
00330 {
00339 Gnome::UI::IconList* wrap(GnomeIconList* object, bool take_copy = false);
00340 }
00341
00342
00343 #endif
00344