EditresP.h revision 6c321187
16c321187Smrg/* $Xorg: EditresP.h,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */ 26c321187Smrg 36c321187Smrg/* 46c321187Smrg 56c321187SmrgCopyright 1989, 1998 The Open Group 66c321187Smrg 76c321187SmrgPermission to use, copy, modify, distribute, and sell this software and its 86c321187Smrgdocumentation for any purpose is hereby granted without fee, provided that 96c321187Smrgthe above copyright notice appear in all copies and that both that 106c321187Smrgcopyright notice and this permission notice appear in supporting 116c321187Smrgdocumentation. 126c321187Smrg 136c321187SmrgThe above copyright notice and this permission notice shall be included in 146c321187Smrgall copies or substantial portions of the Software. 156c321187Smrg 166c321187SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 176c321187SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 186c321187SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 196c321187SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 206c321187SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 216c321187SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 226c321187Smrg 236c321187SmrgExcept as contained in this notice, the name of The Open Group shall not be 246c321187Smrgused in advertising or otherwise to promote the sale, use or other dealings 256c321187Smrgin this Software without prior written authorization from The Open Group. 266c321187Smrg 276c321187Smrg*/ 286c321187Smrg/* $XFree86: xc/lib/Xmu/EditresP.h,v 1.5 2001/01/17 19:42:55 dawes Exp $ */ 296c321187Smrg 306c321187Smrg/* 316c321187Smrg * Author: Chris D. Peterson, MIT X Consortium 326c321187Smrg */ 336c321187Smrg 346c321187Smrg/************************************************************ 356c321187Smrg 366c321187Smrg The Editres Protocol 376c321187Smrg 386c321187Smrg 396c321187Smrg The Client message sent to the application is: 406c321187Smrg 416c321187Smrg ATOM = "ResEditor" --- RES_EDITOR_NAME 426c321187Smrg 436c321187Smrg FORMAT = 32 --- RES_EDIT_SEND_EVENT_FORMAT 446c321187Smrg 456c321187Smrg l[0] = timestamp 466c321187Smrg l[1] = command atom name 476c321187Smrg l[2] = ident of command 486c321187Smrg l[3] = protocol version number to use 496c321187Smrg 506c321187Smrg 516c321187Smrg 526c321187Smrg The binary protocol has the following format: 536c321187Smrg 546c321187Smrg Card8: 8-bit unsingned integer 556c321187Smrg Card16: 16-bit unsingned integer 566c321187Smrg Card32: 32-bit unsingned integer 576c321187Smrg Int16: 16-bit signed integer 586c321187Smrg Window: 32-bit value 596c321187Smrg Widget: 32-bit value 606c321187Smrg String8: ListOfCard8 616c321187Smrg 626c321187Smrg [a][b][c] represent an exclusive list of choices. 636c321187Smrg 646c321187Smrg All widgets are passed as a list of widgets, containing the 656c321187Smrg full instance heirarch of this widget. The hierarchy is ordered 666c321187Smrg from parent to child. Thus the first element of each list is 676c321187Smrg the root of the widget tree (this makes verifying that the widget 686c321187Smrg still exists, MUCH faster). 696c321187Smrg 706c321187Smrg ListOfFoo comprises a list of things in the following format: 716c321187Smrg 726c321187Smrg number: Card16 736c321187Smrg <number> things: ???? 746c321187Smrg 756c321187Smrg This is a synchronous protocol, every request MUST be followed by a 766c321187Smrg reply. 776c321187Smrg 786c321187Smrg Request: 796c321187Smrg 806c321187Smrg Serial Number: Card8 816c321187Smrg Op Code: Card8 - { SendWidgetTree = 0, 826c321187Smrg SetValues = 1, 836c321187Smrg GetResources = 2, 846c321187Smrg GetGeometry = 3, 856c321187Smrg FindChild = 4, 866c321187Smrg GetValues = 5 } 876c321187Smrg Length: Card32 886c321187Smrg Data: 896c321187Smrg 906c321187Smrg Reply: 916c321187Smrg 926c321187Smrg Serial Number: Card8 936c321187Smrg Type: Card8 - { Formatted = 0, 946c321187Smrg Unformatted = 1, 956c321187Smrg ProtocolMismatch = 2 966c321187Smrg } 976c321187Smrg Length: Card32 986c321187Smrg 996c321187Smrg 1006c321187Smrg Byte Order: 1016c321187Smrg 1026c321187Smrg All Fields are MSB -> LSB 1036c321187Smrg 1046c321187Smrg Data: 1056c321187Smrg 1066c321187Smrg Formatted: 1076c321187Smrg 1086c321187Smrg The data contains the reply information for the request as 1096c321187Smrg specified below if the reply type is "Formatted". The return 1106c321187Smrg values for the other reply types are shown below. 1116c321187Smrg 1126c321187Smrg Unformatted: 1136c321187Smrg 1146c321187Smrg Message: String8 1156c321187Smrg 1166c321187Smrg ProtocolMismatch: 1176c321187Smrg 1186c321187Smrg RequestedVersion: Card8 1196c321187Smrg 1206c321187Smrg------------------------------------------------------------ 1216c321187Smrg 1226c321187Smrg SendWidgetTree: 1236c321187Smrg 1246c321187Smrg ---> 1256c321187Smrg 1266c321187Smrg Number of Entries: Card16 1276c321187Smrg Entry: 1286c321187Smrg widget: ListOfWidgets 1296c321187Smrg name: String8 1306c321187Smrg class: String8 1316c321187Smrg window: Card32 1326c321187Smrg toolkit: String8 1336c321187Smrg 1346c321187Smrg Send Widget Tree returns the toolkit type, and a fuly specified list 1356c321187Smrg of widgets for each widget in the tree. This is enough information 1366c321187Smrg to completely reconstruct the entire widget heirarchy. 1376c321187Smrg 1386c321187Smrg The window return value contains the Xid of the window currently 1396c321187Smrg used by this widget. If the widget is unrealized then 0 is returned, 1406c321187Smrg and if widget is a non-windowed object a value of 2 is returned. 1416c321187Smrg 1426c321187Smrg SetValues: 1436c321187Smrg 1446c321187Smrg name: String8 1456c321187Smrg type: String8 1466c321187Smrg value: String8 1476c321187Smrg Number of Entries: Card16 1486c321187Smrg Entry: 1496c321187Smrg widget: ListOfWidgets 1506c321187Smrg 1516c321187Smrg ---> 1526c321187Smrg 1536c321187Smrg Number of Entries: Card16 1546c321187Smrg Entry: 1556c321187Smrg widget: ListOfWidgets 1566c321187Smrg message: String8 1576c321187Smrg 1586c321187Smrg SetValues will allow the same resource to be set on a number of 1596c321187Smrg widgets. This function will return an error message if the SetValues 1606c321187Smrg request caused an Xt error. 1616c321187Smrg 1626c321187Smrg GetValues: 1636c321187Smrg 1646c321187Smrg names: ListOfString8 1656c321187Smrg widget: Widget 1666c321187Smrg 1676c321187Smrg ---> 1686c321187Smrg novalues: ListOfCard16 1696c321187Smrg values: ListOfString8 1706c321187Smrg 1716c321187Smrg GetValues will allow a number of resource values to be read 1726c321187Smrg on a particular widget. The request specifies the names of 1736c321187Smrg the resources wanted and the widget id these resources are 1746c321187Smrg from. The reply returns a list of indices from the requests 1756c321187Smrg name list of resources for which a value can not be returned. 1766c321187Smrg It also returns a list of returned values, in the order of the 1776c321187Smrg requests names list, skipping those indices present in novalues. 1786c321187Smrg 1796c321187Smrg GetResources: 1806c321187Smrg 1816c321187Smrg Number of Entries: Card16 1826c321187Smrg Entry 1836c321187Smrg widget: ListOfWidgets: 1846c321187Smrg 1856c321187Smrg ----> 1866c321187Smrg 1876c321187Smrg Number of Entries: Card16 1886c321187Smrg Entry 1896c321187Smrg Widget: ListOfWidgets: 1906c321187Smrg Error: Bool 1916c321187Smrg 1926c321187Smrg [ Message: String 8 ] 1936c321187Smrg [ Number of Resources: Card16 1946c321187Smrg Resource: 1956c321187Smrg Kind: {normal, constraint} 1966c321187Smrg Name: String8 1976c321187Smrg Class: String8 1986c321187Smrg Type: String8 ] 1996c321187Smrg 2006c321187Smrg GetResource retrieves the kind, name, class and type for every 2016c321187Smrg widget passed to it. If an error occured with the resource fetch 2026c321187Smrg Error will be set to True for the given widget and a message 2036c321187Smrg is returned rather than the resource info. 2046c321187Smrg 2056c321187Smrg GetGeometry: 2066c321187Smrg 2076c321187Smrg Number of Entries: Card16 2086c321187Smrg Entry 2096c321187Smrg Widget: ListOfWidgets: 2106c321187Smrg 2116c321187Smrg ----> 2126c321187Smrg 2136c321187Smrg Number of Entries: Card16 2146c321187Smrg Entry 2156c321187Smrg Widget: ListOfWidgets: 2166c321187Smrg Error: Bool 2176c321187Smrg 2186c321187Smrg [ message: String 8 ] 2196c321187Smrg [ mapped: Boolean 2206c321187Smrg X: Int16 2216c321187Smrg Y: Int16 2226c321187Smrg Width: Card16 2236c321187Smrg Height: Card16 2246c321187Smrg BorderWidth: Card16 ] 2256c321187Smrg 2266c321187Smrg GetGeometry retreives the mapping state, x, y, width, height 2276c321187Smrg and border width for each widget specified. If an error occured 2286c321187Smrg with the geometry fetch "Error" will be set to True for the given 2296c321187Smrg widget and a message is returned rather than the geometry info. 2306c321187Smrg X an Y corrospond to the root coordinates of the upper left corner 2316c321187Smrg of the widget (outside the window border). 2326c321187Smrg 2336c321187Smrg FindChild: 2346c321187Smrg 2356c321187Smrg Widget: ListOfWidgets 2366c321187Smrg X: Int16 2376c321187Smrg Y: Int16 2386c321187Smrg 2396c321187Smrg ---> 2406c321187Smrg 2416c321187Smrg Widget: ListOfWidgets 2426c321187Smrg 2436c321187Smrg Find Child returns a descendent of the widget specified that 2446c321187Smrg is at the root coordinates specified. 2456c321187Smrg 2466c321187Smrg NOTE: 2476c321187Smrg 2486c321187Smrg The returned widget is undefined if the point is contained in 2496c321187Smrg two or more mapped widgets, or in two overlapping Rect objs. 2506c321187Smrg 2516c321187Smrg GetValues: 2526c321187Smrg 2536c321187Smrg names: ListOfString8 2546c321187Smrg widget: Widget 2556c321187Smrg 2566c321187Smrg ---> 2576c321187Smrg 2586c321187Smrg values: ListOfString8 2596c321187Smrg 2606c321187Smrg GetValues will allow a number of resource values to be read 2616c321187Smrg on a particular widget. Currently only InterViews 3.0.1 Styles 2626c321187Smrg and their attributes are supported. In addition, the current 2636c321187Smrg user interface only supports the return of 1 resource. The ability 2646c321187Smrg to specify and return multiple resources is defined for future editres 2656c321187Smrg interfaces where some or all of a widgets resource values are returned 2666c321187Smrg and displayed at once. 2676c321187Smrg 2686c321187Smrg 2696c321187Smrg************************************************************/ 2706c321187Smrg 2716c321187Smrg#include <X11/Intrinsic.h> 2726c321187Smrg#include <X11/Xfuncproto.h> 2736c321187Smrg 2746c321187Smrg#define XER_NBBY 8 /* number of bits in a byte */ 2756c321187Smrg#define BYTE_MASK 255 2766c321187Smrg 2776c321187Smrg#define HEADER_SIZE 6 2786c321187Smrg 2796c321187Smrg#define EDITRES_IS_OBJECT 2 2806c321187Smrg#define EDITRES_IS_UNREALIZED 0 2816c321187Smrg 2826c321187Smrg/* 2836c321187Smrg * Format for atoms 2846c321187Smrg */ 2856c321187Smrg#define EDITRES_FORMAT 8 2866c321187Smrg#define EDITRES_SEND_EVENT_FORMAT 32 2876c321187Smrg 2886c321187Smrg/* 2896c321187Smrg * Atoms 2906c321187Smrg */ 2916c321187Smrg#define EDITRES_NAME "Editres" 2926c321187Smrg#define EDITRES_COMMAND_ATOM "EditresCommand" 2936c321187Smrg#define EDITRES_COMM_ATOM "EditresComm" 2946c321187Smrg#define EDITRES_CLIENT_VALUE "EditresClientVal" 2956c321187Smrg#define EDITRES_PROTOCOL_ATOM "EditresProtocol" 2966c321187Smrg 2976c321187Smrgtypedef enum { 2986c321187Smrg SendWidgetTree = 0, 2996c321187Smrg SetValues = 1, 3006c321187Smrg GetResources = 2, 3016c321187Smrg GetGeometry = 3, 3026c321187Smrg FindChild = 4, 3036c321187Smrg GetValues = 5 3046c321187Smrg} EditresCommand; 3056c321187Smrg 3066c321187Smrgtypedef enum { 3076c321187Smrg NormalResource = 0, 3086c321187Smrg ConstraintResource = 1 3096c321187Smrg} ResourceType; 3106c321187Smrg 3116c321187Smrg/* 3126c321187Smrg * The type of a resource identifier 3136c321187Smrg */ 3146c321187Smrgtypedef unsigned char ResIdent; 3156c321187Smrg 3166c321187Smrgtypedef enum { 3176c321187Smrg PartialSuccess = 0, 3186c321187Smrg Failure = 1, 3196c321187Smrg ProtocolMismatch = 2 3206c321187Smrg} EditResError; 3216c321187Smrg 3226c321187Smrgtypedef struct _WidgetInfo { 3236c321187Smrg unsigned short num_widgets; 3246c321187Smrg unsigned long *ids; 3256c321187Smrg Widget real_widget; 3266c321187Smrg} WidgetInfo; 3276c321187Smrg 3286c321187Smrgtypedef struct _ProtocolStream { 3296c321187Smrg unsigned long size, alloc; 3306c321187Smrg unsigned char *real_top, *top, *current; 3316c321187Smrg} ProtocolStream; 3326c321187Smrg 3336c321187Smrg/************************************************************ 3346c321187Smrg * Function definitions for reading and writing protocol requests 3356c321187Smrg ************************************************************/ 3366c321187Smrg_XFUNCPROTOBEGIN 3376c321187Smrg 3386c321187Smrgvoid _XEditResPutString8 3396c321187Smrg( 3406c321187Smrg ProtocolStream *stream, 3416c321187Smrg char *str 3426c321187Smrg ); 3436c321187Smrg 3446c321187Smrgvoid _XEditResPut8 3456c321187Smrg( 3466c321187Smrg ProtocolStream *stream, 3476c321187Smrg unsigned int value 3486c321187Smrg ); 3496c321187Smrg 3506c321187Smrgvoid _XEditResPut16 3516c321187Smrg( 3526c321187Smrg ProtocolStream *stream, 3536c321187Smrg unsigned int value 3546c321187Smrg ); 3556c321187Smrg 3566c321187Smrgvoid _XEditResPut32 3576c321187Smrg( 3586c321187Smrg ProtocolStream *stream, 3596c321187Smrg unsigned long value 3606c321187Smrg ); 3616c321187Smrg 3626c321187Smrgvoid _XEditResPutWidgetInfo 3636c321187Smrg( 3646c321187Smrg ProtocolStream *stream, 3656c321187Smrg WidgetInfo *info 3666c321187Smrg ); 3676c321187Smrg 3686c321187Smrgvoid _XEditResResetStream 3696c321187Smrg( 3706c321187Smrg ProtocolStream *stream 3716c321187Smrg ); 3726c321187Smrg 3736c321187SmrgBool _XEditResGet8 3746c321187Smrg( 3756c321187Smrg ProtocolStream *stream, 3766c321187Smrg unsigned char *value 3776c321187Smrg ); 3786c321187Smrg 3796c321187SmrgBool _XEditResGet16 3806c321187Smrg( 3816c321187Smrg ProtocolStream *stream, 3826c321187Smrg unsigned short *value 3836c321187Smrg ); 3846c321187Smrg 3856c321187SmrgBool _XEditResGetSigned16 3866c321187Smrg( 3876c321187Smrg ProtocolStream *stream, 3886c321187Smrg short *value 3896c321187Smrg ); 3906c321187Smrg 3916c321187SmrgBool _XEditResGet32 3926c321187Smrg( 3936c321187Smrg ProtocolStream *stream, 3946c321187Smrg unsigned long *value 3956c321187Smrg ); 3966c321187Smrg 3976c321187SmrgBool _XEditResGetString8 3986c321187Smrg( 3996c321187Smrg ProtocolStream *stream, 4006c321187Smrg char **str 4016c321187Smrg ); 4026c321187Smrg 4036c321187SmrgBool _XEditResGetWidgetInfo 4046c321187Smrg( 4056c321187Smrg ProtocolStream *stream, 4066c321187Smrg WidgetInfo *info 4076c321187Smrg ); 4086c321187Smrg 4096c321187Smrg_XFUNCPROTOEND 410