3 Copyright 1989, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
28 * Author: Chris D. Peterson, MIT X Consortium
31 /************************************************************
36 The Client message sent to the application is:
38 ATOM = "ResEditor" --- RES_EDITOR_NAME
40 FORMAT = 32 --- RES_EDIT_SEND_EVENT_FORMAT
43 l[1] = command atom name
44 l[2] = ident of command
45 l[3] = protocol version number to use
49 The binary protocol has the following format:
51 Card8: 8-bit unsingned integer
52 Card16: 16-bit unsingned integer
53 Card32: 32-bit unsingned integer
54 Int16: 16-bit signed integer
59 [a][b][c] represent an exclusive list of choices.
61 All widgets are passed as a list of widgets, containing the
62 full instance heirarch of this widget. The hierarchy is ordered
63 from parent to child. Thus the first element of each list is
64 the root of the widget tree (this makes verifying that the widget
65 still exists, MUCH faster).
67 ListOfFoo comprises a list of things in the following format:
72 This is a synchronous protocol, every request MUST be followed by a
78 Op Code: Card8 - { SendWidgetTree = 0,
90 Type: Card8 - { Formatted = 0,
99 All Fields are MSB -> LSB
105 The data contains the reply information for the request as
106 specified below if the reply type is "Formatted". The return
107 values for the other reply types are shown below.
115 RequestedVersion: Card8
117 ------------------------------------------------------------
123 Number of Entries: Card16
125 widget: ListOfWidgets
131 Send Widget Tree returns the toolkit type, and a fuly specified list
132 of widgets for each widget in the tree. This is enough information
133 to completely reconstruct the entire widget heirarchy.
135 The window return value contains the Xid of the window currently
136 used by this widget. If the widget is unrealized then 0 is returned,
137 and if widget is a non-windowed object a value of 2 is returned.
144 Number of Entries: Card16
146 widget: ListOfWidgets
150 Number of Entries: Card16
152 widget: ListOfWidgets
155 SetValues will allow the same resource to be set on a number of
156 widgets. This function will return an error message if the SetValues
157 request caused an Xt error.
165 novalues: ListOfCard16
166 values: ListOfString8
168 GetValues will allow a number of resource values to be read
169 on a particular widget. The request specifies the names of
170 the resources wanted and the widget id these resources are
171 from. The reply returns a list of indices from the requests
172 name list of resources for which a value can not be returned.
173 It also returns a list of returned values, in the order of the
174 requests names list, skipping those indices present in novalues.
178 Number of Entries: Card16
180 widget: ListOfWidgets:
184 Number of Entries: Card16
186 Widget: ListOfWidgets:
189 [ Message: String 8 ]
190 [ Number of Resources: Card16
192 Kind: {normal, constraint}
197 GetResource retrieves the kind, name, class and type for every
198 widget passed to it. If an error occured with the resource fetch
199 Error will be set to True for the given widget and a message
200 is returned rather than the resource info.
204 Number of Entries: Card16
206 Widget: ListOfWidgets:
210 Number of Entries: Card16
212 Widget: ListOfWidgets:
215 [ message: String 8 ]
221 BorderWidth: Card16 ]
223 GetGeometry retreives the mapping state, x, y, width, height
224 and border width for each widget specified. If an error occured
225 with the geometry fetch "Error" will be set to True for the given
226 widget and a message is returned rather than the geometry info.
227 X an Y corrospond to the root coordinates of the upper left corner
228 of the widget (outside the window border).
232 Widget: ListOfWidgets
238 Widget: ListOfWidgets
240 Find Child returns a descendent of the widget specified that
241 is at the root coordinates specified.
245 The returned widget is undefined if the point is contained in
246 two or more mapped widgets, or in two overlapping Rect objs.
255 values: ListOfString8
257 GetValues will allow a number of resource values to be read
258 on a particular widget. Currently only InterViews 3.0.1 Styles
259 and their attributes are supported. In addition, the current
260 user interface only supports the return of 1 resource. The ability
261 to specify and return multiple resources is defined for future editres
262 interfaces where some or all of a widgets resource values are returned
263 and displayed at once.
266 ************************************************************/
268 #include <X11/Intrinsic.h>
269 #include <X11/Xfuncproto.h>
271 #define XER_NBBY 8 /* number of bits in a byte */
272 #define BYTE_MASK 255
274 #define HEADER_SIZE 6
276 #define EDITRES_IS_OBJECT 2
277 #define EDITRES_IS_UNREALIZED 0
282 #define EDITRES_FORMAT 8
283 #define EDITRES_SEND_EVENT_FORMAT 32
288 #define EDITRES_NAME "Editres"
289 #define EDITRES_COMMAND_ATOM "EditresCommand"
290 #define EDITRES_COMM_ATOM "EditresComm"
291 #define EDITRES_CLIENT_VALUE "EditresClientVal"
292 #define EDITRES_PROTOCOL_ATOM "EditresProtocol"
305 ConstraintResource = 1
309 * The type of a resource identifier
311 typedef unsigned char ResIdent;
319 typedef struct _WidgetInfo {
320 unsigned short num_widgets;
325 typedef struct _ProtocolStream {
326 unsigned long size, alloc;
327 unsigned char *real_top, *top, *current;
330 /************************************************************
331 * Function definitions for reading and writing protocol requests
332 ************************************************************/
335 void _XEditResPutString8
337 ProtocolStream *stream,
343 ProtocolStream *stream,
349 ProtocolStream *stream,
355 ProtocolStream *stream,
359 void _XEditResPutWidgetInfo
361 ProtocolStream *stream,
365 void _XEditResResetStream
367 ProtocolStream *stream
372 ProtocolStream *stream,
378 ProtocolStream *stream,
379 unsigned short *value
382 Bool _XEditResGetSigned16
384 ProtocolStream *stream,
390 ProtocolStream *stream,
394 Bool _XEditResGetString8
396 ProtocolStream *stream,
400 Bool _XEditResGetWidgetInfo
402 ProtocolStream *stream,