2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
32 static char rcsid[] = "$XConsortium: dogs.c /main/3 1995/10/27 10:43:03 rswiston $"
36 /*****************************************************************************
38 * dogs.c - Square & Dog widget demo source file.
40 ******************************************************************************/
44 #include <Mrm/MrmPublic.h>
48 XtAppContext app_context;
55 static void create_cb();
56 static void bark_cb();
58 static void scale_cb();
59 static void help_cb();
60 static void exit_cb();
62 static MrmHierarchy mrm_id = 0;
63 static char *mrm_vec[]={"dogs.uid", NULL};
64 static MrmCode mrm_class;
65 static MRMRegisterArg mrm_names[] = {
66 {"create_cb", (XtPointer)create_cb },
67 {"bark_cb", (XtPointer)bark_cb },
68 {"tb_cb", (XtPointer)tb_cb },
69 {"scale_cb", (XtPointer)scale_cb },
70 {"help_cb", (XtPointer)help_cb },
71 {"exit_cb", (XtPointer)exit_cb }
74 static Widget dog1_id;
75 static Widget dog2_id;
76 static Widget dog3_id;
77 static Widget help_id;
85 Widget app_main = NULL;
89 SquareMrmInitialize();
92 XtToolkitInitialize();
93 app_context = XtCreateApplicationContext();
94 display = XtOpenDisplay(app_context, NULL, argv[0], "Dogs",
95 NULL, 0, &argc, argv);
97 if (display == NULL) {
98 fprintf(stderr, "%s: Can't open display\n", argv[0]);
102 XtSetArg (args[0], XtNallowShellResize, True);
103 XtSetArg (args[1], XtNminWidth, 620);
104 XtSetArg (args[2], XtNminHeight, 370);
105 shell = XtAppCreateShell(argv[0], NULL, applicationShellWidgetClass,
108 if (MrmOpenHierarchy(1, mrm_vec, NULL, &mrm_id) != MrmSUCCESS) exit(0);
109 MrmRegisterNames(mrm_names, XtNumber(mrm_names));
110 MrmFetchWidget (mrm_id, "app_main", shell, &app_main, &mrm_class);
112 XtManageChild(app_main);
113 XtRealizeWidget(shell);
114 XtAppMainLoop(app_context);
117 static void create_cb(w, id, reason)
120 unsigned long *reason;
123 case k_dog1_id: dog1_id = w; break;
124 case k_dog2_id: dog2_id = w; break;
125 case k_dog3_id: dog3_id = w; break;
128 XtUnmanageChild((Widget)XmMessageBoxGetChild(help_id,
129 XmDIALOG_CANCEL_BUTTON));
130 XtUnmanageChild((Widget)XmMessageBoxGetChild(help_id,
131 XmDIALOG_HELP_BUTTON));
136 static void bark_cb (w, volume, cb)
141 XBell(XtDisplay(w), *volume);
144 static void tb_cb (w, tag, cb)
147 XmToggleButtonCallbackStruct *cb;
153 case(1) : dog = dog1_id; break;
154 case(2) : dog = dog2_id; break;
155 case(3) : dog = dog3_id; break;
157 XtSetArg(args[0], SquareNmakeSquare, cb->set);
158 XtSetValues(dog, args, 1);
161 static void scale_cb(w, tag, cb)
164 XmScaleCallbackStruct *cb;
170 case(1) : dog = dog1_id; break;
171 case(2) : dog = dog2_id; break;
172 case(3) : dog = dog3_id; break;
174 XtSetArg(args[0], DogNwagTime, cb->value);
175 XtSetValues(dog, args, 1);
178 static void help_cb (w, name, cb)
185 if (name == NULL) return;
186 XtSetArg (args[0], XmNmessageString, name);
187 XtSetValues(help_id, args, 1);
188 XtManageChild(help_id);
191 static void exit_cb (w, name, cb)