Blame include/X11/Xmu/EditresP.h

Packit cd2a55
/*
Packit cd2a55
Packit cd2a55
Copyright 1989, 1998  The Open Group
Packit cd2a55
Packit cd2a55
Permission to use, copy, modify, distribute, and sell this software and its
Packit cd2a55
documentation for any purpose is hereby granted without fee, provided that
Packit cd2a55
the above copyright notice appear in all copies and that both that
Packit cd2a55
copyright notice and this permission notice appear in supporting
Packit cd2a55
documentation.
Packit cd2a55
Packit cd2a55
The above copyright notice and this permission notice shall be included in
Packit cd2a55
all copies or substantial portions of the Software.
Packit cd2a55
Packit cd2a55
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Packit cd2a55
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Packit cd2a55
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
Packit cd2a55
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
Packit cd2a55
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit cd2a55
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Packit cd2a55
Packit cd2a55
Except as contained in this notice, the name of The Open Group shall not be
Packit cd2a55
used in advertising or otherwise to promote the sale, use or other dealings
Packit cd2a55
in this Software without prior written authorization from The Open Group.
Packit cd2a55
Packit cd2a55
*/
Packit cd2a55
Packit cd2a55
/*
Packit cd2a55
 * Author:  Chris D. Peterson, MIT X Consortium
Packit cd2a55
 */
Packit cd2a55
Packit cd2a55
/************************************************************
Packit cd2a55
Packit cd2a55
		The Editres Protocol
Packit cd2a55
Packit cd2a55
Packit cd2a55
  The Client message sent to the application is:
Packit cd2a55
Packit cd2a55
  ATOM = "ResEditor" 		--- RES_EDITOR_NAME
Packit cd2a55
Packit cd2a55
  FORMAT = 32                   --- RES_EDIT_SEND_EVENT_FORMAT
Packit cd2a55
Packit cd2a55
  l[0] = timestamp
Packit cd2a55
  l[1] = command atom name
Packit cd2a55
  l[2] = ident of command
Packit cd2a55
  l[3] = protocol version number to use
Packit cd2a55
Packit cd2a55
Packit cd2a55
Packit cd2a55
  The binary protocol has the following format:
Packit cd2a55
Packit cd2a55
	Card8:		8-bit unsingned integer
Packit cd2a55
	Card16:		16-bit unsingned integer
Packit cd2a55
	Card32:		32-bit unsingned integer
Packit cd2a55
	Int16:		16-bit signed integer
Packit cd2a55
	Window:		32-bit value
Packit cd2a55
	Widget:		32-bit value
Packit cd2a55
	String8:        ListOfCard8
Packit cd2a55
Packit cd2a55
	[a][b][c] represent an exclusive list of choices.
Packit cd2a55
Packit cd2a55
	All widgets are passed as a list of widgets, containing the
Packit cd2a55
	full instance heirarch of this widget.  The hierarchy is ordered
Packit cd2a55
	from parent to child.  Thus the first element of each list is
Packit cd2a55
	the root of the widget tree (this makes verifying that the widget
Packit cd2a55
	still exists, MUCH faster).
Packit cd2a55
Packit cd2a55
	ListOfFoo comprises a list of things in the following format:
Packit cd2a55
Packit cd2a55
	number:			Card16
Packit cd2a55
	<number> things:	????
Packit cd2a55
Packit cd2a55
  This is a synchronous protocol, every request MUST be followed by a
Packit cd2a55
  reply.
Packit cd2a55
Packit cd2a55
  Request:
Packit cd2a55
Packit cd2a55
	Serial Number:	Card8
Packit cd2a55
	Op Code:	Card8 -	{ SendWidgetTree = 0,
Packit cd2a55
				  SetValues = 1,
Packit cd2a55
				  GetResources = 2,
Packit cd2a55
				  GetGeometry = 3,
Packit cd2a55
				  FindChild = 4,
Packit cd2a55
				  GetValues = 5 }
Packit cd2a55
	Length:		Card32
Packit cd2a55
	Data:
Packit cd2a55
Packit cd2a55
   Reply:
Packit cd2a55
Packit cd2a55
	Serial Number:	Card8
Packit cd2a55
	Type:		Card8 - { Formatted = 0,
Packit cd2a55
	                          Unformatted = 1,
Packit cd2a55
				  ProtocolMismatch = 2
Packit cd2a55
				}
Packit cd2a55
	Length:		Card32
Packit cd2a55
Packit cd2a55
Packit cd2a55
   Byte Order:
Packit cd2a55
Packit cd2a55
	All Fields are MSB -> LSB
Packit cd2a55
Packit cd2a55
    Data:
Packit cd2a55
Packit cd2a55
    	Formatted:
Packit cd2a55
Packit cd2a55
        	The data contains the reply information for the request as
Packit cd2a55
		specified below if the reply type is "Formatted".  The return
Packit cd2a55
		values for the other reply types are shown below.
Packit cd2a55
Packit cd2a55
        Unformatted:
Packit cd2a55
Packit cd2a55
		Message:	String8
Packit cd2a55
Packit cd2a55
	ProtocolMismatch:
Packit cd2a55
Packit cd2a55
		RequestedVersion:   	Card8
Packit cd2a55
Packit cd2a55
------------------------------------------------------------
Packit cd2a55
Packit cd2a55
   SendWidgetTree:
Packit cd2a55
Packit cd2a55
	--->
Packit cd2a55
Packit cd2a55
	Number of Entries:	Card16
Packit cd2a55
	Entry:
Packit cd2a55
		widget:		ListOfWidgets
Packit cd2a55
		name:		String8
Packit cd2a55
		class:		String8
Packit cd2a55
		window:		Card32
Packit cd2a55
         	toolkit:        String8
Packit cd2a55
Packit cd2a55
	Send Widget Tree returns the toolkit type, and a fuly specified list
Packit cd2a55
        of widgets for each widget in the tree.  This is enough information
Packit cd2a55
        to completely reconstruct the entire widget heirarchy.
Packit cd2a55
Packit cd2a55
	The window return value contains the Xid of the window currently
Packit cd2a55
	used by this widget.  If the widget is unrealized then 0 is returned,
Packit cd2a55
	and if widget is a non-windowed object a value of 2 is returned.
Packit cd2a55
Packit cd2a55
   SetValues:
Packit cd2a55
Packit cd2a55
	name:	String8
Packit cd2a55
	type:	String8
Packit cd2a55
	value:  String8
Packit cd2a55
	Number of Entries:	Card16
Packit cd2a55
	Entry:
Packit cd2a55
		widget:		ListOfWidgets
Packit cd2a55
Packit cd2a55
	--->
Packit cd2a55
Packit cd2a55
	Number of Entries:	Card16
Packit cd2a55
	Entry:
Packit cd2a55
		widget:		ListOfWidgets
Packit cd2a55
		message:	String8
Packit cd2a55
Packit cd2a55
	SetValues will allow the same resource to be set on a number of
Packit cd2a55
	widgets.  This function will return an error message if the SetValues
Packit cd2a55
	request caused an Xt error.
Packit cd2a55
Packit cd2a55
  GetValues:
Packit cd2a55
Packit cd2a55
        names:                ListOfString8
Packit cd2a55
        widget:               Widget
Packit cd2a55
Packit cd2a55
        --->
Packit cd2a55
	novalues:             ListOfCard16
Packit cd2a55
	values:               ListOfString8
Packit cd2a55
Packit cd2a55
        GetValues will allow a number of resource values to be read
Packit cd2a55
        on a particular widget.  The request specifies the names of
Packit cd2a55
	the resources wanted and the widget id these resources are
Packit cd2a55
	from.  The reply returns a list of indices from the requests
Packit cd2a55
	name list of resources for which a value can not be returned.
Packit cd2a55
	It also returns a list of returned values, in the order of the
Packit cd2a55
        requests names list, skipping those indices present in novalues.
Packit cd2a55
Packit cd2a55
   GetResources:
Packit cd2a55
Packit cd2a55
	Number of Entries:	Card16
Packit cd2a55
	Entry
Packit cd2a55
		widget:		ListOfWidgets:
Packit cd2a55
Packit cd2a55
	---->
Packit cd2a55
Packit cd2a55
	Number of Entries:	Card16
Packit cd2a55
	Entry
Packit cd2a55
		Widget:			ListOfWidgets:
Packit cd2a55
		Error:			Bool
Packit cd2a55
Packit cd2a55
		[ Message:		String 8 ]
Packit cd2a55
		[ Number of Resources:	Card16
Packit cd2a55
		Resource:
Packit cd2a55
			Kind:	{normal, constraint}
Packit cd2a55
			Name:	String8
Packit cd2a55
			Class:	String8
Packit cd2a55
			Type:	String8 ]
Packit cd2a55
Packit cd2a55
	GetResource retrieves the kind, name, class and type for every
Packit cd2a55
	widget passed to it.  If an error occured with the resource fetch
Packit cd2a55
	Error will be set to True for the given widget and a message
Packit cd2a55
	is returned rather than the resource info.
Packit cd2a55
Packit cd2a55
  GetGeometry:
Packit cd2a55
Packit cd2a55
	Number of Entries:	Card16
Packit cd2a55
	Entry
Packit cd2a55
		Widget:		ListOfWidgets:
Packit cd2a55
Packit cd2a55
	---->
Packit cd2a55
Packit cd2a55
	Number of Entries:	Card16
Packit cd2a55
	Entry
Packit cd2a55
		Widget:			ListOfWidgets:
Packit cd2a55
		Error:			Bool
Packit cd2a55
Packit cd2a55
		[ message:		String 8 ]
Packit cd2a55
		[ mapped:       Boolean
Packit cd2a55
		  X: 		Int16
Packit cd2a55
		  Y:  		Int16
Packit cd2a55
		  Width: 	Card16
Packit cd2a55
	      	  Height:	Card16
Packit cd2a55
		  BorderWidth:	Card16 ]
Packit cd2a55
Packit cd2a55
	GetGeometry retreives the mapping state, x, y, width, height
Packit cd2a55
	and border width for each widget specified.  If an error occured
Packit cd2a55
	with the geometry fetch "Error" will be set to True for the given
Packit cd2a55
	widget and a message is returned rather than the geometry info.
Packit cd2a55
	X an Y corrospond to the root coordinates of the upper left corner
Packit cd2a55
	of the widget (outside the window border).
Packit cd2a55
Packit cd2a55
  FindChild:
Packit cd2a55
Packit cd2a55
	Widget:		ListOfWidgets
Packit cd2a55
	X:		Int16
Packit cd2a55
	Y:		Int16
Packit cd2a55
Packit cd2a55
	--->
Packit cd2a55
Packit cd2a55
	Widget:		ListOfWidgets
Packit cd2a55
Packit cd2a55
	Find Child returns a descendent of the widget specified that
Packit cd2a55
	is at the root coordinates specified.
Packit cd2a55
Packit cd2a55
	NOTE:
Packit cd2a55
Packit cd2a55
	The returned widget is undefined if the point is contained in
Packit cd2a55
	two or more mapped widgets, or in two overlapping Rect objs.
Packit cd2a55
Packit cd2a55
  GetValues:
Packit cd2a55
Packit cd2a55
        names:                ListOfString8
Packit cd2a55
        widget:               Widget
Packit cd2a55
Packit cd2a55
        --->
Packit cd2a55
Packit cd2a55
	values:               ListOfString8
Packit cd2a55
Packit cd2a55
        GetValues will allow a number of resource values to be read
Packit cd2a55
        on a particular widget.  Currently only InterViews 3.0.1 Styles
Packit cd2a55
	and their attributes are supported.  In addition, the current
Packit cd2a55
	user interface  only supports the return of 1 resource.  The ability
Packit cd2a55
	to specify and return multiple resources is defined for future editres
Packit cd2a55
	interfaces where some or all of a widgets resource values are returned
Packit cd2a55
	and displayed at once.
Packit cd2a55
Packit cd2a55
Packit cd2a55
************************************************************/
Packit cd2a55
Packit cd2a55
#include <X11/Intrinsic.h>
Packit cd2a55
#include <X11/Xfuncproto.h>
Packit cd2a55
Packit cd2a55
#define XER_NBBY 8		/* number of bits in a byte */
Packit cd2a55
#define BYTE_MASK 255
Packit cd2a55
Packit cd2a55
#define HEADER_SIZE 6
Packit cd2a55
Packit cd2a55
#define EDITRES_IS_OBJECT 2
Packit cd2a55
#define EDITRES_IS_UNREALIZED 0
Packit cd2a55
Packit cd2a55
/*
Packit cd2a55
 * Format for atoms
Packit cd2a55
 */
Packit cd2a55
#define EDITRES_FORMAT             8
Packit cd2a55
#define EDITRES_SEND_EVENT_FORMAT 32
Packit cd2a55
Packit cd2a55
/*
Packit cd2a55
 * Atoms
Packit cd2a55
 */
Packit cd2a55
#define EDITRES_NAME         "Editres"
Packit cd2a55
#define EDITRES_COMMAND_ATOM "EditresCommand"
Packit cd2a55
#define EDITRES_COMM_ATOM    "EditresComm"
Packit cd2a55
#define EDITRES_CLIENT_VALUE "EditresClientVal"
Packit cd2a55
#define EDITRES_PROTOCOL_ATOM "EditresProtocol"
Packit cd2a55
Packit cd2a55
typedef enum {
Packit cd2a55
  SendWidgetTree = 0,
Packit cd2a55
	       SetValues      = 1,
Packit cd2a55
	       GetResources   = 2,
Packit cd2a55
	       GetGeometry    = 3,
Packit cd2a55
	       FindChild      = 4,
Packit cd2a55
	       GetValues      = 5
Packit cd2a55
} EditresCommand;
Packit cd2a55
Packit cd2a55
typedef enum {
Packit cd2a55
  NormalResource     = 0,
Packit cd2a55
  ConstraintResource = 1
Packit cd2a55
} ResourceType;
Packit cd2a55
Packit cd2a55
/*
Packit cd2a55
 * The type of a resource identifier
Packit cd2a55
 */
Packit cd2a55
typedef unsigned char ResIdent;
Packit cd2a55
Packit cd2a55
typedef enum {
Packit cd2a55
  PartialSuccess   = 0,
Packit cd2a55
  Failure	   = 1,
Packit cd2a55
  ProtocolMismatch = 2
Packit cd2a55
} EditResError;
Packit cd2a55
Packit cd2a55
typedef struct _WidgetInfo {
Packit cd2a55
    unsigned short num_widgets;
Packit cd2a55
  unsigned long *ids;
Packit cd2a55
    Widget real_widget;
Packit cd2a55
} WidgetInfo;
Packit cd2a55
Packit cd2a55
typedef struct _ProtocolStream {
Packit cd2a55
    unsigned long size, alloc;
Packit cd2a55
    unsigned char *real_top, *top, *current;
Packit cd2a55
} ProtocolStream;
Packit cd2a55
Packit cd2a55
/************************************************************
Packit cd2a55
 * Function definitions for reading and writing protocol requests
Packit cd2a55
 ************************************************************/
Packit cd2a55
_XFUNCPROTOBEGIN
Packit cd2a55
Packit cd2a55
void _XEditResPutString8
Packit cd2a55
(
Packit cd2a55
 ProtocolStream		*stream,
Packit cd2a55
 _Xconst char		*str
Packit cd2a55
 );
Packit cd2a55
Packit cd2a55
void _XEditResPut8
Packit cd2a55
(
Packit cd2a55
 ProtocolStream		*stream,
Packit cd2a55
 unsigned int		value
Packit cd2a55
 );
Packit cd2a55
Packit cd2a55
void _XEditResPut16
Packit cd2a55
(
Packit cd2a55
 ProtocolStream		*stream,
Packit cd2a55
 unsigned int		value
Packit cd2a55
 );
Packit cd2a55
Packit cd2a55
void _XEditResPut32
Packit cd2a55
(
Packit cd2a55
 ProtocolStream		*stream,
Packit cd2a55
 unsigned long		value
Packit cd2a55
 );
Packit cd2a55
Packit cd2a55
void _XEditResPutWidgetInfo
Packit cd2a55
(
Packit cd2a55
 ProtocolStream		*stream,
Packit cd2a55
 WidgetInfo		*info
Packit cd2a55
 );
Packit cd2a55
Packit cd2a55
void _XEditResResetStream
Packit cd2a55
(
Packit cd2a55
 ProtocolStream		*stream
Packit cd2a55
 );
Packit cd2a55
Packit cd2a55
Bool _XEditResGet8
Packit cd2a55
(
Packit cd2a55
 ProtocolStream		*stream,
Packit cd2a55
 unsigned char		*value
Packit cd2a55
 );
Packit cd2a55
Packit cd2a55
Bool _XEditResGet16
Packit cd2a55
(
Packit cd2a55
 ProtocolStream		*stream,
Packit cd2a55
 unsigned short		*value
Packit cd2a55
 );
Packit cd2a55
Packit cd2a55
Bool _XEditResGetSigned16
Packit cd2a55
(
Packit cd2a55
 ProtocolStream		*stream,
Packit cd2a55
 short			*value
Packit cd2a55
 );
Packit cd2a55
Packit cd2a55
Bool _XEditResGet32
Packit cd2a55
(
Packit cd2a55
 ProtocolStream		*stream,
Packit cd2a55
 unsigned long		*value
Packit cd2a55
 );
Packit cd2a55
Packit cd2a55
Bool _XEditResGetString8
Packit cd2a55
(
Packit cd2a55
 ProtocolStream		*stream,
Packit cd2a55
 char			**str
Packit cd2a55
 );
Packit cd2a55
Packit cd2a55
Bool _XEditResGetWidgetInfo
Packit cd2a55
(
Packit cd2a55
 ProtocolStream		*stream,
Packit cd2a55
 WidgetInfo		*info
Packit cd2a55
 );
Packit cd2a55
Packit cd2a55
_XFUNCPROTOEND