home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
m
/
master12.zip
/
mastering
/
Newapp
/
Main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-19
|
4KB
|
141 lines
/* Main.c -- This file contains declarations for global variables and
the application's main() routine. */
/* Declare information for 'what' strings. */
char ident1[]="@(#)NewApp -- An example from Mastering Motif.";
char ident2[]="@(#) Version: A.00.17 [01 Aug 1992]";
char ident3[]="@(#)(c) 1989, 1990, 1991 by Hewlett-Packard Company.";
#include "Global.h"
#include "Icon.h"
/****************************
Declare the global widgets.
***************************/
Widget topLevel;
Widget mainWindow;
Widget menuBar;
Widget workArea;
Widget printOptions;
Widget exitDialog;
/* Declare general-purpose global variables for Xt argument lists. */
Arg al[20]; /* arg list */
int ac; /* arg count */
/*******************************
Application-defined resources.
******************************/
static XrmOptionDescRec option_list[] =
{
{ "-session", "session", XrmoptionSepArg, NULL },
};
typedef struct
{
char * session;
} ApplicationArgs, *ApplicationArgsPtr;
static ApplicationArgs applicationArgs;
static XtResource resources[] =
{
{
"session", "Session", XmRString, sizeof (char *),
XtOffset (ApplicationArgsPtr, session), XmRImmediate, (XtPointer) NULL,
},
};
/******************************************************************************
M a i n ( )
******************************************************************************/
void main (argc,argv)
unsigned int argc;
char **argv;
{
XtAppContext app_context;
char *applicationName = XtNewString (argv[0]);
/*************************************
Initialize toolkit and open display.
************************************/
topLevel = XtAppInitialize(&app_context, "Newapp", option_list,
1, &argc, argv, NULL, al, 0);
/* topLevel = XtInitialize(applicationName, "Newapp",
option_list, 1, &argc, argv); */
/*** Establish the window manager and session manager protocols. ***/
CreateWindowManagerProtocols(topLevel);
CreateSessionManagerProtocols(topLevel);
/*** Get application-specific resources. ***/
XtGetApplicationResources(topLevel, &applicationArgs, resources, 1, NULL,0);
/*** Create the Exit dialog (as a child of the top-level shell). ***/
exitDialog = CreateExitDialog(topLevel);
/************************
Create the Main Window.
***********************/
/*** Create the Main Window widget. ***/
ac = 0;
mainWindow = XmCreateMainWindow (topLevel, "mainWindow", al, ac);
/*** Create the pulldown menu in the main window. ***/
menuBar = CreateMenuBar (mainWindow);
XtManageChild (menuBar);
/*** Create a form as the work area for the main window. ***/
ac = 0;
workArea = XmCreateForm (mainWindow, "workArea", al, ac);
/*** Put the printer options menu in the main window ***/
printOptions = CreatePrinterOptionMenu(mainWindow);
XtManageChild (printOptions);
XmMainWindowSetAreas (mainWindow, menuBar, printOptions, NULL, NULL, workArea);
XtManageChild (mainWindow);
/******************************
Set up session manager and
window manager protocols.
******************************/
/*
CreateWindowManagerProtocols(topLevel);
CreateSessionManagerProtocols(topLevel);
*/
/* Set default main window title and icon */
ac = 0;
XtSetArg (al[ac], XmNtitle, "New Application - (untitled)"); ac++;
XtSetArg (al[ac], XmNiconName, "Newapp"); ac++;
XtSetArg (al[ac], XmNwidth, 400); ac++; /* The default size can be */
XtSetArg (al[ac], XmNheight, 250); ac++; /* overridden with -geometry. */
XtSetArg (al[ac], XmNallowShellResize, True); ac++;
XtSetArg (al[ac], XmNdeleteResponse, XmDO_NOTHING); ac++;
XtSetArg (al[ac], XmNiconPixmap,
XCreateBitmapFromData(XtDisplay(topLevel),
RootWindowOfScreen(XtScreen(topLevel)),
Icon_bits,
Icon_width,
Icon_height)); ac++;
XtSetValues (topLevel, al, ac);
XtRealizeWidget(topLevel);
XtAppMainLoop (app_context);
}