1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
#include "buttonbox.hh"
#include <gfc/gtk/box.hh>
#include <gfc/gtk/stockid.hh>
// ButtonBoxFrame
ButtonBoxFrame::ButtonBoxFrame(bool horizontal, const char *title, int spacing, Gtk::ButtonBoxStyle layout)
{
set_label(title);
Gtk::ButtonBox *bbox;
if (horizontal)
bbox = new Gtk::HButtonBox;
else
bbox = new Gtk::VButtonBox;
bbox->set_border_width(5);
add(*bbox);
bbox->set_layout(layout);
bbox->set_spacing(spacing);
Gtk::Button *button = new Gtk::Button(Gtk::StockId::OK);
bbox->add(*button);
button = new Gtk::Button(Gtk::StockId::CANCEL);
bbox->add(*button);
button = new Gtk::Button(Gtk::StockId::HELP);
bbox->add(*button);
}
ButtonBoxFrame::~ButtonBoxFrame()
{
}
// ButtonBoxWindow
ButtonBoxWindow::ButtonBoxWindow()
{
set_title("Button Boxes");
set_border_width(10);
Gtk::VBox *main_vbox = new Gtk::VBox;
add(*main_vbox);
// Horizontal Button Boxes
Gtk::Frame *frame = new Gtk::Frame("Horizontal Button Boxes");
main_vbox->pack_start(*frame, true, true, 10);
Gtk::Box *box = new Gtk::VBox;
box->set_border_width(10);
frame->add(*box);
ButtonBoxFrame *button_box_frame = new ButtonBoxFrame(true, "Spread (spacing 40)", 40, Gtk::BUTTONBOX_SPREAD);
box->pack_start(*button_box_frame);
button_box_frame = new ButtonBoxFrame(true, "Edge (spacing 30)", 30, Gtk::BUTTONBOX_EDGE);
box->pack_start(*button_box_frame, true, true, 5);
button_box_frame = new ButtonBoxFrame(true, "Start (spacing 20)", 20, Gtk::BUTTONBOX_START);
box->pack_start(*button_box_frame, true, true, 5);
button_box_frame = new ButtonBoxFrame(true, "End (spacing 10)", 10, Gtk::BUTTONBOX_END);
box->pack_start(*button_box_frame, true, true, 5);
// Vertical Button Boxes
frame = new Gtk::Frame("Vertical Button Boxes");
main_vbox->pack_start(*frame, true, true, 10);
box = new Gtk::HBox;
box->set_border_width(10);
frame->add(*box);
button_box_frame = new ButtonBoxFrame(false, "Spread (spacing 5)", 5, Gtk::BUTTONBOX_SPREAD);
box->pack_start(*button_box_frame);
button_box_frame = new ButtonBoxFrame(false, "Edge (spacing 30)", 30, Gtk::BUTTONBOX_EDGE);
box->pack_start(*button_box_frame, true, true, 5);
button_box_frame = new ButtonBoxFrame(false, "Start (spacing 20)", 20, Gtk::BUTTONBOX_START);
box->pack_start(*button_box_frame, true, true, 5);
button_box_frame = new ButtonBoxFrame(false, "End (spacing 20)", 20, Gtk::BUTTONBOX_END);
box->pack_start(*button_box_frame, true, true, 5);
show_all();
}
ButtonBoxWindow::~ButtonBoxWindow()
{
}
int main (int argc, char *argv[])
{
using namespace Main;
init(&argc, &argv);
ButtonBoxWindow window;
window.sig_destroy().connect(sigc::ptr_fun(&GFC::Main::quit));
run();
return 0;
}
|