AboutDialog::AboutDialog(FXMainWindow *owner) : FXDialogBox(owner, FXStringFormat(_("About %s"), PACKAGE), DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE, 0,0,0,0, 0,0,0,0, 0,0) { m_contents = new FXVerticalFrame(this, LAYOUT_FILL_X|LAYOUT_FILL_Y); FXFontDesc fontdescription; getApp()->getNormalFont()->getFontDesc(fontdescription); fontdescription.size += 10; fontdescription.weight = FXFont::Bold; m_boldfont = new FXFont(getApp(),fontdescription); m_boldfont->create(); getApp()->getNormalFont()->getFontDesc(fontdescription); fontdescription.size -= 10; m_smallfont = new FXFont(getApp(),fontdescription); m_smallfont->create(); new FXLabel(m_contents, "", ICO_BIG, ICON_BELOW_TEXT|LAYOUT_CENTER_X|LAYOUT_FILL_Y); FXLabel *label = new FXLabel(m_contents, (FXString)"\n"+PACKAGE+" "+VERSION, 0, LAYOUT_CENTER_X|LAYOUT_FILL_Y); label->setFont(m_boldfont); new FXLabel(m_contents, (FXString)"\n"+_("Copyright (C) 2008~ David Vachulka ([email protected])\nand others")+"\n", 0, JUSTIFY_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y); label = new FXLabel(m_contents, FXStringFormat(_("Built with the FOX Toolkit Library version %d.%d.%d (http://www.fox-toolkit.org)"),FOX_MAJOR,FOX_MINOR,FOX_LEVEL), 0, JUSTIFY_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y); label->setFont(m_smallfont); #ifdef HAVE_OPENSSL label = new FXLabel(m_contents, FXStringFormat(_("Built with %s"), OPENSSL_VERSION_TEXT), 0, JUSTIFY_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y); label->setFont(m_smallfont); #endif #ifdef HAVE_LUA label = new FXLabel(m_contents, FXStringFormat(_("Built with %s"), LUA_RELEASE), 0, JUSTIFY_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y); label->setFont(m_smallfont); #endif label = new FXLabel(m_contents, _("Uses http://www.famfamfam.com/lab/icons/"), 0, JUSTIFY_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y); label->setFont(m_smallfont); m_buttonframe = new FXHorizontalFrame(m_contents, LAYOUT_FILL_X); m_buttonClose = new dxEXButton(m_contents, _("C&lose"), 0, this, FXDialogBox::ID_ACCEPT, BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X, 0,0,0,0, 10,10,2,2); }
void fit_panel::config_spectral_range() { double wls, wle, wld; m_fit->get_sampling(wls, wle, wld); if(wld == 0.0) { m_wl_entry->setText(FXStringFormat("%.3g-%.3g", wls, wle)); } else { m_wl_entry->setText(FXStringFormat("%.3g-%.3g,%g", wls, wle, wld)); } range_dirty = false; }
long fit_window::on_cmd_run_fit(FXObject*, FXSelector, void* ptr) { reg_check_point(this); struct fit_parameters* fps = fit_parameters_new(); for (unsigned j = 0; j < m_parameters.size(); j++) { if (m_parameters[j].selected) { fit_parameters_add (fps, &m_parameters[j].fp); } } if (fps->number > 0) { m_fit->run(fps); for (unsigned k = 0; k < m_parameters.size(); k++) { param_info& p = m_parameters[k]; FXString s = FXStringFormat("%g", m_fit->get_parameter_value(k)); p.text_field->setText(s); p.is_dirty = true; } m_canvas->update_limits(); } fit_parameters_free(fps); return 1; }
FXbool CDDBInfo::getLocalInfo(disc_data* info) { FXString localpath=FXStringFormat("%s%c%s",FXSystem::getHomeDirectory().text(),PATHSEP,".cddb"); if(cddb_read_local(localpath.text(),discid,info)<0) { return FALSE; } return TRUE; }
void fx_disp_table_window::setup_dialog() { int rows = m_iterator->rows(); m_table = new FXTable(this, NULL, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|TABLE_READONLY); m_table->setTableSize(rows, 3); m_table->setRowHeaderWidth(0); m_table->setColumnText(0, "Wavelength (nm)"); m_table->setColumnText(1, "n"); m_table->setColumnText(2, "k"); for (int i = 0; i < rows; i++) { float n, k; float wl = m_iterator->get_nk_row(i, &n, &k); m_table->setItemText(i, 0, FXStringFormat("%g", wl)); m_table->setItemText(i, 1, FXStringFormat("%g", n)); m_table->setItemText(i, 2, FXStringFormat("%g", k)); } }
long fit_panel::on_update_param(FXObject *_txt, FXSelector, void*) { FXTextField *txt = (FXTextField *) _txt; param_info* p = (param_info*) txt->getUserData(); if(p->is_dirty) { unsigned k = this->get_parameter_index(p); FXString s = FXStringFormat("%g", m_fit->get_parameter_value(k)); txt->setText(s, false); p->is_dirty = false; return 1; } return 0; }
// Set bunch of patterns void FileSelector::setPatternList(const FXchar **ptrns) { filefilter->clearItems(); if(ptrns) { while(ptrns[0] && ptrns[1]) { filefilter->appendItem(FXStringFormat("%s (%s)",ptrns[0],ptrns[1])); ptrns+=2; } } if(!filefilter->getNumItems()) filefilter->appendItem(allfiles); setCurrentPattern(0); }
static FXString denormalize (int norm, int pow_exp, int& dot_pos) { int nsign = (norm < 0 ? -1 : 1); int p = ipow10 (pow_exp); if (norm < 0) norm = -norm; int int_part = norm / p, frac_part = norm % p; char buf[64]; sprintf (buf, "%s%d", nsign < 0 ? "-" : "", int_part); dot_pos = strlen (buf); if (pow_exp == 0) return FXString(buf); return FXStringFormat("%s.%.*d", buf, pow_exp, frac_part); }
void ProgressDialog::setProgress(FXuint a_value) // This function assumes the range of a_value is [0, 100] { #if 1 static time_t t0; if (!m_startTimeSet) t0 = time(NULL); int nSecondsPassed = time(NULL) - t0; #else #ifndef __unix__ static struct timeb t0, t1; if (!m_startTimeSet) ftime(&t0); ftime(&t1); int nSecondsPassed = ((t1.time * 1000 + t1.millitm) - (t0.time * 1000 + t0.millitm) + 500) / 1000; #else static struct timeval t0, t1; if (!m_startTimeSet) gettimeofday(&t0, NULL); gettimeofday(&t1, NULL); int nSecondsPassed = ((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec) + 500000) / 1000000; #endif #endif m_startTimeSet = true; m_progressBar->setProgress(a_value); if (nSecondsPassed == 0) return; if (a_value == 0) return; unsigned int todo = 100 - a_value; unsigned int nSecondsLeft = (unsigned int) (todo / ((float) a_value / nSecondsPassed) + 0.5f); if (nSecondsLeft > 99 * 60 + 59) // just in case :-) nSecondsLeft = 99 * 60 + 59; FXString timeString = FXStringFormat("ETA=%02d:%02d", nSecondsLeft / 60, nSecondsLeft % 60); m_timeInfo->setText(timeString); }
fit_window::fit_window(fit_manager* fit, FXApp* a,const FXString& name,FXIcon *ic,FXIcon *mi,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb,FXint hs,FXint vs) : FXMainWindow(a, "Dispersion Fit", ic, mi, opts, x, y, w, h, pl, pr, pt, pb, hs, vs), m_canvas(0), m_fit(fit) { // Menubar menubar = new FXMenuBar(this, LAYOUT_SIDE_TOP|LAYOUT_FILL_X); statusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|FRAME_RAISED|STATUSBAR_WITH_DRAGCORNER); // fit menu fitmenu = new FXMenuPane(this); new FXMenuCommand(fitmenu, "&Run", NULL, this, ID_RUN_FIT); new FXMenuTitle(menubar, "&Fit", NULL, fitmenu); // plot menu plotmenu = new FXMenuPane(this); new FXMenuCommand(plotmenu, "&Auto Scale", NULL, this, ID_PLOT_SCALE); new FXMenuTitle(menubar, "&Plot", NULL, plotmenu); FXHorizontalFrame *mf = new FXHorizontalFrame(this, LAYOUT_FILL_X|LAYOUT_FILL_Y); FXScrollWindow *iw = new FXScrollWindow(mf, VSCROLLER_ALWAYS | HSCROLLING_OFF | LAYOUT_FILL_Y); FXMatrix *matrix = new FXMatrix(iw, 2, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_Y|MATRIX_BY_COLUMNS, 0, 0, 0, 0, DEFAULT_SPACING, DEFAULT_SPACING, DEFAULT_SPACING, DEFAULT_SPACING, 1, 1); new FXLabel(matrix, "Range"); m_wl_entry = new FXTextField(matrix, 10, this, ID_SPECTR_RANGE, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_ROW); { double wls, wle, wld; m_fit->get_sampling(wls, wle, wld); if (wld == 0.0) m_wl_entry->setText(FXStringFormat("%.3g-%.3g", wls, wle)); else m_wl_entry->setText(FXStringFormat("%.3g-%.3g,%g", wls, wle, wld)); } m_parameters.resize(m_fit->parameters_number()); m_bold_font = new FXFont(getApp(), "helvetica", 9, FXFont::Bold, FXFont::Italic); Str pname; FXString label_text; int current_layer = 0; for (unsigned k = 0; k < m_parameters.size(); k++) { param_info* p = this->get_parameter_pointer(k); m_fit->get_parameter(k, &p->fp); if (p->fp.id == PID_LAYER_N && p->fp.layer_nb != current_layer) { current_layer = p->fp.layer_nb; label_text.format("Layer %i", current_layer); FXLabel *lab = new FXLabel(matrix, label_text); lab->setFont(m_bold_font); new FXLabel(matrix, ""); } get_param_name(&p->fp, pname.str()); FXString fxpname((const FXchar *) pname.cstr()); FXCheckButton* bt = new FXCheckButton(matrix, fxpname, this, ID_PARAM_SELECT); FXTextField* tf = new fx_numeric_field(matrix, 10, this, ID_PARAM_VALUE, FRAME_SUNKEN|FRAME_THICK|TEXTFIELD_REAL|LAYOUT_FILL_ROW); tf->setUserData(p); bt->setUserData(p); p->text_field = tf; p->selected = false; p->is_dirty = true; } m_canvas = new plot_canvas(mf, NULL, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y); m_fit->config_plot(m_canvas); }
FXbool CDDBInfo::getRemoteInfo(disc_data* info) { cdsock_t sock; char http_string[512]; int http_string_len=sizeof(http_string); FXbool success=FALSE; if(!querystring.empty()) { sock=cddb_connect(&host,pserver,&hello,http_string,&http_string_len); if(sock!=-1) { if(settings.cddbproto==CDDB_PROTOCOL_CDDBP) { // Send handshake if(!cddb_handshake(sock,&hello)||!cddb_proto(sock)) { cddb_quit(sock,CDDB_MODE_CDDBP); return FALSE; } } FXint result=cddb_query(querystring.text(),sock,(settings.cddbproto==CDDB_PROTOCOL_CDDBP)?CDDB_MODE_CDDBP:CDDB_MODE_HTTP,&query,http_string); if(result!=-1&&query.query_match!=QUERY_NOMATCH) { choice=0; if(query.query_matches>1&&settings.promptmultiple&&signal!=NULL) { setStatus(CDINFO_INTERACT); // Signal to main thread that input is requested signal->signal(); // Wait for GUI operation to complete FXMutex mtx; mtx.lock(); condition.wait(mtx); } if(settings.cddbproto==CDDB_PROTOCOL_HTTP) { cddb_quit(sock,CDDB_MODE_HTTP); sock=cddb_connect(&host,pserver,&hello,http_string,&http_string_len); } if(sock!=-1) result=cddb_read(query.query_list[choice].list_category,query.query_list[choice].list_id,sock,(settings.cddbproto==CDDB_PROTOCOL_CDDBP)?CDDB_MODE_CDDBP:CDDB_MODE_HTTP,info,http_string); else result=-1; if(result!=-1) { success = TRUE; if(settings.localcopy) { // Save entry in home directory FXString localpath=FXStringFormat("%s%c%s",FXSystem::getHomeDirectory().text(),PATHSEP,".cddb"); // Create CDDB direcotry if it does not exist if(!FXStat::exists(localpath)) FXDir::create(localpath); //Write to the local database cddb_write_local(localpath.text(),&hello,&discinfo,info,"Generated by fxcd"); } } } cddb_quit(sock,(settings.cddbproto==CDDB_PROTOCOL_CDDBP)?CDDB_MODE_CDDBP:CDDB_MODE_HTTP); } } return success; }