void FeOverlay::edit_dialog( const std::string &msg_str, std::string &text ) { sf::Vector2i size; sf::Vector2f text_scale; int char_size; get_common( size, text_scale, char_size ); FeTextPrimative message( m_fePresent.get_font(), m_textColour, m_bgColour, char_size ); message.setWordWrap( true ); FeTextPrimative tp( m_fePresent.get_font(), m_textColour, m_bgColour, char_size ); float slice = size.y / 3; message.setSize( size.x, slice ); message.setTextScale( text_scale ); message.setString( msg_str ); tp.setPosition( 0, slice ); tp.setSize( size.x, size.y - slice ); tp.setTextScale( text_scale ); std::vector<sf::Drawable *> draw_list; draw_list.push_back( &message ); draw_list.push_back( &tp ); std::basic_string<sf::Uint32> str; sf::Utf8::toUtf32( text.begin(), text.end(), std::back_inserter( str ) ); if ( edit_loop( draw_list, str, &tp ) == true ) { text.clear(); sf::Utf32::toUtf8( str.begin(), str.end(), std::back_inserter( text ) ); } }
int FeOverlay::display_config_dialog( FeBaseConfigMenu *m, bool &parent_setting_changed ) { FeConfigContextImp ctx( m_feSettings, *this ); ctx.update_to_menu( m ); // // Set up display objects // sf::Vector2i size; sf::Vector2f text_scale; int char_size; get_common( size, text_scale, char_size ); const sf::Font *font = m_fePresent.get_font(); std::vector<sf::Drawable *> draw_list; float slice = size.y / 8; sf::RectangleShape bg( sf::Vector2f( size.x, size.y ) ); bg.setFillColor( m_bgColour ); bg.setOutlineColor( m_textColour ); bg.setOutlineThickness( -2 ); draw_list.push_back( &bg ); FeTextPrimative heading( font, m_selColour, sf::Color::Transparent, char_size / 2 ); heading.setSize( size.x, slice ); heading.setOutlineColor( m_textColour ); heading.setOutlineThickness( -2 ); heading.setTextScale( text_scale ); heading.setString( ctx.title ); draw_list.push_back( &heading ); unsigned int width = size.x - 4; if ( ctx.style == FeConfigContext::EditList ) width = size.x / 2 - 2; int rows = ( size.y - slice * 2 ) / ( char_size * 0.75 * text_scale.y ); // // The "settings" (left) list, also used to list submenu and exit options... // FeListBox sdialog( font, m_textColour, sf::Color::Transparent, m_selColour, sf::Color( 0, 0, 200, 200 ), char_size / 2, rows ); sdialog.setPosition( 2, slice ); sdialog.setSize( width, size.y - slice * 2 ); sdialog.init(); sdialog.setTextScale( text_scale ); draw_list.push_back( &sdialog ); // // The "values" (right) list shows the values corresponding to a setting. // FeListBox vdialog( font, m_textColour, sf::Color::Transparent, m_textColour, sf::Color( 0, 0, 200, 200 ), char_size / 2, rows ); if ( ctx.style == FeConfigContext::EditList ) { // // We only use the values listbox in the "EditList" mode // vdialog.setPosition( width + 2, slice ); vdialog.setSize( width, size.y - slice * 2 ); vdialog.init(); vdialog.setTextScale( text_scale ); draw_list.push_back( &vdialog ); } FeTextPrimative footer( font, m_textColour, sf::Color::Transparent, char_size / 3 ); footer.setPosition( 0, size.y - slice ); footer.setSize( size.x, slice ); footer.setOutlineColor( m_textColour ); footer.setOutlineThickness( -2 ); footer.setWordWrap( true ); footer.setTextScale( text_scale ); draw_list.push_back( &footer ); ctx.curr_sel = sdialog.getRowCount() / 2; if ( ctx.curr_sel >= (int)ctx.left_list.size() ) ctx.curr_sel = ctx.left_list.size() - 1; sdialog.setText( ctx.curr_sel, ctx.left_list ); vdialog.setText( ctx.curr_sel, ctx.right_list ); if ( !ctx.help_msg.empty() ) { footer.setString( ctx.help_msg ); ctx.help_msg = ""; } else { footer.setString( ctx.curr_opt().help_msg ); } // // Event loop processing // while ( true ) { FeEventLoopCtx c( draw_list, ctx.curr_sel, ctx.exit_sel, ctx.left_list.size() - 1 ); while ( event_loop( c ) == false ) { footer.setString( ctx.curr_opt().help_msg ); sdialog.setText( ctx.curr_sel, ctx.left_list ); vdialog.setText( ctx.curr_sel, ctx.right_list ); } // // User selected something, process it // if ( ctx.curr_sel < 0 ) // exit { if ( ctx.save_req ) { if ( m->save( ctx ) ) parent_setting_changed = true; } return ctx.curr_sel; } FeBaseConfigMenu *sm( NULL ); if ( m->on_option_select( ctx, sm ) == false ) continue; if ( !ctx.help_msg.empty() ) { footer.setString( ctx.help_msg ); ctx.help_msg = ""; } int t = ctx.curr_opt().type; if ( t > Opt::INFO ) { if ( ctx.save_req ) { if ( m->save( ctx ) ) parent_setting_changed = true; ctx.save_req=false; } switch (t) { case Opt::RELOAD: return display_config_dialog( m, parent_setting_changed ); case Opt::MENU: if ( sm ) return display_config_dialog( sm, parent_setting_changed ); break; case Opt::SUBMENU: if ( sm ) { bool test( false ); int sm_ret = display_config_dialog( sm, test ); if ( sm_ret < 0 ) return sm_ret; if ( test ) ctx.save_req = true; // // The submenu may have changed stuff in this menu, need // to update our variables as a result // ctx.update_to_menu( m ); sdialog.setText( ctx.curr_sel, ctx.left_list ); vdialog.setText( ctx.curr_sel, ctx.right_list ); } break; case Opt::EXIT: case Opt::DEFAULTEXIT: default: return ctx.curr_sel; } } else if ( t != Opt::INFO ) // Opt::EDIT and Opt::LIST { // // User has selected to edit a specific entry. // Update the UI and enter the appropriate // event loop // sdialog.setSelColor( m_textColour ); FeTextPrimative *tp = vdialog.setEditMode( true, m_selColour ); if ( tp == NULL ) continue; if ( t == Opt::LIST ) { int original_value = ctx.curr_opt().get_vindex(); int new_value = original_value; FeEventLoopCtx c( draw_list, new_value, -1, ctx.curr_opt().values_list.size() - 1 ); while ( event_loop( c ) == false ) { tp->setString(ctx.curr_opt().values_list[new_value]); } if (( new_value >= 0 ) && ( new_value != original_value )) { ctx.save_req = true; ctx.curr_opt().set_value( new_value ); ctx.right_list[ctx.curr_sel] = ctx.curr_opt().get_value(); } } else { const std::string &e_str( ctx.curr_opt().get_value() ); std::basic_string<sf::Uint32> str; sf::Utf8::toUtf32( e_str.begin(), e_str.end(), std::back_inserter( str ) ); if ( edit_loop( draw_list, str, tp ) == true ) { ctx.save_req = true; std::string d_str; sf::Utf32::toUtf8( str.begin(), str.end(), std::back_inserter( d_str ) ); ctx.curr_opt().set_value( d_str ); ctx.right_list[ctx.curr_sel] = d_str; } } tp->setString( ctx.right_list[ctx.curr_sel] ); sdialog.setSelColor( m_selColour ); vdialog.setEditMode( false, m_textColour ); } } return ctx.curr_sel; }
void _cdecl main (SHORT argc, char *argv[]) { // bool ok = FALSE; // char test[5]; // test for trap 05 errors ULONG ulTimes; // need for Trap Ctrl-Break Signal #ifdef TESTING if(!dout) { DosBeep(500,300); } if(!memout) { DosBeep(1000,300); } #endif #ifdef ERR_HAND rc = set_int24(); if(rc != 0) { err_exit("Error initializing error handler", 3); } MYEXCEPTIONREGISTRATIONRECORD myExceptionRegRecord; myExceptionRegRecord.prev_structure = NULL; myExceptionRegRecord.ExceptionHandler = MyExceptionHandler; DosSetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD) &myExceptionRegRecord); DosSetSignalExceptionFocus(SIG_SETFOCUS, &ulTimes); if(setjmp(myExceptionRegRecord.env)) goto OnException; #endif DBG_INI(dout<<"file "<<__FILE__<<" line "<<__LINE__<<" settings.numlock_on = "<<settings.numlock_on<<endl); filesys_init(); get_current_directory(cwd); // init cur dir Mem::vmem_setup(); strcpy(exe_dir, *argv); // assume loaded via X:\subdir\KED.EXE DBG_FILE(dout << "EXE_DIR = " << exe_dir <<endl); DBG_MEM(memout<< " main after except setup "<< checkmem2 << endl); assure_windows_ready(); if(!thread_init()) { err_exit("Error creating initial threads", 5); } process_env_string ("EDITOR"); /* do parameters from environment string */ strcpy (progname,*argv); argc--; /* don't count program name */ argv++; while (argc--) { /* process each parameter */ process_arg (*argv); argv++; } if (!*settings.help_path) { /* help is usually in same dir as program */ delta_filename (settings.help_path, progname, "*.HLP"); } //#ifdef TESTING //if(!debug_on) { // dout.close(); // memout.close(); //} //#endif assure_1_view(); DBG_INI(dout<<"edit.cpp line "<<__LINE__<<" shell_command.s = °"<<settings.shell_command.s<<"°"<<endl); DBG_INI(dout<<"file "<<__FILE__<<" line "<<__LINE__<<" settings.numlock_on = "<<settings.numlock_on<<endl); // ok = load_keys(); // Version 2.08 // if(!ok) // err_exit("Failed to load Keyboard driver", 10); edit_loop(); // test[5000] = 'A'; // test trap array bounds goto Ked_Exit; OnException: #ifdef ERR_HAND DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD) &myExceptionRegRecord); // Screen.term_mess = "application trapped"; err_exit(" application trapped", 20); #endif Ked_Exit: #ifdef ERR_HAND if(ORG_NUMLOCK) { DBG_NUML(dout<<" exit - setting NUMLOCK on"<<endl); numlock_set(TRUE); } else { DBG_NUML(dout<<" exit - setting NUMLOCK off"<<endl); numlock_set(FALSE); } DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD) &myExceptionRegRecord); #endif DBG_MEM(memout<< " main after except setup "<< checkmem2 << endl); DBG_BUGS(dout<<'\n'<<" Normal Closedown in LOGFILE "<<endl); }