bool button_t::handle_key(key_type key, bool pressed, modifiers_t modifiers) { if (pressed == false) return false; button_state_set_t::iterator state(button_modifier_state(state_set_m, modifier_mask_m, modifiers)); if (state == state_set_m.end()) state = button_default_state(state_set_m); if (state->hit_proc_m.empty() || enabled_m == false) return false; if (key == 0x0d && is_default_m) // return { state->hit_proc_m(state->value_m, state->contributing_m); } else if (key == 0x1b && is_cancel_m) // escape { state->hit_proc_m(state->value_m, state->contributing_m); } else { return false; } return true; }
void button_t::measure(extents_t& result) { result = metrics::measure(control_m); button_state_set_t::iterator state(button_modifier_state(state_set_m, modifier_mask_m, modifiers_m)); boost::shared_ptr<GG::Font> font = implementation::DefaultFont(); if (state == state_set_m.end()) state = button_default_state(state_set_m); extents_t cur_text_extents(metrics::measure_text(state->name_m, font)); result.width() -= cur_text_extents.width(); result.height() = Value(control_m->Height()); long width_additional(0); for (button_state_set_t::iterator iter(state_set_m.begin()), last(state_set_m.end()); iter != last; ++iter) { extents_t tmp(metrics::measure_text(iter->name_m, font)); width_additional = (std::max)(width_additional, tmp.width()); } result.width() += width_additional; result.width() += Value(2 * implementation::CharWidth()); result.width() = (std::max)(result.width(), 70L); }
void button_t::set_contributing(modifiers_t modifiers, const dictionary_t& value) { button_state_set_t::iterator state(button_modifier_state(state_set_m, modifier_mask_m, modifiers)); if (state == state_set_m.end()) state = button_default_state(state_set_m); state->contributing_m = value; }
void button_t::set(modifiers_t modifiers, const any_regular_t& value) { button_state_set_t::iterator state(button_modifier_state(state_set_m, modifier_mask_m, modifiers)); if (state == state_set_m.end()) state = button_default_state(state_set_m); if (state->value_m != value) state->value_m = value; }
::OSStatus button_modifier_key_handler_t::handle_event(::EventHandlerCallRef /*next*/, ::EventRef event) { assert(button_m); button_t& button(*button_m); ::UInt32 os_modifiers; get_event_parameter<kEventParamKeyModifiers>(event, os_modifiers); modifiers_t modifiers(implementation::convert_modifiers(os_modifiers)); button_state_set_t::iterator state(button_modifier_state(button.state_set_m, button.modifier_mask_m, modifiers)); if (state == button.state_set_m.end()) state = button_default_state(button.state_set_m); implementation::set_name(button.control_m, state->name_m); implementation::set_control_alt_text(button.control_m, state->alt_text_m); return noErr; }
::OSStatus button_hit_handler_t::handle_event(::EventHandlerCallRef /*next*/, ::EventRef event) { assert(button_m); button_t& button(*button_m); ::UInt32 os_modifiers; get_event_parameter<kEventParamKeyModifiers>(event, os_modifiers); modifiers_t modifiers(implementation::convert_modifiers(os_modifiers)); button_state_set_t::iterator state(button_modifier_state(button.state_set_m, button.modifier_mask_m, modifiers)); if (state == button.state_set_m.end()) state = button_default_state(button.state_set_m); if (!state->hit_proc_m.empty()) state->hit_proc_m(state->value_m, state->contributing_m); return noErr; }
bool button_t::handle_key(key_type key, bool pressed, modifiers_t /* modifiers */) { if (pressed == false) return false; modifiers_m = modifier_state(); // // Look up the state which this modifier should trigger. // button_state_set_t::iterator state(button_modifier_state(state_set_m, modifier_mask_m, modifiers_m)); if (state == state_set_m.end()) state = button_default_state(state_set_m); // // Set the window text. // control_m->SetText(state->name_m); // // Set the alt text if need be. // if (!state->alt_text_m.empty()) implementation::set_control_alt_text(control_m, state->alt_text_m); if (state->hit_proc_m.empty() || enabled_m == false) return false; if ((key.first == GG::GGK_RETURN || key.first == GG::GGK_KP_ENTER) && is_default_m) state->hit_proc_m(state->value_m, state->contributing_m); else if (key.first == GG::GGK_ESCAPE && is_cancel_m) state->hit_proc_m(state->value_m, state->contributing_m); else return false; return true; }