IconTextMenuItem.h
Go to the documentation of this file.00001 #ifndef ICONMENULABEL_H_
00002 #define ICONMENULABEL_H_
00003
00004 #include "gtkutil/image.h"
00005
00006 #include <gtk/gtklabel.h>
00007 #include <gtk/gtkmenuitem.h>
00008 #include <gtk/gtkhbox.h>
00009 #include <gtk/gtkimage.h>
00010 #include <string>
00011
00012 namespace gtkutil
00013 {
00014
00024 class IconTextMenuItem
00025 {
00026 private:
00027
00028 GtkWidget* _icon;
00029 GtkWidget* _label;
00030
00031 public:
00032
00033
00034 IconTextMenuItem (const std::string& icon, const std::string& text) :
00035 _icon(gtkutil::getImage(icon)), _label(gtk_label_new(text.c_str()))
00036 {
00037 }
00038
00039
00040
00041 operator GtkWidget* ()
00042 {
00043 GtkWidget* hbx = gtk_hbox_new(FALSE, 4);
00044 gtk_box_pack_start(GTK_BOX(hbx), _icon, FALSE, FALSE, 0);
00045 gtk_box_pack_start(GTK_BOX(hbx), _label, FALSE, FALSE, 0);
00046
00047 GtkWidget* menuItem = gtk_menu_item_new();
00048 gtk_container_add(GTK_CONTAINER(menuItem), hbx);
00049 return menuItem;
00050 }
00051
00052 };
00053
00054 }
00055
00056 #endif