2
* textxw.c A simple test program for the Xw Widget Set
4
* Copyright (c) 1998 Rasca Gmelch
6
* Permission to use, copy, modify, distribute, and sell this software and its
7
* documentation for any purpose is hereby granted without fee, provided that
8
* the above copyright notice appear in all copies and that both that
9
* copyright notice and this permission notice appear in supporting
10
* documentation. The author makes no representations about the suitability
11
* of this software for any purpose. It is provided "as is" without express
12
* or implied warranty.
14
* THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
16
* THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
19
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
24
#include <X11/Intrinsic.h>
25
#include <X11/StringDefs.h>
26
#include <X11/Shell.h>
29
#include <Xw/Button.h>
30
#include <Xw/Toggle.h>
34
Widget toplevel, form, t1, t2;
38
Quit (Widget w, XtPointer client, XtPointer call)
40
XtVaSetValues ((Widget)client, XtNsensitive, True, NULL);
41
XtVaSetValues ((Widget)w, XtNsensitive, False, NULL);
42
XtUnmapWidget (toplevel);
43
XtDestroyWidget (toplevel);
48
Toggle (Widget w, XtPointer client, XtPointer call)
50
printf (" toggle pressed\n");
54
TestCallback (Widget w, XtPointer client, XtPointer call)
56
FieldReturnStruct *ret;
59
ret = (FieldReturnStruct *) call;
60
printf("ret->string=%s\n", ret->string);
61
str = XwFieldGetString(w);
62
printf("TEXT: item=%s\n", str);
66
XwFieldSetString(w, str);
67
XwFieldInsert(w, 4, "4");
68
XwFieldReplace(w, 8, 10, "XXX");
69
XwFieldSetSelection (w, 5, 10, (Time)0);
70
XtVaGetValues(w, XtNstring, &val, NULL);
71
printf("GetValues: %s\n", val);
78
EchoCallback (w, client, call)
83
FieldReturnStruct *ret;
85
ret = (FieldReturnStruct *) call;
86
printf("ret->string=%s\n", ret->string);
89
static char *fallback_resources[] = {
90
"*XwLabel*font: -*-helvetica-*",
91
"*background: #e0e0e0",
92
"*variablewidth*font: -adobe-helvetica-medium-r-normal--*-120-*",
93
"*monospaced*font: -*-courier-medium-r-*-*-14-*-*-*-*-*-*",
94
"*form*font: -*-fixed-bold-r-normal-*-13-*",
95
"*Form*top: ChainTop",
96
"*Form*bottom: ChainBottom",
97
"*Form*left: ChainLeft",
98
"*Form*right: ChainRight",
100
"*toggle.label: &Toggle",
101
/* "*quit.accelerators: Alt<KeyPress>q: set() notify() unset()", */
108
main (int argc, char **argv)
110
Widget quit, label, toggle, pic, box;
115
toplevel = XtVaAppInitialize (&app_con, "XTextxw", NULL, 0,
116
&argc, argv, fallback_resources, XtNinput, True, NULL);
118
disp = XtDisplay (toplevel);
119
root = RootWindow (disp, DefaultScreen (disp));
120
pic_bm = XCreateBitmapFromData (disp, root,
121
testxw_bits, testxw_width, testxw_height);
123
form = XtVaCreateManagedWidget("form", xwBoxWidgetClass, toplevel,
124
XtNexpand, True, XtNorientation, XtorientVertical, NULL);
125
box = XtVaCreateManagedWidget("box1", xwBoxWidgetClass, form,
126
XtNorientation, XtorientHorizontal, NULL);
127
quit = XtVaCreateManagedWidget ("quit", xwButtonWidgetClass, box,
129
label= XtVaCreateManagedWidget("label", xwLabelWidgetClass, box,
130
XtNlabel, "This &is an example \n2 line label ..", NULL);
131
toggle = XtVaCreateManagedWidget ("toggle", xwToggleWidgetClass, box,
132
XtNstate, True, NULL);
133
pic = XtVaCreateManagedWidget ("pic", xwButtonWidgetClass, box,
134
XtNbitmap, pic_bm, NULL);
135
XtAddCallback (quit, XtNcallback, Quit, (XtPointer) toggle);
136
XtAddCallback(toggle, XtNcallback, Toggle, (XtPointer) quit);
138
box = XtVaCreateManagedWidget("box2", xwBoxWidgetClass, form,
139
XtNorientation, XtorientVertical, XtNexpand, True, NULL);
140
/* t1 = XtVaCreateManagedWidget("variablewidth", xwFieldWidgetClass, box, */
141
/* XtNstring, "A Free alternative to the Motif XmTextField", */
143
/* XtAddCallback(t1, XtNactivateCallback, EchoCallback, (XtPointer) NULL); */
145
/* t2 = XtVaCreateManagedWidget("monospaced", xwFieldWidgetClass, form,
146
XtNstring, "Fixed Length",
147
XtNinsertPosition, 0,
151
XtAddCallback(t2, XtNactivateCallback, EchoCallback, (XtPointer) NULL); */
153
XtRealizeWidget(toplevel);
154
/* XtInstallAllAccelerators (form, quit); */
155
/* XtInstallAllAccelerators (form, toggle); */
156
XtAppMainLoop(app_con);