annotate etc/tests/external-widget/test-ew-motif.c @ 5781:0853e1ec8529

Use alloca_{rawbytes,ibytes} in #'copy-file, #'insert-file-contents-internal src/ChangeLog addition: 2014-01-20 Aidan Kehoe <kehoea@parhasard.net> * fileio.c (Fcopy_file, Finsert_file_contents_internal): Use alloca_{rawbytes,ibytes} here instead of the implicit alloca on the stack; doesn't change where the buffers are allocated for these two functions, but does mean that decisions about alloca vs. malloc based on buffer size are made in the same place (ultimately, the ALLOCA() macro).
author Aidan Kehoe <kehoea@parhasard.net>
date Mon, 20 Jan 2014 17:53:07 +0000
parents 6a8c6c6f6c8e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4894
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
1 /* Test external widget code in Motif.
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
2 Copyright (C) 1993 Ben Wing.
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
3
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
4 This file is part of XEmacs.
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
5
5412
6a8c6c6f6c8e Convert to GPLv3 or later from plain text GPLv2 or later.
Mats Lidell <matsl@xemacs.org>
parents: 5231
diff changeset
6 XEmacs is free software: you can redistribute it and/or modify it
4894
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
7 under the terms of the GNU General Public License as published by the
5412
6a8c6c6f6c8e Convert to GPLv3 or later from plain text GPLv2 or later.
Mats Lidell <matsl@xemacs.org>
parents: 5231
diff changeset
8 Free Software Foundation, either version 3 of the License, or (at your
6a8c6c6f6c8e Convert to GPLv3 or later from plain text GPLv2 or later.
Mats Lidell <matsl@xemacs.org>
parents: 5231
diff changeset
9 option) any later version.
4894
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
10
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
14 for more details.
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
15
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
16 You should have received a copy of the GNU General Public License
5412
6a8c6c6f6c8e Convert to GPLv3 or later from plain text GPLv2 or later.
Mats Lidell <matsl@xemacs.org>
parents: 5231
diff changeset
17 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
4894
03ab78e48ef6 Add copyright and license information based on Ben's recollections.
Jerry James <james@xemacs.org>
parents: 2
diff changeset
18
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
19 #include <Xm/Xm.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
20 #include <Xm/RowColumn.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
21 #include <Xm/Scale.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
22 #include <Xm/PushB.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
23 #include <Xm/Label.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
24 #include <Xm/Text.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
25 #include <Xm/PanedW.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
26 #include "ExternalClient.h"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
27
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
28 #ifdef TOOLTALK
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
29 #include <desktop/tt_c.h>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
30 char *HxProcID;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
31 #endif
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
32
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
33 XtAppContext xt_app_con;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
34
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
35 void ScaleValueChangedCB(Widget scale, XtPointer app_data, XtPointer widget_data)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
36 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
37 XmScaleCallbackStruct *xms = (XmScaleCallbackStruct *) widget_data;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
38 Widget label = (Widget) app_data;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
39 char labelarr[10];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
40 XmString labelstr;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
41 #if 0
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
42 sprintf(labelarr, "%d", xms->value);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
43 labelstr = XmStringCreateLocalized(labelarr);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
44 XtVaSetValues(label, XmNlabelString, labelstr, NULL);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
45 XmStringFree(labelstr);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
46 #endif
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
47 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
48
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
49 #ifdef TOOLTALK
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
50 static void
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
51 handle_tt_input(XtPointer client_data, int *source, XtInputId *id)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
52 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
53 Tt_message m = tt_message_receive();
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
54
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
55 if (m && !(tt_ptr_error(m))) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
56 tt_message_destroy(m);
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
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
60 Tt_status
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
61 HxInitializeToolTalk()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
62 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
63 static Boolean initialized = FALSE;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
64
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
65 if (!initialized) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
66 int fd;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
67 Tt_status status;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
68
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
69 HxProcID = tt_open();
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
70 fd = tt_fd();
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
71 if (TT_OK != (status = tt_session_join( tt_default_session() )))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
72 return status;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
73 (void)XtAppAddInput(xt_app_con, fd, (void *)XtInputReadMask, handle_tt_input, NULL);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
74 initialized = TRUE;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
75 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
76
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
77 return TT_OK;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
78 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
79 #endif
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
80
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
81 main(int argc, char **argv)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
82 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
83 Widget shell, rowcolumn, scale, pushbutton, label1, label2, text;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
84 Widget paned, text2;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
85 int n, i;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
86 Widget widlist[100];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
87 Widget emacscli[100];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
88 Arg args[100];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
89 int no_ews = 1;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
90 char buf[100];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
91
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
92 if (argc > 1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
93 no_ews = atoi (argv[1]);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
94
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
95 shell = XtAppInitialize(&xt_app_con, "Testmotif", NULL, 0,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
96 &argc, argv, NULL, NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
97
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
98 #ifdef TOOLTALK
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
99 HxInitializeToolTalk();
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
100 #endif
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
101
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
102 rowcolumn = XmCreateRowColumn(shell, "rowcolumn", NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
103 XtManageChild(rowcolumn);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
104
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
105 n = 0;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
106 XtSetArg(args[n], XmNtraversalOn, TRUE); n++;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
107 #if 0
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
108 label1 = XmCreateLabel(rowcolumn, "label1", args, n);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
109 #endif
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
110 label1 = XtVaCreateWidget("label1", xmLabelWidgetClass, rowcolumn,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
111 XmNwidth, 50, XmNheight, 30,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
112 XmNtraversalOn, TRUE, NULL);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
113 label2 = XmCreateLabel(rowcolumn, "label2", NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
114 scale = XmCreateScale(rowcolumn, "scale", NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
115 XtAddCallback(scale, XmNvalueChangedCallback, ScaleValueChangedCB, label1);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
116 paned = XmCreatePanedWindow(rowcolumn, "paned", NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
117 n = 0;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
118 widlist[n++] = label1;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
119 widlist[n++] = label2;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
120 widlist[n++] = scale;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
121 widlist[n++] = paned;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
122 XtManageChildren(widlist, n);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
123
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
124 pushbutton = XmCreatePushButton(paned, "pushbutton", NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
125 text = XmCreateText(paned, "text", NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
126 for (i=0; i<no_ews; i++) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
127 sprintf (buf, "extcli%d", i);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
128 emacscli[i] = XtVaCreateWidget(buf, externalClientWidgetClass, paned,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
129 XmNwidth, 500, XmNheight, 200,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
130 XmNtraversalOn, TRUE,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
131 #ifdef TOOLTALK
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
132 XtNuseToolTalk, TRUE,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
133 #endif
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
134 NULL);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
135 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
136 text2 = XmCreateText(paned, "text2", NULL, 0);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
137 n = 0;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
138 widlist[n++] = pushbutton;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
139 widlist[n++] = text;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
140 for (i=0; i<no_ews; i++)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
141 widlist[n++] = emacscli[i];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
142 widlist[n++] = text2;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
143 XtManageChildren(widlist, n);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
144
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
145 XtRealizeWidget(shell);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
146
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
147 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
148 XmString lab;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
149 char labarr[1000];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
150 char tmpbuf[50];
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
151
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
152 strcpy (labarr, "window:");
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
153 for (i=0; i<no_ews; i++) {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
154 sprintf (tmpbuf, " %d", XtWindow(emacscli[i]));
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
155 strcat (labarr, tmpbuf);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
156 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
157 lab = XmStringCreateLocalized(labarr);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
158 XtVaSetValues(label2, XmNlabelString, lab, NULL);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
159 XmStringFree(lab);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
160 }
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
161
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
162 XtAppMainLoop(xt_app_con);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
163 }