本文整理汇总了C++中FXString::format方法的典型用法代码示例。如果您正苦于以下问题:C++ FXString::format方法的具体用法?C++ FXString::format怎么用?C++ FXString::format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FXString
的用法示例。
在下文中一共展示了FXString::format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveBackup
bool BackupMgr::SaveBackup(SciDoc*sci)
{
FXString savename;
FXString untitled;
untitled.format(FN_FMT, backupdir.text(), abs(getpid()), SciDocUtils::ID(sci));
if (SciDocUtils::Filename(sci).empty()) {
savename=untitled;
} else {
if (FXStat::isFile(untitled)) {
RemoveBackup(untitled);
}
#ifdef WIN32
savename=SciDocUtils::Filename(sci).text();
savename.substitute(':', '%', true);
savename.prepend(backupdir.text());
#else
savename.format("%s%s", backupdir.text(), SciDocUtils::Filename(sci).text());
#endif
}
if (MakePath(FXPath::directory(savename))) {
if (SciDocUtils::SaveToFile(sci,savename.text(),false)) {
SciDocUtils::NeedBackup(sci, false);
return true;
} else {
lasterror=SciDocUtils::GetLastError(sci);
ErrorMessage(_("Failed to save backup"), savename);
return false;
}
} else {
return false;
}
}
示例2: setup_config_parameters
void recipe_window::setup_config_parameters()
{
spectral_range *range = &recipe->config->spectr_range;
FXString text;
if (range->active) {
FXString text;
text.format("%g-%g", range->min, range->max);
range_textfield->setText(text);
} else {
range_textfield->setText("");
}
if (recipe->config->threshold_given) {
text.format("%g", recipe->config->chisq_threshold);
chisq_textfield->setText(text);
} else {
chisq_textfield->setText("");
}
text.format("%d", recipe->config->nb_max_iters);
iter_textfield->setText(text);
if (recipe->config->subsampling != 1) {
text.format("%d", recipe->config->subsampling);
subsamp_textfield->setText(text);
} else {
subsamp_textfield->setText("");
}
}
示例3: update_textfield
static void update_textfield(fx_numeric_field *tf, fx_disp_window *disp_win, int param_id)
{
FXString vstr;
double *pvalue = disp_win->map_parameter(param_id);
vstr.format("%g", *pvalue);
tf->setText(vstr);
}
示例4:
void
PlaybackWindow::setPlaybackPacketsProcessed(unsigned int packets)
{
FXString s;
s.format("Processed %u of %u", packets_processed, total_packets);
processedLabel->setText(s);
}
示例5: RemoveBackup
void BackupMgr::RemoveBackup(SciDoc*sci)
{
FXString untitled;
SciDocUtils::NeedBackup(sci,false);
untitled.format(FN_FMT, backupdir.text(), abs(getpid()), SciDocUtils::ID(sci));
RemoveBackup(untitled);
if (!SciDocUtils::Filename(sci).empty()) {
FXString savename;
#ifdef WIN32
savename=SciDocUtils::Filename(sci).text();
savename.substitute(':', '%', true);
savename.prepend(backupdir.text());
#else
savename.format("%s%s", backupdir.text(), SciDocUtils::Filename(sci).text());
#endif
RemoveBackup(savename);
}
}
示例6: UpdateListItem
void ShortcutList::UpdateListItem(MenuSpec*spec)
{
FXint n=acclist->findItemByData(spec);
if (n>=0) {
FXString txt;
txt.format("%s\t%s", spec->pref, spec->accel);
acclist->setItemText(n, txt);
handle(acclist,FXSEL(SEL_CHANGED,ID_SEL_KEYBIND),(void*)(FXival)n);
}
}
示例7: onUpdWindowSelect
// Update handler for window menus
long FXMDIClient::onUpdWindowSelect(FXObject *sender,FXSelector sel,void*){
FXint which=FXSELID(sel)-ID_MDI_1;
FXMDIChild *child=(FXMDIChild*)childAtIndex(which);
if(child){
FXString string;
if(which<9)
string.format("&%d %s",which+1,child->getTitle().text());
else
string.format("1&0 %s",child->getTitle().text());
sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETSTRINGVALUE),(void*)&string);
sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SHOW),NULL);
if(child==active)
sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_CHECK),NULL);
else
sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_UNCHECK),NULL);
}
else{
sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_HIDE),NULL);
}
return 1;
}
示例8: add_matrix_component
void fx_disp_lookup_window::add_matrix_component(int index, bool create)
{
FXString istr;
istr.format("%d", index + 1);
FXButton *db = new FXButton(matrix, istr, NULL, this, ID_MENU_COMPONENT + index, FRAME_SUNKEN);
FXTextField *tf1 = new FXTextField(matrix, 24, this, ID_COMPONENT_NAME + index, FRAME_SUNKEN);
tf1->setText(CSTR(disp->disp.lookup.component[index].disp->name));
FXTextField *tf2 = create_textfield(matrix, this, ID_PARAM_0 + 1 + index);
if (create) {
db->create();
tf1->create();
tf2->create();
}
}
示例9: set_numeric_textfield
void set_numeric_textfield(FXTextField *tf, double value)
{
FXString text;
text.format("%g", value);
tf->setText(text);
}
示例10: FXDialogBox
long
PlaybackWindow::onStart(FXObject *, FXSelector sel, void*)
{
// If we're PAUSED, then just set the state back to playing.
// There's no need to re-open the socket or anything.
if (state == PAUSED) {
state = PLAYING;
startButton->disable();
stopButton->enable();
pauseButton->enable();
//rewindButton->disable();
// Fake the playback_start_time, so that the time-based
// asynchronous playback will pick up where it left off.
playback_start_time += get_time() - pause_time;
return 1;
}
/* Starting the capture from the beginning. */
progress->setProgress(0);
pcap_if_t *devs = NULL;
char errbuf[PCAP_ERRBUF_SIZE];
// Open the capture file.
pcap_file = pcap_open_offline(filename.text(), errbuf);
if (!pcap_file) {
FXMessageBox::information( this, MBOX_OK, "File Open Error", "Can't open original file %s for reading.\n", filename.text() );
// Set the GUI and app state to
// the STOPPED state.
state = STOPPED;
progress->setProgress(0);
startButton->enable();
stopButton->disable();
pauseButton->disable();
return 1;
}
// Prompt for the interface if one isn't set, or if called from the Play button click.
if (FXSELID(sel) == ID_START_BUTTON || pcap_if.length() == 0) {
// Popup window with list of interfaces in it.
pcap_findalldevs(&devs, errbuf);
if (devs) {
// Show the interface Window.
FXDialogBox *dlg = new FXDialogBox(this, "Select a device", DECOR_CLOSE|DECOR_TITLE|DECOR_BORDER);
InterfaceWindow *ifwin = new InterfaceWindow(dlg, devs, "Select Playback Device", "Playback");
FXuint res = dlg->execute();
if (res) {
// User selected an interface. Start capturing.
pcap_if = ifwin->getSelectedInterface()->name;
cout << "User selected " << pcap_if << endl;
}
else {
// User pushed cancel from the interface window.
pcap_if = "";
}
delete dlg;
}
else {
// report error.
cout << "Error finding devices " << errbuf << endl;
#ifdef WIN32
const char *privs = "Administrator";
#else
const char *privs = "root user";
#endif
FXString s;
s.format("There was an error trying to open the network device.\nThis most likely means that you do not have permission to open raw sockets.\nEnsure that you have %s privileges and try again.\n\nError: %s", privs, errbuf);
FXMessageBox::error(this, MBOX_OK, "Capture Error", "%s", s.text());
}
pcap_freealldevs(devs);
}
// Begin playback if an interface was selected.
if (pcap_if.length() > 0) {
live_capture = pcap_open_live(pcap_if.c_str(), 9999, 1/*promisc*/, 5/*read_timeout*/, errbuf);
if (live_capture) {
int res = pcap_setnonblock(live_capture, 1, errbuf);
if (res >= 0) {
}
else
cout << "Error setting nonblock: " << errbuf << endl;
#ifndef WIN32
send_handle = pcap_get_selectable_fd(live_capture);
#else
send_handle = 0;
#endif
if (send_handle >= 0) {
// Set the GUI and app state to
// the PLAYING state.
state = PLAYING;
//.........这里部分代码省略.........
示例11: translate
void MacroRecorder::translate(TranslateFunc callback, void* user_data)
{
for (FXint i=list.no()-1; i>=0; i--) {
FXString text;
MacroMessage* mm=list[i];
switch (mm->message) {
case SCI_CUT: {
text=_LUAMOD_".cut()";
break;
}
case SCI_COPY: {
text=_LUAMOD_".copy()";
break;
}
case SCI_CLEARALL: {
text=_LUAMOD_".text(\"\")";
break;
}
case SCI_SELECTALL: {
text=_LUAMOD_".select(0,"_LUAMOD_".nchars())";
break;
}
case SCI_HOME:
case SCI_VCHOME:{
text=_LUAMOD_".go(\"edge\", -1)";
break;
}
case SCI_HOMEEXTEND:
case SCI_VCHOMEEXTEND:{
text=_LUAMOD_".go(\"edge\", -1, true)";
break;
}
case SCI_LINEEND: {
text=_LUAMOD_".go(\"edge\", 1)";
break;
}
case SCI_LINEENDEXTEND: {
text=_LUAMOD_".go(\"edge\", 1, true)";
break;
}
case SCI_DOCUMENTSTART: {
text=_LUAMOD_".go(\"body\", -1)";
break;
}
case SCI_DOCUMENTSTARTEXTEND: {
text=_LUAMOD_".go(\"body\", -1, true)";
break;
}
case SCI_DOCUMENTEND: {
text=_LUAMOD_".go(\"body\", 1)";
break;
}
case SCI_DOCUMENTENDEXTEND: {
text=_LUAMOD_".go(\"body\", 1, true)";
break;
}
case SCI_HOMERECTEXTEND:
case SCI_VCHOMERECTEXTEND: {
text=_LUAMOD_".go(\"edge\", -1, true, true)";
break;
}
case SCI_LINEENDRECTEXTEND: {
text=_LUAMOD_".go(\"edge\", 1, true, true)";
break;
}
case SCI_GOTOLINE: {
text.format(_LUAMOD_".caret(%ld,%ld)", mm->wParam+1, mm->lParam);
break;
}
case SCI_GOTOPOS: {
if ((i>1)&&(list[i-1]->message==SCI_SEARCHNEXT)&&(list[i-2]->message==SCI_REPLACETARGET)&&(list[i-2]->wParam==2)) {
// If message was generated inside SciSearch::ReplaceAllInDoc() just ignore it.
} else {
text.format(_LUAMOD_".caret(%ld)", mm->wParam);
}
break;
}
case SCI_REPLACESEL: {
FXString s=(char*)mm->lParam;
FXint n=s.contains('\n');
if ( (n>0) && (s.length()>1) ) { // If multiple lines, split into lines for playback...
int p;
for (p=0; p<n; p++) {
FXString part=s.section('\n', p);
requote(part);
text.format(_LUAMOD_".insert(\"%s\\n\",true)", part.text());
callback(text.text(), user_data);
}
if (!s.section('\n', n).empty()) { // there may still be text beyond the last LF...
FXString part=s.section('\n', n);
requote(part);
text.format(_LUAMOD_".insert(\"%s\",true)", part.text());
callback(text.text(), user_data);
}
//.........这里部分代码省略.........
示例12: listFontSizes
// Fill the list with font sizes
void FontSelector::listFontSizes()
{
const FXuint sizeint[] =
{
60, 80, 90, 100, 110, 120, 140, 160, 200, 240, 300, 360, 420, 480, 640
};
FXFontDesc* fonts;
FXuint numfonts, f, s, lasts;
int selindex = -1;
sizelist->clearItems();
size->setText("");
FXString string;
if (FXFont::listFonts(fonts, numfonts, selected.face, selected.weight, selected.slant, selected.setwidth, selected.encoding, selected.flags))
{
FXASSERT(0 < numfonts);
lasts = 0;
if (fonts[0].flags&FXFont::Scalable)
{
for (f = 0; f < ARRAYNUMBER(sizeint); f++)
{
s = sizeint[f];
string.format("%.1f", 0.1*s);
sizelist->appendItem(string, NULL, (void*)(FXuval)s);
if (selected.size == s)
{
selindex = sizelist->getNumItems()-1;
}
lasts = s;
}
}
else
{
for (f = 0; f < numfonts; f++)
{
s = fonts[f].size;
if (s != lasts)
{
string.format("%.1f", 0.1*s);
sizelist->appendItem(string, NULL, (void*)(FXuval)s);
if (selected.size == s)
{
selindex = sizelist->getNumItems()-1;
}
lasts = s;
}
}
}
if (selindex == -1)
{
selindex = 0;
}
if (0 < sizelist->getNumItems())
{
sizelist->setCurrentItem(selindex);
sizelist->makeItemVisible(selindex);
size->setText(sizelist->getItemText(selindex));
selected.size = (FXuint)(FXuval)sizelist->getItemData(selindex);
}
FXFREE(&fonts);
}
}
示例13: onParseAllSources
// When BuildClassTree() is called, ctags parses all source files in the directory list.
// This routine is called by the CmdIO object, once for each line of output from ctags.
long TagParserBase::onParseAllSources(FXObject*o, FXSelector sel, void*p)
{
const FXString* s=(const FXString*)p;
if (FXSELTYPE(sel)==SEL_IO_EXCEPT) { return 1; }
LocationIndex dirindex=(LocationIndex)((FXuval)((CmdIO*)o)->getUserData());
FXString ancestor=FXString::null;
FXString scopename=FXString::null;
FXint linenum=ExtractLineNumber(s);
FXchar kind=s->section('\t', 3)[0];
FXString tagname=s->section('\t',0);
FXString filename=s->section('\t',1);
if (current_filename!=filename) {
current_filename=filename;
dirs[dirindex]->append(filename);
}
const FXchar ext=Ascii::toLower(FXPath::extension(filename)[0]);
if ( (kind=='n') ) {
if (ext=='c') { return 1; } // namespaces are only interesting if they are in a public header
}
for (FXint i=4; i<=s->contains('\t'); i++) {
const FXString sect=s->section('\t', i);
if (sect.find(':')>0) {
const FXString key=sect.section(':',0);
if ((kind=='s')&&(key=="access")) { // ignore structs defined inside a class
return 1;
} else if ((kind=='f')&&((key=="class")||(key=="namespace"))) {
scopename=sect.section(':',1,1024);
StripNamespace(scopename);
} else if (key=="inherits") {
ancestor=sect.section(':',1);
if (ancestor.find(',')>0) {
ancestor=ancestor.section(',',0); // can't do multiple inheritence
}
StripNamespace(ancestor);
}
}
}
switch (kind) {
case 'c':
case 'n':
case 's': {
tag_info_list->append(kind, tagname, ancestor, dirindex, dirs[dirindex]->no()-1, linenum);
break;
}
default: {
FXString* entry = new FXString();
entry->format(
"%c\t%s%s%s\t%d",
kind,
scopename.text(),
scopename.empty()?"":"::",
tagname.text(),
linenum
);
dirs[dirindex]->tail()->append(entry);
break;
}
}
return 1;
}
示例14: runcmd
// Launch a command and initiate a startup notification
int runcmd(FXString cmd, FXString cmdname, FXString dir, FXString startdir, FXbool usesn = true, FXString snexcepts = "")
{
int ret;
// Change to current directory
ret = chdir(dir.text());
if (ret < 0)
{
int errcode = errno;
if (errcode)
{
fprintf(stderr, _("Error: Can't enter folder %s: %s"), dir.text(), strerror(errcode));
}
else
{
fprintf(stderr, _("Error: Can't enter folder %s"), dir.text());
}
return(-1);
}
// Get rid of possible command options
cmdname = cmdname.before(' ');
// Check if command is in the startup notification exception list
FXbool startup_notify = true;
if (snexcepts != "")
{
FXString entry;
for (int i = 0; ; i++)
{
entry = snexcepts.section(':', i);
if (streq(entry.text(), ""))
{
break;
}
if (streq(entry.text(), cmdname.text()))
{
startup_notify = false;
break;
}
}
}
// Run command with startup notification
if (usesn && startup_notify)
{
Display* xdisplay;
SnDisplay* display;
SnLauncherContext* context;
Time timestamp;
// Open display
xdisplay = XOpenDisplay(NULL);
if (xdisplay == NULL)
{
fprintf(stderr, _("Error: Can't open display\n"));
ret = chdir(startdir.text());
if (ret < 0)
{
int errcode = errno;
if (errcode)
{
fprintf(stderr, _("Error: Can't enter folder %s: %s"), startdir.text(), strerror(errcode));
}
else
{
fprintf(stderr, _("Error: Can't enter folder %s"), startdir.text());
}
}
return(-1);
}
// Message displayed in the task bar (if any)
FXString message;
message.format(_("Start of %s"), cmdname.text());
// Initiate launcher context
display = sn_display_new(xdisplay, NULL, NULL);
context = sn_launcher_context_new(display, DefaultScreen(xdisplay));
sn_launcher_context_set_name(context, message.text());
sn_launcher_context_set_binary_name(context, cmdname.text());
sn_launcher_context_set_description(context, message.text());
sn_launcher_context_set_icon_name(context, cmdname.text());
timestamp = gettimestamp();
sn_launcher_context_initiate(context, "Xfe", cmd.text(), timestamp);
// Run command in background
cmd += " &";
static pid_t child_pid = 0;
switch ((child_pid = fork()))
{
case -1:
fprintf(stderr, _("Error: Fork failed: %s\n"), strerror(errno));
break;
case 0: // Child
sn_launcher_context_setup_child_process(context);
//.........这里部分代码省略.........
示例15: Running
void StatusBar::Running(const char*what, const char*howtokill)
{
FXString status;
status.format(_("Running %s (press %s to cancel)"), what, howtokill);
Mode(status.text());
}