当前位置: 技术问答>linux和unix
关于motif中获得用户输入的一个问题!
来源: 互联网 发布时间:2015-06-05
本文导语: 如何通过一个弹出窗口来获得用户输入啊。。。 我部分代码如下: static void postDialog ( Widget parent, XtPointer client_data, XtPointer call_data ) { Widget dialog, rowcol_v, rowcol_h, text1, text2, ok_button, can...
如何通过一个弹出窗口来获得用户输入啊。。。
我部分代码如下:
static void
postDialog ( Widget parent, XtPointer client_data, XtPointer call_data )
{
Widget dialog, rowcol_v, rowcol_h, text1, text2, ok_button, cancel_button;
scaleValues* scale_v = (scaleValues *) client_data;
if (NULL == scale_v)
printf("invalid scaleValues in postDialog()n");
dialog = XtVaCreatePopupShell ("dialog",
xmDialogShellWidgetClass, parent,
XmNtitle, "Dialog shell",
XmNdeleteResponse, XmDESTROY,
NULL);
rowcol_v = XtVaCreateWidget ("rowcol_v",
xmRowColumnWidgetClass, dialog, NULL);
rowcol_h = XtVaCreateWidget ("rowcol_h1",
xmRowColumnWidgetClass, rowcol_v,
XmNorientation, XmHORIZONTAL,
NULL);
XtVaCreateManagedWidget ("Width Scale:",
xmLabelGadgetClass, rowcol_h, NULL);
text1 = XtVaCreateManagedWidget ("width",
xmTextFieldWidgetClass, rowcol_h,
XmNmaxLength, 4,
XmNcursorPositionVisible, False,
NULL);
XtManageChild (rowcol_h);
rowcol_h = XtVaCreateWidget ("rowcol_h2",
xmRowColumnWidgetClass, rowcol_v,
XmNorientation, XmHORIZONTAL,
NULL);
XtVaCreateManagedWidget ("Height Scale:",
xmLabelGadgetClass, rowcol_h, NULL);
text2 = XtVaCreateManagedWidget ("height",
xmTextFieldWidgetClass, rowcol_h,
XmNmaxLength, 4,
XmNcursorPositionVisible, False,
NULL);
XtManageChild (rowcol_h);
rowcol_h = XtVaCreateWidget ("rowcol_h3",
xmFormWidgetClass, rowcol_v,
XmNfractionBase, 5,
NULL);
ok_button = XtVaCreateManagedWidget ("OK",
xmPushButtonGadgetClass, rowcol_h,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_POSITION,
XmNleftPosition, 1,
XmNrightAttachment, XmATTACH_POSITION,
XmNrightPosition, 2,
XmNshowAsDefault, True,
XmNdefaultButtonShadowThickness, 1,
XmNuserData, rowcol_v,
NULL);
XtAddCallback (ok_button, XmNactivateCallback, getScaleValue, scale_v);
cancel_button = XtVaCreateManagedWidget ("Cancel",
xmPushButtonGadgetClass, rowcol_h,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_POSITION,
XmNleftPosition, 3,
XmNrightAttachment, XmATTACH_POSITION,
XmNrightPosition, 4,
XmNshowAsDefault, False,
XmNdefaultButtonShadowThickness, 1,
NULL);
XtAddCallback (cancel_button, XmNactivateCallback, closeDialog, dialog);
XtManageChild (rowcol_h);
XtManageChild (rowcol_v);
XtPopup (dialog, XtGrabNone);
}
其中typedef struct {
char* width; /* width scale value */
char* height; /* height scale value */
} scaleValues;
代码很长但是很简单。。
如何实现getScaleValue啊?
望知道的指点迷津!先谢了
我部分代码如下:
static void
postDialog ( Widget parent, XtPointer client_data, XtPointer call_data )
{
Widget dialog, rowcol_v, rowcol_h, text1, text2, ok_button, cancel_button;
scaleValues* scale_v = (scaleValues *) client_data;
if (NULL == scale_v)
printf("invalid scaleValues in postDialog()n");
dialog = XtVaCreatePopupShell ("dialog",
xmDialogShellWidgetClass, parent,
XmNtitle, "Dialog shell",
XmNdeleteResponse, XmDESTROY,
NULL);
rowcol_v = XtVaCreateWidget ("rowcol_v",
xmRowColumnWidgetClass, dialog, NULL);
rowcol_h = XtVaCreateWidget ("rowcol_h1",
xmRowColumnWidgetClass, rowcol_v,
XmNorientation, XmHORIZONTAL,
NULL);
XtVaCreateManagedWidget ("Width Scale:",
xmLabelGadgetClass, rowcol_h, NULL);
text1 = XtVaCreateManagedWidget ("width",
xmTextFieldWidgetClass, rowcol_h,
XmNmaxLength, 4,
XmNcursorPositionVisible, False,
NULL);
XtManageChild (rowcol_h);
rowcol_h = XtVaCreateWidget ("rowcol_h2",
xmRowColumnWidgetClass, rowcol_v,
XmNorientation, XmHORIZONTAL,
NULL);
XtVaCreateManagedWidget ("Height Scale:",
xmLabelGadgetClass, rowcol_h, NULL);
text2 = XtVaCreateManagedWidget ("height",
xmTextFieldWidgetClass, rowcol_h,
XmNmaxLength, 4,
XmNcursorPositionVisible, False,
NULL);
XtManageChild (rowcol_h);
rowcol_h = XtVaCreateWidget ("rowcol_h3",
xmFormWidgetClass, rowcol_v,
XmNfractionBase, 5,
NULL);
ok_button = XtVaCreateManagedWidget ("OK",
xmPushButtonGadgetClass, rowcol_h,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_POSITION,
XmNleftPosition, 1,
XmNrightAttachment, XmATTACH_POSITION,
XmNrightPosition, 2,
XmNshowAsDefault, True,
XmNdefaultButtonShadowThickness, 1,
XmNuserData, rowcol_v,
NULL);
XtAddCallback (ok_button, XmNactivateCallback, getScaleValue, scale_v);
cancel_button = XtVaCreateManagedWidget ("Cancel",
xmPushButtonGadgetClass, rowcol_h,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_POSITION,
XmNleftPosition, 3,
XmNrightAttachment, XmATTACH_POSITION,
XmNrightPosition, 4,
XmNshowAsDefault, False,
XmNdefaultButtonShadowThickness, 1,
NULL);
XtAddCallback (cancel_button, XmNactivateCallback, closeDialog, dialog);
XtManageChild (rowcol_h);
XtManageChild (rowcol_v);
XtPopup (dialog, XtGrabNone);
}
其中typedef struct {
char* width; /* width scale value */
char* height; /* height scale value */
} scaleValues;
代码很长但是很简单。。
如何实现getScaleValue啊?
望知道的指点迷津!先谢了
|
如果是模式对话框,在XtPopup之后建立一个事件循环。如果不是模式,需要把scaleValue放在全局变量里。
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。