我正在做一个项目,该项目应该翻译用户输入,但这不是问题所在。事实上,我是libmotif的新手,我想要一个切换按钮来选择翻译方式(法语到意大利语或意大利语到法语(。因此,我已经在这个菜单栏上有了一个级联按钮,我得到了这个警告:警告:名称:main_list类:XmRowColumn尝试将错误的子类型添加到同类RowColumn小部件
警告:在XtAddCallback 中找不到回调列表
此外,我可以把切换按钮放在其他功能的参数中查看他的状态吗?
//Création de la fenêtre principal
Widget main_window = XtVaCreateManagedWidget("main_window", xmMainWindowWidgetClass, top_widget, NULL) ;
//Menu
Widget menu_bar = XmCreateMenuBar(main_window, (String) "main_list", NULL, 0);
XtManageChild(menu_bar);
Widget quit = XtVaCreateManagedWidget("Quit", xmCascadeButtonWidgetClass, menu_bar,NULL);
Widget toggle = XtVaCreateManagedWidget("Fr vers It", xmToggleButtonWidgetClass, menu_bar, NULL);
//Callbacks
XtAddCallback(quit, XmNactivateCallback, quit_call, NULL);
XtAddCallback(toggle,XmNactivateCallback, toggle_call, NULL);
您只能将一个CascadeButton或CascadeBbuttonGadget附加到菜单栏。你不能在上面放一个切换按钮。你可以创建一个下拉按钮,并将切换按钮连接到上
#include <Xm/RowColumn.h>
#include <Xm/MainW.h>
#include <Xm/CascadeB.h>
#include <Xm/SeparatoG.h>
#include <Xm/PushBG.h>
#include <Xm/ToggleBG.h>
main(argc, argv)
int argc;
char *argv[];
{
Widget toplevel, MainWindow, menuBar, FilePullDown;
XmString label_str;
XtAppContext app;
XtSetLanguageProc (NULL, NULL, NULL);
toplevel = XtVaAppInitialize (&app, "Program", NULL, 0,
&argc, argv, NULL, NULL);
MainWindow = XtVaCreateManagedWidget ("mainWindow",
xmMainWindowWidgetClass, toplevel,
XmNscrollingPolicy, XmAUTOMATIC,
NULL);
menuBar = XmCreateMenuBar (MainWindow, "menuBar", NULL, 0);
FilePullDown = XmCreatePulldownMenu (menuBar, "Language", NULL, 0);
label_str = XmStringCreateLocalized ("Language or Exit");
XtVaCreateManagedWidget ("File",
xmCascadeButtonWidgetClass, menuBar,
XmNlabelString, label_str,
XmNmnemonic, 'F',
XmNsubMenuId, FilePullDown,
NULL);
XmStringFree (label_str);
/* Now add the menu items */
XtVaCreateManagedWidget ("Italian or French",
xmToggleButtonGadgetClass, FilePullDown, NULL);
XtVaCreateManagedWidget ("separator",
xmSeparatorGadgetClass, FilePullDown, NULL);
XtVaCreateManagedWidget ("Exit",
xmPushButtonGadgetClass, FilePullDown, NULL);
XtManageChild (menuBar);
XtRealizeWidget (toplevel);
XtAppMainLoop (app);
}