void GLUI_CommandLine::deactivate( void ) { // if the commit_flag is set, add the current command to // history and call deactivate as normal // Trick deactivate into calling callback if and only if commit_flag set. // A bit subtle, but deactivate checks that orig_text and text // are the same to decide whether or not to call the callback. // Force them to be different for commit, and the same for no commit. if (commit_flag) { add_to_history(text.c_str()); orig_text = ""; Super::deactivate( ); set_text( "" ); commit_flag = false; } else { orig_text = text; } }
Label::Label(const String &p_text) { align=ALIGN_LEFT; valign=VALIGN_TOP; text=""; word_cache=NULL; word_cache_dirty=true; autowrap=false; line_count=0; set_v_size_flags(0); clip=false; set_ignore_mouse(true); total_char_cache=0; visible_chars=-1; percent_visible=1; lines_skipped=0; max_lines_visible=-1; set_text(p_text); uppercase=false; }
void GlobalSearchPositions::create_objects() { add_item(new BC_MenuItem("16")); add_item(new BC_MenuItem("32")); add_item(new BC_MenuItem("64")); add_item(new BC_MenuItem("128")); add_item(new BC_MenuItem("256")); add_item(new BC_MenuItem("512")); add_item(new BC_MenuItem("1024")); add_item(new BC_MenuItem("2048")); add_item(new BC_MenuItem("4096")); add_item(new BC_MenuItem("8192")); add_item(new BC_MenuItem("16384")); add_item(new BC_MenuItem("32768")); add_item(new BC_MenuItem("65536")); add_item(new BC_MenuItem("131072")); char string[BCTEXTLEN]; sprintf(string, "%d", plugin->config.global_positions); set_text(string); }
bool CRpcResponse::handleExceptions(IXslProcessor *xslp, IMultiException *me, const char *serv, const char *meth, const char *errorXslt) { IEspContext *context=queryContext(); if (me->ordinality()>0) { StringBuffer text; me->errorMessage(text); text.append('\n'); WARNLOG("Exception(s) in %s::%s - %s", serv, meth, text.str()); if (errorXslt) { me->serialize(text.clear()); StringBuffer theOutput; xslTransformHelper(xslp, text.str(), errorXslt, theOutput, context->queryXslParameters()); set_text(theOutput.str()); } } return false; }
/* * call-seq: * detect_all(text=nil, declared_encoding=nil) * * Find all charset matches that appear to be consistent with the input, * returning an array of results. The results are ordered with the * best quality match first. * * Because the detection only looks at a limited amount of the * input byte data, some of the returned charsets may fail to handle * the all of input data. * * Return an error if * * no charset appears to match the data * * no input text has been provided (with +text+ or set with #text= ) */ static VALUE UCharsetDetector_detect_all(int argc, VALUE *argv, VALUE self) { VALUE text; VALUE declared_encoding; rb_scan_args(argc, argv, "02", &text, &declared_encoding); set_text(self, text); set_declared_encoding(self, declared_encoding); UCharsetDetector *detector; Data_Get_Struct(self, UCharsetDetector, detector); UErrorCode status = U_ZERO_ERROR; int32_t matches_found; const UCharsetMatch **matches = ucsdet_detectAll(detector, &matches_found, &status); ensure(status); VALUE ary = rb_ary_new(); int i = 0; for (i = 0; i < matches_found; i++) { const char *encoding_name = ucsdet_getName(matches[i], &status); ensure(status); int32_t encoding_confidence = ucsdet_getConfidence(matches[i], &status); ensure(status); const char *encoding_language = ucsdet_getLanguage(matches[i], &status); ensure(status); VALUE hash = rb_hash_new(); rb_hash_aset(hash, ID2SYM(rb_intern("encoding")), rb_str_new2(encoding_name)); rb_hash_aset(hash, ID2SYM(rb_intern("confidence")), INT2NUM(encoding_confidence)); rb_hash_aset(hash, ID2SYM(rb_intern("language")), rb_str_new2(encoding_language)); rb_ary_push(ary, hash); } return ary; }
void GaugeCDI::Update(double TrackBearing, double WaypointBearing) { // JMW changed layout here to fit reorganised display // insert waypoint bearing ".<|>." into CDIScale string" TCHAR CDIScale[] = TEXT("330..340..350..000..010..020..030..040..050..060..070..080..090..100..110..120..130..140..150..160..170..180..190..200..210..220..230..240..250..260..270..280..290..300..310..320..330..340..350..000..010..020..030..040."); TCHAR CDIDisplay[25] = TEXT(""); int j; int CDI_WP_Bearing = (int)WaypointBearing/2; CDIScale[CDI_WP_Bearing + 9] = 46; CDIScale[CDI_WP_Bearing + 10] = 60; CDIScale[CDI_WP_Bearing + 11] = 124; // "|" character CDIScale[CDI_WP_Bearing + 12] = 62; CDIScale[CDI_WP_Bearing + 13] = 46; for (j=0;j<24;j++) CDIDisplay[j] = CDIScale[(j + (int)(TrackBearing)/2)]; CDIDisplay[24] = _T('\0'); // JMW fix bug! This indicator doesn't always display correctly! // JMW added arrows at end of CDI to point to track if way off.. int deltacdi = iround(WaypointBearing - TrackBearing); while (deltacdi>180) { deltacdi-= 360; } while (deltacdi<-180) { deltacdi+= 360; } if (deltacdi>20) { CDIDisplay[21]='>'; CDIDisplay[22]='>'; CDIDisplay[23]='>'; } if (deltacdi<-20) { CDIDisplay[0]='<'; CDIDisplay[1]='<'; CDIDisplay[2]='<'; } set_text(CDIDisplay); // end of new code to display CDI scale }
void gui_filterbar_c::fill_tags() { int lnki = 0; auto make_ht = [&]( const ts::wsptr &htt ) -> ts::wstr_c { ts::wstr_c x( CONSTWSTR("<cstm=a\1>"), htt ); x.append( CONSTWSTR("<cstm=b\1>, ") ); x.replace_all( CONSTWSTR("\1"), ts::wmake<int>( lnki++ ) ); return x; }; ts::wstr_c t; for (int i = 0; i < BIT_count; ++i) t.append( make_ht(tagname(i)) ); for(const ts::str_c &ht : contacts().get_all_tags()) t.append(make_ht(from_utf8(ht))); t.trunc_length(2); set_text(t); }
void OptionButton::_select(int p_idx, bool p_emit) { if (p_idx < 0) return; if (p_idx == current) return; ERR_FAIL_INDEX(p_idx, popup->get_item_count()); for (int i = 0; i < popup->get_item_count(); i++) { popup->set_item_checked(i, i == p_idx); } current = p_idx; set_text(popup->get_item_text(current)); set_icon(popup->get_item_icon(current)); if (is_inside_tree() && p_emit) emit_signal("item_selected", current); }
void ItemColorChannel::remove_char() { std::string text = get_text(); if (text.empty()) { *m_number = 0.0f; } else { text.pop_back(); if (!text.empty()) { *m_number = std::stof(text); } else { *m_number = 0.0f; } } set_text(text); }
// Called when a message is received from PebbleKitJS static void in_received_handler(DictionaryIterator *received, void *context) { bool ok = false; int status = 0; Tuple *tuple; tuple = dict_find(received, STATUS_KEY); if(tuple) { status = (int)tuple->value->uint32; //APP_LOG(APP_LOG_LEVEL_DEBUG, "Received Status: %d", (int)tuple->value->uint32); } if (status == 1) { /* tuple = dict_find(received, MESSAGE_KEY); if(tuple) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Received Message: %s", tuple->value->cstring); }*/ if (!initialized) { initialized = true; hide_loadscreen(); show_window(); } if (tupleInt(received, RECORDING) == 1) { vibes_double_pulse(); } mode = tupleInt(received, MODE); setMode(mode, tupleInt(received, RECORDING)); setBattery(tupleInt(received, BATTERY)); set_text(tupleStr(received, CURRENT), tupleStr(received, REMAIN)); } else { if (initialized) { initialized = false; hide_window(); show_loadscreen(); } set_loadText(status); } }
/** * \brief Set the text displayed in the control. */ void ptb::key_edit::set_label() { std::string t; switch ( m_button.get_type() ) { case bear::input::controller_button::controller_keyboard: t = bear::input::keyboard::get_translated_name_of (m_button.get_key_info().get_code()); break; case bear::input::controller_button::controller_joystick: t = bear::input::joystick_button::get_translated_name_of (m_button.get_joystick_button()); break; case bear::input::controller_button::controller_mouse: t = bear::input::mouse::get_translated_name_of(m_button.get_mouse_code()); break; default: { } } set_text(t); } // key_edit::set_label()
void inbox(DictionaryIterator *iter, void *context) { Tuple *t = dict_read_first(iter); do { switch (t->key) { case DISPLAY_MESSAGE: set_text(strcpy(DisplayMessage, t->value->cstring)); break; case MESSAGE: switch(t->value->int32) { case IS_LEVEL: car_is_level(); break; case BEGIN_LOGGING: begin_logging(); break; }; break; default: break; }; } while ((t = dict_read_next(iter)) != NULL); }
void textbox::append_text(const std::string& text, bool auto_scroll, const SDL_Color& color) { if(text_image_.get() == NULL) { set_text(text, color); return; } //disallow adding multi-line text to a single-line text box if(wrap_ == false && std::find_if(text.begin(),text.end(),utils::isnewline) != text.end()) { return; } const bool is_at_bottom = get_position() == get_max_position(); const wide_string& wtext = utils::string_to_wstring(text); const surface new_text = add_text_line(wtext, color); surface new_surface = create_compatible_surface(text_image_,std::max<size_t>(text_image_->w,new_text->w),text_image_->h+new_text->h); SDL_SetAlpha(new_text.get(),0,0); SDL_SetAlpha(text_image_.get(),0,0); sdl_blit(text_image_,NULL,new_surface,NULL); SDL_Rect target = create_rect(0 , text_image_->h , new_text->w , new_text->h); sdl_blit(new_text,NULL,new_surface,&target); text_image_.assign(new_surface); text_.resize(text_.size() + wtext.size()); std::copy(wtext.begin(),wtext.end(),text_.end()-wtext.size()); set_dirty(true); update_text_cache(false); if(auto_scroll && is_at_bottom) scroll_to_bottom(); handle_text_changed(text_); }
VOID edit_box(LONG tree, WORD sobj) { LONG obspec; WORD where, type, exitobj, ok, nilok; BYTE name[9], text[2], bxchar; GRECT p; if (rcs_state != ALRT_STATE) { get_fields(tree, sobj, &type, &obspec, &p); ini_tree(&tree, BOXDIAL); where = set_obname(tree, BOXNAME, name, ad_view, sobj); if ( where != NIL && tree_view() && tree_kind( get_kind(where)) ) nilok = FALSE; else nilok = TRUE; bxchar = LHIBT(LHIWD(LLGET(obspec))); set_text(tree, OCHRITEM, (LONG)ADDR(&text[0]), 2); text[0] = bxchar? bxchar: '@'; text[1] = '\0'; do { exitobj = hndl_dial(tree, OCHRITEM, &p); desel_obj(tree, exitobj); ok = DEFAULT & GET_FLAGS(tree, exitobj); } while (ok && !name_ok(name, where, nilok)); if (ok) { rcs_edited = TRUE; get_obname(name, ad_view, sobj); bxchar = (text[0] == '@')? '\0': text[0]; LLSET(obspec, (LLGET(obspec) & 0xffffffL) | ((LONG) ((UWORD) bxchar) << 24)); } } }
void setup() { set_adj("large", "treasure", "sandy"); set_id("chest"); set_untouched_desc("There is a large treasure chest at the bottom of the " "hole."); set_long("The treasure chest is still a bit sandy, but otherwise has weathered well. There is some writing on the outside of it."); set_objects( ([ ]) ); #ifdef USE_SIZE set_size(LARGE); #endif #ifdef USE_MASS set_mass(LARGE); #endif set_max_capacity(LARGE); set_text("Written on the treasure chest is a poem:\n" "\tI used to have a treasure chest.\n" "\tIt got so heavy that I had to rest.\n" "\tI let it slip away from me,\n" "\tBut I didn't need it anyway,\n" "\tSo I let it slip away...\n"); }
void browser::onLoad( Berkelium::Window* win ) { #ifdef BROWSER_USE_EXCEPTIONS try #endif { browser_instance& w = *instances.at( win ); sf::Mutex mtx; mtx.lock(); { std::cout << "Browser bindings set." << std::endl; set_text( w ); js::bindings_complete( w ); } mtx.unlock(); } #ifdef BROWSER_USE_EXCEPTIONS catch( ... ) { } #endif }
void nsatari_search_restore_form( struct s_search_form_session *s, OBJECT *obj) { if ((s->state.flags & SEARCH_FLAG_SHOWALL) != 0) { obj[TOOLBAR_CB_SHOWALL].ob_state |= OS_SELECTED; } else { obj[TOOLBAR_CB_SHOWALL].ob_state &= ~OS_SELECTED; } if ((s->state.flags & SEARCH_FLAG_CASE_SENSITIVE) != 0) { obj[TOOLBAR_CB_CASESENSE].ob_state |= OS_SELECTED; } else { obj[TOOLBAR_CB_CASESENSE].ob_state &= ~OS_SELECTED; } if (s->state.back_avail == false) { obj[TOOLBAR_BT_SEARCH_BACK].ob_state |= OS_DISABLED; } else { obj[TOOLBAR_BT_SEARCH_BACK].ob_state &= ~OS_DISABLED; } TEDINFO *t = ((TEDINFO *)get_obspec(obj, TOOLBAR_TB_SRCH)); set_text(obj, TOOLBAR_TB_SRCH, s->state.text, t->te_txtlen); }
TextBox::TextBox(TextBoxType _type) { type = _type; buffer_size = 100; TextFont buttonfont = Engine::get_game_font(); //build forwards button forward_button = std::make_shared<Button>(ButtonType::Single); forward_button->set_visible(text_stack.can_forward()); forward_button->set_alignment(ButtonAlignment::BottomLeft); backward_button = std::make_shared<Button>(ButtonType::Single); backward_button->set_visible(text_stack.can_backward()); backward_button->set_alignment(ButtonAlignment::BottomLeft); if(type == TextBoxType::Bar){ forward_button->move_text(0.0f, 0.0f); forward_button->set_picture("gui/game/next"); forward_button->set_on_click([&] () { LOG(INFO) << "forward button pressed"; if(text_stack.can_forward()){ traverse_text(Direction::NEXT); if(!text_stack.can_forward()){ forward_button->set_picture("gui/game/next"); } Engine::get_gui()->refresh_gui(); } else{ hide_buttons(); Engine::close_notification_bar(); } }); this->add(forward_button); } if(type == TextBoxType::ExternalScriptHelp){ forward_button->move_text(0.0f, 0.0f); forward_button->set_picture("gui/game/next"); forward_button->set_on_click([&] () { LOG(INFO) << "forward button pressed"; if(text_stack.can_forward()){ traverse_text(Direction::NEXT); if(!text_stack.can_forward()){ forward_button->set_picture("gui/game/next"); forward_button->set_visible(false); forward_button->set_clickable(false); } Engine::get_gui()->refresh_gui(); } }); this->add(forward_button); } else if(type == TextBoxType::Display){ forward_button->move_text(0.0f, 0.0f); forward_button->set_picture("gui/game/next"); forward_button->set_on_click([&] () { LOG(INFO) << "forward button pressed"; if(text_stack.can_forward()){ traverse_text(Direction::NEXT); if(!text_stack.can_forward()){ forward_button->set_picture("gui/game/next"); } else if(text_stack.can_forward()){ forward_button->set_picture("gui/game/next"); } if(!text_stack.can_backward()){ backward_button->set_picture("gui/game/prev"); } else if(text_stack.can_backward()){ backward_button->set_picture("gui/game/prev"); } Engine::get_gui()->refresh_gui(); } }); backward_button->move_text(0.0f, 0.0f); backward_button->set_picture("gui/game/prev"); backward_button->set_on_click([&] () { LOG(INFO) << "backward button pressed"; if(text_stack.can_backward()){ traverse_text(Direction::PREVIOUS); if(!text_stack.can_backward()){ backward_button->set_picture("gui/game/prev"); } else if(text_stack.can_backward()){ backward_button->set_picture("gui/game/prev"); } if(!text_stack.can_forward()){ forward_button->set_picture("gui/game/next"); } else if(text_stack.can_forward()){ forward_button->set_picture("gui/game/next"); } Engine::get_gui()->refresh_gui(); } }); this->add(forward_button); this->add(backward_button); } // text object for notifications text = std::make_shared<GUIText>(); text->set_width(1.0f); text->set_height(1.0f); text->set_x_offset(0.0f); text->set_y_offset(0.0f); set_text(""); this->add(text); }
void TextBox::clear_text() { set_text(""); text_stack.clear(); Engine::get_gui()->refresh_gui(); }
void write_controls(const SfxOptions& options) { DisableEvents de(*this); set_list_pos(module_ctrl_id, ArcAPI::sfx().find_by_name(options.name)); set_check(replace_icon_ctrl_id, options.replace_icon); set_text(icon_path_ctrl_id, options.icon_path); set_check(replace_version_ctrl_id, options.replace_version); set_text(ver_info_product_name_ctrl_id, options.ver_info.product_name); set_text(ver_info_version_ctrl_id, options.ver_info.version); set_text(ver_info_company_name_ctrl_id, options.ver_info.company_name); set_text(ver_info_file_description_ctrl_id, options.ver_info.file_description); set_text(ver_info_comments_ctrl_id, options.ver_info.comments); set_text(ver_info_legal_copyright_ctrl_id, options.ver_info.legal_copyright); set_check(append_install_config_ctrl_id, options.append_install_config); set_text(install_config_title_ctrl_id, options.install_config.title); set_text(install_config_begin_prompt_ctrl_id, options.install_config.begin_prompt); TriState value; if (options.install_config.progress == L"yes") value = triTrue; else if (options.install_config.progress == L"no") value = triFalse; else value = triUndef; set_check3(install_config_progress_ctrl_id, value); set_text(install_config_run_program_ctrl_id, options.install_config.run_program); set_text(install_config_directory_ctrl_id, options.install_config.directory); set_text(install_config_execute_file_ctrl_id, options.install_config.execute_file); set_text(install_config_execute_parameters_ctrl_id, options.install_config.execute_parameters); }
void show_server_info_dialog(Gtk::Window& w, Glib::ustring game_v, Glib::ustring host_v, Server data, std::function<void()> cb_launch) { PlayerListModelColumns player_list_columns; RuleListModelColumns rule_list_columns; // Set models auto game = Gtk::manage(new Gtk::Label(game_v)); game->set_halign(Gtk::Align::ALIGN_START); auto host = Gtk::manage(new Gtk::Label(host_v)); host->set_halign(Gtk::Align::ALIGN_START); auto name = Gtk::manage(new Gtk::Label); name->set_halign(Gtk::Align::ALIGN_START); auto terrain = Gtk::manage(new Gtk::Label); terrain->set_halign(Gtk::Align::ALIGN_START); auto ping = Gtk::manage(new Gtk::Label); ping->set_halign(Gtk::Align::ALIGN_START); auto players = Gtk::manage(new Gtk::Label); players->set_halign(Gtk::Align::ALIGN_START); set_label_from_optional(name, data.name); set_label_from_optional(terrain, data.terrain); set_label_from_optional(ping, data.ping); try { players->set_text(Glib::ustring::compose("%1 / %2", data.player_count.value(), data.player_limit.value())); } catch (const std::experimental::bad_optional_access&) {} auto player_list = Gtk::ListStore::create(player_list_columns); for (auto v : data.players) { auto& row = *player_list->append(); row[player_list_columns.name] = v.name; try { row[player_list_columns.ping] = std::stoi(v.info.at("ping")); } catch (...) {} try { row[player_list_columns.score] = std::stoi(v.info.at("score")); } catch (...) {} } auto rule_list = Gtk::ListStore::create(rule_list_columns); for (auto v : data.rules) { auto& row = *rule_list->append(); row[rule_list_columns.key] = v.first; row[rule_list_columns.value] = v.second; } // Create presentation auto server_info_data_grid = Gtk::manage(new Gtk::Grid); server_info_data_grid->set_row_spacing(5); server_info_data_grid->set_column_spacing(5); { auto i = -1; auto name_label = Gtk::manage(new Gtk::Label); name_label->set_markup("<b>Name:</b>"); name_label->set_halign(Gtk::Align::ALIGN_END); server_info_data_grid->attach(*name_label, 0, i++, 1, 1); server_info_data_grid->attach_next_to(*name, *name_label, Gtk::PositionType::POS_RIGHT, 1, 1); auto host_label = Gtk::manage(new Gtk::Label); host_label->set_markup("<b>Host:</b>"); host_label->set_halign(Gtk::Align::ALIGN_END); server_info_data_grid->attach(*host_label, 0, i++, 1, 1); server_info_data_grid->attach_next_to(*host, *host_label, Gtk::PositionType::POS_RIGHT, 1, 1); auto game_label = Gtk::manage(new Gtk::Label); game_label->set_markup("<b>Game:</b>"); game_label->set_halign(Gtk::Align::ALIGN_END); server_info_data_grid->attach(*game_label, 0, i++, 1, 1); server_info_data_grid->attach_next_to(*game, *game_label, Gtk::PositionType::POS_RIGHT, 1, 1); auto terrain_label = Gtk::manage(new Gtk::Label); terrain_label->set_markup("<b>Terrain:</b>"); terrain_label->set_halign(Gtk::Align::ALIGN_END); server_info_data_grid->attach(*terrain_label, 0, i++, 1, 1); server_info_data_grid->attach_next_to(*terrain, *terrain_label, Gtk::PositionType::POS_RIGHT, 1, 1); auto players_label = Gtk::manage(new Gtk::Label); players_label->set_markup("<b>Players:</b>"); players_label->set_halign(Gtk::Align::ALIGN_END); server_info_data_grid->attach(*players_label, 0, i++, 1, 1); server_info_data_grid->attach_next_to(*players, *players_label, Gtk::PositionType::POS_RIGHT, 1, 1); auto ping_label = Gtk::manage(new Gtk::Label); ping_label->set_markup("<b>Ping:</b>"); ping_label->set_halign(Gtk::Align::ALIGN_END); server_info_data_grid->attach(*ping_label, 0, i++, 1, 1); server_info_data_grid->attach_next_to(*ping, *ping_label, Gtk::PositionType::POS_RIGHT, 1, 1); } auto player_list_view = Gtk::manage(new Gtk::TreeView(player_list)); { auto col = Gtk::manage(new Gtk::TreeViewColumn("Name")); col->pack_start(player_list_columns.name); player_list_view->append_column(*col); } { auto col = Gtk::manage(new Gtk::TreeViewColumn("Score")); col->pack_start(player_list_columns.score); player_list_view->append_column(*col); } { auto col = Gtk::manage(new Gtk::TreeViewColumn("Ping")); col->pack_start(player_list_columns.ping); player_list_view->append_column(*col); } auto player_list_sw = Gtk::manage(new Gtk::ScrolledWindow); player_list_sw->set_hexpand(true); player_list_sw->set_vexpand(true); player_list_sw->add(*player_list_view); auto server_info_grid = Gtk::manage(new Gtk::Grid); server_info_grid->set_row_spacing(10); { auto i = -1; server_info_grid->attach(*server_info_data_grid, 0, i++, 1, 1); server_info_grid->attach(*player_list_sw, 0, i++, 1, 1); } // Server rules auto rule_list_view = Gtk::manage(new Gtk::TreeView(rule_list)); { auto col = Gtk::manage(new Gtk::TreeViewColumn("Key")); col->pack_start(rule_list_columns.key); rule_list_view->append_column(*col); } { auto col = Gtk::manage(new Gtk::TreeViewColumn("Value")); col->pack_start(rule_list_columns.value); rule_list_view->append_column(*col); } auto server_rules_sw = Gtk::manage(new Gtk::ScrolledWindow); server_rules_sw->add(*rule_list_view); // The stack auto stack = Gtk::manage(new Gtk::Stack); stack->property_margin().set_value(10); stack->add(*server_info_grid, "info", "Information"); stack->add(*server_rules_sw, "rules", "Rules"); auto stack_switcher = Gtk::manage(new Gtk::StackSwitcher); stack_switcher->set_stack(*stack); stack_switcher->set_halign(Gtk::Align::ALIGN_CENTER); // The dialog Gtk::Dialog dialog_window("Server info", w); auto content = dialog_window.get_content_area(); content->pack_start(*stack_switcher, Gtk::PackOptions::PACK_SHRINK); content->pack_start(*stack); auto connect_button = dialog_window.add_button("Connect", 0); auto close_button = dialog_window.add_button("Close", 0); connect_button->signal_clicked().connect([&dialog_window, cb_launch]() { try { cb_launch(); } catch (const std::bad_function_call&) {} }); dialog_window.show_all(); dialog_window.run(); }
void OptionButton::clear() { popup->clear(); set_text(""); current = -1; }
/* this gets called each time the settings dialog is opened: */ static void display_settings(void) { char spare[255]; // read current settings and display them /* "Browser" tab: */ set_text( SETTINGS_EDIT_HOMEPAGE, nsoption_charp(homepage_url), INPUT_HOMEPAGE_URL_MAX_LEN ); if( nsoption_bool(block_ads) ) { OBJ_CHECK( SETTINGS_CB_HIDE_ADVERTISEMENT ); } else { OBJ_UNCHECK( SETTINGS_CB_HIDE_ADVERTISEMENT ); } if( nsoption_bool(target_blank) ) { OBJ_UNCHECK( SETTINGS_CB_DISABLE_POPUP_WINDOWS ); } else { OBJ_CHECK( SETTINGS_CB_DISABLE_POPUP_WINDOWS ); } if( nsoption_bool(send_referer) ) { OBJ_CHECK( SETTINGS_CB_SEND_HTTP_REFERRER ); } else { OBJ_UNCHECK( SETTINGS_CB_SEND_HTTP_REFERRER ); } if( nsoption_bool(do_not_track) ) { OBJ_CHECK( SETTINGS_CB_SEND_DO_NOT_TRACK ); } else { OBJ_UNCHECK( SETTINGS_CB_SEND_DO_NOT_TRACK ); } set_text( SETTINGS_BT_SEL_LOCALE, nsoption_charp(accept_language) ? nsoption_charp(accept_language) : (char*)"en", INPUT_LOCALE_MAX_LEN ); tmp_option_expire_url = nsoption_int(expire_url); snprintf( spare, 255, "%02d", nsoption_int(expire_url) ); set_text( SETTINGS_EDIT_HISTORY_AGE, spare, 2 ); /* "Cache" tab: */ tmp_option_memory_cache_size = nsoption_int(memory_cache_size) / 1000000; snprintf( spare, 255, "%03.1f", tmp_option_memory_cache_size ); set_text( SETTINGS_STR_MAX_MEM_CACHE, spare, 5 ); /* "Paths" tab: */ set_text( SETTINGS_EDIT_DOWNLOAD_PATH, nsoption_charp(downloads_path), LABEL_PATH_MAX_LEN ); set_text( SETTINGS_EDIT_HOTLIST_FILE, nsoption_charp(hotlist_file), LABEL_PATH_MAX_LEN ); set_text( SETTINGS_EDIT_CA_BUNDLE, nsoption_charp(ca_bundle), LABEL_PATH_MAX_LEN ); set_text( SETTINGS_EDIT_CA_CERTS_PATH, nsoption_charp(ca_path), LABEL_PATH_MAX_LEN ); set_text( SETTINGS_EDIT_EDITOR, nsoption_charp(atari_editor), LABEL_PATH_MAX_LEN ); /* "Rendering" tab: */ set_text( SETTINGS_BT_SEL_FONT_RENDERER, nsoption_charp(atari_font_driver), LABEL_FONT_RENDERER_MAX_LEN ); SET_BIT(dlgtree[SETTINGS_CB_TRANSPARENCY].ob_state, OS_SELECTED, nsoption_int(atari_transparency) ? 1 : 0 ); SET_BIT(dlgtree[SETTINGS_CB_ENABLE_ANIMATION].ob_state, OS_SELECTED, nsoption_bool(animate_images) ? 1 : 0 ); SET_BIT(dlgtree[SETTINGS_CB_FG_IMAGES].ob_state, OS_SELECTED, nsoption_bool(foreground_images) ? 1 : 0 ); SET_BIT(dlgtree[SETTINGS_CB_BG_IMAGES].ob_state, OS_SELECTED, nsoption_bool(background_images) ? 1 : 0 ); // TODO: enable this option? /* SET_BIT(dlgtree[SETTINGS_CB_INCREMENTAL_REFLOW].ob_state, OS_SELECTED, nsoption_bool(incremental_reflow) ? 1 : 0 );*/ SET_BIT(dlgtree[SETTINGS_CB_ANTI_ALIASING].ob_state, OS_SELECTED, nsoption_int(atari_font_monochrom) ? 0 : 1 ); // TODO: activate this option? tmp_option_min_reflow_period = nsoption_int(min_reflow_period); snprintf( spare, 255, "%04d", tmp_option_min_reflow_period ); set_text( SETTINGS_EDIT_MIN_REFLOW_PERIOD, spare, INPUT_MIN_REFLOW_PERIOD_MAX_LEN ); tmp_option_minimum_gif_delay = (float)nsoption_int(minimum_gif_delay) / (float)100; snprintf( spare, 255, "%01.1f", tmp_option_minimum_gif_delay ); set_text( SETTINGS_EDIT_MIN_GIF_DELAY, spare, 3 ); /* "Network" tab: */ set_text( SETTINGS_EDIT_PROXY_HOST, nsoption_charp(http_proxy_host), INPUT_PROXY_HOST_MAX_LEN ); snprintf( spare, 255, "%5d", nsoption_int(http_proxy_port) ); set_text( SETTINGS_EDIT_PROXY_PORT, spare, INPUT_PROXY_PORT_MAX_LEN ); set_text( SETTINGS_EDIT_PROXY_USERNAME, nsoption_charp(http_proxy_auth_user), INPUT_PROXY_USERNAME_MAX_LEN ); set_text( SETTINGS_EDIT_PROXY_PASSWORD, nsoption_charp(http_proxy_auth_pass), INPUT_PROXY_PASSWORD_MAX_LEN ); SET_BIT(dlgtree[SETTINGS_CB_USE_PROXY].ob_state, OS_SELECTED, nsoption_bool(http_proxy) ? 1 : 0 ); SET_BIT(dlgtree[SETTINGS_CB_PROXY_AUTH].ob_state, OS_SELECTED, nsoption_int(http_proxy_auth) ? 1 : 0 ); tmp_option_max_cached_fetch_handles = nsoption_int(max_cached_fetch_handles); snprintf( spare, 255, "%2d", nsoption_int(max_cached_fetch_handles) ); set_text( SETTINGS_EDIT_MAX_CACHED_CONNECTIONS, spare , 2 ); tmp_option_max_fetchers = nsoption_int(max_fetchers); snprintf( spare, 255, "%2d", nsoption_int(max_fetchers) ); set_text( SETTINGS_EDIT_MAX_FETCHERS, spare , 2 ); tmp_option_max_fetchers_per_host = nsoption_int(max_fetchers_per_host); snprintf( spare, 255, "%2d", nsoption_int(max_fetchers_per_host) ); set_text( SETTINGS_EDIT_MAX_FETCHERS_PER_HOST, spare , 2 ); /* "Style" tab: */ tmp_option_font_min_size = nsoption_int(font_min_size); snprintf( spare, 255, "%3d", nsoption_int(font_min_size) ); set_text( SETTINGS_EDIT_MIN_FONT_SIZE, spare , 3 ); tmp_option_font_size = nsoption_int(font_size); snprintf( spare, 255, "%3d", nsoption_int(font_size) ); set_text( SETTINGS_EDIT_DEF_FONT_SIZE, spare , 3 ); toggle_objects(); }
void UI_INPUTBOX::process(int focus) { int ascii, clear_lastkey, key, key_used, key_check; // check if mouse is pressed if (B1_PRESSED && is_mouse_on()) { set_focus(); } if (disabled_flag) return; if (my_wnd->selected_gadget == this) focus = 1; key_used = 0; changed_flag = 0; oldposition = position; pressed_down = 0; clear_lastkey = (flags & UI_INPUTBOX_FLAG_KEYTHRU) ? 0 : 1; if (focus) { key = my_wnd->keypress; switch (key) { case 0: break; //case KEY_LEFT: case KEY_BACKSP: if (position > 0) position--; text[position] = 0; if (flags & UI_INPUTBOX_FLAG_PASSWD) { passwd_text[position] = 0; } changed_flag = 1; key_used = 1; break; case KEY_ENTER: pressed_down = 1; locked = 0; changed_flag = 1; key_used = 1; break; case KEY_ESC: if (flags & UI_INPUTBOX_FLAG_ESC_CLR){ if (position > 0) { set_text(""); key_used = 1; } else { key_used = 0; clear_lastkey = 0; } } if (flags & UI_INPUTBOX_FLAG_ESC_FOC) { clear_focus(); } break; default: if (!locked) { // MWA -- determine if alt or ctrl held down on this key and don't process if it is. We // need to be able to pass these keys back to the top level. (And anyway -- ctrl-a shouldn't // print out an A in the input window if ( key & (KEY_ALTED | KEY_CTRLED) ) { clear_lastkey = 0; break; } // get an ascii char from the input if possible key_check = keypad_to_ascii(key); if(key_check == -1){ key_check = key_to_ascii(key); } ascii = validate_input(key_check); if ((ascii > 0) && (ascii < 255)) { if (flags & UI_INPUTBOX_FLAG_LETTER_FIRST) { if ((position == 0) && !is_letter((char) ascii)) break; } key_used = 1; if ( position < length ) { text[position] = (char) ascii; text[position + 1] = 0; if (flags & UI_INPUTBOX_FLAG_PASSWD) { passwd_text[position] = (char) INPUTBOX_PASSWD_CHAR; passwd_text[position + 1] = 0; } position++; // check to see if we should limit by pixel width if (pixel_limit > -1) { int _w; if (flags & UI_INPUTBOX_FLAG_PASSWD) { gr_get_string_size(&_w, NULL, passwd_text); } else { gr_get_string_size(&_w, NULL, text); } if (_w > pixel_limit) { position--; locked = 1; text[position] = 0; if (flags & UI_INPUTBOX_FLAG_PASSWD) { passwd_text[position] = 0; } } } } changed_flag = 1; } } break; } if (clear_lastkey || (key_used && (flags & UI_INPUTBOX_FLAG_EAT_USED)) ) my_wnd->last_keypress=0; } }
void fatal_error(char *message, char *file, int line) { set_text(); printf("Error (%s line %d): %s\n", file, line, message); exit(1); }
void GLUI_EditText::deactivate( void ) { int new_int_val; float new_float_val; double new_double_val; active = false; if ( NOT glui ) return; if ( debug ) dump( stdout, "-> DISACTIVATE" ); sel_start = sel_end = insertion_pt = -1; /***** Retrieve the current value from the text *****/ /***** The live variable will be updated by set_text() ****/ if ( data_type == GLUI_EDITTEXT_FLOAT ) { if ( text.length() == 0 ) /* zero-length string - make it "0.0" */ text = "0.0"; new_float_val = atof( text.c_str() ); set_float_val( new_float_val ); } else if ( data_type == GLUI_EDITTEXT_DOUBLE ) { if ( text.length() == 0 ) /* zero-length string - make it "0.0" */ text = "0.0"; new_double_val = atof( text.c_str() ); set_double_val( new_double_val ); } else if ( data_type == GLUI_EDITTEXT_INT ) { if ( text.length() == 0 ) /* zero-length string - make it "0" */ text = "0"; new_int_val = atoi( text.c_str() ); set_int_val( new_int_val ); } else if ( data_type == GLUI_EDITTEXT_TEXT ) { set_text(text); /* This will force callbacks and gfx refresh */ } update_substring_bounds(); /******** redraw text without insertion point ***********/ redraw(); /***** Now do callbacks if value changed ******/ if ( orig_text != text ) { this->execute_callback(); if ( 0 ) { /* THE CODE BELOW IS FROM WHEN SPINNER ALSO MAINTAINED CALLBACKS */ if ( spinner == NULL ) { /** Are we independent of a spinner? **/ if ( callback ) { callback( this ); } } else { /* We're attached to a spinner */ spinner->do_callbacks(); /* Let the spinner do the callback stuff */ } } } if ( debug ) dump( stdout, "<- DISACTIVATE" ); }
// ============================================================================ Value* AngleControl::set_property(Value** arg_list, int count) { Value* val = arg_list[0]; Value* prop = arg_list[1]; if (prop == n_text || prop == n_caption) { const TCHAR* text = val->to_string(); caption = val->get_heap_ptr(); if (parent_rollout != NULL && parent_rollout->page != NULL) set_text(text, GetDlgItem(parent_rollout->page, control_ID +1), n_left); } else if(prop == n_diameter || prop == n_width || prop == n_height) { if(parent_rollout && parent_rollout->page) SetDiameter(val->to_int()); } else if(prop == n_degrees) { if(parent_rollout && parent_rollout->page) SetDegrees(val->to_float()); } else if(prop == n_radians) { if(parent_rollout && parent_rollout->page) SetRadians(val->to_float()); } else if (prop == n_range) { if(parent_rollout && parent_rollout->page) { Point3 p; if (is_point3(val)) p = val->to_point3(); else throw TypeError (MaxSDK::GetResourceStringAsMSTR(IDS_ANGLE_RANGE_MUST_BE_A_VECTOR), val); m_min = p.x; m_max = p.y; SetDegrees(m_degrees = p.z); } } else if(prop == n_startDegrees) { if(parent_rollout && parent_rollout->page) SetStartDegrees(val->to_float()); } else if(prop == n_startRadians) { if(parent_rollout && parent_rollout->page) SetStartRadians(val->to_float()); } else if(prop == n_dir) { if (val != n_CW && val != n_CCW) throw RuntimeError (MaxSDK::GetResourceStringAsMSTR(IDS_ANGLE_DIR_BAD_VALUE), val); if(parent_rollout && parent_rollout->page) m_dirCCW = val != n_CW; Invalidate(); } else if(prop == n_color) { if(parent_rollout && parent_rollout->page) SetColor(val); } else if(prop == n_bitmap) { if(parent_rollout && parent_rollout->page) SetBitmap(val); } else return RolloutControl::set_property(arg_list, count); return val; }
//---------------------------------------------------------------------------------------------- // WM INIT //---------------------------------------------------------------------------------------------- void cDlgSetTrigger :: wm_init () { CheckDlgButton ( hwnd, ID_PRESSED, TRUE ); set_text (); RECT r; GetWindowRect ( hwnd, &r ); iInitialWindowHeight = r.bottom - r.top; int iCtrlDimY = 23; int iMarginY = 12; int iGutterY = 6; iInitialComboPosY = 81; HWND hHead = GetDlgItem ( hwnd, ID_HEAD ); SetWindowFont ( hHead, g_hDialogBoxHeadFont, TRUE ); mojo::register_for_key_events ( /* &KeyBuf, */ hwnd ); mojo::start_swallowing_key_events ( hwnd ); add_combo(); const int iDimX = 90; int iLockDimX = 160; int iLockPosX = iMarginX * 2; int iLockBottom = iMarginY + iCtrlDimY * 3; int iPressedBottom = iLockBottom + 3 * iCtrlDimY + iMarginY; //--------------------------------- // PRESSED STUFF //--------------------------------- PressedLabel.hwnd = GetDlgItem ( hwnd, ID_PRESSED_LABEL ); PressedLabel.init(); register_child ( &PressedLabel, nAnchor::left, 0, iMarginX, nAnchor::bottom, 0, - ( iPressedBottom + 3 * iCtrlDimY ) , nAnchor::right, 0, -iMarginX, nAnchor::bottom, 0, - ( iPressedBottom + 2 * iCtrlDimY ) ); Pressed.hwnd = GetDlgItem ( hwnd, ID_PRESSED ); register_child ( &Pressed, nAnchor::left, 0, iLockPosX , nAnchor::bottom, 0, - ( iPressedBottom + 2 * iCtrlDimY ), nAnchor::left, 0, iLockPosX + iLockDimX, nAnchor::bottom, 0, - ( iPressedBottom + iCtrlDimY ) ); Released.hwnd = GetDlgItem ( hwnd, ID_RELEASED ); register_child ( &Released, nAnchor::left, 0, iLockPosX , nAnchor::bottom, 0, - ( iPressedBottom + iCtrlDimY ), nAnchor::left, 0, iLockPosX + iLockDimX, nAnchor::bottom, 0, - iPressedBottom ); //--------------------------------- // LOCK STUFF //--------------------------------- LockLabel.hwnd = GetDlgItem ( hwnd, ID_LOCK_LABEL ); LockLabel.init(); register_child ( &LockLabel, nAnchor::left, 0, iMarginX, nAnchor::bottom, 0, - ( iLockBottom + 3 * iCtrlDimY ) , nAnchor::right, 0, -iMarginX, nAnchor::bottom, 0, - ( iLockBottom + 2 * iCtrlDimY ) ); CapsLockOn.hwnd = GetDlgItem ( hwnd, ID_CAPSLOCK_ON ); register_child ( &CapsLockOn, nAnchor::left, 0, iLockPosX, nAnchor::bottom, 0, - ( iLockBottom + 2 * iCtrlDimY ) , nAnchor::left, 0, iMarginX + iLockDimX, nAnchor::bottom, 0, - ( iLockBottom + 1 * iCtrlDimY ) ); NumLockOn.hwnd = GetDlgItem ( hwnd, ID_NUMLOCK_ON ); register_child ( &NumLockOn, nAnchor::left, 0, iLockPosX + iLockDimX, nAnchor::bottom, 0, - ( iLockBottom + 2 * iCtrlDimY ) , nAnchor::left, 0, iMarginX + 2 * iLockDimX, nAnchor::bottom, 0, - ( iLockBottom + 1 * iCtrlDimY ) ); ScrollLockOn.hwnd = GetDlgItem ( hwnd, ID_SCROLLLOCK_ON ); register_child ( &ScrollLockOn, nAnchor::left, 0, iLockPosX + 2* iLockDimX, nAnchor::bottom, 0, - ( iLockBottom + 2 * iCtrlDimY ) , nAnchor::left, 0, iMarginX + 3 * iLockDimX, nAnchor::bottom, 0, - ( iLockBottom + 1 * iCtrlDimY ) ); CapsLockOff.hwnd = GetDlgItem ( hwnd, ID_CAPSLOCK_OFF ); register_child ( &CapsLockOff, nAnchor::left, 0, iLockPosX, nAnchor::bottom, 0, - ( iLockBottom + iCtrlDimY ), nAnchor::left, 0, iMarginX + iLockDimX, nAnchor::bottom, 0, - iLockBottom ); NumLockOff.hwnd = GetDlgItem ( hwnd, ID_NUMLOCK_OFF ); register_child ( &NumLockOff, nAnchor::left, 0, iLockPosX + iLockDimX, nAnchor::bottom, 0, - ( iLockBottom + iCtrlDimY ), nAnchor::left, 0, iMarginX + 2 * iLockDimX, nAnchor::bottom, 0, - iLockBottom ); ScrollLockOff.hwnd = GetDlgItem ( hwnd, ID_SCROLLLOCK_OFF ); register_child ( &ScrollLockOff, nAnchor::left, 0, iLockPosX + 2* iLockDimX, nAnchor::bottom, 0, - ( iLockBottom + iCtrlDimY ), nAnchor::left, 0, iMarginX + 3 * iLockDimX, nAnchor::bottom, 0, - iLockBottom ); //--------------------------------- // BOTTOM BUTTONS //--------------------------------- Clear.hwnd = GetDlgItem ( hwnd, ID_CLEAR ); register_child ( &Clear, nAnchor::left, 0, iMarginX, nAnchor::bottom, 0, - ( 1 * iMarginY + iCtrlDimY ), nAnchor::left, 0, iMarginX + iDimX, nAnchor::bottom, 0, - ( 1 * iMarginY ) ); OK.hwnd = GetDlgItem ( hwnd, IDOK ); register_child ( &OK, nAnchor::right, 0, - ( iMarginX * 2 + iDimX * 2 ), nAnchor::bottom, 0, - ( 1 * iMarginY + iCtrlDimY ), nAnchor::right, 0, - ( iMarginX * 2 + iDimX ), nAnchor::bottom, 0, - ( 1 * iMarginY ) ); Cancel.hwnd = GetDlgItem ( hwnd, IDCANCEL ); register_child ( &Cancel, nAnchor::right, 0, - ( iMarginX * 1 + iDimX * 1 ), nAnchor::bottom, 0, - ( 1 * iMarginY + iCtrlDimY ), nAnchor::right, 0, - ( iMarginX * 1 ), nAnchor::bottom, 0, - ( 1 * iMarginY ) ); Link.hwnd = GetDlgItem ( hwnd, ID_LINK ); register_child ( &Link, nAnchor::left, 0, iMarginX, nAnchor::bottom, 0, - ( 3 * iGutterY + 2 * iCtrlDimY ), nAnchor::left, 0, iMarginX + 200, nAnchor::bottom, 0, - ( 3 * iGutterY + iCtrlDimY) ); this->reposition_children (); }
int main(int argc, char *argv[]) { int ch, size; struct Options opts = {0}; struct PNGImage png = {0}; struct GBImage gb = {0}; struct Tilemap tilemap = {0}; char *ext; const char *errmsg = "Warning: The PNG's %s setting is not the same as the setting defined on the command line."; if (argc == 1) { usage(); } opts.mapfile = ""; opts.palfile = ""; opts.outfile = ""; depth = 2; while((ch = getopt(argc, argv, "Dd:Ffho:Tt:uPp:Vvx:")) != -1) { switch(ch) { case 'D': opts.debug = true; break; case 'd': depth = strtoul(optarg, NULL, 0); break; case 'F': opts.hardfix = true; case 'f': opts.fix = true; break; case 'h': opts.horizontal = true; break; case 'o': opts.outfile = optarg; break; case 'P': opts.palout = true; break; case 'p': opts.palfile = optarg; break; case 'T': opts.mapout = true; break; case 't': opts.mapfile = optarg; break; case 'u': opts.unique = true; break; case 'V': printf("rgbgfx %s\n", get_package_version_string()); exit(0); case 'v': opts.verbose = true; break; case 'x': opts.trim = strtoul(optarg, NULL, 0); break; default: usage(); /* NOTREACHED */ } } argc -= optind; argv += optind; if (argc == 0) { usage(); } opts.infile = argv[argc - 1]; if (depth != 1 && depth != 2) { errx(1, "Depth option must be either 1 or 2."); } colors = 1 << depth; input_png_file(opts, &png); png.mapfile = ""; png.palfile = ""; get_text(&png); if (png.horizontal != opts.horizontal) { if (opts.verbose) { warnx(errmsg, "horizontal"); } if (opts.hardfix) { png.horizontal = opts.horizontal; } } if (png.horizontal) { opts.horizontal = png.horizontal; } if (png.trim != opts.trim) { if (opts.verbose) { warnx(errmsg, "trim"); } if (opts.hardfix) { png.trim = opts.trim; } } if (png.trim) { opts.trim = png.trim; } if (opts.trim > png.width / 8 - 1) { errx(1, "Trim (%i) for input png file '%s' too large (max: %i)", opts.trim, opts.infile, png.width / 8 - 1); } if (strcmp(png.mapfile, opts.mapfile) != 0) { if (opts.verbose) { warnx(errmsg, "tilemap file"); } if (opts.hardfix) { png.mapfile = opts.mapfile; } } if (!*opts.mapfile) { opts.mapfile = png.mapfile; } if (png.mapout != opts.mapout) { if (opts.verbose) { warnx(errmsg, "tilemap file"); } if (opts.hardfix) { png.mapout = opts.mapout; } } if (png.mapout) { opts.mapout = png.mapout; } if (strcmp(png.palfile, opts.palfile) != 0) { if (opts.verbose) { warnx(errmsg, "palette file"); } if (opts.hardfix) { png.palfile = opts.palfile; } } if (!*opts.palfile) { opts.palfile = png.palfile; } if (png.palout != opts.palout) { if (opts.verbose) { warnx(errmsg, "palette file"); } if (opts.hardfix) { png.palout = opts.palout; } } if (png.palout) { opts.palout = png.palout; } if (!*opts.mapfile && opts.mapout) { if ((ext = strrchr(opts.infile, '.')) != NULL) { size = ext - opts.infile + 9; opts.mapfile = malloc(size); strncpy(opts.mapfile, opts.infile, size); *strrchr(opts.mapfile, '.') = '\0'; strcat(opts.mapfile, ".tilemap"); } else { opts.mapfile = malloc(strlen(opts.infile) + 9); strcpy(opts.mapfile, opts.infile); strcat(opts.mapfile, ".tilemap"); } } if (!*opts.palfile && opts.palout) { if ((ext = strrchr(opts.infile, '.')) != NULL) { size = ext - opts.infile + 5; opts.palfile = malloc(size); strncpy(opts.palfile, opts.infile, size); *strrchr(opts.palfile, '.') = '\0'; strcat(opts.palfile, ".pal"); } else { opts.palfile = malloc(strlen(opts.infile) + 5); strcpy(opts.palfile, opts.infile); strcat(opts.palfile, ".pal"); } } gb.size = png.width * png.height * depth / 8; gb.data = calloc(gb.size, 1); gb.trim = opts.trim; gb.horizontal = opts.horizontal; if (*opts.outfile || *opts.mapfile) { png_to_gb(png, &gb); create_tilemap(opts, &gb, &tilemap); } if (*opts.outfile) { output_file(opts, gb); } if (*opts.mapfile) { output_tilemap_file(opts, tilemap); } if (*opts.palfile) { output_palette_file(opts, png); } if (opts.fix || opts.debug) { set_text(&png); output_png_file(opts, &png); } free_png_data(&png); free(gb.data); return 0; }
static void form_event(int index, int external) { char spare[255]; bool is_button = false; bool checked = OBJ_SELECTED(index); char * tmp; MENU pop_menu, me_data; /* For font driver popup: */ int num_font_drivers = 2; /* Just a small collection of locales, each country has at least one ATARI-clone user! :) */ int num_locales = 15; short x, y; int choice, i; switch(index) { case SETTINGS_SAVE: OBJ_UNCHECK(index); OBJ_REDRAW(index); save_settings(); break; case SETTINGS_ABORT: OBJ_UNCHECK(index); OBJ_REDRAW(index); close_settings(); break; case SETTINGS_CB_USE_PROXY: if( checked ) { ENABLE_OBJ(SETTINGS_EDIT_PROXY_HOST); ENABLE_OBJ(SETTINGS_EDIT_PROXY_PORT); ENABLE_OBJ(SETTINGS_CB_PROXY_AUTH); } else { DISABLE_OBJ(SETTINGS_EDIT_PROXY_HOST); DISABLE_OBJ(SETTINGS_EDIT_PROXY_PORT); DISABLE_OBJ(SETTINGS_CB_PROXY_AUTH); } FORMEVENT(SETTINGS_CB_PROXY_AUTH); OBJ_REDRAW(SETTINGS_CB_USE_PROXY); break; case SETTINGS_CB_PROXY_AUTH: if( checked && OBJ_SELECTED( SETTINGS_CB_USE_PROXY ) ) { ENABLE_OBJ(SETTINGS_EDIT_PROXY_USERNAME); ENABLE_OBJ(SETTINGS_EDIT_PROXY_PASSWORD); } else { DISABLE_OBJ(SETTINGS_EDIT_PROXY_USERNAME); DISABLE_OBJ(SETTINGS_EDIT_PROXY_PASSWORD); } break; case SETTINGS_CB_ENABLE_ANIMATION: if( checked ) { ENABLE_OBJ( SETTINGS_EDIT_MIN_GIF_DELAY ); } else { DISABLE_OBJ( SETTINGS_EDIT_MIN_GIF_DELAY ); } break; case SETTINGS_BT_SEL_FONT_RENDERER: if( external ) { objc_offset(dlgtree, SETTINGS_BT_SEL_FONT_RENDERER, &x, &y); // point mn_tree tree to states popup: pop_menu.mn_tree = gemtk_obj_get_tree(POP_FONT_RENDERER); pop_menu.mn_menu = 0; pop_menu.mn_item = POP_FONT_RENDERER_INTERNAL; pop_menu.mn_scroll = SCROLL_NO; pop_menu.mn_keystate = 0; // find the selected menu item and uncheck others: for(i=pop_menu.mn_item; i<=num_font_drivers; i++) { get_string(pop_menu.mn_tree, i, spare); tmp = gemtk_obj_get_text(dlgtree, SETTINGS_BT_SEL_FONT_RENDERER); if (strcasecmp(&spare[2], tmp)) { menu_icheck(pop_menu.mn_tree, i, 0); } else { menu_icheck(pop_menu.mn_tree, i, 1); } set_string(pop_menu.mn_tree, i, spare); } menu_popup(&pop_menu, x, y, &me_data); choice = me_data.mn_item; if( choice > 0 && choice <= num_font_drivers ) { get_string(pop_menu.mn_tree, choice, spare); for(i=2; i<(int)strlen(spare); i++) { spare[i]= (char)tolower(spare[i]); } set_text(SETTINGS_BT_SEL_FONT_RENDERER, (char*)&spare[2], LABEL_FONT_RENDERER_MAX_LEN); OBJ_REDRAW(SETTINGS_BT_SEL_FONT_RENDERER); } } tmp = gemtk_obj_get_text(dlgtree, SETTINGS_BT_SEL_FONT_RENDERER); if (strcasecmp(tmp, "freetype") == 0) { ENABLE_OBJ(SETTINGS_CB_ANTI_ALIASING); } else { DISABLE_OBJ(SETTINGS_CB_ANTI_ALIASING); } break; case SETTINGS_BT_SEL_LOCALE: objc_offset(dlgtree, SETTINGS_BT_SEL_LOCALE, &x, &y); // point mn_tree tree to states popup: pop_menu.mn_tree = gemtk_obj_get_tree(POP_LANGUAGE); pop_menu.mn_menu = 0; pop_menu.mn_item = POP_LANGUAGE_CS; pop_menu.mn_scroll = SCROLL_NO; pop_menu.mn_keystate = 0; // find the selected menu item and uncheck others: for(i=pop_menu.mn_item; i<=num_locales; i++) { get_string(pop_menu.mn_tree, i, spare); tmp = gemtk_obj_get_text(dlgtree, SETTINGS_BT_SEL_LOCALE); if (strcasecmp(&spare[2], tmp)) { menu_icheck(pop_menu.mn_tree, i, 0); } else { menu_icheck(pop_menu.mn_tree, i, 1); } set_string(pop_menu.mn_tree, i, spare); } menu_popup(&pop_menu, x, y, &me_data); choice = me_data.mn_item; if( choice > 0 && choice <= num_locales ) { get_string(pop_menu.mn_tree, choice, spare); for(i=2; i<(int)strlen(spare); i++) { spare[i]= (char)tolower(spare[i]); } set_text(SETTINGS_BT_SEL_LOCALE, (char*)&spare[2], 5); } OBJ_REDRAW(SETTINGS_BT_SEL_LOCALE); break; /* case SETTINGS_INPUT_TOOLBAR_BGCOLOR: objc_offset( FORM(win), SETTINGS_INPUT_TOOLBAR_BGCOLOR, &x, &y ); choice = color_popup(x, y, tmp_option_atari_toolbar_bg); snprintf( spare, 255, "%06x", choice ); tmp_option_atari_toolbar_bg = choice; ObjcStrCpy( dlgtree, SETTINGS_INPUT_TOOLBAR_BGCOLOR, spare ); is_button = true; OBJ_REDRAW(SETTINGS_INPUT_TOOLBAR_BGCOLOR); break; */ /* case SETTINGS_BT_TOOLBAR_ICONSET: objc_offset( FORM(win), SETTINGS_BT_TOOLBAR_ICONSET, &x, &y ); tmp = toolbar_iconset_popup(x,y); if( tmp != NULL ){ ObjcStrCpy( dlgtree, SETTINGS_BT_TOOLBAR_ICONSET, tmp ); } is_button = true; break; */ case SETTINGS_INC_MEM_CACHE: case SETTINGS_DEC_MEM_CACHE: if( index == SETTINGS_DEC_MEM_CACHE ) tmp_option_memory_cache_size -= 0.1; else tmp_option_memory_cache_size += 0.1; if( tmp_option_memory_cache_size < 0.5 ) tmp_option_memory_cache_size = 0.5; if( tmp_option_memory_cache_size > 999.9 ) tmp_option_memory_cache_size = 999.9; snprintf( spare, 255, "%03.1f", tmp_option_memory_cache_size ); set_text( SETTINGS_STR_MAX_MEM_CACHE, spare, 5 ); is_button = true; OBJ_REDRAW(SETTINGS_STR_MAX_MEM_CACHE); break; case SETTINGS_INC_CACHED_CONNECTIONS: case SETTINGS_DEC_CACHED_CONNECTIONS: if( index == SETTINGS_INC_CACHED_CONNECTIONS ) tmp_option_max_cached_fetch_handles += 1; else tmp_option_max_cached_fetch_handles -= 1; if( tmp_option_max_cached_fetch_handles > 31 ) tmp_option_max_cached_fetch_handles = 31; snprintf( spare, 255, "%02d", tmp_option_max_cached_fetch_handles ); set_text( SETTINGS_EDIT_MAX_CACHED_CONNECTIONS, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_CACHED_CONNECTIONS); break; case SETTINGS_INC_MAX_FETCHERS: case SETTINGS_DEC_MAX_FETCHERS: if( index == SETTINGS_INC_MAX_FETCHERS ) tmp_option_max_fetchers += 1; else tmp_option_max_fetchers -= 1; if( tmp_option_max_fetchers > 31 ) tmp_option_max_fetchers = 31; snprintf( spare, 255, "%02d", tmp_option_max_fetchers ); set_text( SETTINGS_EDIT_MAX_FETCHERS, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_FETCHERS); break; case SETTINGS_INC_MAX_FETCHERS_PER_HOST: case SETTINGS_DEC_MAX_FETCHERS_PER_HOST: if( index == SETTINGS_INC_MAX_FETCHERS_PER_HOST ) tmp_option_max_fetchers_per_host += 1; else tmp_option_max_fetchers_per_host -= 1; if( tmp_option_max_fetchers_per_host > 31 ) tmp_option_max_fetchers_per_host = 31; snprintf( spare, 255, "%02d", tmp_option_max_fetchers_per_host ); set_text( SETTINGS_EDIT_MAX_FETCHERS_PER_HOST, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_FETCHERS_PER_HOST); break; case SETTINGS_INC_HISTORY_AGE: case SETTINGS_DEC_HISTORY_AGE: if( index == SETTINGS_INC_HISTORY_AGE ) tmp_option_expire_url += 1; else tmp_option_expire_url -= 1; if( tmp_option_expire_url > 99 ) tmp_option_expire_url = 0; snprintf( spare, 255, "%02d", tmp_option_expire_url ); set_text( SETTINGS_EDIT_HISTORY_AGE, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_HISTORY_AGE); break; case SETTINGS_INC_GIF_DELAY: case SETTINGS_DEC_GIF_DELAY: if( index == SETTINGS_INC_GIF_DELAY ) tmp_option_minimum_gif_delay += 0.1; else tmp_option_minimum_gif_delay -= 0.1; if( tmp_option_minimum_gif_delay < 0.1 ) tmp_option_minimum_gif_delay = 0.1; if( tmp_option_minimum_gif_delay > 9.0 ) tmp_option_minimum_gif_delay = 9.0; snprintf( spare, 255, "%01.1f", tmp_option_minimum_gif_delay ); set_text( SETTINGS_EDIT_MIN_GIF_DELAY, spare, 3 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MIN_GIF_DELAY); break; case SETTINGS_INC_MIN_FONT_SIZE: case SETTINGS_DEC_MIN_FONT_SIZE: if( index == SETTINGS_INC_MIN_FONT_SIZE ) tmp_option_font_min_size += 1; else tmp_option_font_min_size -= 1; if( tmp_option_font_min_size > 500 ) tmp_option_font_min_size = 500; if( tmp_option_font_min_size < 10 ) tmp_option_font_min_size = 10; snprintf( spare, 255, "%03d", tmp_option_font_min_size ); set_text( SETTINGS_EDIT_MIN_FONT_SIZE, spare, 3 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MIN_FONT_SIZE); break; case SETTINGS_INC_DEF_FONT_SIZE: case SETTINGS_DEC_DEF_FONT_SIZE: if( index == SETTINGS_INC_DEF_FONT_SIZE ) tmp_option_font_size += 1; else tmp_option_font_size -= 1; if( tmp_option_font_size > 999 ) tmp_option_font_size = 999; if( tmp_option_font_size < 50 ) tmp_option_font_size = 50; snprintf( spare, 255, "%03d", tmp_option_font_size ); set_text( SETTINGS_EDIT_DEF_FONT_SIZE, spare, 3 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_DEF_FONT_SIZE); break; case SETTINGS_INC_INCREMENTAL_REFLOW: case SETTINGS_DEC_INCREMENTAL_REFLOW: if( index == SETTINGS_INC_INCREMENTAL_REFLOW ) tmp_option_min_reflow_period += 1; else tmp_option_min_reflow_period -= 1; if( tmp_option_min_reflow_period > 9999 ) tmp_option_min_reflow_period = 10; snprintf( spare, 255, "%04d", tmp_option_min_reflow_period ); set_text( SETTINGS_EDIT_MIN_REFLOW_PERIOD, spare, 4 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MIN_REFLOW_PERIOD); break; default: break; } if( is_button ) { // remove selection indicator from button element: OBJ_UNCHECK(index); OBJ_REDRAW(index); } }