Added an arrow to the MenuButton class

This commit is contained in:
Joel Holdsworth 2008-12-29 16:29:30 +00:00
parent b4ce796c94
commit e17cf45b08
2 changed files with 45 additions and 14 deletions

View file

@ -30,17 +30,29 @@ using namespace sigc;
namespace gui {
namespace widgets {
const ArrowType arrowType = ARROW_DOWN;
const ShadowType shadowType = SHADOW_NONE;
MenuButton::MenuButton() :
Button()
{}
Button(),
arrow(arrowType, shadowType)
{
setup_button();
}
MenuButton::MenuButton(const Gtk::StockID& stock_id)
: Button(stock_id)
{}
MenuButton::MenuButton(const Gtk::StockID& stock_id) :
Button(stock_id),
arrow(arrowType, shadowType)
{
setup_button();
}
MenuButton::MenuButton(const Glib::ustring& label, bool mnemonic)
: Button(label, mnemonic)
{}
MenuButton::MenuButton(const Glib::ustring& label, bool mnemonic) :
Button(label, mnemonic),
arrow(arrowType, shadowType)
{
setup_button();
}
Gtk::Menu&
MenuButton::get_menu()
@ -48,12 +60,6 @@ MenuButton::get_menu()
return menu;
}
void
MenuButton::on_pressed()
{
popup();
}
void
MenuButton::popup()
{
@ -61,6 +67,20 @@ MenuButton::popup()
0, gtk_get_current_event_time());
}
void
MenuButton::setup_button()
{
arrow.set(ARROW_DOWN, SHADOW_NONE);
set_image_position(POS_RIGHT);
set_image(arrow);
}
void
MenuButton::on_pressed()
{
popup();
}
void
MenuButton::on_menu_position(int& x, int& y, bool& push_in)
{

View file

@ -78,6 +78,11 @@ public:
protected:
/**
* An internal method which sets up the button at creat time.
**/
void setup_button();
/**
* An event handler for when the button is pressed.
**/
@ -103,6 +108,12 @@ private:
* The internal menu object which is the popup menu of this widget.
**/
Gtk::Menu menu;
/**
* The arrow widget that will be displayed to hint the user that this
* button is a drop-down.
**/
Gtk::Arrow arrow;
};
} // gui