home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / include / Xm / TextFP.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-30  |  14.6 KB  |  359 lines

  1. /* 
  2.  * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC. 
  3.  * ALL RIGHTS RESERVED 
  4. */ 
  5. /* 
  6.  * Motif Release 1.2
  7. */ 
  8. /*   $RCSfile: TextFP.h,v $ $Revision: 10.1 $ $Date: 1994/02/03 15:51:52 $ */
  9. /*
  10. *  (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 HEWLETT-PACKARD COMPANY */
  11. #ifndef _XmTextFP_h
  12. #define _XmTextFP_h
  13.  
  14. #include <Xm/PrimitiveP.h>
  15. #include <Xm/TextF.h>
  16.  
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20.  
  21. /*
  22.  * Defines for different cursors
  23.  */
  24.  
  25. #define IBEAM_WIDTH 3
  26. #define CARET_WIDTH 9
  27. #define CARET_HEIGHT 5
  28.  
  29. #ifdef NOT_DEF
  30. static unsigned char caretBits[] = {
  31.    0x10, 0x00, 0x38, 0x00, 0x6c, 0x00, 0xc6, 0x00, 0x83, 0x01};
  32. #endif /* NOT_DEF */
  33.  
  34. /*
  35.  * Here is the Text Field Widget class structure.
  36.  */
  37.  
  38. typedef struct _XmTextFieldClassPart
  39.   {
  40.     XtPointer extension;        /* Pointer to extension record. */
  41.   }
  42.   XmTextFieldClassPart;
  43.  
  44. typedef struct _XmTextFieldClassRec
  45.   {
  46.     CoreClassPart core_class;  /* Not RectObjClassPart so I can reference
  47.                   core_class s */
  48.     XmPrimitiveClassPart primitive_class;
  49.     XmTextFieldClassPart text_class;
  50.   }
  51.   XmTextFieldClassRec;
  52.  
  53. externalref XmTextFieldClassRec xmTextFieldClassRec;
  54.  
  55. /*
  56.  * Here is the Text Field Widget instance structures.
  57.  */
  58.  
  59. typedef struct _XmTextFieldPart
  60.   {
  61.     XtCallbackList activate_callback;       /* Command activate callback */
  62.     XtCallbackList focus_callback;  /* Verify losing focus callback */
  63.     XtCallbackList losing_focus_callback;  /* Verify losing focus callback */
  64.     XtCallbackList modify_verify_callback; /* Verify value to change callback */
  65.     XtCallbackList wcs_modify_verify_callback; /* Verify value to change 
  66.                         * callback */
  67.     XtCallbackList motion_verify_callback; /* Verify insert cursor position to
  68.                           change callback */
  69.     XtCallbackList gain_primary_callback; /* Gained ownership of Primary
  70.                                              Selection */
  71.     XtCallbackList lose_primary_callback; /* Lost ownership of Primary
  72.                                              Selection */
  73.     XtCallbackList value_changed_callback; /* Notify that value has change                              callback */
  74.     char * value;        /* pointer to widget value stored as char* */
  75.     wchar_t * wc_value;        /* pointer to widget value stored as wchar_t* */
  76.  
  77.     XmFontList font_list;    /* Uses only the font portion of fontlist */
  78.     XFontStruct *font;            /* font retrieved from the fontlist */
  79.     XmTextScanType *selection_array; /* Description of what to cycle
  80.                          through on selections */
  81.     _XmHighlightData highlight;    /* Info on the highlighting regions. */
  82.  
  83.     GC gc;            /* Normal GC for drawing text and cursor */
  84.     GC image_gc;        /* Image GC for drawing text cursor*/
  85.     GC save_gc;                 /* GC for saving/restoring under IBeam */
  86.  
  87.     Pixmap ibeam_off;        /* pixmap for area under the IBeam */
  88.     Pixmap add_mode_cursor;    /* The add mode cursor pixmap */
  89.     Pixmap cursor;        /* The ibeam cursor stencil */
  90.     Pixmap putback;        /* AVAILABLE: was in 1.1 but not really used */
  91.     Pixmap stipple_tile;    /* The tile pattern for the stippled I-beam */
  92.     Pixmap image_clip;        /* The clip rect needed for image gc */
  93.  
  94.     XmTextPosition cursor_position;/* Character location of the insert cursor */
  95.     XmTextPosition new_h_offset;/* Used in setvaluesalmost proc */
  96.     XmTextPosition h_offset;      /* The x position of the first character
  97.                                    (relative to left edge of the widget) */
  98.     XmTextPosition orig_left;     /* Left primary selection prior to extend */
  99.     XmTextPosition orig_right;    /* Right primary selection prior to extend */
  100.     XmTextPosition prim_pos_left; /* Left primary selection position */
  101.     XmTextPosition prim_pos_right; /* Right primary selection position */
  102.     XmTextPosition prim_anchor;    /* Primary selection pivot point */
  103.  
  104.     XmTextPosition sec_pos_left; /* Left secondary selection position */
  105.     XmTextPosition sec_pos_right; /* Right secondary selection position */
  106.     XmTextPosition sec_anchor;    /* Secondary selection pivot point */
  107.  
  108.     XmTextPosition stuff_pos;    /* Position to stuff the primary selection */
  109.  
  110.     Position select_pos_x;    /* x position for timer-based scrolling */
  111.  
  112.     Time prim_time;             /* Timestamp of primary selection */
  113.     Time dest_time;             /* Timestamp of destination selection */
  114.     Time sec_time;              /* Timestamp of secondary selection */
  115.     Time last_time;             /* Time of last selection event */
  116.  
  117.     XtIntervalId timer_id;    /* Blinking cursor timer */
  118.     XtIntervalId select_id;     /* Timer based scrolling identifier */
  119.  
  120.     int blink_rate;        /* Rate of blinking text cursor in msec */
  121.     int selection_array_count;  /* Selection array count */
  122.     int threshold;        /* Selection threshold */
  123.     int size_allocd;        /* Size allocated for value string */
  124.     int string_length;          /* The number of characters in the string 
  125.                    (including the trailing NULL) */
  126.     int cursor_height;        /* Save cursor dimensions */
  127.     int cursor_width;        /* Save cursor dimensions */
  128.     int sarray_index;        /* Index into selection array */
  129.     int max_length;        /* Maximum number of character that can be
  130.                    inserted into the text field widget */
  131.  
  132.     int max_char_size;          /* Max bytes per character in cur locale */
  133.     short columns;        /* The number of characters in the width */
  134.  
  135.     Dimension margin_width;    /* Height between text borders and text */
  136.     Dimension margin_height;    /* Width between text borders and text */
  137.     Dimension average_char_width;/* Average character width based on font */
  138.     Dimension margin_top;   /* Height between text borders and top of text */
  139.     Dimension margin_bottom;/* Height between text borders and bottom of text */
  140.     Dimension font_ascent;  /* Ascent of font or fontset used by widget */
  141.     Dimension font_descent;  /* Descent of font or fontset used by widget */
  142.  
  143.     Boolean resize_width;    /* Allows the widget to grow horizontally
  144.                    when borders are reached */
  145.     Boolean pending_delete;    /* Delete primary selection on insert when
  146.                    set to True */
  147.     Boolean editable;        /* Sets editablility of text */
  148.     Boolean verify_bell;          /* Determines if bell is sounded when verify
  149.                                    *  callback returns doit - False
  150.                                    */
  151.     Boolean cursor_position_visible;    /* Sets visibility of insert cursor */
  152.  
  153.     Boolean traversed;          /* Flag used with losing focus verification to
  154.                                    indicate a traversal key pressed event */
  155.     Boolean add_mode;        /* Add mode for cursor movement */
  156.     Boolean has_focus;        /* Flag that indicates whether the widget
  157.                        has input focus */
  158.     Boolean blink_on;        /* State of Blinking insert cursor */
  159.     short int cursor_on;    /* Indicates whether the cursor is visible */
  160.     Boolean refresh_ibeam_off;    /* Indicates whether the area under IBeam needs
  161.                    to be re-captured */
  162.     Boolean have_inverted_image_gc;  /* fg/bg of image gc have been swapped */
  163.     Boolean has_primary;    /* Indicates that is has the
  164.                    primary selection */
  165.     Boolean has_secondary;    /* Indicates that is has the
  166.                    secondary selection */
  167.     Boolean has_destination;    /* Indicates that is has the
  168.                    destination selection */
  169.     Boolean sec_drag;           /* Indicates a secondary drag was made */ 
  170.     Boolean selection_move;    /* Indicates that the action requires a
  171.                    secondary move (i.e. copy & cut) */
  172.     Boolean pending_off;    /* indicates pending delete state */
  173.     Boolean fontlist_created;   /* Indicates that the text field widget created
  174.                    it's own fontlist */
  175.     Boolean has_rect;        /* currently has clipping rectangle */
  176.     Boolean do_drop;        /* Indicates that the widget the recieved the
  177.                    button release, did not have a previous
  178.                                    button press, so it is o.k. to request
  179.                    the MOTIF_DROP selection. */
  180.     Boolean cancel;        /* Cancels selection actions when true */
  181.     Boolean extending;        /* Indicates extending primary selection */
  182.     Boolean sec_extending;      /* Indicates extending secondary selection */
  183.     Boolean changed_visible;    /* Indicates whether the dest_visible flag
  184.                                    is in a temporary changed state */
  185.     Boolean have_fontset;       /* The widgets font is a fontset, not a 
  186.                  * fontstruct... use R5 draw routines */
  187.     Boolean in_setvalues;    /* used to disable unnecessary redisplays */
  188.     Boolean do_resize;        /* used to prevent inappropriate resizes */
  189.     Boolean redisplay;        /* used to set redisplay flag in setvalues */
  190.     Boolean overstrike;        /* overstrike mode for character input */
  191.     Boolean sel_start;        /* overstrike mode for character input */
  192.     XtPointer extension;    /* Pointer to extension record. */
  193.   }
  194.   XmTextFieldPart;
  195.  
  196. typedef struct _XmTextFieldRec
  197.   {
  198.     CorePart core;
  199.     XmPrimitivePart primitive;
  200.     XmTextFieldPart text;
  201.   }
  202.   XmTextFieldRec;
  203.  
  204. /****************
  205.  *
  206.  * Macros for the uncached data
  207.  *
  208.  ****************/
  209.  
  210. #define TextF_ActivateCallback(tfg)        (((XmTextFieldWidget)(tfg)) -> \
  211.                        text.activate_callback)
  212. #define TextF_LosingFocusCallback(tfg)        (((XmTextFieldWidget)(tfg)) -> \
  213.                        text.losing_focus_callback)
  214. #define TextF_FocusCallback(tfg)        (((XmTextFieldWidget)(tfg)) -> \
  215.                        text.focus_callback)
  216. #define TextF_ModifyVerifyCallback(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  217.                        text.modify_verify_callback)
  218. #define TextF_ModifyVerifyCallbackWcs(tfg)      (((XmTextFieldWidget)(tfg)) -> \
  219.                        text.wcs_modify_verify_callback)
  220. #define TextF_MotionVerifyCallback(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  221.                        text.motion_verify_callback)
  222. #define TextF_ValueChangedCallback(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  223.                        text.value_changed_callback)
  224. #define TextF_Value(tfg)                        (((XmTextFieldWidget)(tfg)) -> \
  225.                        text.value)
  226. #define TextF_WcValue(tfg)                      (((XmTextFieldWidget)(tfg)) -> \
  227.                        text.wc_value)
  228. #define TextF_MarginHeight(tfg)                (((XmTextFieldWidget)(tfg)) -> \
  229.                        text.margin_height)
  230. #define TextF_MarginWidth(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  231.                        text.margin_width)
  232. #define TextF_CursorPosition(tfg)        (((XmTextFieldWidget)(tfg)) -> \
  233.                        text.cursor_position)
  234. #define TextF_Columns(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  235.                        text.columns)
  236. #define TextF_MaxLength(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  237.                        text.max_length)
  238. #define TextF_BlinkRate(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  239.                        text.blink_rate)
  240. #define TextF_FontList(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  241.                        text.font_list)
  242. #define TextF_Font(tfg)                (((XmTextFieldWidget)(tfg)) -> \
  243.                        text.font)
  244. #define TextF_FontAscent(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  245.                        text.font_ascent)
  246. #define TextF_FontDescent(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  247.                        text.font_descent)
  248. #define TextF_SelectionArray(tfg)        (((XmTextFieldWidget)(tfg)) -> \
  249.                        text.selection_array)
  250. #define TextF_SelectionArrayCount(tfg)        (((XmTextFieldWidget)(tfg)) -> \
  251.                        text.selection_array_count)
  252. #define TextF_ResizeWidth(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  253.                        text.resize_width)
  254. #define TextF_PendingDelete(tfg)        (((XmTextFieldWidget)(tfg)) -> \
  255.                        text.pending_delete)
  256. #define TextF_Editable(tfg)            (((XmTextFieldWidget)(tfg)) -> \
  257.                        text.editable)
  258. #define TextF_CursorPositionVisible(tfg)    (((XmTextFieldWidget)(tfg)) -> \
  259.                        text.cursor_position_visible)
  260. #define TextF_Threshold(tfg)               (((XmTextFieldWidget)(tfg)) -> \
  261.                        text.threshold)
  262. #define TextF_UseFontSet(tfg)               (((XmTextFieldWidget)(tfg)) -> \
  263.                        text.have_fontset)
  264.  
  265. /********    Private Function Declarations    ********/
  266. #ifdef _NO_PROTO
  267.  
  268. extern int _XmTextFieldCountBytes() ;
  269. extern Widget _XmTextFieldGetDropReciever() ;
  270. extern void _XmTextFToggleCursorGC() ;
  271. extern void _XmTextFieldDrawInsertionPoint() ;
  272. extern void _XmTextFieldSetClipRect() ;
  273. extern void _XmTextFieldSetCursorPosition() ;
  274. extern Boolean _XmTextFieldReplaceText() ;
  275. extern void _XmTextFieldDeselectSelection() ;
  276. extern Boolean _XmTextFieldSetDestination() ;
  277. extern void _XmTextFieldStartSelection() ;
  278. extern void _XmTextFieldSetSel2() ;
  279.  
  280. #else
  281.  
  282. extern int _XmTextFieldCountBytes( 
  283.                         XmTextFieldWidget tf,
  284.                         wchar_t *wc_value,
  285.                         int num_chars) ;
  286. extern Widget _XmTextFieldGetDropReciever( 
  287.                         Widget w) ;
  288. extern void _XmTextFToggleCursorGC( 
  289.                         Widget widget) ;
  290. extern void _XmTextFieldDrawInsertionPoint( 
  291.                         XmTextFieldWidget tf,
  292. #if NeedWidePrototypes
  293.                         int turn_on) ;
  294. #else
  295.                         Boolean turn_on) ;
  296. #endif /* NeedWidePrototypes */
  297. extern void _XmTextFieldSetClipRect( 
  298.                         XmTextFieldWidget tf) ;
  299. extern void _XmTextFieldSetCursorPosition( 
  300.                         XmTextFieldWidget tf,
  301.                         XEvent *event,
  302.                         XmTextPosition position,
  303. #if NeedWidePrototypes
  304.                         int adjust_flag,
  305.                         int call_cb) ;
  306. #else
  307.                         Boolean adjust_flag,
  308.                         Boolean call_cb) ;
  309. #endif /* NeedWidePrototypes */
  310. extern Boolean _XmTextFieldReplaceText( 
  311.                         XmTextFieldWidget tf,
  312.                         XEvent *event,
  313.                         XmTextPosition replace_prev,
  314.                         XmTextPosition replace_next,
  315.                         char *insert,
  316.                         int insert_length,
  317. #if NeedWidePrototypes
  318.                         int move_cursor) ;
  319. #else
  320.                         Boolean move_cursor) ;
  321. #endif /* NeedWidePrototypes */
  322. extern void _XmTextFieldDeselectSelection( 
  323.                         Widget w,
  324. #if NeedWidePrototypes
  325.                         int disown,
  326. #else
  327.                         Boolean disown,
  328. #endif /* NeedWidePrototypes */
  329.                         Time sel_time) ;
  330. extern Boolean _XmTextFieldSetDestination( 
  331.                         Widget w,
  332.                         XmTextPosition position,
  333.                         Time set_time) ;
  334. extern void _XmTextFieldStartSelection( 
  335.                         XmTextFieldWidget tf,
  336.                         XmTextPosition left,
  337.                         XmTextPosition right,
  338.                         Time sel_time) ;
  339. extern void _XmTextFieldSetSel2( 
  340.                         Widget w,
  341.                         XmTextPosition left,
  342.                         XmTextPosition right,
  343. #if NeedWidePrototypes
  344.                         int disown,
  345. #else
  346.                         Boolean disown,
  347. #endif /* NeedWidePrototypes */
  348.                         Time sel_time) ;
  349.  
  350. #endif /* _NO_PROTO */
  351. /********    End Private Function Declarations    ********/
  352.  
  353.  
  354. #ifdef __cplusplus
  355. }  /* Close scope of 'extern "C"' declaration which encloses file. */
  356. #endif
  357.  
  358. #endif /* _XmTextFieldWidgetP_h */
  359.