]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GXpmBtnTbl.h
Change glob() API to accept a dir parameter.
[lyx.git] / src / frontends / gtk / GXpmBtnTbl.h
1 // -*- C++ -*-
2 /**
3  * \file GXpmBtnTbl.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Huang Ying
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef XPM_BTN_TBL_H
13 #define XPM_BTN_TBL_H
14
15 #include <gtkmm.h>
16
17 #include <boost/scoped_array.hpp>
18
19 class GXpmBtnTbl : public Gtk::Table {
20 public:
21         typedef char const ** XpmData;
22         typedef sigc::signal<void, int, int> SigType;
23         struct XbmData {
24                 unsigned char const* data_;
25                 int width_;
26                 int height_;
27                 GdkColor fg_;
28         };
29
30         class GXpmBtn : public Gtk::Button {
31         public:
32                 GXpmBtn() : row_(-1), col_(-1)
33                 {
34                         signal_clicked().connect(sigc::mem_fun(*this,
35                                            &GXpmBtn::onButtonClicked));
36                 }
37                 void setRow(int row) { row_ = row; }
38                 void setCol(int col) { col_ = col; }
39                 int getRow() { return row_; }
40                 int getCol() { return col_; }
41                 void setXpm(XpmData xpm);
42                 void setXpm(Glib::RefPtr<Gdk::Pixmap> pixmap,
43                             Glib::RefPtr<Gdk::Bitmap> mask);
44                 Glib::RefPtr<Gdk::Pixmap> getPixmap() { return pixmap_; }
45                 Glib::RefPtr<Gdk::Bitmap> getMask() { return mask_; }
46                 SigType signalClicked() { return signalClicked_; }
47
48                 void onButtonClicked()
49                 {
50                         signalClicked_.emit(row_, col_);
51                 }
52         private:
53                 int row_;
54                 int col_;
55                 Glib::RefPtr<Gdk::Pixmap> pixmap_;
56                 Glib::RefPtr<Gdk::Bitmap> mask_;
57                 SigType signalClicked_;
58         };
59
60         GXpmBtnTbl(int rows, int cols, XpmData xpms[]);
61         //GXpmBtnTbl(int rows, int cols, XpmData xpm);
62         GXpmBtnTbl(int rows, int cols, XbmData const & xbm);
63         ~GXpmBtnTbl();
64
65         GXpmBtn * getBtn(int row, int col)
66         {
67                 return &btns_[index(row, col)];
68         }
69
70         SigType signalClicked() { return signalClicked_; }
71 private:
72         int index(int row, int col) { return row * cols_ + col; }
73         void on_realize();
74         void construct();
75         void setBtnXpm(XpmData xpms[]);
76         void setBtnXpm(XbmData const & xbm);
77
78         int rows_;
79         int cols_;
80         boost::scoped_array<GXpmBtn> btns_;
81         XbmData const * xbm_;
82         SigType signalClicked_;
83 };
84
85
86 void buttonSetXpm(Gtk::Button * btn, char const ** xpm);
87
88
89 #endif