4
* Created on: Mar 22, 2012
7
* Released under GNU GPL. Read the file 'COPYING' for more information.
10
#include "ui/widget/anchor-selector.h"
12
#include "widgets/icon.h"
13
#include "ui/icon-names.h"
19
void AnchorSelector::setupButton(const Glib::ustring& icon, Gtk::ToggleButton& button) {
20
Gtk::Widget* buttonIcon = Gtk::manage(sp_icon_get_icon(icon, Inkscape::ICON_SIZE_SMALL_TOOLBAR));
23
button.set_relief(Gtk::RELIEF_NONE);
25
button.add(*buttonIcon);
26
button.set_can_focus(false);
29
AnchorSelector::AnchorSelector()
30
: Gtk::Alignment(0.5, 0, 0, 0),
31
_container(3, 3, true)
33
setupButton(INKSCAPE_ICON("boundingbox_top_left"), _buttons[0]);
34
setupButton(INKSCAPE_ICON("boundingbox_top"), _buttons[1]);
35
setupButton(INKSCAPE_ICON("boundingbox_top_right"), _buttons[2]);
36
setupButton(INKSCAPE_ICON("boundingbox_left"), _buttons[3]);
37
setupButton(INKSCAPE_ICON("boundingbox_center"), _buttons[4]);
38
setupButton(INKSCAPE_ICON("boundingbox_right"), _buttons[5]);
39
setupButton(INKSCAPE_ICON("boundingbox_bottom_left"), _buttons[6]);
40
setupButton(INKSCAPE_ICON("boundingbox_bottom"), _buttons[7]);
41
setupButton(INKSCAPE_ICON("boundingbox_bottom_right"), _buttons[8]);
43
for(int i = 0; i < 9; ++i) {
44
_buttons[i].signal_clicked().connect(
45
sigc::bind(sigc::mem_fun(*this, &AnchorSelector::btn_activated), i));
46
_container.attach(_buttons[i], i % 3, i % 3+1, i / 3, i / 3+1, Gtk::FILL, Gtk::FILL);
49
_buttons[4].set_active();
51
this->add(_container);
54
AnchorSelector::~AnchorSelector()
56
// TODO Auto-generated destructor stub
59
void AnchorSelector::btn_activated(int index)
62
if(_selection == index && _buttons[index].get_active() == false)
64
_buttons[index].set_active(true);
66
else if(_selection != index && _buttons[index].get_active())
68
int old_selection = _selection;
70
_buttons[old_selection].set_active(false);
71
_selectionChanged.emit();
75
void AnchorSelector::setAlignment(int horizontal, int vertical)
77
int index = 3 * vertical + horizontal;
78
if(index >= 0 && index < 9)
80
_buttons[index].set_active(!_buttons[index].get_active());
86
} // namespace Inkscape
91
c-file-style:"stroustrup"
92
c-file-offsets:((innamespace . 0)(inline-open . 0))
97
// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :