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

  1. /*
  2. * $XConsortium: TextP.h,v 1.54 95/06/14 15:07:27 kaleb Exp $
  3. */
  4.  
  5.  
  6. /***********************************************************
  7.  
  8. Copyright (c) 1987, 1988, 1994  X Consortium
  9.  
  10. Permission is hereby granted, free of charge, to any person obtaining a copy
  11. of this software and associated documentation files (the "Software"), to deal
  12. in the Software without restriction, including without limitation the rights
  13. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14. copies of the Software, and to permit persons to whom the Software is
  15. furnished to do so, subject to the following conditions:
  16.  
  17. The above copyright notice and this permission notice shall be included in
  18. all copies or substantial portions of the Software.
  19.  
  20. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  23. X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  24. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  25. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26.  
  27. Except as contained in this notice, the name of the X Consortium shall not be
  28. used in advertising or otherwise to promote the sale, use or other dealings
  29. in this Software without prior written authorization from the X Consortium.
  30.  
  31.  
  32. Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
  33.  
  34.                         All Rights Reserved
  35.  
  36. Permission to use, copy, modify, and distribute this software and its 
  37. documentation for any purpose and without fee is hereby granted, 
  38. provided that the above copyright notice appear in all copies and that
  39. both that copyright notice and this permission notice appear in 
  40. supporting documentation, and that the name of Digital not be
  41. used in advertising or publicity pertaining to distribution of the
  42. software without specific, written prior permission.  
  43.  
  44. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  45. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  46. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  47. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  48. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  49. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  50. SOFTWARE.
  51.  
  52. ******************************************************************/
  53.  
  54. #ifndef _XawTextP_h
  55. #define _XawTextP_h
  56.  
  57. #include <X11/Xaw/Text.h>
  58. #include <X11/Xaw/SimpleP.h>
  59.  
  60. /****************************************************************
  61.  *
  62.  * Text widget private
  63.  *
  64.  ****************************************************************/
  65. #define MAXCUT    30000    /* Maximum number of characters that can be cut. */
  66.  
  67. #define GETLASTPOS  XawTextSourceScan(ctx->text.source, 0, \
  68.                       XawstAll, XawsdRight, 1, TRUE)
  69.  
  70. #define zeroPosition ((XawTextPosition) 0)
  71.  
  72. extern XtActionsRec _XawTextActionsTable[];
  73. extern Cardinal _XawTextActionsTableCount;
  74.  
  75. #define XawLF    0x0a
  76. #define XawCR    0x0d
  77. #define XawTAB    0x09
  78. #define XawBS    0x08
  79. #define XawSP    0x20
  80. #define XawDEL    0x7f
  81. #define XawESC  0x1b
  82. #define XawBSLASH '\\'
  83.  
  84. /* constants that subclasses may want to know */
  85. #define DEFAULT_TEXT_HEIGHT ((Dimension)~0)
  86.  
  87. /* displayable text management data structures */
  88.  
  89. typedef struct {
  90.   XawTextPosition position;
  91.   Position y;
  92.   Dimension textWidth;
  93. } XawTextLineTableEntry, *XawTextLineTableEntryPtr;
  94.  
  95. typedef struct {
  96.     XawTextPosition   left, right;
  97.     XawTextSelectType type;
  98.     Atom*         selections;
  99.     int             atom_count;
  100.     int             array_size;
  101. } XawTextSelection;
  102.  
  103. typedef struct _XawTextSelectionSalt {
  104.     struct _XawTextSelectionSalt    *next;
  105.     XawTextSelection    s;
  106.     /* 
  107.      * The element "contents" stores the CT string which is gotten in the
  108.      * function _XawTextSaltAwaySelection().
  109.     */ 
  110.     char        *contents;
  111.     int            length;
  112. } XawTextSelectionSalt;
  113.  
  114. /* Line Tables are n+1 long - last position displayed is in last lt entry */
  115. typedef struct {
  116.   XawTextPosition     top;    /* Top of the displayed text.        */
  117.   int             lines;    /* How many lines in this table.    */
  118.   XawTextLineTableEntry *info;  /* A dynamic array, one entry per line  */
  119. } XawTextLineTable, *XawTextLineTablePtr;
  120.  
  121.  
  122. typedef struct _XawTextMargin {
  123.   Position left, right, top, bottom;
  124. } XawTextMargin;
  125.  
  126. #define VMargins(ctx) ( (ctx)->text.margin.top + (ctx)->text.margin.bottom )
  127. #define HMargins(ctx) ( (ctx)->text.margin.left + (ctx)->text.margin.right )
  128.  
  129. #define IsPositionVisible(ctx, pos) \
  130.         (pos >= ctx->text.lt.info[0].position && \
  131.          pos < ctx->text.lt.info[ctx->text.lt.lines].position)
  132.  
  133. /*
  134.  * Search & Replace data structure.
  135.  */
  136.  
  137. struct SearchAndReplace {
  138.   Boolean selection_changed;    /* flag so that the selection cannot be
  139.                    changed out from underneath query-replace.*/
  140.   Widget search_popup;        /* The poppup widget that allows searches.*/
  141.   Widget label1;        /* The label widgets for the search window. */
  142.   Widget label2;
  143.   Widget left_toggle;        /* The left search toggle radioGroup. */
  144.   Widget right_toggle;        /* The right search toggle radioGroup. */
  145.   Widget rep_label;        /* The Replace label string. */
  146.   Widget rep_text;        /* The Replace text field. */
  147.   Widget search_text;        /* The Search text field. */
  148.   Widget rep_one;        /* The Replace one button. */
  149.   Widget rep_all;        /* The Replace all button. */
  150. };
  151.     
  152. /* Private Text Definitions */
  153.  
  154. typedef int (*ActionProc)();
  155.  
  156. /* New fields for the Text widget class record */
  157.  
  158. typedef struct {int empty;} TextClassPart;
  159.  
  160. struct text_move {
  161.     int h, v;
  162.     struct text_move * next;
  163. };
  164.  
  165. /* Full class record declaration */
  166. typedef struct _TextClassRec {
  167.     CoreClassPart    core_class;
  168.     SimpleClassPart    simple_class;
  169.     TextClassPart    text_class;
  170. } TextClassRec;
  171.  
  172. extern TextClassRec textClassRec;
  173.  
  174. /* New fields for the Text widget record */
  175. typedef struct _TextPart {
  176.     /* resources */
  177.  
  178.     Widget              source, sink;
  179.     XawTextPosition    insertPos;
  180.     XawTextSelection    s;
  181.     XawTextSelectType    *sarray;       /* Array to cycle for selections. */
  182.     XawTextSelectionSalt    *salt;         /* salted away selections */
  183.     int            options;         /* wordbreak, scroll, etc. */
  184.     int            dialog_horiz_offset; /* position for popup dialog */
  185.     int            dialog_vert_offset;  /* position for popup dialog */
  186.     Boolean        display_caret;         /* insertion pt visible iff T */
  187.     Boolean             auto_fill;           /* Auto fill mode? */
  188.     XawTextScrollMode   scroll_vert, scroll_horiz; /*what type of scrollbars.*/
  189.     XawTextWrapMode     wrap;            /* The type of wrapping. */
  190.     XawTextResizeMode   resize;                 /* what to resize */
  191.     XawTextMargin       r_margin;            /* The real margins. */
  192.     XtCallbackList    unrealize_callbacks; /* used for scrollbars */
  193.     
  194.     /* private state */
  195.  
  196.     XawTextMargin       margin;            /* The current margins. */
  197.     XawTextLineTable    lt;
  198.     XawTextScanDirection extendDir;
  199.     XawTextSelection    origSel;    /* the selection being modified */
  200.     Time        lasttime;        /* timestamp of last processed action */
  201.     Time        time;        /* time of last key or button action */ 
  202.     Position        ev_x, ev_y;        /* x, y coords for key or button action */
  203.     Widget        vbar, hbar;        /* The scroll bars (none = NULL). */
  204.     struct SearchAndReplace * search;/* Search and replace structure. */
  205.     Widget          file_insert;    /* The file insert popup widget. */
  206.     XawTextPosition  *updateFrom;   /* Array of start positions for update. */
  207.     XawTextPosition  *updateTo;        /* Array of end positions for update. */
  208.     int            numranges;        /* How many update ranges there are. */
  209.     int            maxranges;        /* How many ranges we have space for */
  210.     XawTextPosition  lastPos;        /* Last position of source. */
  211.     GC              gc;
  212.     Boolean        showposition;   /* True if we need to show the position. */
  213.     Boolean         hasfocus;       /* TRUE if we currently have input focus.*/
  214.     Boolean        update_disabled; /* TRUE if display updating turned off */
  215.     Boolean         single_char;    /* Single character replaced. */
  216.     XawTextPosition  old_insert;    /* Last insertPos for batched updates */
  217.     short           mult;        /* Multiplier. */
  218.     struct text_move * copy_area_offsets; /* Text offset area (linked list) */
  219.  
  220.     /* private state, shared w/Source and Sink */
  221.     Boolean        redisplay_needed; /* in SetValues */
  222.     XawTextSelectionSalt    *salt2;         /* salted away selections */
  223. } TextPart;
  224.  
  225. /*************************************************************
  226.  *
  227.  * Resource types private to Text widget.
  228.  *
  229.  *************************************************************/
  230.  
  231. #define XtRScrollMode "ScrollMode"
  232. #define XtRWrapMode "WrapMode"
  233. #define XtRResizeMode "ResizeMode"
  234.  
  235. /****************************************************************
  236.  *
  237.  * Full instance record declaration
  238.  *
  239.  ****************************************************************/
  240.  
  241. typedef struct _TextRec {
  242.     CorePart    core;
  243.     SimplePart    simple;
  244.     TextPart    text;
  245. } TextRec;
  246.  
  247. /********************************************
  248.  *
  249.  * Semi-private functions
  250.  * for use by other Xaw modules only
  251.  *
  252.  *******************************************/
  253.  
  254. extern void _XawTextBuildLineTable (
  255. #if NeedFunctionPrototypes
  256.     TextWidget /*ctx*/, 
  257.     XawTextPosition /*top pos*/, 
  258.     _XtBoolean /* force_rebuild */
  259. #endif
  260. );
  261.  
  262. extern char* _XawTextGetSTRING(
  263. #if NeedFunctionPrototypes
  264.     TextWidget /*ctx*/, 
  265.     XawTextPosition /*left*/, 
  266.     XawTextPosition /*right*/
  267. #endif
  268. ); 
  269.  
  270. extern void _XawTextSaltAwaySelection(
  271. #if NeedFunctionPrototypes
  272.     TextWidget /*ctx*/, 
  273.     Atom* /*selections*/, 
  274.     int /*num_atoms*/
  275. #endif
  276. ); 
  277.  
  278. extern void _XawTextPosToXY(
  279. #if NeedFunctionPrototypes
  280.     Widget            /* w */,
  281.     XawTextPosition        /* pos */,
  282.     Position *            /* x */,
  283.     Position *            /*y */
  284. #endif
  285. );
  286.  
  287. #endif /* _XawTextP_h */
  288.  
  289.  
  290.