Back to index

easystroke  0.5.5.1
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
SelectButton Class Reference

#include <win.h>

Collaboration diagram for SelectButton:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SelectButton (ButtonInfo bi, bool def, bool any)
 ~SelectButton ()
bool run ()

Public Attributes

ButtonInfo event

Private Member Functions

bool on_button_press (GdkEventButton *ev)
void on_any_toggled ()

Private Attributes

Gtk::MessageDialog * dialog
Gtk::EventBox * eventbox
Gtk::ToggleButton * toggle_shift
Gtk::ToggleButton * toggle_control
Gtk::ToggleButton * toggle_alt
Gtk::ToggleButton * toggle_super
Gtk::ToggleButton * toggle_any
Gtk::ComboBoxText * select_button
Gtk::RadioButton * radio_timeout_default
Gtk::RadioButton * radio_instant
Gtk::RadioButton * radio_click_hold
sigc::connection handler [2]

Detailed Description

Definition at line 106 of file win.h.


Constructor & Destructor Documentation

SelectButton::SelectButton ( ButtonInfo  bi,
bool  def,
bool  any 
)

Definition at line 455 of file prefs.cc.

                                                            {
       widgets->get_widget("dialog_select", dialog);
       dialog->set_message(_("Select a Mouse or Pen Button"));
       dialog->set_secondary_text(_("Please place your mouse or pen in the box below and press the button that you want to select.  You can also hold down additional modifiers."));
       widgets->get_widget("eventbox", eventbox);
       widgets->get_widget("toggle_shift", toggle_shift);
       widgets->get_widget("toggle_alt", toggle_alt);
       widgets->get_widget("toggle_control", toggle_control);
       widgets->get_widget("toggle_super", toggle_super);
       widgets->get_widget("toggle_any", toggle_any);
       widgets->get_widget("radio_timeout_default", radio_timeout_default);
       widgets->get_widget("radio_instant", radio_instant);
       widgets->get_widget("radio_click_hold", radio_click_hold);
       Gtk::Bin *box_button;
       widgets->get_widget("box_button", box_button);
       Gtk::HBox *hbox_button_timeout;
       widgets->get_widget("hbox_button_timeout", hbox_button_timeout);
       select_button = dynamic_cast<Gtk::ComboBoxText *>(box_button->get_child());
       if (!select_button) {
              select_button = Gtk::manage(new Gtk::ComboBoxText);
              box_button->add(*select_button);
              for (int i = 1; i <= 12; i++)
                     select_button->append_text(Glib::ustring::compose(_("Button %1"), i));
              select_button->show();
       }
       select_button->set_active(bi.button-1);
       toggle_shift->set_active(bi.button && (bi.state & GDK_SHIFT_MASK));
       toggle_control->set_active(bi.button && (bi.state & GDK_CONTROL_MASK));
       toggle_alt->set_active(bi.button && (bi.state & GDK_MOD1_MASK));
       toggle_super->set_active(bi.button && (bi.state & GDK_SUPER_MASK));
       toggle_any->set_active(any && bi.button && bi.state == AnyModifier);
       if (any) {
              hbox_button_timeout->show();
              toggle_any->show();
       } else {
              hbox_button_timeout->hide();
              toggle_any->hide();
       }
       if (bi.instant)
              radio_instant->set_active();
       else if (bi.click_hold)
              radio_click_hold->set_active();
       else
              radio_timeout_default->set_active();

       Gtk::Button *select_default;
       widgets->get_widget("select_default", select_default);
       if (def)
              select_default->show();
       else
              select_default->hide();

       if (!eventbox->get_children().size()) {
              eventbox->set_events(Gdk::BUTTON_PRESS_MASK);

              Glib::RefPtr<Gdk::Pixbuf> pb = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB,true,8,400,200);
              pb->fill(0x808080ff);
              WIDGET(Gtk::Image, box, pb);
              eventbox->add(box);
              box.show();
       }
       handler[0] = eventbox->signal_button_press_event().connect(sigc::mem_fun(*this, &SelectButton::on_button_press));
       handler[1] = toggle_any->signal_toggled().connect(sigc::mem_fun(*this, &SelectButton::on_any_toggled));
       on_any_toggled();
}

Here is the call graph for this function:

Definition at line 521 of file prefs.cc.

                            {
       handler[0].disconnect();
       handler[1].disconnect();
}

Member Function Documentation

void SelectButton::on_any_toggled ( ) [private]

Definition at line 588 of file prefs.cc.

                                  {
       bool any = toggle_any->get_active(); 
       toggle_shift->set_sensitive(!any);
       toggle_control->set_sensitive(!any);
       toggle_alt->set_sensitive(!any);
       toggle_super->set_sensitive(!any);
}

Here is the caller graph for this function:

bool SelectButton::on_button_press ( GdkEventButton *  ev) [private]

Definition at line 572 of file prefs.cc.

                                                     {
       event.button = ev->button;
       event.state  = ev->state;
       event.instant = radio_instant->get_active();
       event.click_hold = radio_click_hold->get_active();
       if (toggle_any->get_active()) {
              event.state = AnyModifier;
       } else {
              if (event.state & Mod4Mask)
                     event.state |= GDK_SUPER_MASK;
              event.state &= gtk_accelerator_get_default_mod_mask();
       }
       dialog->response(3);
       return true;
}

Here is the caller graph for this function:

Definition at line 526 of file prefs.cc.

                       {
       grabber->queue_suspend();
       dialog->show();
       Gtk::Button *select_ok;
       widgets->get_widget("select_ok", select_ok);
       select_ok->grab_focus();
       int response;
       do {
              response = dialog->run();
       } while (!response);
       dialog->hide();
       grabber->queue_resume();
       switch (response) {
              case 1: // Okay
                     event.button = select_button->get_active_row_number() + 1;
                     if (!event.button)
                            return false;
                     event.state = 0;
                     if (toggle_any->get_active()) {
                            event.state = AnyModifier;
                            return true;
                     }
                     if (toggle_shift->get_active())
                            event.state |= GDK_SHIFT_MASK;
                     if (toggle_control->get_active())
                            event.state |= GDK_CONTROL_MASK;
                     if (toggle_alt->get_active())
                            event.state |= GDK_MOD1_MASK;
                     if (toggle_super->get_active())
                            event.state |= GDK_SUPER_MASK;
                     event.instant = radio_instant->get_active();
                     event.click_hold = radio_click_hold->get_active();
                     return true;
              case 2: // Default
                     event.button = 0;
                     event.state = 0;
                     event.instant = false;
                     return true;
              case 3: // Click - all the work has already been done
                     return true;
              case -1: // Cancel
              default: // Something went wrong
                     return false;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Gtk::MessageDialog* SelectButton::dialog [private]

Definition at line 113 of file win.h.

Definition at line 111 of file win.h.

Gtk::EventBox* SelectButton::eventbox [private]

Definition at line 117 of file win.h.

sigc::connection SelectButton::handler[2] [private]

Definition at line 121 of file win.h.

Gtk::RadioButton * SelectButton::radio_click_hold [private]

Definition at line 120 of file win.h.

Gtk::RadioButton * SelectButton::radio_instant [private]

Definition at line 120 of file win.h.

Gtk::RadioButton* SelectButton::radio_timeout_default [private]

Definition at line 120 of file win.h.

Gtk::ComboBoxText* SelectButton::select_button [private]

Definition at line 119 of file win.h.

Gtk::ToggleButton * SelectButton::toggle_alt [private]

Definition at line 118 of file win.h.

Gtk::ToggleButton * SelectButton::toggle_any [private]

Definition at line 118 of file win.h.

Gtk::ToggleButton * SelectButton::toggle_control [private]

Definition at line 118 of file win.h.

Gtk::ToggleButton* SelectButton::toggle_shift [private]

Definition at line 118 of file win.h.

Gtk::ToggleButton * SelectButton::toggle_super [private]

Definition at line 118 of file win.h.


The documentation for this class was generated from the following files: