~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to Xw/testxw.c

  • Committer: Bazaar Package Importer
  • Author(s): Christian Marillat
  • Date: 2004-08-29 10:53:42 UTC
  • Revision ID: james.westby@ubuntu.com-20040829105342-qgmnry37eadfkoxx
Tags: upstream-1.1.3
ImportĀ upstreamĀ versionĀ 1.1.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * textxw.c     A simple test program for the Xw Widget Set
 
3
 *
 
4
 * Copyright (c) 1998 Rasca Gmelch
 
5
 *
 
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.
 
13
 *
 
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
 
20
 * SOFTWARE.
 
21
 */
 
22
 
 
23
#include <stdio.h>
 
24
#include <X11/Intrinsic.h>
 
25
#include <X11/StringDefs.h>
 
26
#include <X11/Shell.h>
 
27
#include <Xw/Box.h>
 
28
#include <Xw/Label.h>
 
29
#include <Xw/Button.h>
 
30
#include <Xw/Toggle.h>
 
31
#include <Xw/Field.h>
 
32
#include "testxw.xbm"
 
33
 
 
34
Widget toplevel, form, t1, t2;
 
35
XtAppContext app_con;
 
36
 
 
37
void
 
38
Quit (Widget w, XtPointer client, XtPointer call)
 
39
{
 
40
        XtVaSetValues ((Widget)client, XtNsensitive, True, NULL);
 
41
        XtVaSetValues ((Widget)w, XtNsensitive, False, NULL);
 
42
        XtUnmapWidget (toplevel);
 
43
        XtDestroyWidget (toplevel);
 
44
        exit(0);
 
45
}
 
46
 
 
47
void
 
48
Toggle (Widget w, XtPointer client, XtPointer call)
 
49
{
 
50
        printf ("  toggle pressed\n");
 
51
}
 
52
 
 
53
void
 
54
TestCallback (Widget w, XtPointer client, XtPointer call)
 
55
{
 
56
        FieldReturnStruct *ret;
 
57
        char *str, *s, *val;
 
58
 
 
59
        ret = (FieldReturnStruct *) call;
 
60
        printf("ret->string=%s\n", ret->string);
 
61
        str = XwFieldGetString(w);
 
62
        printf("TEXT: item=%s\n", str);
 
63
        s = str;
 
64
        while (*s)
 
65
                *s++ = '*';
 
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);
 
72
        XtFree(str);
 
73
}
 
74
 
 
75
/*
 
76
 */
 
77
void
 
78
EchoCallback (w, client, call)
 
79
Widget w;
 
80
XtPointer client;
 
81
XtPointer call;
 
82
{
 
83
  FieldReturnStruct *ret;
 
84
 
 
85
  ret = (FieldReturnStruct *) call;
 
86
  printf("ret->string=%s\n", ret->string);
 
87
}
 
88
 
 
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",
 
99
"*quit.label: &Quit",
 
100
"*toggle.label: &Toggle",
 
101
/* "*quit.accelerators: Alt<KeyPress>q: set() notify() unset()", */
 
102
        NULL
 
103
};
 
104
 
 
105
/*
 
106
 */
 
107
int
 
108
main (int argc, char **argv)
 
109
{
 
110
        Widget quit, label, toggle, pic, box;
 
111
        Pixmap pic_bm;
 
112
        Display *disp;
 
113
        Window root;
 
114
 
 
115
        toplevel = XtVaAppInitialize (&app_con, "XTextxw", NULL, 0,
 
116
                             &argc, argv, fallback_resources, XtNinput, True, NULL);
 
117
 
 
118
        disp = XtDisplay (toplevel);
 
119
        root = RootWindow (disp, DefaultScreen (disp));
 
120
        pic_bm = XCreateBitmapFromData (disp, root,
 
121
                                testxw_bits, testxw_width, testxw_height);
 
122
 
 
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,
 
128
                                NULL);
 
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);
 
137
 
 
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", */
 
142
                                /* NULL); */
 
143
/*      XtAddCallback(t1, XtNactivateCallback, EchoCallback, (XtPointer) NULL); */
 
144
 
 
145
/*      t2 = XtVaCreateManagedWidget("monospaced", xwFieldWidgetClass, form,
 
146
                               XtNstring, "Fixed Length",
 
147
                               XtNinsertPosition, 0,
 
148
                               XtNlength, 16,
 
149
                               XtNfromVert, t1,
 
150
                               NULL);
 
151
        XtAddCallback(t2, XtNactivateCallback, EchoCallback, (XtPointer) NULL); */
 
152
 
 
153
        XtRealizeWidget(toplevel);
 
154
        /* XtInstallAllAccelerators (form, quit); */
 
155
        /* XtInstallAllAccelerators (form, toggle); */
 
156
        XtAppMainLoop(app_con);
 
157
        return (0);
 
158
}
 
159