2004-02-23 00:21:04 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file GXpmBtnTbl.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Huang Ying
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef XPM_BTN_TBL_H
|
|
|
|
#define XPM_BTN_TBL_H
|
|
|
|
|
|
|
|
#include <boost/scoped_array.hpp>
|
|
|
|
|
|
|
|
|
2004-09-26 13:18:29 +00:00
|
|
|
class GXpmBtnTbl : public Gtk::Table {
|
2004-02-23 00:21:04 +00:00
|
|
|
public:
|
|
|
|
typedef char const ** XpmData;
|
|
|
|
typedef SigC::Signal2<void, int, int> SigType;
|
2004-09-26 13:18:29 +00:00
|
|
|
|
|
|
|
struct XbmData {
|
2004-02-23 00:21:04 +00:00
|
|
|
unsigned char const* data_;
|
|
|
|
int width_;
|
|
|
|
int height_;
|
|
|
|
GdkColor fg_;
|
|
|
|
};
|
2004-09-26 13:18:29 +00:00
|
|
|
|
|
|
|
class GXpmBtn : public Gtk::Button {
|
2004-02-23 00:21:04 +00:00
|
|
|
public:
|
|
|
|
GXpmBtn() : row_(-1), col_(-1)
|
|
|
|
{
|
|
|
|
signal_clicked().connect(
|
|
|
|
SigC::slot(*this,
|
|
|
|
&GXpmBtn::onButtonClicked));
|
|
|
|
}
|
|
|
|
void setRow(int row) { row_ = row; }
|
|
|
|
void setCol(int col) { col_ = col; }
|
|
|
|
int getRow() { return row_; }
|
|
|
|
int getCol() { return col_; }
|
|
|
|
void setXpm(XpmData xpm);
|
|
|
|
void setXpm(Glib::RefPtr<Gdk::Pixmap> pixmap,
|
|
|
|
Glib::RefPtr<Gdk::Bitmap> mask);
|
|
|
|
Glib::RefPtr<Gdk::Pixmap> getPixmap() { return pixmap_; }
|
|
|
|
Glib::RefPtr<Gdk::Bitmap> getMask() { return mask_; }
|
|
|
|
SigType signalClicked() { return signalClicked_; }
|
2004-09-26 13:18:29 +00:00
|
|
|
|
2004-02-23 00:21:04 +00:00
|
|
|
void onButtonClicked()
|
2004-09-26 13:18:29 +00:00
|
|
|
{
|
|
|
|
signalClicked_.emit(row_, col_);
|
|
|
|
}
|
2004-02-23 00:21:04 +00:00
|
|
|
private:
|
|
|
|
int row_;
|
|
|
|
int col_;
|
|
|
|
Glib::RefPtr<Gdk::Pixmap> pixmap_;
|
|
|
|
Glib::RefPtr<Gdk::Bitmap> mask_;
|
|
|
|
SigType signalClicked_;
|
|
|
|
};
|
2004-09-26 13:18:29 +00:00
|
|
|
|
2004-02-23 00:21:04 +00:00
|
|
|
GXpmBtnTbl(int rows, int cols, XpmData xpms[]);
|
|
|
|
//GXpmBtnTbl(int rows, int cols, XpmData xpm);
|
2004-09-26 13:18:29 +00:00
|
|
|
GXpmBtnTbl(int rows, int cols, XbmData const & xbm);
|
2004-02-23 00:21:04 +00:00
|
|
|
~GXpmBtnTbl();
|
2004-09-26 13:18:29 +00:00
|
|
|
|
|
|
|
GXpmBtn * getBtn(int row, int col)
|
|
|
|
{
|
|
|
|
return &btns_[index(row, col)];
|
|
|
|
}
|
|
|
|
|
2004-02-23 00:21:04 +00:00
|
|
|
SigType signalClicked() { return signalClicked_; }
|
|
|
|
private:
|
|
|
|
int index(int row, int col) { return row * cols_ + col; }
|
|
|
|
void on_realize();
|
|
|
|
void construct();
|
|
|
|
void setBtnXpm(XpmData xpms[]);
|
2004-09-26 13:18:29 +00:00
|
|
|
void setBtnXpm(XbmData const & xbm);
|
2004-02-23 00:21:04 +00:00
|
|
|
|
|
|
|
int rows_;
|
|
|
|
int cols_;
|
|
|
|
boost::scoped_array<GXpmBtn> btns_;
|
|
|
|
const XbmData * xbm_;
|
|
|
|
SigType signalClicked_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-09-26 13:18:29 +00:00
|
|
|
void buttonSetXpm(Gtk::Button * btn, char const ** xpm);
|
2004-02-23 00:21:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|