1 /* 2 * Motif 3 * 4 * Copyright (c) 1987-2012, The Open Group. All rights reserved. 5 * 6 * These libraries and programs are free software; you can 7 * redistribute them and/or modify them under the terms of the GNU 8 * Lesser General Public License as published by the Free Software 9 * Foundation; either version 2 of the License, or (at your option) 10 * any later version. 11 * 12 * These libraries and programs are distributed in the hope that 13 * they will be useful, but WITHOUT ANY WARRANTY; without even the 14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 15 * PURPOSE. See the GNU Lesser General Public License for more 16 * details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with these librararies and programs; if not, write 20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 21 * Floor, Boston, MA 02110-1301 USA 22 */ 23 #ifndef _XmTextFP_h 24 #define _XmTextFP_h 25 26 #include <Xm/PrimitiveP.h> 27 #include <Xm/TextF.h> 28 #ifdef USE_XFT 29 #include <X11/Xft/Xft.h> 30 #endif 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* 37 * Defines for different cursors 38 */ 39 40 #define IBEAM_WIDTH 3 41 #define CARET_WIDTH 9 42 #define CARET_HEIGHT 5 43 44 /* 45 * Here is the Text Field Widget class structure. 46 */ 47 48 typedef struct _XmTextFieldClassPart { 49 XtPointer extension; /* Pointer to extension record. */ 50 } XmTextFieldClassPart; 51 52 typedef struct _XmTextFieldClassRec { 53 CoreClassPart core_class; /* Not RectObjClassPart so I can reference 54 core_class s */ 55 XmPrimitiveClassPart primitive_class; 56 XmTextFieldClassPart text_class; 57 } XmTextFieldClassRec; 58 59 externalref XmTextFieldClassRec xmTextFieldClassRec; 60 61 /* 62 * On the spot support. 63 */ 64 typedef struct _OnTheSpotData { 65 XmTextPosition start; 66 XmTextPosition end; 67 XmTextPosition cursor; 68 int over_len; 69 int over_maxlen; 70 char *over_str; 71 int under_preedit; 72 Boolean under_verify_preedit; 73 Boolean verify_commit; 74 int pad; 75 } OnTheSpotDataRec, *OnTheSpotData; 76 77 /* 78 * Here is the Text Field Widget instance structures. 79 */ 80 81 typedef struct _XmTextFieldPart { 82 XtCallbackList activate_callback; /* Command activate callback */ 83 XtCallbackList focus_callback; /* Verify gain focus callback */ 84 XtCallbackList losing_focus_callback; /* Verify losing focus 85 callback */ 86 XtCallbackList modify_verify_callback; /* Verify value to change 87 callback */ 88 XtCallbackList wcs_modify_verify_callback; /* Verify value to change 89 callback */ 90 XtCallbackList motion_verify_callback; /* Verify insert cursor position 91 to change callback */ 92 XtCallbackList gain_primary_callback; /* Gained ownership of Primary 93 Selection */ 94 XtCallbackList lose_primary_callback; /* Lost ownership of Primary 95 Selection */ 96 XtCallbackList value_changed_callback; /* Notify that value has changed 97 callback */ 98 char * value; /* pointer to widget value stored as char * */ 99 wchar_t * wc_value; /* pointer to widget value stored as 100 wchar_t * */ 101 102 XmFontList font_list; /* Uses only the font portion of fontlist */ 103 #if USE_XFT 104 XtPointer font; /* font retrieved from the fontlist */ 105 #else 106 XFontStruct *font; /* font retrieved from the fontlist */ 107 #endif 108 XmTextScanType *selection_array; /* Description of what to cycle 109 through on selections */ 110 _XmHighlightData highlight; /* Info on the highlighting regions. */ 111 112 GC gc; /* Normal GC for drawing text and cursor */ 113 GC image_gc; /* Image GC for drawing text cursor*/ 114 GC save_gc; /* GC for saving/restoring under IBeam */ 115 116 Pixmap ibeam_off; /* pixmap for area under the IBeam */ 117 Pixmap add_mode_cursor; /* The add mode cursor pixmap */ 118 Pixmap cursor; /* The ibeam cursor stencil */ 119 Pixmap putback; /* AVAILABLE: was in 1.1 but not really used */ 120 Pixmap stipple_tile; /* The tile pattern for the stippled I-beam */ 121 Pixmap image_clip; /* AVAILABLE: was in 1.2 but not used now */ 122 123 XmTextPosition cursor_position; /* Character location of the insert 124 cursor */ 125 XmTextPosition new_h_offset; /* AVAILABLE: was in 1.1 but not used */ 126 XmTextPosition h_offset; /* The x position of the first character 127 (relative to left edge of widget) */ 128 XmTextPosition orig_left; /* Left primary selection prior to 129 extend */ 130 XmTextPosition orig_right; /* Right primary selection prior to 131 extend */ 132 XmTextPosition prim_pos_left; /* Left primary selection position */ 133 XmTextPosition prim_pos_right; /* Right primary selection position */ 134 XmTextPosition prim_anchor; /* Primary selection pivot point */ 135 136 XmTextPosition sec_pos_left; /* Left secondary selection position */ 137 XmTextPosition sec_pos_right; /* Right secondary selection position */ 138 XmTextPosition sec_anchor; /* Secondary selection pivot point */ 139 140 XmTextPosition stuff_pos; /* Position to stuff the primary selection */ 141 142 Position select_pos_x; /* x position for timer-based scrolling */ 143 144 Time prim_time; /* Timestamp of primary selection */ 145 Time dest_time; /* Timestamp of destination selection */ 146 Time sec_time; /* Timestamp of secondary selection */ 147 Time last_time; /* Time of last selection event */ 148 149 XtIntervalId timer_id; /* Blinking cursor timer */ 150 XtIntervalId select_id; /* Timer based scrolling identifier */ 151 152 int blink_rate; /* Rate of blinking text cursor in msec */ 153 int selection_array_count; /* Selection array count */ 154 int threshold; /* Selection threshold */ 155 int size_allocd; /* Size allocated for value string */ 156 int string_length; /* The number of characters in the string 157 (including the trailing NULL) */ 158 int cursor_height; /* Save cursor dimensions */ 159 int cursor_width; /* Save cursor dimensions */ 160 int sarray_index; /* Index into selection array */ 161 int max_length; /* Maximum number of character that can be 162 inserted into the text field widget */ 163 164 int max_char_size; /* Max bytes per character in cur locale */ 165 short columns; /* The number of characters in the width */ 166 167 Dimension margin_width; /* Height between text borders and text */ 168 Dimension margin_height; /* Width between text borders and text */ 169 Dimension average_char_width; /* Average character width based on font */ 170 Dimension margin_top; /* Height between text borders and top of 171 text */ 172 Dimension margin_bottom; /* Height between text borders and bottom of 173 text */ 174 Dimension font_ascent; /* Ascent of font or fontset used by widget */ 175 Dimension font_descent; /* Descent of font or fontset used by widget */ 176 177 Boolean resize_width; /* Allows the widget to grow horizontally 178 when borders are reached */ 179 Boolean pending_delete; /* Delete primary selection on insert when 180 set to True */ 181 Boolean editable; /* Sets editablility of text */ 182 Boolean verify_bell; /* Determines if bell is sounded when verify 183 callback returns doit - False */ 184 Boolean cursor_position_visible; /* Sets visibility of insert cursor */ 185 186 Boolean traversed; /* Flag used with losing focus verification to 187 indicate a traversal key pressed event */ 188 Boolean add_mode; /* Add mode for cursor movement */ 189 Boolean has_focus; /* Flag that indicates whether the widget 190 has input focus */ 191 Boolean blink_on; /* State of Blinking insert cursor */ 192 short int cursor_on; /* Indicates whether the cursor is visible */ 193 Boolean refresh_ibeam_off; /* Indicates whether the area under IBeam needs 194 to be re-captured */ 195 Boolean have_inverted_image_gc; /* fg/bg of image gc have been swapped */ 196 Boolean has_primary; /* Indicates that is has the 197 primary selection */ 198 Boolean has_secondary; /* Indicates that is has the 199 secondary selection */ 200 Boolean has_destination; /* Indicates that is has the 201 destination selection */ 202 Boolean sec_drag; /* Indicates a secondary drag was made */ 203 Boolean selection_move; /* Indicates that the action requires a 204 secondary move (i.e. copy & cut) */ 205 Boolean pending_off; /* indicates pending delete state */ 206 Boolean fontlist_created; /* Indicates that the text field widget created 207 it's own fontlist */ 208 Boolean has_rect; /* currently has clipping rectangle */ 209 Boolean do_drop; /* Indicates that the widget the recieved the 210 button release, did not have a previous 211 button press, so it is o.k. to request 212 the MOTIF_DROP selection. */ 213 Boolean cancel; /* Cancels selection actions when true */ 214 Boolean extending; /* Indicates extending primary selection */ 215 Boolean sec_extending; /* Indicates extending secondary selection */ 216 Boolean changed_visible; /* Indicates whether the dest_visible flag 217 is in a temporary changed state */ 218 Boolean have_fontset; /* The widgets font is a fontset, not a 219 fontstruct... use R5 draw routines */ 220 Boolean in_setvalues; /* used to disable unnecessary redisplays */ 221 Boolean do_resize; /* used to prevent inappropriate resizes */ 222 Boolean redisplay; /* used to set redisplay flag in setvalues */ 223 Boolean overstrike; /* overstrike mode for character input */ 224 Boolean sel_start; /* overstrike mode for character input */ 225 XtPointer extension; /* Pointer to extension record. */ 226 227 XtCallbackList destination_callback; /* Selection destination cb */ 228 Boolean selection_link; /* Indicates that the action requires a 229 link */ 230 /* New for 2.0 */ 231 Boolean take_primary; /* Indicates that is has to take the 232 primary selection */ 233 GC cursor_gc; /* 1-bit depth GC for creating the I-beam 234 stipples (normal & add mode) */ 235 XtIntervalId drag_id; /* timer to start btn1 drag */ 236 _XmTextActionRec *transfer_action; /* to keep track of delayed action */ 237 /* Boolean rt_save; */ /* used for MT work */ 238 OnTheSpotData onthespot; /* data for on-the-spot im support */ 239 240 Boolean check_set_render_table; /* used for MT safe work */ 241 Boolean programmatic_highlights; /* XmTextFieldSetHighlight called */ 242 #ifdef USE_XFT 243 Boolean use_xft; 244 #endif 245 } XmTextFieldPart; 246 247 typedef struct _XmTextFieldRec { 248 CorePart core; 249 XmPrimitivePart primitive; 250 XmTextFieldPart text; 251 } XmTextFieldRec; 252 253 254 /**************** 255 * 256 * Macros for the uncached data 257 * 258 ****************/ 259 260 #define TextF_ActivateCallback(tfg) \ 261 (((XmTextFieldWidget)(tfg)) -> text.activate_callback) 262 #define TextF_LosingFocusCallback(tfg) \ 263 (((XmTextFieldWidget)(tfg)) -> text.losing_focus_callback) 264 #define TextF_FocusCallback(tfg) \ 265 (((XmTextFieldWidget)(tfg)) -> text.focus_callback) 266 #define TextF_ModifyVerifyCallback(tfg) \ 267 (((XmTextFieldWidget)(tfg)) -> text.modify_verify_callback) 268 #define TextF_ModifyVerifyCallbackWcs(tfg) \ 269 (((XmTextFieldWidget)(tfg)) -> text.wcs_modify_verify_callback) 270 #define TextF_MotionVerifyCallback(tfg) \ 271 (((XmTextFieldWidget)(tfg)) -> text.motion_verify_callback) 272 #define TextF_ValueChangedCallback(tfg) \ 273 (((XmTextFieldWidget)(tfg)) -> text.value_changed_callback) 274 #define TextF_Value(tfg) \ 275 (((XmTextFieldWidget)(tfg)) -> text.value) 276 #define TextF_WcValue(tfg) \ 277 (((XmTextFieldWidget)(tfg)) -> text.wc_value) 278 #define TextF_MarginHeight(tfg) \ 279 (((XmTextFieldWidget)(tfg)) -> text.margin_height) 280 #define TextF_MarginWidth(tfg) \ 281 (((XmTextFieldWidget)(tfg)) -> text.margin_width) 282 #define TextF_CursorPosition(tfg) \ 283 (((XmTextFieldWidget)(tfg)) -> text.cursor_position) 284 #define TextF_Columns(tfg) \ 285 (((XmTextFieldWidget)(tfg)) -> text.columns) 286 #define TextF_MaxLength(tfg) \ 287 (((XmTextFieldWidget)(tfg)) -> text.max_length) 288 #define TextF_BlinkRate(tfg) \ 289 (((XmTextFieldWidget)(tfg)) -> text.blink_rate) 290 #define TextF_FontList(tfg) \ 291 (((XmTextFieldWidget)(tfg)) -> text.font_list) 292 #define TextF_Font(tfg) \ 293 ((XFontStruct*)(((XmTextFieldWidget)(tfg)) -> text.font)) 294 #define TextF_FontAscent(tfg) \ 295 (((XmTextFieldWidget)(tfg)) -> text.font_ascent) 296 #define TextF_FontDescent(tfg) \ 297 (((XmTextFieldWidget)(tfg)) -> text.font_descent) 298 #define TextF_SelectionArray(tfg) \ 299 (((XmTextFieldWidget)(tfg)) -> text.selection_array) 300 #define TextF_SelectionArrayCount(tfg) \ 301 (((XmTextFieldWidget)(tfg)) -> text.selection_array_count) 302 #define TextF_ResizeWidth(tfg) \ 303 (((XmTextFieldWidget)(tfg)) -> text.resize_width) 304 #define TextF_PendingDelete(tfg) \ 305 (((XmTextFieldWidget)(tfg)) -> text.pending_delete) 306 #define TextF_Editable(tfg) \ 307 (((XmTextFieldWidget)(tfg)) -> text.editable) 308 #define TextF_CursorPositionVisible(tfg) \ 309 (((XmTextFieldWidget)(tfg)) -> text.cursor_position_visible) 310 #define TextF_Threshold(tfg) \ 311 (((XmTextFieldWidget)(tfg)) -> text.threshold) 312 #define TextF_UseFontSet(tfg) \ 313 (((XmTextFieldWidget)(tfg)) -> text.have_fontset) 314 #ifdef USE_XFT 315 #define TextF_UseXft(tfg) \ 316 (((XmTextFieldWidget)(tfg)) -> text.use_xft) 317 #define TextF_XftFont(tfg) \ 318 ((XftFont*)(((XmTextFieldWidget)(tfg)) -> text.font)) 319 #endif 320 321 /* 322 * On the spot support. 323 */ 324 #define PreStart(tfg) (((XmTextFieldWidget)(tfg)) -> \ 325 text.onthespot->start) 326 #define PreEnd(tfg) (((XmTextFieldWidget)(tfg)) -> \ 327 text.onthespot->end) 328 #define PreCursor(tfg) (((XmTextFieldWidget)(tfg)) -> \ 329 text.onthespot->cursor) 330 #define FUnderVerifyPreedit(tfg) (((XmTextFieldWidget)(tfg)) -> \ 331 text.onthespot->under_verify_preedit) 332 #define FVerifyCommitNeeded(tfg) (((XmTextFieldWidget)(tfg)) -> \ 333 text.onthespot->verify_commit) 334 335 #ifdef __cplusplus 336 } /* Close scope of 'extern "C"' declaration which encloses file. */ 337 #endif 338 339 #endif /* _XmTextFieldWidgetP_h */ 340