lyx_mirror/src/frontends/gtk/GXpmBtnTbl.h
Lars Gullik Bjønnes d86c6d46bb Move to gtk 2.4
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9011 a592a061-630c-0410-9148-cb99ea01b6c8
2004-09-26 16:48:30 +00:00

90 lines
2.0 KiB
C++

// -*- 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 <gtkmm.h>
#include <boost/scoped_array.hpp>
class GXpmBtnTbl : public Gtk::Table {
public:
typedef char const ** XpmData;
typedef sigc::signal<void, int, int> SigType;
struct XbmData {
unsigned char const* data_;
int width_;
int height_;
GdkColor fg_;
};
class GXpmBtn : public Gtk::Button {
public:
GXpmBtn() : row_(-1), col_(-1)
{
signal_clicked().connect(sigc::mem_fun(*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_; }
void onButtonClicked()
{
signalClicked_.emit(row_, col_);
}
private:
int row_;
int col_;
Glib::RefPtr<Gdk::Pixmap> pixmap_;
Glib::RefPtr<Gdk::Bitmap> mask_;
SigType signalClicked_;
};
GXpmBtnTbl(int rows, int cols, XpmData xpms[]);
//GXpmBtnTbl(int rows, int cols, XpmData xpm);
GXpmBtnTbl(int rows, int cols, XbmData const & xbm);
~GXpmBtnTbl();
GXpmBtn * getBtn(int row, int col)
{
return &btns_[index(row, col)];
}
SigType signalClicked() { return signalClicked_; }
private:
int index(int row, int col) { return row * cols_ + col; }
void on_realize();
void construct();
void setBtnXpm(XpmData xpms[]);
void setBtnXpm(XbmData const & xbm);
int rows_;
int cols_;
boost::scoped_array<GXpmBtn> btns_;
XbmData const * xbm_;
SigType signalClicked_;
};
void buttonSetXpm(Gtk::Button * btn, char const ** xpm);
#endif