📄 dna3.cc
字号:
armboxcb(0,&a,0); //-------------Event loop-------------------------------------------// XtManageChild(form); for(i=0;i<10;i++) if(radiopush[i]) XtManageChild(radiopush[i]); //// Show any error messages. //// The calling routine checks the returned answers, sets a.needrepeat, //// a.message1, and a.messagemode, and calls dialogbox() again if it finds //// an inconsistency. This allows the message to appear on top of the //// dialog box (simply raising the window in message() doesn't work). if(a.needrepeat) message(a.message1, a.messagemode); a.needrepeat = 0; event_loop(form); //----------------------------------------------------------------// // Put result back in radioboxes. Only needed for widgets that // // don't have callbacks. // // Also, if radiotype[radio][item] is RADIOTEXT get a string or if// // it is RADIOVALUE get an integer (=2). (Return as a string in // // a.radioanswer[i][j]). Should be replaced entirely. // //----------------------------------------------------------------// for(i=0;i<a.noofradios;i++) { for(j=1;j<a.radiono[i];j++) { switch(a.radiotype[i][j]) { case RADIOTEXT: // Get input string ptr = XmTextGetString(radioslider[i][j]); if(ptr!=NULL) { strcpy(a.radioanswer[i][j],ptr); XtFree(ptr); } break; case RADIOVALUE: // Small slider case RADIOVALUEWIDE: // Wide slider result = atoi(a.radioanswer[i][j]); XmScaleGetValue(radioslider[i][j], &result); itoa(result,a.radioanswer[i][j],10); for(k=strlen(a.radio[i][j]);k;k--) { if(a.radio[i][j][k]=='=') { a.radio[i][j][k+1]=0; strcat(a.radio[i][j],a.radioanswer[i][j]); break; } } break; } } } //--------------------------------------------------------------// // Put result in answer boxes. Only needed for widgets that // // don't have callbacks. Should be replaced entirely. // //--------------------------------------------------------------// for(j=0;j<a.noofboxes;j++) { switch(a.boxtype[j]) { case FILENAME: // Filename strcpy(a.answer[j],clickboxdata[j].title); // Single break; case MULTIFILENAME: // Multiple //// Caller must XtFree clickboxdata[j].list[k]'s //// and delete[] clickboxdata[j].list //// See example in xmtnimage1.cc line 340 a.boxcount[j] = clickboxdata[j].count; //// User did not select any files so no list was created //// in fsokcb(). Create a list and use the old filename. if(a.boxcount[j]==0) { clickboxdata[j].list = new char*[1]; clickboxdata[j].list[0] = XtMalloc(FILENAMELENGTH); strcpy(clickboxdata[j].list[0], clickboxdata[j].title); a.boxcount[j]=1; } a.boxlist[j] = clickboxdata[j].list; strcpy(a.answer[j],a.boxlist[j][0]); break; } } //// Save all the information needed to unmanage the dialog. //// This may happen right away or later, depending on `a.keep' . a.widget = w; // array of 200 Widgets a.form = form; // DialogForm Widget a.clickboxdata = clickboxdata; // Array of clickboxinfo structs a.widgetcount = wc; // No. of widgets on form } //// If it is a normal dialog, delete the current widgets & data. //// If dialog was kept on screen from before, use the data that //// was saved previously in its dialoginfo struct. if(a.keep!=ON) { for(j=0;j<a.noofboxes;j++) { if(a.boxtype[j]==FILENAME || a.boxtype[j]==MULTIFILENAME) { for(k=0;k<a.clickboxdata[j].wc;k++) XtDestroyWidget(a.clickboxdata[j].w[k]); delete[] a.clickboxdata[j].w; if(a.clickboxdata[j].dirmask) { strcpy(dirmask,a.clickboxdata[j].dirmask); delete[] a.clickboxdata[j].dirmask; } } }// if(a.want_changecicb)// XtRemoveEventHandler(g.drawing_area, SubstructureNotifyMask, // FALSE,(XtEH)dialogchangecicb, (XtP)&a); XtRemoveEventHandler(XtParent((form)), FocusChangeMask, False, (XtEH)raisecb, (XtP)NULL); XtUnmanageChild(a.form); if(a.clickboxdata!=NULL) delete[] a.clickboxdata; for(k=0;k<a.widgetcount;k++) if(a.widget[k]!=NULL) XtDestroyWidget(a.widget[k]); if(a.widget!=NULL) delete[] a.widget; } return;} //--------------------------------------------------------------------//// dialogclickboxcb - callback for getting a value in dialog box. //// Calls clickbox(), using 'answer' in a clickboxinfo struct as the //// initial value, converts the integer returned by clickbox() to a //// string and stores it in the 'c->widget's XmNlabelString. ////--------------------------------------------------------------------//void dialogclickboxcb(Widget w, XtP client_data, XmACB *call_data){ w=w; call_data=call_data; // Keep compiler quiet int box=0,j,k,answer; Arg args[100]; XmString xms; char tempstring[256]; int n=0; dialoginfo *a = (dialoginfo*)client_data; //// Figure out which box for(k=0;k<4;k++) for(j=0;j<a->noofboxes;j++) if(w==a->boxwidget[j][k] && w!=0) box = j; clickboxinfo *c = a->c[box]; answer = clickbox(c->title, c->startval, c->minval, c->maxval, null, 10); if(g.getout){ g.getout=0; return; } c->answer = answer; c->startval = answer; //// Redraw the label in the pushbutton widget that called the clickbox. itoa(answer,tempstring,10); XtSetArg(args[n], XmNlabelString, xms=XmStringCreateSimple(tempstring)); n++; XtSetValues(c->widget[0], args, n); XmStringFree(xms); //// Put answer back in dialoginfo in case dialog remains on screen itoa(answer, a->answer[box], 10); return;}//---------------------------------------------------------------------//// dialogdoubleclickboxcb - callback for getting a value in dialog box.////---------------------------------------------------------------------//void dialogdoubleclickboxcb(Widget w, XtPointer client_data, XmACB *call_data){ w=w; call_data=call_data; // Keep compiler quiet double fanswer; Arg args[100]; XmString xms; char tempstring[256]; int box=0,j,n; dialoginfo *a = (dialoginfo*)client_data; //// Figure out which box for(j=0;j<a->noofboxes;j++) if(w==a->boxwidget[j][0]) box = j; clickboxinfo *c = a->c[box]; fanswer = clickbox(c->title, c->fstartval, c->fminval, c->fmaxval, null, 10); if(g.getout){ g.getout=0; return; } c->fanswer = fanswer; c->fstartval = fanswer; // Redraw the label in the pushbutton widget that called the clickbox. gcvt(c->fanswer, g.signif, tempstring); n = 0; XtSetArg(args[n], XmNlabelString, xms=XmStringCreateSimple(tempstring)); n++; XtSetValues(c->widget[0], args, n); XmStringFree(xms); gcvt(fanswer, g.signif, a->answer[box]); return;}//--------------------------------------------------------------------//// dialogmulticlickboxcb - callback for getting a value in dialog box //// using multiclickbox(). ////--------------------------------------------------------------------//void dialogmulticlickboxcb(Widget w, XtPointer client_data, XmACB *call_data){ w=w; call_data=call_data; // Keep compiler quiet int col[3]; uint color=0; Arg args[100]; XmString xms; char tempstring[256]; int box=0, j, k, n=0; dialoginfo *a = (dialoginfo*)client_data; //// Figure out which box for(j=0;j<a->noofboxes;j++) for(k=0;k<3;k++) if(w==a->boxwidget[j][k]) box = j; clickboxinfo *c = a->c[box]; // Redraw the labels in the pushbutton widgets that called the clickbox. for(k=0;k<3;k++) { n = 0; itoa(col[k],tempstring,10); XtSetArg(args[n], XmNlabelString, xms=XmStringCreateSimple(tempstring)); n++; XtSetValues(c->widget[k], args, n); XmStringFree(xms); } itoa(color, a->answer[box], 10); c->answer = color; c->startval = color;} //------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -