Debian Codegraph @

demos/unsupported/dainput/dainput_ui.c

raw
1 /* $XConsortium: dainput_ui.c /main/5 1995/07/15 20:47:32 drk $ */
2 /*
3 * Motif
4 *
5 * Copyright (c) 1987-2012, The Open Group. All rights reserved.
6 *
7 * These libraries and programs are free software; you can
8 * redistribute them and/or modify them under the terms of the GNU
9 * Lesser General Public License as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * These libraries and programs are distributed in the hope that
14 * they will be useful, but WITHOUT ANY WARRANTY; without even the
15 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU Lesser General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with these librararies and programs; if not, write
21 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
22 * Floor, Boston, MA 02110-1301 USA
23 *
24 */
25 /*
26 * HISTORY
27 */
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <memory.h>
32 #include <Xm/Xm.h>
33 #include <Xm/CascadeB.h>
34 #include <Xm/CascadeBG.h>
35 #include <Xm/DrawingA.h>
36 #include <Xm/MainW.h>
37 #include <Xm/PushB.h>
38 #include <Xm/RowColumn.h>
39 #include <Xm/XmIm.h>
40 #include "dainput.h"
41
42 #define WI_DAINPUT 0
43 #define WI_MAINWINDOW 1
44 #define WI_MENUBAR 2
45 #define WI_FILE 3
46 #define WI_FILEMENU 4
47 #define WI_EXIT 5
48 #define WI_HELP 6
49 #define WI_HELPMENU 7
50 #define WI_OVERVIEW 8
51 #define WI_WORKAREA 9
52
53 /****************************************************************
54 *
55 * Main C code for presentation component
56 *
57 ****************************************************************/
58
59 /**************************************************************
60 * DaCreateGui:
61 **************************************************************/
62 Widget DaCreateGui(char * name,
63 char * aclass,
64 int argc,
65 char ** argv,
66 Display * display)
67 {
68 Arg args[15];
69 Widget widget_array[10];
70 int n;
71
72 /***************** object of type : ApplicationShell *****************/
73 n = 0;
74 /* Setup argc & argv attribute */
75 XtSetArg(args[n], XtNargc, argc); n++;
76 XtSetArg(args[n], XtNargv, argv); n++;
77
78 widget_array[WI_DAINPUT] =
79 XtAppCreateShell(name, aclass, applicationShellWidgetClass,
80 display, args, n);
81
82 /***************** mainWindow : XmMainWindow *****************/
83 widget_array[WI_MAINWINDOW] =
84 XmCreateMainWindow(widget_array[WI_DAINPUT], "mainWindow", NULL, 0);
85
86 /***************** menuBar : XmMenuBar *****************/
87 widget_array[WI_MENUBAR] =
88 XmCreateMenuBar(widget_array[WI_MAINWINDOW], "menuBar", NULL, 0);
89
90 /***************** File : XmCascadeButton *****************/
91 widget_array[WI_FILE] =
92 XmCreateCascadeButton(widget_array[WI_MENUBAR], "File", NULL, 0);
93
94 /***************** fileMenu : XmPulldownMenu *****************/
95 widget_array[WI_FILEMENU] =
96 XmCreatePulldownMenu(widget_array[WI_MENUBAR], "fileMenu", NULL, 0);
97 {
98 Arg args[1];
99 XtSetArg(args[0], XmNsubMenuId, widget_array[WI_FILEMENU]);
100 XtSetValues(widget_array[WI_FILE], args, 1);
101 }
102
103 /***************** Exit : XmPushButton *****************/
104 widget_array[WI_EXIT] =
105 XmCreatePushButton(widget_array[WI_FILEMENU], "Exit", NULL, 0);
106
107 XtAddCallback(widget_array[WI_EXIT],
108 XmNactivateCallback, DaExit, NULL);
109
110 /***************** Help : XmCascadeButton *****************/
111 widget_array[WI_HELP] =
112 XmCreateCascadeButton(widget_array[WI_MENUBAR], "Help", NULL, 0);
113
114 /***************** helpMenu : XmPulldownMenu *****************/
115 widget_array[WI_HELPMENU] =
116 XmCreatePulldownMenu(widget_array[WI_MENUBAR], "helpMenu", NULL, 0);
117 {
118 Arg args[1];
119 XtSetArg(args[0], XmNsubMenuId, widget_array[WI_HELPMENU]);
120 XtSetValues(widget_array[WI_HELP], args, 1);
121 }
122
123 /***************** Overview : XmPushButton *****************/
124 widget_array[WI_OVERVIEW] =
125 XmCreatePushButton(widget_array[WI_HELPMENU], "Overview", NULL, 0);
126
127 XtAddCallback(widget_array[WI_OVERVIEW],
128 XmNactivateCallback, DaOverView, NULL);
129
130 /***************** workArea : XmDrawingArea *****************/
131 n = 0;
132 XtSetArg(args[n], XmNwidth, 300); n++;
133 XtSetArg(args[n], XmNheight, 35); n++;
134 widget_array[WI_WORKAREA] =
135 XmCreateDrawingArea(widget_array[WI_MAINWINDOW], "workArea", args, n);
136
137 /*
138 * Register drawing area for input method support and set input
139 * context values.
140 */
141 XmImRegister(widget_array[WI_WORKAREA], 0);
142 {
143 Pixel bg, fg;
144 Pixmap bg_pixmap;
145 n = 0;
146 XtSetArg(args[n], XmNbackground, &bg); n++;
147 XtSetArg(args[n], XmNforeground, &fg); n++;
148 XtSetArg(args[n], XmNbackgroundPixmap, &bg_pixmap);n++;
149 XtGetValues(widget_array[WI_WORKAREA], args, n);
150 n = 0;
151 XtSetArg(args[n], XmNbackground, bg); n++;
152 XtSetArg(args[n], XmNforeground, fg); n++;
153 XtSetArg(args[n], XmNbackgroundPixmap, bg_pixmap);n++;
154 XmImSetValues(widget_array[WI_WORKAREA], args, n);
155 }
156
157 /*
158 * Add event handler for focus events. This is needed for the
159 * input method to correctly display the input area.
160 */
161 XtAddEventHandler(widget_array[WI_WORKAREA],
162 EnterWindowMask|LeaveWindowMask|FocusChangeMask,
163 False, DaFocusHandler, NULL);
164
165 XtAddCallback(widget_array[WI_WORKAREA],
166 XmNexposeCallback, DaRedrawText, NULL);
167
168 XtAddCallback(widget_array[WI_WORKAREA],
169 XmNinputCallback, DaInputText, NULL);
170
171 XtAddCallback(widget_array[WI_WORKAREA],
172 XmNresizeCallback, DaResizedText, NULL);
173
174
175 /***************** menuBar : XmMenuBar *****************/
176 n = 0;
177 XtSetArg(args[n], XmNmenuHelpWidget, widget_array[WI_HELP]); n++;
178 XtSetValues(widget_array[WI_MENUBAR], args, n);
179
180
181 XtManageChild(widget_array[WI_EXIT]);
182 XtManageChild(widget_array[WI_FILE]);
183 XtManageChild(widget_array[WI_OVERVIEW]);
184 XtManageChild(widget_array[WI_HELP]);
185 XtManageChild(widget_array[WI_MENUBAR]);
186 XtManageChild(widget_array[WI_WORKAREA]);
187 XtManageChild(widget_array[WI_MAINWINDOW]);
188
189 /*
190 * Return the first created widget.
191 */
192 return widget_array[WI_DAINPUT];
193 }
194