annotate etc/tests/external-widget/test-ew-motif.c @ 3040:cf9ebb038c1c

[xemacs-hg @ 2005-11-01 22:50:59 by viteno] Update xemacs_extra_name.
author viteno
date Tue, 01 Nov 2005 22:50:59 +0000
parents ac2d302a0011
children 03ab78e48ef6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
1 #include <Xm/Xm.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
2 #include <Xm/RowColumn.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
3 #include <Xm/Scale.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
4 #include <Xm/PushB.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
5 #include <Xm/Label.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
6 #include <Xm/Text.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
7 #include <Xm/PanedW.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
8 #include "ExternalClient.h"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
9
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
10 #ifdef TOOLTALK
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
11 #include <desktop/tt_c.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
12 char *HxProcID;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
13 #endif
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
14
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
15 XtAppContext xt_app_con;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
16
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
17 void ScaleValueChangedCB(Widget scale, XtPointer app_data, XtPointer widget_data)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
18 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
19 XmScaleCallbackStruct *xms = (XmScaleCallbackStruct *) widget_data;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
20 Widget label = (Widget) app_data;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
21 char labelarr[10];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
22 XmString labelstr;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
23 #if 0
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
24 sprintf(labelarr, "%d", xms->value);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
25 labelstr = XmStringCreateLocalized(labelarr);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
26 XtVaSetValues(label, XmNlabelString, labelstr, NULL);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
27 XmStringFree(labelstr);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
28 #endif
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
29 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
30
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
31 #ifdef TOOLTALK
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
32 static void
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
33 handle_tt_input(XtPointer client_data, int *source, XtInputId *id)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
34 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
35 Tt_message m = tt_message_receive();
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
36
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
37 if (m && !(tt_ptr_error(m))) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
38 tt_message_destroy(m);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
39 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
40 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
41
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
42 Tt_status
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
43 HxInitializeToolTalk()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
44 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
45 static Boolean initialized = FALSE;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
46
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
47 if (!initialized) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
48 int fd;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
49 Tt_status status;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
50
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
51 HxProcID = tt_open();
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
52 fd = tt_fd();
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
53 if (TT_OK != (status = tt_session_join( tt_default_session() )))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
54 return status;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
55 (void)XtAppAddInput(xt_app_con, fd, (void *)XtInputReadMask, handle_tt_input, NULL);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
56 initialized = TRUE;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
57 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
58
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
59 return TT_OK;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
60 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
61 #endif
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
62
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
63 main(int argc, char **argv)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
64 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
65 Widget shell, rowcolumn, scale, pushbutton, label1, label2, text;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
66 Widget paned, text2;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
67 int n, i;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
68 Widget widlist[100];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
69 Widget emacscli[100];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
70 Arg args[100];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
71 int no_ews = 1;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
72 char buf[100];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
73
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
74 if (argc > 1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
75 no_ews = atoi (argv[1]);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
76
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
77 shell = XtAppInitialize(&xt_app_con, "Testmotif", NULL, 0,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
78 &argc, argv, NULL, NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
79
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
80 #ifdef TOOLTALK
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
81 HxInitializeToolTalk();
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
82 #endif
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
83
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
84 rowcolumn = XmCreateRowColumn(shell, "rowcolumn", NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
85 XtManageChild(rowcolumn);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
86
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
87 n = 0;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
88 XtSetArg(args[n], XmNtraversalOn, TRUE); n++;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
89 #if 0
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
90 label1 = XmCreateLabel(rowcolumn, "label1", args, n);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
91 #endif
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
92 label1 = XtVaCreateWidget("label1", xmLabelWidgetClass, rowcolumn,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
93 XmNwidth, 50, XmNheight, 30,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
94 XmNtraversalOn, TRUE, NULL);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
95 label2 = XmCreateLabel(rowcolumn, "label2", NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
96 scale = XmCreateScale(rowcolumn, "scale", NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
97 XtAddCallback(scale, XmNvalueChangedCallback, ScaleValueChangedCB, label1);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
98 paned = XmCreatePanedWindow(rowcolumn, "paned", NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
99 n = 0;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
100 widlist[n++] = label1;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
101 widlist[n++] = label2;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
102 widlist[n++] = scale;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
103 widlist[n++] = paned;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
104 XtManageChildren(widlist, n);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
105
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
106 pushbutton = XmCreatePushButton(paned, "pushbutton", NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
107 text = XmCreateText(paned, "text", NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
108 for (i=0; i<no_ews; i++) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
109 sprintf (buf, "extcli%d", i);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
110 emacscli[i] = XtVaCreateWidget(buf, externalClientWidgetClass, paned,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
111 XmNwidth, 500, XmNheight, 200,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
112 XmNtraversalOn, TRUE,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
113 #ifdef TOOLTALK
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
114 XtNuseToolTalk, TRUE,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
115 #endif
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
116 NULL);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
117 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
118 text2 = XmCreateText(paned, "text2", NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
119 n = 0;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
120 widlist[n++] = pushbutton;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
121 widlist[n++] = text;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
122 for (i=0; i<no_ews; i++)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
123 widlist[n++] = emacscli[i];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
124 widlist[n++] = text2;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
125 XtManageChildren(widlist, n);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
126
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
127 XtRealizeWidget(shell);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
128
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
129 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
130 XmString lab;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
131 char labarr[1000];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
132 char tmpbuf[50];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
133
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
134 strcpy (labarr, "window:");
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
135 for (i=0; i<no_ews; i++) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
136 sprintf (tmpbuf, " %d", XtWindow(emacscli[i]));
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
137 strcat (labarr, tmpbuf);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
138 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
139 lab = XmStringCreateLocalized(labarr);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
140 XtVaSetValues(label2, XmNlabelString, lab, NULL);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
141 XmStringFree(lab);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
142 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
143
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
144 XtAppMainLoop(xt_app_con);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
145 }