📄 listing_12_8.c
字号:
/************************************************************************* **** listing_12_8.c **** **** Demonstration of option menus. **** *************************************************************************/#include <Xm/BulletinB.h>#include <Xm/RowColumn.h>#include <Xm/PushB.h>void InitFontMenu(); /* FORWARD Definitions */void InitSizeMenu();Widget appshell, /* Application Shell */ the_bb; /* The work area */Arg arglist[16]; /* Used to set resources */void main( argc, argv ) int argc; char *argv[];{ appshell = XtInitialize( argv[0], "Listing_12_8", NULL, 0, &argc, argv ); the_bb = XmCreateBulletinBoard( appshell, "TheBB", NULL, 0 ); XtManageChild( the_bb ); InitFontMenu(); InitSizeMenu(); XtRealizeWidget( appshell ); XtMainLoop();}/************************************************************************* **** InitFontMenu() **** **** Creates the option menu for font selection. **** *************************************************************************/void InitFontMenu(){ Widget menu, pane, btns[3]; pane = XmCreatePulldownMenu( the_bb, "Font_Pane", NULL, 0 ); btns[0] = XmCreatePushButton( pane, "Font_Cour", NULL, 0 ); btns[1] = XmCreatePushButton( pane, "Font_Helv", NULL, 0 ); btns[2] = XmCreatePushButton( pane, "Font_Time", NULL, 0 ); XtManageChildren( btns, 3 ); XtSetArg( arglist[0], XmNsubMenuId, pane ); XtSetArg( arglist[1], XmNmenuHistory, btns[0] ); menu = XmCreateOptionMenu( the_bb, "Font_Menu", arglist, 2 ); XtManageChild( menu );}/************************************************************************* **** InitSizeMenu() **** **** Creates the option menu for font size selection. **** *************************************************************************/void InitSizeMenu(){ Widget menu, pane, btns[5]; pane = XmCreatePulldownMenu( the_bb, "Size_Pane", NULL, 0 ); btns[0] = XmCreatePushButton( pane, "Size_10", NULL, 0 ); btns[1] = XmCreatePushButton( pane, "Size_12", NULL, 0 ); btns[2] = XmCreatePushButton( pane, "Size_14", NULL, 0 ); btns[3] = XmCreatePushButton( pane, "Size_18", NULL, 0 ); btns[4] = XmCreatePushButton( pane, "Size_24", NULL, 0 ); XtManageChildren( btns, 5 ); XtSetArg( arglist[0], XmNsubMenuId, pane ); XtSetArg( arglist[1], XmNmenuHistory, btns[0] ); menu = XmCreateOptionMenu( the_bb, "Size_Menu", arglist, 2 ); XtManageChild( menu );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -