home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-bin / x11r6.1 / include / x11 / xmu / editresp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-17  |  8.8 KB  |  344 lines

  1. /* $XConsortium: EditresP.h,v 1.13 94/04/17 20:16:06 dave Exp $ */
  2.  
  3. /*
  4.  
  5. Copyright (c) 1989  X Consortium
  6.  
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13.  
  14. The above copyright notice and this permission notice shall be included in
  15. all copies or substantial portions of the Software.
  16.  
  17. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  20. X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  21. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23.  
  24. Except as contained in this notice, the name of the X Consortium shall not be
  25. used in advertising or otherwise to promote the sale, use or other dealings
  26. in this Software without prior written authorization from the X Consortium.
  27.  
  28. */
  29.  
  30. /*
  31.  * Author:  Chris D. Peterson, MIT X Consortium
  32.  */
  33.  
  34. /************************************************************
  35.  
  36.         The Editres Protocol
  37.  
  38.  
  39.   The Client message sent to the application is:
  40.  
  41.   ATOM = "ResEditor"         --- RES_EDITOR_NAME
  42.  
  43.   FORMAT = 32                   --- RES_EDIT_SEND_EVENT_FORMAT
  44.  
  45.   l[0] = timestamp
  46.   l[1] = command atom name
  47.   l[2] = ident of command.
  48.   l[3] = protocol version number to use.
  49.  
  50.  
  51.  
  52.   The binary protocol has the following format:
  53.  
  54.     Card8:        8-bit unsingned integer
  55.     Card16:        16-bit unsingned integer
  56.     Card32:        32-bit unsingned integer
  57.     Int16:        16-bit signed integer
  58.     Window:        32-bit value
  59.     Widget:        32-bit value
  60.     String8:        ListOfCard8
  61.     
  62.     [a][b][c] represent an exclusive list of choices.
  63.  
  64.     All widgets are passed as a list of widgets, containing the 
  65.     full instance heirarch of this widget.  The hierarchy is ordered
  66.     from parent to child.  Thus the first element of each list is
  67.     the root of the widget tree (this makes verifying that the widget
  68.     still exists, MUCH faster).
  69.  
  70.     ListOfFoo comprises a list of things in the following format:
  71.     
  72.     number:            Card16
  73.     <number> things:    ????
  74.     
  75.   This is a synchronous protocol, every request MUST be followed by a
  76.   reply.  
  77.  
  78.   Request:
  79.  
  80.     Serial Number:    Card8
  81.     Op Code:    Card8 -    { SendWidgetTree = 0,
  82.                   SetValues = 1,
  83.                   GetResources = 2,
  84.                   GetGeometry = 3,
  85.                   FindChild = 4,
  86.                   GetValues = 5 }
  87.     Length:        Card32
  88.     Data:        
  89.  
  90.    Reply:
  91.  
  92.     Serial Number:    Card8
  93.     Type:        Card8 - { Formatted = 0,
  94.                               Unformatted = 1,
  95.                   ProtocolMismatch = 2
  96.                 }
  97.     Length:        Card32
  98.  
  99.  
  100.    Byte Order:
  101.  
  102.     All Fields are MSB -> LSB
  103.  
  104.     Data:
  105.  
  106.         Formatted:
  107.  
  108.             The data contains the reply information for the request as
  109.         specified below if the reply type is "Formatted".  The return
  110.         values for the other reply types are shown below.
  111.  
  112.         Unformatted:
  113.  
  114.         Message:    String8
  115.  
  116.     ProtocolMismatch:
  117.  
  118.         RequestedVersion:       Card8
  119.  
  120. ------------------------------------------------------------
  121.  
  122.    SendWidgetTree:
  123.  
  124.     --->
  125.  
  126.     Number of Entries:    Card16
  127.     Entry:
  128.         widget:        ListOfWidgets
  129.         name:        String8
  130.         class:        String8
  131.         window:        Card32
  132.              toolkit:        String8
  133.  
  134.     Send Widget Tree returns the toolkit type, and a fuly specified list
  135.         of widgets for each widget in the tree.  This is enough information
  136.         to completely reconstruct the entire widget heirarchy.
  137.  
  138.     The window return value contains the Xid of the window currently 
  139.     used by this widget.  If the widget is unrealized then 0 is returned,
  140.     and if widget is a non-windowed object a value of 2 is returned.
  141.  
  142.    SetValues:
  143.  
  144.     name:    String8
  145.     type:    String8
  146.     value:  String8
  147.     Number of Entries:    Card16
  148.     Entry:
  149.         widget:        ListOfWidgets
  150.  
  151.     --->
  152.  
  153.     Number of Entries:    Card16
  154.     Entry:
  155.         widget:        ListOfWidgets
  156.         message:    String8
  157.  
  158.     SetValues will allow the same resource to be set on a number of 
  159.     widgets.  This function will return an error message if the SetValues
  160.     request caused an Xt error.
  161.     
  162.   GetValues:
  163.  
  164.         names:                ListOfString8       
  165.         widget:               Widget
  166.  
  167.         --->
  168.     novalues:             ListOfCard16
  169.     values:               ListOfString8
  170.                    
  171.         GetValues will allow a number of resource values to be read 
  172.         on a particular widget.  The request specifies the names of
  173.     the resources wanted and the widget id these resources are
  174.     from.  The reply returns a list of indices from the requests
  175.     name list of resources for which a value can not be returned.
  176.     It also returns a list of returned values, in the order of the
  177.         requests names list, skipping those indices present in novalues.
  178.  
  179.    GetResources:
  180.  
  181.     Number of Entries:    Card16
  182.     Entry
  183.         widget:        ListOfWidgets:
  184.  
  185.     ---->
  186.  
  187.     Number of Entries:    Card16
  188.     Entry
  189.         Widget:            ListOfWidgets:
  190.         Error:            Bool
  191.  
  192.         [ Message:        String 8 ]
  193.         [ Number of Resources:    Card16
  194.         Resource:
  195.             Kind:    {normal, constraint}
  196.             Name:    String8
  197.             Class:    String8    
  198.             Type:    String8 ]
  199.  
  200.     GetResource retrieves the kind, name, class and type for every 
  201.     widget passed to it.  If an error occured with the resource fetch
  202.     Error will be set to True for the given widget and a message
  203.     is returned rather than the resource info.
  204.  
  205.   GetGeometry:
  206.  
  207.     Number of Entries:    Card16
  208.     Entry
  209.         Widget:        ListOfWidgets:
  210.  
  211.     ---->
  212.  
  213.     Number of Entries:    Card16
  214.     Entry
  215.         Widget:            ListOfWidgets:
  216.         Error:            Bool
  217.  
  218.         [ message:        String 8 ]
  219.         [ mapped:       Boolean
  220.           X:         Int16
  221.           Y:          Int16
  222.           Width:     Card16
  223.                 Height:    Card16
  224.           BorderWidth:    Card16 ]
  225.  
  226.     GetGeometry retreives the mapping state, x, y, width, height
  227.     and border width for each widget specified.  If an error occured 
  228.     with the geometry fetch "Error" will be set to True for the given 
  229.     widget and a message is returned rather than the geometry info.  
  230.     X an Y corrospond to the root coordinates of the upper left corner
  231.     of the widget (outside the window border).
  232.     
  233.   FindChild:
  234.  
  235.     Widget:        ListOfWidgets
  236.     X:        Int16
  237.     Y:        Int16
  238.     
  239.     --->
  240.  
  241.     Widget:        ListOfWidgets
  242.  
  243.     Find Child returns a descendent of the widget specified that 
  244.     is at the root coordinates specified.
  245.  
  246.     NOTE:
  247.  
  248.     The returned widget is undefined if the point is contained in
  249.     two or more mapped widgets, or in two overlapping Rect objs.
  250.  
  251.   GetValues:
  252.  
  253.         names:                ListOfString8       
  254.         widget:               Widget
  255.  
  256.         --->
  257.     
  258.     values:               ListOfString8
  259.  
  260.         GetValues will allow a number of resource values to be read 
  261.         on a particular widget.  Currently only InterViews 3.0.1 Styles 
  262.     and their attributes are supported.  In addition, the current
  263.     user interface  only supports the return of 1 resource.  The ability
  264.     to specify and return multiple resources is defined for future editres
  265.     interfaces where some or all of a widgets resource values are returned
  266.     and displayed at once. 
  267.  
  268.  
  269. ************************************************************/
  270.  
  271. #include <X11/Intrinsic.h>
  272. #include <X11/Xfuncproto.h>
  273.  
  274. #define XER_NBBY 8        /* number of bits in a byte */
  275. #define BYTE_MASK 255
  276.  
  277. #define HEADER_SIZE 6
  278.  
  279. #define EDITRES_IS_OBJECT 2
  280. #define EDITRES_IS_UNREALIZED 0
  281.  
  282. /*
  283.  * Format for atoms.
  284.  */
  285.  
  286. #define EDITRES_FORMAT             8
  287. #define EDITRES_SEND_EVENT_FORMAT 32
  288.  
  289. /*
  290.  * Atoms
  291.  */
  292.  
  293. #define EDITRES_NAME         "Editres"
  294. #define EDITRES_COMMAND_ATOM "EditresCommand"
  295. #define EDITRES_COMM_ATOM    "EditresComm"
  296. #define EDITRES_CLIENT_VALUE "EditresClientVal"
  297. #define EDITRES_PROTOCOL_ATOM "EditresProtocol"
  298.  
  299. typedef enum { SendWidgetTree = 0, 
  300.            SetValues      = 1,
  301.            GetResources   = 2,
  302.            GetGeometry    = 3, 
  303.            FindChild      = 4,
  304.            GetValues      = 5
  305.          } EditresCommand;
  306.  
  307. typedef enum {NormalResource = 0, ConstraintResource = 1} ResourceType;
  308.  
  309. /*
  310.  * The type of a resource identifier.
  311.  */
  312.  
  313. typedef unsigned char ResIdent;
  314.  
  315. typedef enum {PartialSuccess= 0, Failure= 1, ProtocolMismatch= 2} EditResError;
  316.  
  317. typedef struct _WidgetInfo {
  318.     unsigned short num_widgets;
  319.     unsigned long * ids;
  320.     Widget real_widget;
  321. } WidgetInfo;
  322.  
  323. typedef struct _ProtocolStream {
  324.     unsigned long size, alloc;
  325.     unsigned char *real_top, *top, *current;
  326. } ProtocolStream;
  327.  
  328. /************************************************************
  329.  *
  330.  * Function definitions for reading and writing protocol requests.
  331.  *
  332.  ************************************************************/
  333.  
  334. _XFUNCPROTOBEGIN
  335.  
  336. void _XEditResPutString8(), _XEditResPut8(), _XEditResPut16();
  337. void _XEditResPut32(), _XEditResPutWidgetInfo(), _XEditResPutWidget();
  338. void _XEditResResetStream();
  339.  
  340. Boolean _XEditResGet8(), _XEditResGet16(), _XEditResGetSigned16();
  341. Boolean _XEditResGet32(), _XEditResGetString8(), _XEditResGetWidgetInfo();
  342.  
  343. _XFUNCPROTOEND
  344.