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