]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/pixbutton.h
Clean-up of the button controller.
[lyx.git] / src / frontends / gnome / pixbutton.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor
6  *       
7  *          Copyright 2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #ifndef GNOME_PIXBUTTON
12 #define GNOME_PIXBUTTON
13
14 #include <gtk--/button.h>
15 #include <gtk--/box.h>
16 #include <gtk--/label.h>
17 #include <gnome--/pixmap.h>
18 #include <gnome--/stock.h>
19
20 /* Button class used in LyX Gnome frontend for buttons with pixmaps and
21    accelerators */
22
23 namespace Gnome
24 {
25   class PixButton: public Gtk::Button
26   {
27   public:
28     PixButton(string label, string pixname): Button()
29     {
30       Gtk::Box * b = manage( new Gtk::HBox() );
31       l = manage( new Gtk::Label(label) );
32       Gnome::Pixmap * p = Gtk::wrap( GNOME_PIXMAP( gnome_stock_pixmap_widget(0, pixname.c_str()) ) );
33
34       b->set_spacing(3);
35       b->children().push_back(Gtk::Box_Helpers::Element(*p, false, false));
36       b->children().push_back(Gtk::Box_Helpers::Element(*l, false, false));
37
38       add(*b);
39
40       accelkey_ = l->parse_uline(label);
41       
42       l->show();
43       p->show();
44       b->show();
45     }
46
47     guint get_accelkey() { return accelkey_; }
48
49     void set_text(string const & newlabel) { l->set_text(newlabel); }
50
51   protected:
52     guint accelkey_;
53     Gtk::Label * l;
54   };
55 }
56
57 #endif
58