/* * @OPENGROUP_COPYRIGHT@ * COPYRIGHT NOTICE * Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc. * Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group * ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for * the full copyright text. * * This software is subject to an open license. It may only be * used on, with or for operating systems which are themselves open * source systems. You must contact The Open Group for a license * allowing distribution and sublicensing of this software on, with, * or for operating systems which are not Open Source programs. * * See http://www.opengroup.org/openmotif/license for full * details of the license agreement. Any use, reproduction, or * distribution of the program constitutes recipient's acceptance of * this agreement. * * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS * PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY * WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY * OR FITNESS FOR A PARTICULAR PURPOSE * * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT * NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE * EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. */ /* * HISTORY */ #ifdef REV_INFO #ifndef lint static char rcsid[] = "$XConsortium: dogs.c /main/5 1995/07/14 10:07:19 drk $" #endif #endif /***************************************************************************** * * dogs.c - Square & Dog widget demo source file. * ******************************************************************************/ #include #include #include #include "Square.h" #include "Dog.h" XtAppContext app_context; #define k_dog1_id 1 #define k_dog2_id 2 #define k_dog3_id 3 #define k_help_id 4 static void create_cb(); static void bark_cb(); static void tb_cb(); static void scale_cb(); static void help_cb(); static void exit_cb(); static MrmHierarchy mrm_id; static char *mrm_vec[]={"dogs.uid"}; static MrmCode mrm_class; static MRMRegisterArg mrm_names[] = { {"create_cb", (caddr_t)create_cb }, {"bark_cb", (caddr_t)bark_cb }, {"tb_cb", (caddr_t)tb_cb }, {"scale_cb", (caddr_t)scale_cb }, {"help_cb", (caddr_t)help_cb }, {"exit_cb", (caddr_t)exit_cb } }; static Widget dog1_id; static Widget dog2_id; static Widget dog3_id; static Widget help_id; main(argc, argv) int argc; char **argv; { Widget shell; Display *display; Widget app_main = NULL; Arg args[3]; MrmInitialize (); SquareMrmInitialize(); DogMrmInitialize(); XtToolkitInitialize(); app_context = XtCreateApplicationContext(); display = XtOpenDisplay(app_context, NULL, argv[0], "Dogs", NULL, 0, &argc, argv); if (display == NULL) { fprintf(stderr, "%s: Can't open display\n", argv[0]); exit(1); } XtSetArg (args[0], XtNallowShellResize, True); XtSetArg (args[1], XtNminWidth, 620); XtSetArg (args[2], XtNminHeight, 370); shell = XtAppCreateShell(argv[0], NULL, applicationShellWidgetClass, display, args, 3); if (MrmOpenHierarchy (1, mrm_vec, NULL, &mrm_id) != MrmSUCCESS) exit(0); MrmRegisterNames(mrm_names, XtNumber(mrm_names)); MrmFetchWidget (mrm_id, "app_main", shell, &app_main, &mrm_class); XtManageChild(app_main); XtRealizeWidget(shell); XtAppMainLoop(app_context); } static void create_cb(w, id, reason) Widget w; int *id; unsigned long *reason; { switch (*id) { case k_dog1_id: dog1_id = w; break; case k_dog2_id: dog2_id = w; break; case k_dog3_id: dog3_id = w; break; case k_help_id: help_id = w; XtUnmanageChild((Widget)XmMessageBoxGetChild(help_id, XmDIALOG_CANCEL_BUTTON)); XtUnmanageChild((Widget)XmMessageBoxGetChild(help_id, XmDIALOG_HELP_BUTTON)); break; } } static void bark_cb (w, volume, cb) Widget w; int *volume; XtPointer cb; { XBell(XtDisplay(w), *volume); } static void tb_cb (w, tag, cb) Widget w; int *tag; XmToggleButtonCallbackStruct *cb; { Arg args[1]; Widget dog; switch (*tag) { case(1) : dog = dog1_id; break; case(2) : dog = dog2_id; break; case(3) : dog = dog3_id; break; } XtSetArg(args[0], SquareNmakeSquare, cb->set); XtSetValues(dog, args, 1); } static void scale_cb(w, tag, cb) Widget w; int *tag; XmScaleCallbackStruct *cb; { Arg args[1]; Widget dog; switch (*tag) { case(1) : dog = dog1_id; break; case(2) : dog = dog2_id; break; case(3) : dog = dog3_id; break; } XtSetArg(args[0], DogNwagTime, cb->value); XtSetValues(dog, args, 1); } static void help_cb (w, name, cb) Widget w; XmString name; XtPointer cb; { Arg args[1]; if (name == NULL) return; XtSetArg (args[0], XmNmessageString, name); XtSetValues(help_id, args, 1); XtManageChild(help_id); } static void exit_cb (w, name, cb) Widget w; XmString name; XtPointer cb; { exit(0); }