void revise_nl_model (MODEL *pmod, GtkWidget *parent) { const char *title = NULL; const char *query = NULL; const char *defstr; void (*okfunc)() = NULL; switch (pmod->ci) { case GMM: title = N_("gretl: GMM"); query = N_("GMM: Specify function and orthogonality conditions:"); okfunc = do_gmm_model; break; case MLE: title = N_("gretl: maximum likelihood"); query = N_("MLE: Specify function, and derivatives if possible:"); okfunc = do_mle_model; break; case NLS: title = N_("gretl: nonlinear least squares"); query = N_("NLS: Specify function, and derivatives if possible:"); okfunc = do_nls_model; break; } defstr = gretl_model_get_data(pmod, "nlinfo"); edit_dialog(pmod->ci, _(title), _(query), defstr, okfunc, pmod, VARCLICK_INSERT_TEXT, parent); }
void minibuf_callback (void) { edit_dialog(MINIBUF, _("gretl: command entry"), _("Type a command:"), NULL, do_minibuf, NULL, VARCLICK_NONE, NULL); }
void ChronoDuino::editPreferencesAction() { EditPreferencesDialog edit_dialog(this); if (edit_dialog.exec() == QDialog::Accepted) m_main_window.m_status_bar->showMessage(tr("Preferences saved."), 2000); }
void revise_system_model (void *ptr, GtkWidget *parent) { equation_system *sys = (equation_system *) ptr; edit_dialog(SYSTEM, _("gretl: simultaneous equations system"), _("Specify simultaneous equations:"), NULL, do_eqn_system, sys, VARCLICK_INSERT_TEXT, parent); }
void model_genr_callback (GtkAction *action, gpointer data) { windata_t *vwin = (windata_t *) data; edit_dialog(MODEL_GENR, _("gretl: add var"), _("Enter formula for new variable:"), "", do_model_genr, vwin, VARCLICK_INSERT_NAME, vwin_toplevel(vwin)); }
void MainWindow::onStationClicked() { qDebug() << "Text: " << ((ParamPushButton *) sender())->text(); QSortFilterProxyModel *proxy_model = ((ParamPushButton *) sender())->getModel(); Station *station = ((ParamPushButton *) sender())->station; StationEditDialog edit_dialog(proxy_model, station); edit_dialog.setModal(true); edit_dialog.exec(); }
void MainWindow::onParamClicked() { qDebug() << "Text: " << ((ParamPushButton *) sender())->text(); QModelIndex sender_index = ((ParamPushButton *) sender())->getIndex(); QSortFilterProxyModel *proxy_model = ((ParamPushButton *) sender())->getModel(); QModelIndex index = proxy_model->index(sender_index.row(), VALUE_INDEX); qDebug() << "Old Value: " << proxy_model->data(index).toString(); ParamEditDialog edit_dialog(proxy_model, index); edit_dialog.setModal(true); edit_dialog.exec(); }
void genr_callback (void) { const char *msg; if (dataset->n > 5000) { msg = N_("Enter formula for new variable"); } else { msg = N_("Enter formula for new variable\n" "(or just a name, to enter data manually)"); } edit_dialog(GENR, _("gretl: add var"), _(msg), NULL, do_genr, NULL, VARCLICK_INSERT_NAME, NULL); }
int app_main(char * trackerip, DISPLAYINFO * disp) { UINT16 i, j; char our_file_name[260] = "TEST"; char verstr[50]; int eyelink_ver = 0; int tracker_software_ver = 0; #ifdef WIN32 edit_dialog(NULL,"Create EDF File", "Enter Tracker EDF file name:", our_file_name,260); #endif if(trackerip) set_eyelink_address(trackerip); if(open_eyelink_connection(0)) return -1; /* abort if we can't open link*/ set_offline_mode(); flush_getkey_queue();/* initialize getkey() system */ eyelink_ver = eyelink_get_tracker_version(verstr); if (eyelink_ver == 3) tracker_software_ver = get_tracker_sw_version(verstr); if(init_expt_graphics(NULL, disp)) return exit_eyelink(); /* register window with EXPTSPPT*/ window = SDL_GetVideoSurface(); get_display_information(&dispinfo); /* get window size, characteristics*/ /* NOTE: Camera display does not support 16-color modes NOTE: Picture display examples don't work well with 256-color modes However, all other sample programs should work well. */ if(dispinfo.palsize==16) /* 16-color modes not functional */ { alert_printf("This program cannot use 16-color displays"); return exit_eyelink(); } /* 256-color modes: palettes not supported by this example*/ if(dispinfo.palsize) alert_printf("This program is not optimized for 256-color displays"); i = SCRWIDTH/60; /* select best size for calibration target */ j = SCRWIDTH/300; /* and focal spot in target */ if(j < 2) j = 2; set_target_size(i, j); /* tell DLL the size of target features */ set_calibration_colors(&target_foreground_color, &target_background_color); /* tell EXPTSPPT the colors*/ set_cal_sounds("", "", ""); set_dcorr_sounds("", "off", "off"); clear_full_screen_window(target_background_color); /* clear screen */ get_new_font("Times Roman", SCRHEIGHT/32, 1); /* select a font */ /* Draw text */ graphic_printf(window, target_foreground_color, CENTER, SCRWIDTH/2, 1*SCRHEIGHT/30, "EyeLink Demonstration Experiment: Sample Code"); graphic_printf(window, target_foreground_color, CENTER,SCRWIDTH/2, 2*SCRHEIGHT/30, "Included with the Experiment Programming Kit for Windows"); graphic_printf(window, target_foreground_color, CENTER,SCRWIDTH/2, 3*SCRHEIGHT/30, "All code is Copyright (c) 1997-2002 SR Research Ltd."); graphic_printf(window, target_foreground_color, CENTER,SCRWIDTH/5, 4*SCRHEIGHT/30, "Source code may be used as template for your experiments."); SDL_Flip(window); if(our_file_name[0]) /* If file name set, open it */ { /* add extension */ if(!strstr(our_file_name, ".")) strcat(our_file_name, ".EDF"); i = open_data_file(our_file_name); /* open file */ if(i!=0) /* check for error */ { alert_printf("Cannot create EDF file '%s'", our_file_name); return exit_eyelink(); } /* add title to preamble */ eyecmd_printf("add_file_preamble_text 'RECORDED BY %s' ", program_name); } /* Now configure tracker for display resolution */ /* Set display resolution */ eyecmd_printf("screen_pixel_coords = %ld %ld %ld %ld", dispinfo.left, dispinfo.top, dispinfo.right, dispinfo.bottom); /* Setup calibration type */ eyecmd_printf("calibration_type = HV9"); /* Add resolution to EDF file */ eyemsg_printf("DISPLAY_COORDS %ld %ld %ld %ld", dispinfo.left, dispinfo.top, dispinfo.right, dispinfo.bottom); if(dispinfo.refresh>40) eyemsg_printf("FRAMERATE %1.2f Hz.", dispinfo.refresh); /* SET UP TRACKER CONFIGURATION */ /* set parser saccade thresholds (conservative settings) */ if(eyelink_ver>=2) { eyecmd_printf("select_parser_configuration 0"); // 0 = standard sensitivity if(eyelink_ver == 2) //turn off scenelink camera stuff { eyecmd_printf("scene_camera_gazemap = NO"); } } else { eyecmd_printf("saccade_velocity_threshold = 35"); eyecmd_printf("saccade_acceleration_threshold = 9500"); } // NOTE: set contents before sending messages! // set EDF file contents eyecmd_printf("file_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON"); eyecmd_printf("file_sample_data = LEFT,RIGHT,GAZE,AREA,GAZERES,STATUS%s",(tracker_software_ver>=4)?",HTARGET":""); // set link data (used for gaze cursor) eyecmd_printf("link_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,BUTTON"); eyecmd_printf("link_sample_data = LEFT,RIGHT,GAZE,GAZERES,AREA,STATUS%s",(tracker_software_ver>=4)?",HTARGET":""); /* Program button #5 for use in drift correction */ eyecmd_printf("button_function 5 'accept_target_fixation'"); /* make sure we're still alive */ if(!eyelink_is_connected() || break_pressed()) return end_expt(our_file_name); /* RUN THE EXPERIMENTAL TRIALS (code depends on type of experiment) Calling run_trials() performs a calibration followed by trials This is equivalent to one block of an experiment It will return ABORT_EXPT if the program should exit */ i = run_trials(); return end_expt(our_file_name); }
app_main() { int i, j; char our_file_name[260] = "TEST"; if(open_eyelink_connection(0)) return -1; // abort if we can't open link set_offline_mode(); flush_getkey_queue(); // initialize getkey() system is_eyelink2 = (2 == eyelink_get_tracker_version(NULL) ); get_display_information(&dispinfo); // get window size, characteristics // NOTE: Camera display does not support 16-color modes // NOTE: Picture display examples don't work well with 256-color modes // However, all other sample programs should work well. if(dispinfo.palsize==16) // 16-color modes not functional { alert_printf("This program cannot use 16-color displays"); goto shutdown; } if(dispinfo.refresh < 40) // wait_for_refresh doesn't work! { alert_printf("No refresh synchroniztion available!"); } if(dispinfo.palsize) // 256-color modes: palettes not supported by this example { alert_printf("This program is not optimized for 256-color displays"); } //SEAN -display window if(make_full_screen_window(application_instance)) goto shutdown; // create the window if(init_expt_graphics(full_screen_window, NULL)) goto shutdown; // register window with EXPTSPPT i = SCRWIDTH/60; // select best size for calibration target j = SCRWIDTH/300; // and focal spot in target if(j < 2) j = 2; set_target_size(i, j); // tell DLL the size of target features target_foreground_color = RGB(0,0,0); // color of calibration target target_background_color = RGB(128,128,128); // background for calibration and drift correction set_calibration_colors(target_foreground_color, target_background_color); // tell EXPTSPPT the colors set_cal_sounds("", "", ""); set_dcorr_sounds("", "off", "off"); // draw a title screen // SEAN clear_full_screen_window(target_background_color); // clear screen get_new_font("Times Roman", SCRHEIGHT/32, 1); // select a font // Draw text graphic_printf(target_foreground_color, target_background_color, 1, SCRWIDTH/2, 1*SCRHEIGHT/30, "EyeLink Demonstration Experiment: Sample Code"); graphic_printf(target_foreground_color, target_background_color, 1, SCRWIDTH/2, 2*SCRHEIGHT/30, "Included with the Experiment Programming Kit for Windows"); graphic_printf(target_foreground_color, target_background_color, 1, SCRWIDTH/2, 3*SCRHEIGHT/30, "All code is Copyright (c) 1997-2002 SR Research Ltd."); graphic_printf(target_foreground_color, target_background_color, 0, SCRWIDTH/5, 4*SCRHEIGHT/30, "Source code may be used as template for your experiments."); //SEAN - file i/o i = edit_dialog(full_screen_window, "Create EDF File", // Get the EDF file name "Enter Tracker EDF file name:", our_file_name, 8); if(i==-1) goto shutdown; // ALT-F4: terminate if(i==1) our_file_name[0] = 0; // Cancelled: No file name if(our_file_name[0]) // If file name set, open it { if(!strstr(our_file_name, ".")) strcat(our_file_name, ".EDF"); // add extension i = open_data_file(our_file_name); // open file if(i!=0) // check for error { alert_printf("Cannot create EDF file '%s'", our_file_name); goto shutdown; } // add title to preamble eyecmd_printf("add_file_preamble_text 'RECORDED BY %s' ", program_name); } // Now configure tracker for display resolution eyecmd_printf("screen_pixel_coords = %ld %ld %ld %ld", // Set display resolution dispinfo.left, dispinfo.top, dispinfo.right, dispinfo.bottom); eyecmd_printf("calibration_type = HV9"); // Setup calibration type eyemsg_printf("DISPLAY_COORDS %ld %ld %ld %ld", // Add resolution to EDF file dispinfo.left, dispinfo.top, dispinfo.right, dispinfo.bottom); if(dispinfo.refresh>40) eyemsg_printf("FRAMERATE %1.2f Hz.", dispinfo.refresh); // SET UP TRACKER CONFIGURATION // set parser saccade thresholds (conservative settings) if(is_eyelink2) { eyecmd_printf("select_parser_configuration 0"); // 0 = standard sensitivity } else { eyecmd_printf("saccade_velocity_threshold = 35"); eyecmd_printf("saccade_acceleration_threshold = 9500"); } // set EDF file contents eyecmd_printf("file_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON"); eyecmd_printf("file_sample_data = LEFT,RIGHT,GAZE,AREA,GAZERES,STATUS"); // set link data (used for gaze cursor) eyecmd_printf("link_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,BUTTON"); eyecmd_printf("link_sample_data = LEFT,RIGHT,GAZE,GAZERES,AREA,STATUS"); // Program button #5 for use in drift correction eyecmd_printf("button_function 5 'accept_target_fixation'"); if(!eyelink_is_connected() || break_pressed()) goto end_expt; // make sure we're still alive // RUN THE EXPERIMENTAL TRIALS (code depends on type of experiment) // Calling run_trials() performs a calibration followed by trials // This is equivalent to one block of an experiment // It will return ABORT_EXPT if the program should exit i = run_trials(); end_expt: // END: close, transfer EDF file set_offline_mode(); // set offline mode so we can transfer file pump_delay(500); // delay so tracker is ready eyecmd_printf("close_data_file"); // close data file if(break_pressed()) goto shutdown; // don't get file if we aborted experiment if(our_file_name[0]) // make sure we created a file receive_data_file(our_file_name, "", 0); // transfer the file, ask for a local name shutdown: // CLEANUP close_expt_graphics(); // tell EXPTSPPT to release window close_eyelink_connection(); // disconnect from tracker close_full_screen_window(); return 0; }
void gretl_callback (GtkAction *action, gpointer data) { windata_t *vwin = (windata_t *) data; GtkWidget *parent = NULL; const char *title = NULL; const char *query = NULL; const char *defstr = NULL; gchar *dynquery = NULL; void (*okfunc)() = NULL; Varclick click = VARCLICK_NONE; int ci; ci = gretl_callback_code(gtk_action_get_name(action)); switch (ci) { case GENR: title = N_("gretl: add var"); if (dataset->n > 5000) { query = N_("Enter formula for new variable"); } else { query = N_("Enter formula for new variable\n" "(or just a name, to enter data manually)"); } okfunc = do_genr; click = VARCLICK_INSERT_NAME; break; case VSETMISS: title = N_("gretl: missing code"); dynquery = g_strdup_printf(_("Enter value to be read as \"missing\"\n" "for the variable \"%s\""), dataset->varname[mdata->active_var]); okfunc = do_variable_setmiss; break; case GSETMISS: title = N_("gretl: missing code"); query = N_("Enter value to be read as \"missing\":"); okfunc = do_global_setmiss; break; case GR_BOX: title = N_("gretl: boxplots"); query = N_("Specify variables to plot:"); okfunc = do_box_graph; click = VARCLICK_INSERT_NAME; defstr = get_last_boxplots_string(); break; case GMM: title = N_("gretl: GMM"); query = N_("GMM: Specify function and orthogonality conditions:"); okfunc = do_gmm_model; click = VARCLICK_INSERT_TEXT; data = NULL; break; case MLE: title = N_("gretl: maximum likelihood"); query = N_("MLE: Specify function, and derivatives if possible:"); okfunc = do_mle_model; click = VARCLICK_INSERT_TEXT; data = NULL; break; case NLS: title = N_("gretl: nonlinear least squares"); query = N_("NLS: Specify function, and derivatives if possible:"); okfunc = do_nls_model; click = VARCLICK_INSERT_TEXT; data = NULL; break; case SYSTEM: title = N_("gretl: simultaneous equations system"); query = N_("Specify simultaneous equations:"); data = NULL; okfunc = do_eqn_system; click = VARCLICK_INSERT_TEXT; break; case RESTRICT: title = N_("gretl: linear restrictions"); query = N_("Specify restrictions:"); okfunc = do_restrict; parent = vwin_toplevel(vwin); break; case MINIBUF: title = N_("gretl: command entry"); query = N_("Type a command:"); okfunc = do_minibuf; break; default: fprintf(stderr, "gretl_callback: unrecognized action '%s'\n", gtk_action_get_name(action)); return; } if (dynquery != NULL) { edit_dialog(ci, _(title), dynquery, defstr, okfunc, data, click, parent); g_free(dynquery); } else { edit_dialog(ci, _(title), _(query), defstr, okfunc, data, click, parent); } }
static gboolean press_callback(GtkWidget* widget,GdkEventButton* event,gpointer data) { double mx=event->x; double my=event->y; double width=gtk_widget_get_allocated_width(widget); double height=gtk_widget_get_allocated_height(widget); double spacing=MIN((width-2*gutter)/grid.width,(height-2*gutter)/grid.height); mx-=width/2.0; my-=height/2.0; mx=mx/spacing; my=my/spacing; mx+=grid.width/2.0; my+=grid.height/2.0; int ia,ib; double da,db; int i; ia=0;ib=0; da=db=grid.width+grid.height; for(i=0;i<grid.map.vcount;i++){ double x=grid.map.vertices[i].id%(grid.width+1); double y=(int)(grid.map.vertices[i].id/(grid.width+1)); double d=sqrt((x-mx)*(x-mx)+(y-my)*(y-my)); if(d<da){ db=da; ib=ia; da=d; ia=i; }else if(d<db){ db=d; ib=i; } } int A=MIN(grid.map.vertices[ia].id,grid.map.vertices[ib].id); int B=MAX(grid.map.vertices[ia].id,grid.map.vertices[ib].id); if(draw_state==PLACE_WIRE){ Component c; c.type=WIRE; c.A=A; c.B=B; add_component(c); } if(draw_state==PLACE_RESISTOR){ Component c; c.type=RESISTOR; c.A=A; c.B=B; c.data=calloc(1,sizeof(double)); *(double*)c.data=10; add_component(c); } if(draw_state==PLACE_BATTERY){ Component c; c.type=BATTERY; c.A=A; c.B=B; c.data=calloc(1,sizeof(double)); *(double*)c.data=5; add_component(c); }if(draw_state==DELETE){ for(i=0;i<grid.map.ccount;i++){ if((grid.map.components[i].A==A)&&(grid.map.components[i].B==B)){ remove_component(i); break; } } }if(draw_state==EDIT){ for(i=0;i<grid.map.ccount;i++){ if((grid.map.components[i].A==A)&&(grid.map.components[i].B==B)){ edit_dialog(grid.map.components+i); break; } } } calculate(); //gtk_widget_queue_draw_area(widget,0,0,width,height); gtk_widget_queue_draw(widget); return TRUE; }
int FeOverlay::tags_dialog() { std::vector< std::pair<std::string, bool> > tags_list; m_feSettings.get_current_tags_list( tags_list ); sf::Vector2i size; sf::Vector2f text_scale; int char_size; get_common( size, text_scale, char_size ); if ( tags_list.size() > 8 ) char_size /= 2; std::vector<std::string> list; for ( std::vector< std::pair<std::string, bool> >::iterator itr=tags_list.begin(); itr!=tags_list.end(); ++itr ) { std::string msg; m_feSettings.get_resource( (*itr).second ? "Remove tag: '$1'" : "Add tag: '$1'", (*itr).first, msg ); list.push_back( msg ); } list.push_back( std::string() ); m_feSettings.get_resource( "Create new tag", list.back() ); std::vector<sf::Drawable *> draw_list; 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( m_fePresent.get_font(), m_selColour, sf::Color::Transparent, char_size ); heading.setSize( size.x, size.y / 8 ); heading.setOutlineColor( m_textColour ); heading.setOutlineThickness( -2 ); heading.setTextScale( text_scale ); std::string temp; m_feSettings.get_resource( "Tags", temp ); heading.setString( temp ); draw_list.push_back( &heading ); FeListBox dialog( m_fePresent.get_font(), m_textColour, sf::Color::Transparent, m_selColour, m_selBgColour, char_size, size.y / ( char_size * 1.5 * text_scale.y ) ); dialog.setPosition( 2, size.y / 8 ); dialog.setSize( size.x - 4, size.y * 7 / 8 ); dialog.init(); dialog.setTextScale( text_scale ); draw_list.push_back( &dialog ); int current_i = list.size(); int sel = current_i - 1; dialog.setText( sel, list ); FeEventLoopCtx c( draw_list, sel, current_i, list.size() - 1 ); while ( event_loop( c ) == false ) dialog.setText( sel, list ); if ( sel == (int)tags_list.size() ) { std::string name; edit_dialog( "Enter new tag name", name ); if ( !name.empty() ) { if ( m_feSettings.set_current_tag( name, true ) ) m_fePresent.update_to_new_list( &m_wnd ); // changing tag status altered our current list } } else if (( sel >=0 ) && ( sel < (int)tags_list.size() )) { if ( m_feSettings.set_current_tag( tags_list[sel].first, !(tags_list[sel].second) ) ) m_fePresent.update_to_new_list( &m_wnd ); // changing tag status altered our current list } return sel; }