Home | History | Annotate | Line # | Download | only in Xaw
      1 /***********************************************************
      2 
      3 Copyright 1987, 1988, 1994, 1998  The Open Group
      4 
      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
      9 documentation.
     10 
     11 The above copyright notice and this permission notice shall be included in
     12 all copies or substantial portions of the Software.
     13 
     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.
     20 
     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.
     24 
     25 
     26 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
     27 
     28                         All Rights Reserved
     29 
     30 Permission to use, copy, modify, and distribute this software and its
     31 documentation for any purpose and without fee is hereby granted,
     32 provided that the above copyright notice appear in all copies and that
     33 both that copyright notice and this permission notice appear in
     34 supporting documentation, and that the name of Digital not be
     35 used in advertising or publicity pertaining to distribution of the
     36 software without specific, written prior permission.
     37 
     38 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
     39 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
     40 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
     41 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
     42 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
     43 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
     44 SOFTWARE.
     45 
     46 ******************************************************************/
     47 
     48 #ifndef _XawTextSrcP_h
     49 #define _XawTextSrcP_h
     50 
     51 /*
     52  * TextSrc Object Private Data
     53  */
     54 #include <X11/Xfuncproto.h>
     55 
     56 #include <X11/Xaw/TextSrc.h>
     57 #include <X11/Xaw/TextP.h>	/* This source works with the Text widget */
     58 
     59 _XFUNCPROTOBEGIN
     60 
     61 #ifndef OLDXAW
     62 struct _XawTextAnchor {
     63     XawTextPosition position;
     64     XawTextEntity *entities, *cache;
     65 };
     66 
     67 #define	XAW_TENTF_HIDE		0x0001
     68 #define XAW_TENTF_READ		0x0002
     69 #define XAW_TENTF_REPLACE	0x0004
     70 struct _XawTextEntity {
     71     short type;
     72     short flags;
     73     XawTextEntity *next;
     74     XtPointer data;
     75     XawTextPosition offset;	/* from the anchor */
     76     Cardinal length;
     77     XrmQuark property;
     78 };
     79 #endif
     80 
     81 #if 0	/* no longer used */
     82 /* New fields for the TextSrc object class */
     83 typedef struct {
     84   XtPointer		next_extension;
     85   XrmQuark		record_type;
     86   long			version;
     87   Cardinal		record_size;
     88   int			(*Input)();
     89 } TextSrcExtRec, *TextSrcExt;
     90 #endif
     91 
     92 typedef XawTextPosition (*_XawSrcReadProc)
     93      (Widget, XawTextPosition, XawTextBlock*, int);
     94 
     95 typedef int (*_XawSrcReplaceProc)
     96      (Widget, XawTextPosition, XawTextPosition, XawTextBlock*);
     97 
     98 typedef XawTextPosition (*_XawSrcScanProc)
     99      (Widget, XawTextPosition, XawTextScanType, XawTextScanDirection,
    100       int, Bool);
    101 
    102 typedef XawTextPosition (*_XawSrcSearchProc)
    103      (Widget, XawTextPosition, XawTextScanDirection, XawTextBlock*);
    104 
    105 typedef void (*_XawSrcSetSelectionProc)
    106      (Widget, XawTextPosition, XawTextPosition, Atom);
    107 
    108 typedef Boolean (*_XawSrcConvertSelectionProc)
    109      (Widget, Atom*, Atom*, Atom*, XtPointer*, unsigned long*, int*);
    110 
    111 typedef struct _TextSrcClassPart {
    112     _XawSrcReadProc Read;
    113     _XawSrcReplaceProc Replace;
    114     _XawSrcScanProc Scan;
    115     _XawSrcSearchProc Search;
    116     _XawSrcSetSelectionProc SetSelection;
    117     _XawSrcConvertSelectionProc ConvertSelection;
    118 #ifndef OLDXAW
    119     XtPointer extension;
    120 #endif
    121 } TextSrcClassPart;
    122 
    123 /* Full class record */
    124 typedef struct _TextSrcClassRec {
    125     ObjectClassPart     object_class;
    126     TextSrcClassPart	textSrc_class;
    127 } TextSrcClassRec;
    128 
    129 extern TextSrcClassRec textSrcClassRec;
    130 
    131 #ifndef OLDXAW
    132 typedef struct _XawTextUndo XawTextUndo;
    133 #endif
    134 
    135 /* New fields for the TextSrc object */
    136 typedef struct {
    137     /* resources */
    138     XawTextEditType	edit_mode;
    139     XrmQuark text_format;		/* 2 formats: FMT8BIT for Ascii
    140 					   FMTWIDE for ISO 10646 */
    141 #ifndef OLDXAW
    142     XtCallbackList callback;		/* A callback list to call when the
    143 					   source is changed */
    144     Boolean changed;
    145     Boolean enable_undo;
    146 
    147     /* private state */
    148     Boolean undo_state;			/* to protect undo manipulation */
    149     XawTextUndo *undo;
    150     WidgetList text;			/* TextWidget's using this source */
    151     Cardinal num_text;
    152     XtCallbackList property_callback;
    153     XawTextAnchor **anchors;
    154     int num_anchors;
    155     XtPointer pad[1];	/* for future use and keep binary compatibility */
    156 #endif
    157 } TextSrcPart;
    158 
    159 /* Full instance record */
    160 typedef struct _TextSrcRec {
    161     ObjectPart	object;
    162     TextSrcPart	textSrc;
    163 } TextSrcRec;
    164 
    165 /*
    166  * Semiprivate declarations of functions used in other modules
    167  */
    168 char* _XawTextWCToMB
    169 (
    170  Display	*display,
    171  wchar_t	*wstr,
    172  int		*len_in_out
    173  );
    174 
    175 wchar_t* _XawTextMBToWC
    176 (
    177  Display	*display,
    178  char		*str,
    179  int		*len_in_out
    180  );
    181 
    182 #ifndef OLDXAW
    183 XawTextAnchor *XawTextSourceAddAnchor
    184 (
    185  Widget			source,
    186  XawTextPosition	position
    187  );
    188 
    189 XawTextAnchor *XawTextSourceFindAnchor
    190 (
    191  Widget			source,
    192  XawTextPosition	position
    193  );
    194 
    195 XawTextAnchor *XawTextSourceNextAnchor
    196 (
    197  Widget			 source,
    198  XawTextAnchor		*anchor
    199  );
    200 
    201 XawTextAnchor *XawTextSourcePrevAnchor
    202 (
    203  Widget			 source,
    204  XawTextAnchor		*anchor
    205  );
    206 
    207 XawTextAnchor *XawTextSourceRemoveAnchor
    208 (
    209  Widget			 source,
    210  XawTextAnchor		*anchor
    211  );
    212 
    213 Bool XawTextSourceAnchorAndEntity
    214 (
    215  Widget			  w,
    216  XawTextPosition	  position,
    217  XawTextAnchor		**anchor_return,
    218  XawTextEntity		**entity_return
    219  );
    220 
    221 XawTextEntity *XawTextSourceAddEntity
    222 (
    223  Widget			source,
    224  int			type,
    225  int			flags,
    226  XtPointer		data,
    227  XawTextPosition	position,
    228  Cardinal		length,
    229  XrmQuark		property
    230  );
    231 
    232 void XawTextSourceClearEntities
    233 (
    234  Widget			w,
    235  XawTextPosition	left,
    236  XawTextPosition	right
    237  );
    238 #endif
    239 
    240 #if 0	/* no longer used */
    241 typedef XawTextPosition (*_XawTextPositionFunc)();
    242 #endif
    243 
    244 #define XtInheritInput			((_XawTextPositionFunc)_XtInherit)
    245 #define XtInheritRead			((_XawSrcReadProc)_XtInherit)
    246 #define XtInheritReplace		((_XawSrcReplaceProc)_XtInherit)
    247 #define XtInheritScan			((_XawSrcScanProc)_XtInherit)
    248 #define XtInheritSearch			((_XawSrcSearchProc)_XtInherit)
    249 #define XtInheritSetSelection		((_XawSrcSetSelectionProc)_XtInherit)
    250 #define XtInheritConvertSelection     ((_XawSrcConvertSelectionProc)_XtInherit)
    251 #if 0
    252 #define XtTextSrcExtVersion	      1
    253 #define XtTextSrcExtTypeString        "XT_TEXTSRC_EXT"
    254 #endif
    255 
    256 _XFUNCPROTOEND
    257 
    258 #endif /* _XawTextSrcP_h */
    259