📄 sample_11_1.c
字号:
/************************************************************************* **** filename.c **** **** Sample program template. Description of the program's purpose **** goes here. **** *************************************************************************/#include <Xm/CascadeB.h>#include <Xm/MainW.h>#include <Xm/RowColumn.h>#include <Xm/ScrollBar.h>#include <Xm/Text.h>#include <Xm/Separator.h>Widget InitMainWindow(); /* FORWARD Definitions */Widget InitMenus();Widget InitWorkWindow();Widget InitCommandWindow();void InitOther();Widget appshell, /* Application Shell */ mainwin, /* XmMainWindow */ menubar, /* MainWindow Menu Bar */ workwin, /* MainWindow Work Area */ horzscroll, /* MainWindow Horizontal Scrl */ vertscroll, /* MainWindow Vertical Scroll */ commwin; /* MainWindow Command Window */Arg arglist[16];/************************************************************************* **** 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], "Sample_11_1", NULL, 0, &argc, argv ); mainwin = InitMainWindow( appshell, &horzscroll, &vertscroll ); menubar = InitMenus( mainwin ); workwin = InitWorkWindow( mainwin ); commwin = InitCommandWindow( mainwin ); XmMainWindowSetAreas( mainwin, menubar, commwin, horzscroll, vertscroll, workwin ); InitOther(); XtRealizeWidget( appshell ); XtMainLoop();}/************************************************************************* **** InitMainWindow( parent, hscroll, vscroll ) **** **** This function creates the main window and its scrollbars. The **** "parent" param specifies the main window's parent. The "hscroll" **** and "vscroll" parameters point at variables which will hold the **** IDs of the scrollbars, which are children of the main window. **** *************************************************************************/Widget InitMainWindow( parent, hscroll, vscroll ) Widget parent; Widget *hscroll; Widget *vscroll;{ Widget mwtemp; mwtemp = XmCreateMainWindow( parent, "MainWin", NULL, 0 ); XtManageChild( mwtemp ); *hscroll = XmCreateScrollBar( mwtemp, "HScroll", NULL, 0 ); XtManageChild( *hscroll ); *vscroll = XmCreateScrollBar( mwtemp, "VScroll", NULL, 0 ); XtManageChild( *vscroll ); return( mwtemp );}/************************************************************************* **** InitMenuBar( parent ) **** **** This function creates the menu bar and all pulldown menus. The **** "parent" parameter specifies the parent of the menu bar; the **** pull-downs are children of the menu bar. **** *************************************************************************/Widget InitMenus( parent ) Widget parent;{ Widget mbar, menus[5]; mbar = XmCreateMenuBar( parent, "MenuBar", NULL, 0 ); XtManageChild( mbar ); menus[0] = XmCreateCascadeButton( mbar, "MenuFile", NULL, 0 ); menus[1] = XmCreateCascadeButton( mbar, "MenuEdit", NULL, 0 ); menus[2] = XmCreateCascadeButton( mbar, "MenuView", NULL, 0 ); menus[3] = XmCreateCascadeButton( mbar, "MenuOptions", NULL, 0 ); menus[4] = XmCreateCascadeButton( mbar, "MenuHelp", NULL, 0 ); XtManageChildren( menus, 5 ); XtSetArg( arglist[0], XmNmenuHelpWidget, menus[4] ); XtSetValues( mbar, arglist, 1 ); return( mbar );}/************************************************************************* **** InitWorkWin( parent ) **** **** This function creates the work window and its children. The **** "parent" parameter specifies the parent of the work window. **** *************************************************************************/Widget InitWorkWindow( parent ) Widget parent;{ Widget wwtemp; wwtemp = XmCreateText( parent, "WorkWin", NULL, 0 ); XtManageChild( wwtemp ); return( wwtemp );}/************************************************************************* **** InitDialogs( parent ) **** **** This function creates all of the program's dialogs. Each dialog **** has as its parent the widget specified by the "parent" param. **** *************************************************************************/Widget InitCommandWindow( parent ) Widget parent;{ Widget cwtemp; cwtemp = XmCreateText( parent, "CommWin", NULL, 0 ); XtManageChild( cwtemp ); return( cwtemp );}/************************************************************************* **** 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 + -