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 _XawTextSink_h
     49 #define _XawTextSink_h
     50 
     51 #include <X11/Xaw/Text.h>
     52 
     53 /***********************************************************************
     54  *
     55  * TextSink Object
     56  *
     57  ***********************************************************************/
     58 
     59 /* Resources:
     60 
     61  Name		     Class		RepType		Default Value
     62  ----		     -----		-------		-------------
     63  font                Font            XFontStruct *      XtDefaultFont
     64  foreground          Foreground      Pixel              XtDefaultForeground
     65  background          Background      Pixel              XtDefaultBackground
     66  cursorColor	     Color	      Pixel		XtDefaultForeground
     67 */
     68 
     69 /* Class record constants */
     70 
     71 extern WidgetClass textSinkObjectClass;
     72 
     73 typedef struct _TextSinkClassRec *TextSinkObjectClass;
     74 typedef struct _TextSinkRec      *TextSinkObject;
     75 
     76 typedef enum {XawisOn, XawisOff} XawTextInsertState;
     77 
     78 #ifndef OLDXAW
     79 #ifndef XtNcursorColor
     80 #define XtNcursorColor		"cursorColor"
     81 #endif
     82 
     83 #define XawNtextProperties	"textProperties"
     84 #define XawCTextProperties	"TextProperties"
     85 #define XawRTextProperties	"XawTextProperties"
     86 #endif
     87 
     88 /*
     89  * Public Functions
     90  */
     91 _XFUNCPROTOBEGIN
     92 
     93 /*
     94  * Function:
     95  *	XawTextSinkDisplayText
     96  *
     97  * Parameters:
     98  *	w	  - the TextSink Object
     99  *	x	  - location to start drawing text
    100  *	y	  - ""
    101  *	pos1	  - location of starting and ending points in the text buffer
    102  *	pos2	  - ""
    103  *	highlight - highlight this text?
    104  *
    105  * Description:
    106  *	Stub function that in subclasses will display text.
    107  *
    108  * Note:
    109  *	  This function doesn't actually display anything, it is only a place
    110  *	holder.
    111  */
    112 void XawTextSinkDisplayText
    113 (
    114  Widget			w,
    115 #if NeedWidePrototypes
    116  int			x,
    117  int			y,
    118 #else
    119  Position		x,
    120  Position		y,
    121 #endif
    122  XawTextPosition	pos1,
    123  XawTextPosition	pos2,
    124 #if NeedWidePrototypes
    125  int			highlight
    126 #else
    127  Boolean		highlight
    128 #endif
    129  );
    130 
    131 /*
    132  * Function:
    133  *	XawTextSinkInsertCursor
    134  *
    135  * Parameters:
    136  *	w	- the TextSink Object.
    137  *	x	- location for the cursor.
    138  *	y	- ""
    139  *	state	- whether to turn the cursor on, or off
    140  *
    141  * Description:
    142  *	Places the InsertCursor.
    143  *
    144  * Note:
    145  *	  This function doesn't actually display anything, it is only a place
    146  *	holder.
    147  */
    148 void XawTextSinkInsertCursor
    149 (
    150  Widget			w,
    151 #if NeedWidePrototypes
    152  int			x,
    153  int			y,
    154  int			state
    155 #else
    156  Position		x,
    157  Position		y,
    158  XawTextInsertState	state
    159 #endif
    160  );
    161 
    162 /*
    163  * Function:
    164  *	XawTextSinkClearToBackground
    165  *
    166  * Parameters:
    167  *	w	- TextSink Object
    168  *	x	- location of area to clear
    169  *	y	- ""
    170  *	width	- size of area to clear
    171  *	height	- ""
    172  *
    173  * Description:
    174  *	Clears a region of the sink to the background color.
    175  *
    176  * Note:
    177  *	  This function doesn't actually display anything, it is only a place
    178  *	holder.
    179  */
    180 void XawTextSinkClearToBackground
    181 (
    182  Widget			w,
    183 #if NeedWidePrototypes
    184  int			x,
    185  int			y,
    186  unsigned int		width,
    187  unsigned int		height
    188 #else
    189  Position		x,
    190  Position		y,
    191  Dimension		width,
    192  Dimension		height
    193 #endif
    194  );
    195 
    196 /*
    197  * Function:
    198  *	XawTextSinkFindPosition
    199  *
    200  * Parameters:
    201  *	w		- TextSink Object
    202  *	fromPos		- reference position
    203  *	fromX		- reference location
    204  *	width		- width of section to paint text
    205  *	stopAtWordBreak - returned position is a word break?
    206  *	resPos		- Position to return
    207  *	resWidth	- Width actually used
    208  *	resHeight	- Height actually used
    209  *
    210  * Description:
    211  *	Finds a position in the text.
    212  */
    213 void XawTextSinkFindPosition
    214 (
    215  Widget			w,
    216  XawTextPosition	fromPos,
    217  int			fromX,
    218  int			width,
    219 #if NeedWidePrototypes
    220  int			stopAtWordBreak,
    221 #else
    222  Boolean		stopAtWordBreak,
    223 #endif
    224  XawTextPosition*	pos_return,
    225  int			*width_return,
    226  int			*height_return
    227  );
    228 
    229 /*
    230  * Function:
    231  *	XawTextSinkFindDistance
    232  *
    233  * Parameters:
    234  *	w		- TextSink Object
    235  *	fromPos		- starting Position
    236  *	fromX		- x location of starting Position
    237  *	toPos		- end Position
    238  *	resWidth	- Distance between fromPos and toPos
    239  *	resPos		- Actual toPos used
    240  *	resHeight	- Height required by this text
    241  *
    242  * Description:
    243  *	Find the Pixel Distance between two text Positions.
    244  */
    245 void XawTextSinkFindDistance
    246 (
    247  Widget			w,
    248  XawTextPosition	fromPos,
    249  int			fromX,
    250  XawTextPosition	toPos,
    251  int			*width_return,
    252  XawTextPosition	*pos_return,
    253  int			*height_return
    254  );
    255 
    256 /*
    257  * Function:
    258  *	XawTextSinkResolve
    259  *
    260  * Parameters:
    261  *	w	- TextSink Object
    262  *	pos	- reference Position
    263  *	fromx	- reference Location
    264  *	width	- width to move
    265  *	resPos	- resulting position
    266  *
    267  * Description:
    268  *	Resolves a location to a position.
    269  */
    270 void XawTextSinkResolve
    271 (
    272  Widget			w,
    273  XawTextPosition	fromPos,
    274  int			fromX,
    275  int			width,
    276  XawTextPosition	*pos_return
    277  );
    278 
    279 /*
    280  * Function:
    281  *	XawTextSinkMaxLines
    282  *
    283  * Parameters:
    284  *	w	- TextSink Object
    285  *	height	- height to fit lines into
    286  *
    287  * Returns:
    288  *	Number of lines that will fit
    289  *
    290  * Description:
    291  *	Finds the Maximum number of lines that will fit in a given height.
    292  */
    293 int XawTextSinkMaxLines
    294 (
    295  Widget			w,
    296 #if NeedWidePrototypes
    297  unsigned int		height
    298 #else
    299  Dimension		height
    300 #endif
    301  );
    302 
    303 /*
    304  * Function:
    305  *	XawTextSinkMaxHeight
    306  *
    307  * Parameters:
    308  *	w	- TextSink Object
    309  *	lines	- number of lines
    310  *
    311  * Returns:
    312  *	Height
    313  *
    314  * Description:
    315  *	Finds the Minimum height that will contain a given number lines.
    316  */
    317 int XawTextSinkMaxHeight
    318 (
    319  Widget			w,
    320  int			lines
    321 );
    322 
    323 /*
    324  * Function:
    325  *	XawTextSinkSetTabs
    326  *
    327  * Parameters:
    328  *	w		- TextSink Object
    329  *	tab_count	- number of tabs in the list
    330  *	tabs		- text positions of the tabs
    331  * Description:
    332  *	Sets the Tab stops.
    333  */
    334 void XawTextSinkSetTabs
    335 (
    336  Widget			w,
    337  int			tab_count,
    338  int			*tabs
    339 );
    340 
    341 /*
    342  * Function:
    343  *	XawTextSinkGetCursorBounds
    344  *
    345  * Parameters:
    346  *	w	- TextSink Object
    347  *	rect	- X rectance containing the cursor bounds
    348  * Description:
    349  *	Finds the bounding box for the insert curor (caret).
    350  */
    351 void XawTextSinkGetCursorBounds
    352 (
    353  Widget			w,
    354  XRectangle		*rect_return
    355 );
    356 
    357 _XFUNCPROTOEND
    358 
    359 #endif /* _XawTextSink_h */
    360