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