File: FileSelect3.c

package info (click to toggle)
motif 2.3.4-13
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 81,160 kB
  • ctags: 51,769
  • sloc: ansic: 596,938; cpp: 3,951; yacc: 2,854; makefile: 2,070; csh: 1,199; sh: 1,070; lex: 455
file content (224 lines) | stat: -rw-r--r-- 6,012 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/* 
 * Motif
 *
 * Copyright (c) 1987-2012, The Open Group. All rights reserved.
 *
 * These libraries and programs are free software; you can
 * redistribute them and/or modify them under the terms of the GNU
 * Lesser General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * These libraries and programs are distributed in the hope that
 * they will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE. See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with these librararies and programs; if not, write
 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
 * Floor, Boston, MA 02110-1301 USA
*/ 
/* 
 * HISTORY
*/ 
#ifdef REV_INFO
#ifndef lint
static char rcsid[] = "$TOG: FileSelect3.c /main/11 1999/05/28 15:46:09 jff $"
#endif
#endif
/*
*  (c) Copyright 1987, 1988, 1989 HEWLETT-PACKARD COMPANY */

/* 
 * Create a file selection box with menu bar and button children, as 
 *  detailed in the Motif 1.2 specification
 */

#include <signal.h>
#include <unistd.h>
#include <testlib.h>

#define TARGET_DIR "/tmp/FS/fourteencharac/fourteencharac/fourteencharac/"

Widget fsbox;            /* File Selection Box widget   */
Widget pushButton, toggleButton, arrowButton, drawnButton;
Widget menuBar, cascButton1, cascButton2, pulldown1, pulldown2;
Widget buttonsa[3], buttonsb[3];
Widget drawingArea, scale1;

/* callbacks */

static void OkCB();

static XtCallbackRec ok_cb[] = {
  { OkCB, NULL},
  { NULL, NULL}
};

static void HelpCB();

static XtCallbackRec help_cb[] = {
  { HelpCB, NULL},
  { NULL, NULL}
};


/*-------------------------------------------------------------
**      OkCB        - callback for ok button
*/

/* ARGSUSED */

static void OkCB(Widget w, caddr_t client_data, caddr_t call_data)
{
  printf("OK Callback received\n");
}	

/*-------------------------------------------------------------
**      HelpCB        - callback for help button
*/

/* ARGSUSED */

static void HelpCB(Widget w, caddr_t client_data, caddr_t call_data)
{
  printf("Help Callback received\n");
}


void main (argc,argv)
unsigned int argc;
char **argv;
{
  Arg args[10]; 
  register int n;
  XmString tcs;
  Widget  Frame;

#ifndef MOTIF1_1

/* Ensure target directory for FSB is set up properly */

  if ( access(TARGET_DIR,F_OK | R_OK) ) {
	printf("Target directory %s is not set up\n",TARGET_DIR);
	exit(1);
  }

  /*  initialize toolkit */

  CommonTestInit(argc, argv);
  
  n = 0;
  Frame = XmCreateFrame(Shell1, "Frame", args, n);
  XtManageChild(Frame);

  tcs = XmStringCreateSimple(TARGET_DIR);

  n = 0;
  XtSetArg(args[n], XmNdirMask, tcs);                         	n++;
  XtSetArg(args[n], XmNokCallback, ok_cb); 			n++;
  XtSetArg(args[n], XmNhelpCallback, help_cb); 			n++;
  XtSetArg(args[n], XmNchildPlacement, XmPLACE_ABOVE_SELECTION); n++;
  XtSetArg(args[n], XmNheight, 410); 				n++;
  XtSetArg(args[n], XmNwidth, 400); 				n++;
  XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); 		n++;
  fsbox = XmCreateFileSelectionBox(Frame, "fsbox", args, n);

  XmStringFree(tcs);

  n = 0;
  XtSetArg(args[n], XmNwidth, 100); 				n++;
  XtSetArg(args[n], XmNheight, 75); 				n++;
  drawingArea = XmCreateDrawingArea(fsbox, "Drawarea", args, n);
  XtManageChild(drawingArea);

  n = 0;
  XtSetArg(args[n], XmNorientation, XmHORIZONTAL); 		n++;
  XtSetArg(args[n], XmNscaleWidth, 200); 			n++;
  scale1 = XmCreateScale(drawingArea, "Scale", args, n);
  XtManageChild(scale1);

  n = 0;
  pushButton = XmCreatePushButton(fsbox, "PushMe1", args, n);
  XtManageChild(pushButton);

  tcs = XmStringLtoRCreate("ToggleMe2", XmSTRING_DEFAULT_CHARSET); 

  XtSetArg(args[n], XmNlabelString, tcs); 			n++;
  toggleButton = XmCreateToggleButton(fsbox, "ToggleMe2", args, n);
  XtManageChild(toggleButton);

  XmStringFree(tcs);

  n = 0;
  XtSetArg(args[n], XmNarrowDirection, XmARROW_UP); 		n++;
  arrowButton = XmCreateArrowButton(fsbox, "PointMe3", args, n);
  XtManageChild(arrowButton);

  tcs = XmStringLtoRCreate("DrawnButton", XmSTRING_DEFAULT_CHARSET);

  n = 0;
  XtSetArg(args[n], XmNpushButtonEnabled, True); 		n++;
  XtSetArg(args[n], XmNlabelString, tcs); 			n++;
  drawnButton = XmCreateDrawnButton(fsbox, "drawnbutton", args, n);
  XtManageChild(drawnButton);

  XmStringFree(tcs);

  n = 0;
  menuBar = XmCreateMenuBar(fsbox, "menuBar", args, n);
  XtManageChild(menuBar);

  n = 0;
  pulldown1 = XmCreatePulldownMenu(menuBar, "Pulldown1", args, n);
  pulldown2 = XmCreatePulldownMenu(menuBar, "Pulldown2", args, n);

  n = 0;
  XtSetArg(args[n], XmNsubMenuId, pulldown1); 			n++;
  cascButton1 = XmCreateCascadeButton(menuBar, "Cascade1", args, n);
  XtManageChild(cascButton1);

  n = 0;
  XtSetArg(args[n], XmNsubMenuId, pulldown2); 			n++;
  cascButton2 = XmCreateCascadeButton(menuBar, "Cascade2", args, n);
  XtManageChild(cascButton2);

  buttonsa[0] = XmCreatePushButton(pulldown1, "button11", NULL, 0);
  buttonsa[1] = XmCreatePushButton(pulldown1, "button12", NULL, 0);
  buttonsa[2] = XmCreatePushButton(pulldown1, "button13", NULL, 0);
  buttonsb[0] = XmCreatePushButton(pulldown2, "button21", NULL, 0);
  buttonsb[1] = XmCreateSeparator(pulldown2, "separator22", NULL, 0);
  buttonsb[2] = XmCreatePushButton(pulldown2, "button31", NULL, 0);
  XtManageChildren(buttonsa, 3);
  XtManageChildren(buttonsb, 3);

  XtManageChild(fsbox);
  XtRealizeWidget(Shell1);

  CommonPause();
  CommonPause();

  n = 0;
  XtSetArg(args[n], XmNchildPlacement, XmPLACE_BELOW_SELECTION); 	n++;
  XtSetValues(fsbox, args, n);

  CommonPause();

  n = 0;
  XtSetArg(args[n], XmNchildPlacement, XmPLACE_TOP); 			n++;
  XtSetValues(fsbox, args, n);

  CommonPause();
  CommonPause();  /* Exit */

  /*  process events  */
  XtAppMainLoop(app_context);

#else

  printf("This test is for 1.2 only\n");

#endif
}