⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listing_12_6.c

📁 This source code has been tested under OpenWindows 2.0, Sun s X11/NeWS server. For Xlib programs th
💻 C
字号:
/*************************************************************************                                                                    ****  listing_12_6.c                                                    ****                                                                    ****  A program -- based on the text editor -- that exists solely to    ****  demonstrat cascading pull-downs (Fig 12.7).                       ****                                                                    *************************************************************************/#include <string.h>#include <Xm/MainW.h>#include <Xm/RowColumn.h>#include <Xm/CascadeB.h>#include <Xm/Label.h>#include <Xm/PushB.h>#include <Xm/Separator.h>#include <Xm/Text.h>/*************************************************************************                                                                    ****               F O R W A R D   D E F I N I T I O N S                ****                                                                    *************************************************************************/void    InitMainWindow();void    InitMenuBar();void    InitWorkWindow();void	InitOther();void	InitFileMenu();void	InitEditMenu();void	InitViewMenu();void	InitOptionMenu();void	InitHelpMenu();/*************************************************************************                                                                    ****                   G L O B A L   V A R I A B L E S                  ****                                                                    *************************************************************************/Widget	appshell,			/* Application Shell          */	mainwin,			/* XmMainWindow		      */	menubar,			/* MainWindow Menu Bar	      */	workwin,			/* MainWindow Work Area       */	textwin;			/* Work Window XmText widget  */Arg	arglist[16];			/* For programmatic rsrc stuf *//*************************************************************************                                                                    ****  main( argc, argv )                                                ****                                                                    ****  Program entry point. Creates shell, calls initialization funcs,   ****  and turns control over to event loop.                             ****                                                                    *************************************************************************/void	main( argc, argv )    int     argc;    char    *argv[];{    appshell = XtInitialize( argv[0], "Listing_12_6", NULL, 0, &argc, argv );    InitMainWindow();    InitMenuBar();    InitWorkWindow();    XmMainWindowSetAreas( mainwin, menubar, NULL, NULL, NULL, workwin );    InitOther();    XtRealizeWidget( appshell );    XtMainLoop();}/*************************************************************************                                                                    ****  InitMainWindow()                                                  ****                                                                    ****  This function creates the main window widget and its scrollbars.  ****  The main window is created as a child of the application shell.   ****  The scrollbars are either created along with the main-window (if  ****  its "scrollingPolicy" resource contains TRUE) or separately.      ****                                                                    ****  This function modifies the global "mainwin", and accesses the     ****  global "appshell".                                                ****                                                                    *************************************************************************/void	InitMainWindow(){    mainwin = XmCreateMainWindow( appshell, "MainWin", NULL, 0 );    XtManageChild( mainwin );}/*************************************************************************                                                                    ****  InitMenuBar()                                                     ****                                                                    ****  This function creates the menu bar and all pulldown menus. The    ****  menu bar is created as the child of the main window.              ****                                                                    ****  This function modifies the global "menubar", and accesses the     ****  global "mainwin".                                                 ****                                                                    *************************************************************************/void	InitMenuBar(){    menubar = XmCreateMenuBar( mainwin, "MenuBar", NULL, 0 );    XtManageChild( menubar );    InitFileMenu();    InitEditMenu();    InitViewMenu();    InitOptionMenu();    InitHelpMenu();}/*************************************************************************                                                                    ****  InitFileMenu()                                                    ****                                                                    ****  Creates the File menu: cascade button, pull-down menu pane, and   ****  all menu-pane choices. Attaches callbacks to menu-pane choices.   ****                                                                    *************************************************************************/void	InitFileMenu(){    Widget	topic;    topic = XmCreateCascadeButton( menubar, "FileTopic", NULL, 0 );    XtManageChild( topic );}/*************************************************************************                                                                    ****  InitEditMenu()                                                    ****                                                                    ****  Creates the Edit menu: cascade button, pull-down menu pane, and   ****  all menu-pane choices. Attaches callbacks to menu-pane choices.   ****                                                                    *************************************************************************/void	InitEditMenu(){    Widget	topic;    topic = XmCreateCascadeButton( menubar, "EditTopic", NULL, 0 );    XtManageChild( topic );}/*************************************************************************                                                                    ****  InitViewMenu()                                                    ****                                                                    ****  Creates the View menu: cascade button, pull-down menu pane, and   ****  all menu-pane choices. Attaches callbacks to menu-pane choices.   ****                                                                    *************************************************************************/void	InitViewMenu(){    Widget	topic;    topic = XmCreateCascadeButton( menubar, "ViewTopic", NULL, 0 );    XtManageChild( topic );}/*************************************************************************                                                                    ****  InitOptionMenu()                                                  ****                                                                    ****  Creates the Option menu: cascade button, pull-down menu pane, and ****  all menu-pane choices. Attaches callbacks to menu-pane choices.   ****                                                                    *************************************************************************/void	InitOptionMenu(){    Widget	topic, topic_1, topic_2,		pane, pane_1, pane_2,		choice_1[3], choice_2[5];    pane = XmCreatePulldownMenu( menubar, "Option_Pane", NULL, 0 );    XtSetArg( arglist[0], XmNsubMenuId, pane );    topic = XmCreateCascadeButton( menubar, "OptionTopic", arglist, 1 );    XtManageChild( topic );    pane_1 = XmCreatePulldownMenu( pane, "Opt_Font_Fonts", NULL, 0 );    choice_1[0] = XmCreatePushButton( pane_1, "Opt_Fnt_Cour", NULL, 0 );    choice_1[1] = XmCreatePushButton( pane_1, "Opt_Fnt_Helv", NULL, 0 );    choice_1[2] = XmCreatePushButton( pane_1, "Opt_Fnt_Time", NULL, 0 );    XtManageChildren( choice_1, 3 );    XtSetArg( arglist[0], XmNsubMenuId, pane_1 );    topic_1 = XmCreateCascadeButton( pane, "Option_Font", arglist, 1 );    XtManageChild( topic_1 );    pane_2 = XmCreatePulldownMenu( pane, "Opt_Font_Size", NULL, 0 );    choice_2[0] = XmCreatePushButton( pane_2, "Opt_Siz_10", NULL, 0 );    choice_2[1] = XmCreatePushButton( pane_2, "Opt_Siz_12", NULL, 0 );    choice_2[2] = XmCreatePushButton( pane_2, "Opt_Siz_14", NULL, 0 );    choice_2[3] = XmCreatePushButton( pane_2, "Opt_Siz_18", NULL, 0 );    choice_2[4] = XmCreatePushButton( pane_2, "Opt_Siz_24", NULL, 0 );    XtManageChildren( choice_2, 5 );    XtSetArg( arglist[0], XmNsubMenuId, pane_2 );    topic_2 = XmCreateCascadeButton( pane, "Option_Size", arglist, 1 );    XtManageChild( topic_2 );}/*************************************************************************                                                                    ****  InitHelpMenu()                                                    ****                                                                    ****  Creates the Help menu: cascade button, pull-down menu pane, and   ****  all menu-pane choices. Attaches callbacks to menu-pane choices.   ****                                                                    *************************************************************************/void	InitHelpMenu(){    Widget	topic;    topic = XmCreateCascadeButton( menubar, "HelpTopic", NULL, 0 );    XtManageChild( topic );    XtSetArg( arglist[0], XmNmenuHelpWidget, topic );    XtSetValues( menubar, arglist, 1 );}/*************************************************************************                                                                    ****  InitWorkWindow()                                                  ****                                                                    ****  This function creates the work window and its children. The       ****  work window is created as the child of the main window.           ****                                                                    ****  This function modifies the globals "workwin" and "textwin", and   ****  accesses the global "mainwin".                                    ****                                                                    *************************************************************************/void	InitWorkWindow(){    textwin = XmCreateScrolledText( mainwin, "WorkWin", NULL, 0 );    XtManageChild( textwin );    workwin = XtParent( textwin );}/*************************************************************************                                                                    ****  InitOther()                                                       ****                                                                    ****  This function performs other program initialization, such as      ****  loading any default data.                                         ****                                                                    *************************************************************************/void	InitOther(){}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -