Blame tests/uil/Syntax/Case.c

Packit b099d7
/* 
Packit b099d7
 * Motif
Packit b099d7
 *
Packit b099d7
 * Copyright (c) 1987-2012, The Open Group. All rights reserved.
Packit b099d7
 *
Packit b099d7
 * These libraries and programs are free software; you can
Packit b099d7
 * redistribute them and/or modify them under the terms of the GNU
Packit b099d7
 * Lesser General Public License as published by the Free Software
Packit b099d7
 * Foundation; either version 2 of the License, or (at your option)
Packit b099d7
 * any later version.
Packit b099d7
 *
Packit b099d7
 * These libraries and programs are distributed in the hope that
Packit b099d7
 * they will be useful, but WITHOUT ANY WARRANTY; without even the
Packit b099d7
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
Packit b099d7
 * PURPOSE. See the GNU Lesser General Public License for more
Packit b099d7
 * details.
Packit b099d7
 *
Packit b099d7
 * You should have received a copy of the GNU Lesser General Public
Packit b099d7
 * License along with these librararies and programs; if not, write
Packit b099d7
 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
Packit b099d7
 * Floor, Boston, MA 02110-1301 USA
Packit b099d7
*/ 
Packit b099d7
/* 
Packit b099d7
 * HISTORY
Packit b099d7
*/ 
Packit b099d7
#ifdef REV_INFO
Packit b099d7
#ifndef lint
Packit b099d7
static char rcsid[] = "$XConsortium: Case.c /main/7 1995/07/13 20:39:06 drk $"
Packit b099d7
#endif
Packit b099d7
#endif
Packit b099d7
/*
Packit b099d7
*  (c) Copyright 1989, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
Packit b099d7
#include <stdio.h>
Packit b099d7
Packit b099d7
Packit b099d7
#include <Mrm/MrmAppl.h>                   /* Motif Toolkit */
Packit b099d7
#include <Xm/Label.h>
Packit b099d7
#include <Xm/LabelP.h>
Packit b099d7
#include <Xm/BulletinB.h>
Packit b099d7
#include <Xm/BulletinBP.h>
Packit b099d7
#include <Xm/PushB.h>
Packit b099d7
#include <Xm/PushBP.h>
Packit b099d7
#include <testlib.h>
Packit b099d7
Packit b099d7
static MrmHierarchy	s_MrmHierarchy;		/* MRM database hierarch id */
Packit b099d7
static char		*vec[]={"Case.uid"};
Packit b099d7
						/* MRM database file list   */
Packit b099d7
static MrmCode		class ;
Packit b099d7
Packit b099d7
static void helloworld_button_activate();
Packit b099d7
Packit b099d7
static MrmCount		regnum = 1 ;
Packit b099d7
static MrmRegisterArg	regvec[] = {
Packit b099d7
	{"HELLOWORLD_BUTTON_ACTIVATE",(caddr_t)helloworld_button_activate}
Packit b099d7
	};
Packit b099d7
Packit b099d7
/*
Packit b099d7
 *  Main program
Packit b099d7
 */
Packit b099d7
int main(argc, argv)
Packit b099d7
int argc;
Packit b099d7
char **argv;
Packit b099d7
{
Packit b099d7
     /*
Packit b099d7
     *  Declare the variables to contain the two widget ids
Packit b099d7
     */
Packit b099d7
    Widget hellominimalmain;
Packit b099d7
    Arg arglist[1] ;
Packit b099d7
Packit b099d7
    /*
Packit b099d7
     *  Initialize the MRM. We only register the required classes.
Packit b099d7
     */
Packit b099d7
Packit b099d7
    MrmRegisterClass
Packit b099d7
	(0, NULL, "XmCreateBulletinBoard", XmCreateBulletinBoard,
Packit b099d7
	 (WidgetClass) &xmBulletinBoardClassRec);
Packit b099d7
    MrmRegisterClass
Packit b099d7
	(0, NULL, "XmCreatePushButton", XmCreatePushButton,
Packit b099d7
	 (WidgetClass) &xmPushButtonClassRec);
Packit b099d7
    MrmRegisterClass
Packit b099d7
	(0, NULL, "XmCreateLabel", XmCreateLabel,
Packit b099d7
	 (WidgetClass) &xmLabelClassRec);
Packit b099d7
Packit b099d7
Packit b099d7
    /*
Packit b099d7
     *  Initialize the toolkit.  This call returns the id of the "toplevel"
Packit b099d7
     *  widget.  The applications "main" widget must be the only child
Packit b099d7
     *  of this widget.
Packit b099d7
     */
Packit b099d7
Packit b099d7
    CommonTestUilInit (argc,argv);
Packit b099d7
Packit b099d7
Packit b099d7
    /*
Packit b099d7
     *  Define the Mrm.hierarchy (only 1 file)
Packit b099d7
     */
Packit b099d7
Packit b099d7
    if (MrmOpenHierarchy (1,			    /* number of files	    */
Packit b099d7
			vec, 			    /* files     	    */
Packit b099d7
			NULL,			    /* os_ext_list (null)   */
Packit b099d7
			&s_MrmHierarchy)	    /* ptr to returned id   */
Packit b099d7
			!= MrmSUCCESS) {
Packit b099d7
	printf ("can't open hierarchy\n");
Packit b099d7
     }
Packit b099d7
Packit b099d7
    /*
Packit b099d7
     * 	Register our callback routines so that the resource manager can 
Packit b099d7
     * 	resolve them at widget-creation time.
Packit b099d7
     */
Packit b099d7
Packit b099d7
    if (MrmRegisterNames (regvec, regnum)
Packit b099d7
			!= MrmSUCCESS)
Packit b099d7
			    printf("can't register names\n");
Packit b099d7
Packit b099d7
    /*
Packit b099d7
     *  Call MRM to fetch and create the pushbutton and its container
Packit b099d7
     */
Packit b099d7
Packit b099d7
    if (MrmFetchWidget (s_MrmHierarchy,
Packit b099d7
			"HELLOMINIMAL_MAIN",
Packit b099d7
			Shell1,
Packit b099d7
			&hellominimalmain,
Packit b099d7
			&class)
Packit b099d7
			!= MrmSUCCESS)
Packit b099d7
			    printf("can't fetch interface\n");
Packit b099d7
Packit b099d7
    /*
Packit b099d7
     *  Make the Shell1 widget "manage" the main window (or whatever the
Packit b099d7
     *  the uil defines as the topmost widget).  This will
Packit b099d7
     *  cause it to be "realized" when the Shell1 widget is "realized"
Packit b099d7
     */
Packit b099d7
Packit b099d7
    XtManageChild(hellominimalmain);
Packit b099d7
    
Packit b099d7
    /*
Packit b099d7
     *  Realize the Shell1 widget.  This will cause the entire "managed"
Packit b099d7
     *  widget hierarchy to be displayed
Packit b099d7
     */
Packit b099d7
Packit b099d7
    XtRealizeWidget(Shell1);
Packit b099d7
Packit b099d7
    CommonPause();
Packit b099d7
Packit b099d7
    /*
Packit b099d7
     *  Loop and process events
Packit b099d7
     */
Packit b099d7
Packit b099d7
    XtAppMainLoop(app_context);
Packit b099d7
Packit b099d7
    /* UNREACHABLE */
Packit b099d7
    return (0);
Packit b099d7
}
Packit b099d7
Packit b099d7
static void helloworld_button_activate( widget, tag, callback_data )
Packit b099d7
	Widget	widget;
Packit b099d7
	char    *tag;
Packit b099d7
	XmAnyCallbackStruct *callback_data;
Packit b099d7
{
Packit b099d7
    Arg arglist[2];
Packit b099d7
Packit b099d7
    static int call_count = 0;
Packit b099d7
Packit b099d7
    printf("In hello_world_button_activate\n");
Packit b099d7
Packit b099d7
    call_count += 1 ;
Packit b099d7
    switch ( call_count )
Packit b099d7
        {
Packit b099d7
        case 1:
Packit b099d7
            XtSetArg( arglist[0], XmNlabelString,
Packit b099d7
                XmStringLtoRCreate("Goodbye\nMinimal!",""));
Packit b099d7
            XtSetValues( widget, arglist, 1 );
Packit b099d7
            break ;
Packit b099d7
        case 2:
Packit b099d7
            exit(1);
Packit b099d7
            break ;
Packit b099d7
        }
Packit b099d7
}