1 /* 2 * Copyright(c) 1992 Bell Communications Research, Inc. (Bellcore) 3 * Copyright(c) 1995-99 Andrew Lister 4 * Copyright � 1999, 2000, 2001, 2002, 2003, 2004 by the LessTif Developers. 5 * 6 * All rights reserved 7 * Permission to use, copy, modify and distribute this material for 8 * any purpose and without fee is hereby granted, provided that the 9 * above copyright notice and this permission notice appear in all 10 * copies, and that the name of Bellcore not be used in advertising 11 * or publicity pertaining to this material without the specific, 12 * prior written permission of an authorized representative of 13 * Bellcore. 14 * 15 * BELLCORE MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX- 16 * PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT 17 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN- 19 * FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS. THE 20 * SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL BELLCORE OR 21 * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY 22 * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT- 23 * ING TO THE SOFTWARE. 24 * 25 * MatrixWidget Author: Andrew Wason, Bellcore, aw@bae.bellcore.com 26 * 27 * $Id: MatrixP.h,v 1.81 2006/05/16 19:59:53 tobiasoed Exp $ 28 */ 29 30 /* 31 * MatrixP.h - Private definitions for Matrix widget 32 */ 33 34 #ifndef _Xbae_MatrixP_h 35 #define _Xbae_MatrixP_h 36 37 #include <Xm/ManagerP.h> 38 #include <Xbae/Matrix.h> 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 45 /* 46 * New types for the class methods 47 */ 48 49 typedef void (*XbaeMatrixSetCellProc)(XbaeMatrixWidget, int, int, 50 const String, Boolean); 51 52 typedef String (*XbaeMatrixGetCellProc)(XbaeMatrixWidget, int, int); 53 54 typedef void (*XbaeMatrixEditCellProc)(XbaeMatrixWidget, XEvent *, 55 int, int, String *, Cardinal); 56 57 typedef void (*XbaeMatrixSelectCellProc)(XbaeMatrixWidget, int, int); 58 59 typedef void (*XbaeMatrixSelectRowProc)(XbaeMatrixWidget, int); 60 61 typedef void (*XbaeMatrixShowColumnArrowsProc)(XbaeMatrixWidget, int, Boolean); 62 63 typedef void (*XbaeMatrixSelectColumnProc)(XbaeMatrixWidget, int); 64 65 typedef void (*XbaeMatrixDeselectAllProc)(XbaeMatrixWidget); 66 67 typedef void (*XbaeMatrixSelectAllProc)(XbaeMatrixWidget); 68 69 typedef void (*XbaeMatrixDeselectCellProc)(XbaeMatrixWidget, int, int); 70 71 typedef void (*XbaeMatrixDeselectRowProc)(XbaeMatrixWidget, int); 72 73 typedef void (*XbaeMatrixDeselectColumnProc)(XbaeMatrixWidget, int); 74 75 typedef Boolean (*XbaeMatrixCommitEditProc)(XbaeMatrixWidget, XEvent *, 76 Boolean); 77 78 typedef void (*XbaeMatrixCancelEditProc)(XbaeMatrixWidget, Boolean); 79 80 typedef void (*XbaeMatrixAddRowsProc)(XbaeMatrixWidget, int, String *, 81 String *, Pixel *, Pixel *, int); 82 83 typedef void (*XbaeMatrixAddVarRowsProc)(XbaeMatrixWidget, int, String *, 84 String *, short *, int *, 85 unsigned char*, unsigned char *, 86 Pixel *, Pixel *, int); 87 88 typedef void (*XbaeMatrixDeleteRowsProc)(XbaeMatrixWidget, int, int); 89 90 typedef void (*XbaeMatrixAddColumnsProc)(XbaeMatrixWidget, int, String *, 91 String *, short *, int *, 92 unsigned char*, unsigned char *, 93 Pixel *, Pixel *, int); 94 95 typedef void (*XbaeMatrixDeleteColumnsProc)(XbaeMatrixWidget, int, int); 96 97 typedef void (*XbaeMatrixSetRowColorsProc)(XbaeMatrixWidget, int, Pixel *, 98 int, Boolean); 99 100 typedef void (*XbaeMatrixSetColumnColorsProc)(XbaeMatrixWidget, int, 101 Pixel *, int, Boolean); 102 103 typedef void (*XbaeMatrixSetCellColorProc)(XbaeMatrixWidget, int, int, 104 Pixel, Boolean); 105 106 107 /* 108 * New fields for the Matrix widget class record 109 */ 110 typedef struct { 111 XbaeMatrixSetCellProc set_cell; 112 XbaeMatrixGetCellProc get_cell; 113 XbaeMatrixEditCellProc edit_cell; 114 XbaeMatrixSelectCellProc select_cell; 115 XbaeMatrixShowColumnArrowsProc set_show_column_arrows; 116 XbaeMatrixSelectRowProc select_row; 117 XbaeMatrixSelectColumnProc select_column; 118 XbaeMatrixDeselectAllProc deselect_all; 119 XbaeMatrixSelectAllProc select_all; 120 XbaeMatrixDeselectCellProc deselect_cell; 121 XbaeMatrixDeselectRowProc deselect_row; 122 XbaeMatrixDeselectColumnProc deselect_column; 123 XbaeMatrixCommitEditProc commit_edit; 124 XbaeMatrixCancelEditProc cancel_edit; 125 XbaeMatrixAddRowsProc add_rows; 126 XbaeMatrixAddVarRowsProc add_var_rows; 127 XbaeMatrixDeleteRowsProc delete_rows; 128 XbaeMatrixAddColumnsProc add_columns; 129 XbaeMatrixDeleteColumnsProc delete_columns; 130 XbaeMatrixSetRowColorsProc set_row_colors; 131 XbaeMatrixSetColumnColorsProc set_column_colors; 132 XbaeMatrixSetCellColorProc set_cell_color; 133 XtPointer extension; 134 135 XrmQuark QPointer; 136 XrmQuark QLeft; 137 XrmQuark QRight; 138 XrmQuark QUp; 139 XrmQuark QDown; 140 XrmQuark QPageUp; 141 XrmQuark QPageDown; 142 XrmQuark QFocus; 143 XrmQuark QLoosingFocus; 144 XrmQuark default_qtag; 145 146 } XbaeMatrixClassPart; 147 148 /* 149 * Full class record declaration 150 */ 151 typedef struct _XbaeMatrixClassRec { 152 CoreClassPart core_class; 153 CompositeClassPart composite_class; 154 ConstraintClassPart constraint_class; 155 XmManagerClassPart manager_class; 156 XbaeMatrixClassPart matrix_class; 157 } XbaeMatrixClassRec; 158 159 externalref XbaeMatrixClassRec xbaeMatrixClassRec; 160 161 /* 162 * Inheritance constants for set/get/edit methods 163 */ 164 #define XbaeInheritGetCell ((XbaeMatrixGetCellProc) _XtInherit) 165 #define XbaeInheritSetCell ((XbaeMatrixSetCellProc) _XtInherit) 166 #define XbaeInheritEditCell ((XbaeMatrixEditCellProc) _XtInherit) 167 #define XbaeInheritSelectCell ((XbaeMatrixSelectCellProc) _XtInherit) 168 #define XbaeInheritShowColumnArrows ((XbaeMatrixShowColumnArrowsProc) _XtInherit) 169 #define XbaeInheritSelectRow ((XbaeMatrixSelectRowProc) _XtInherit) 170 #define XbaeInheritSelectColumn ((XbaeMatrixSelectColumnProc) _XtInherit) 171 #define XbaeInheritHighlightCell ((XbaeMatrixHighlightCellProc) _XtInherit) 172 #define XbaeInheritHighlightRow ((XbaeMatrixHighlightRowProc) _XtInherit) 173 #define XbaeInheritHighlightColumn ((XbaeMatrixHighlightColumnProc) _XtInherit) 174 #define XbaeInheritDeselectAll ((XbaeMatrixDeselectAllProc) _XtInherit) 175 #define XbaeInheritSelectAll ((XbaeMatrixSelectAllProc) _XtInherit) 176 #define XbaeInheritDeselectCell ((XbaeMatrixDeselectCellProc) _XtInherit) 177 #define XbaeInheritDeselectRow ((XbaeMatrixDeselectRowProc) _XtInherit) 178 #define XbaeInheritDeselectColumn ((XbaeMatrixDeselectColumnProc) _XtInherit) 179 #define XbaeInheritCommitEdit ((XbaeMatrixCommitEditProc) _XtInherit) 180 #define XbaeInheritCancelEdit ((XbaeMatrixCancelEditProc) _XtInherit) 181 #define XbaeInheritAddRows ((XbaeMatrixAddRowsProc) _XtInherit) 182 #define XbaeInheritAddVarRows ((XbaeMatrixAddVarRowsProc) _XtInherit) 183 #define XbaeInheritDeleteRows ((XbaeMatrixDeleteRowsProc) _XtInherit) 184 #define XbaeInheritAddColumns ((XbaeMatrixAddColumnsProc) _XtInherit) 185 #define XbaeInheritDeleteColumns ((XbaeMatrixDeleteColumnsProc)_XtInherit) 186 #define XbaeInheritSetRowColors ((XbaeMatrixSetRowColorsProc)_XtInherit) 187 #define XbaeInheritSetColumnColors ((XbaeMatrixSetColumnColorsProc)_XtInherit) 188 #define XbaeInheritSetCellColor ((XbaeMatrixSetCellColorProc)_XtInherit) 189 190 /* 191 * Bundle per cell attributes into one structure 192 * This bundles all the "2D array"s that were previously in the XbaeMatrixPart. 193 */ 194 typedef struct _XbaeMatrixPerCellRec { 195 unsigned char shadow_type; /* Per cell shadow type */ 196 unsigned char highlighted; /* Is the cell highlighted ? */ 197 Boolean selected; /* Is the cell selected ? */ 198 Boolean underlined; /* Is the cell underlined ? */ 199 XtPointer user_data; /* userdata; cant be edited in xbae */ 200 Pixel background; /* Background pixel per cell */ 201 Pixel color; /* Foreground pixel per cell */ 202 Widget widget; /* So-called cell widgets */ 203 Pixmap pixmap; /* pixmap; cant be edited in xbae */ 204 Pixmap mask; /* clipmask; cant be edited in xbae */ 205 String CellValue; /* String */ 206 XrmQuark qtag; /* The quarkified tag of the font used to draw the CellValue */ 207 } XbaeMatrixPerCellRec; 208 209 typedef struct { 210 XmFontType type; 211 union { 212 XFontStruct *font_struct; 213 XFontSet font_set; 214 } fontp; 215 short width; 216 short height; 217 short y; 218 Font id; 219 } XbaeMatrixFontInfo; 220 221 /* 222 * New fields for the Matrix widget record 223 */ 224 typedef struct { 225 /* 226 * resources 227 */ 228 Boolean allow_column_resize; /* Public: can columns dynamically resize? */ 229 Boolean allow_row_resize; /* Public: can rows dynamically resize? */ 230 231 Boolean fill; /* Public: fill available space? */ 232 Boolean horz_fill; /* Public: when filled, extend the 'last' column to fill available space? */ 233 Boolean vert_fill; /* Public: when filled, extend the 'last' row to fill available space? */ 234 Boolean non_fixed_detached_left; /* Public: when filled, put empty space after fixed columns */ 235 Boolean non_fixed_detached_top; /* Public: when filled, put empty space after fixed rows */ 236 Boolean trailing_attached_right; /* Public: when filled, put trailing columns fixed to right */ 237 Boolean trailing_attached_bottom; /* Public: when filled, put trailing rows fixed to bottom */ 238 239 Boolean bold_labels; /* Public: draw bold row/column labels? */ 240 Boolean useXbaeInput; /* Public: Whether to use XbaeInput widget */ 241 Boolean reverse_select; /* Public: reverse colours - selected cells? */ 242 Boolean scroll_select; /* Public: flag to scroll a selected cell */ 243 Boolean traverse_fixed; /* Public: allow traversal to fixed cells? */ 244 Boolean calc_cursor_position; /* Public: calculate insert pos from click */ 245 Boolean text_field_is_mapped; /* Private: Is the text field on top of a cell? */ 246 unsigned int disable_redisplay; /* Private: disable redisplay counter */ 247 248 Boolean show_arrows; /* Public: sow arrows when text obscured? */ 249 Boolean *show_column_arrows; /* Public: which columns will show arrows */ 250 Boolean *column_font_bold; /* Public: which columns have bold fonts */ 251 252 Boolean button_labels; /* Public: draw labels as buttons? */ 253 Boolean *column_button_labels; /* Public: which column labels are buttons */ 254 Boolean *row_button_labels; /* Public: which row labels are buttons */ 255 256 Boolean column_width_in_pixels; /* Public: column width mesured in pixels? */ 257 Boolean row_height_in_pixels; /* Public: row height mesured in pixels? */ 258 short row_label_width; /* Public: max width of row labels in chars */ 259 short *column_widths; /* Public: width of each column in chars or pixels */ 260 short *row_heights; /* Public: height of each row in chars or pixels */ 261 int *column_positions; /* Private: pixel position of each column */ 262 int *row_positions; /* Private: pixel position of each row */ 263 264 int visible_fixed_column_width; 265 int visible_fixed_row_height; 266 int visible_trailing_fixed_column_width; 267 int visible_trailing_fixed_row_height; 268 int visible_non_fixed_height; 269 int visible_non_fixed_width; 270 271 int *column_max_lengths; /* Public: max length of each col in chars */ 272 273 Boolean multi_line_cell; /* Public: Whether to draw more than one line in a cell */ 274 unsigned char wrap_type; /* Public: How to wrap the lines in multi_line_cell mode */ 275 276 unsigned char scrollbar_placement; /* Public: placement of the scrollbars */ 277 unsigned char selection_policy; /* Public: as for XmList */ 278 unsigned char grid_type; /* Public: shadowed in/shadowed out/plain */ 279 unsigned char shadow_type; /* Public: matrix window shadow type */ 280 unsigned char cell_shadow_type; /* Public: cell shadow type */ 281 282 unsigned char hsb_display_policy; /* Public: horiz scroll bar display policy */ 283 unsigned char vsb_display_policy; /* Public: vert scroll bar display policy */ 284 285 unsigned char row_label_alignment; /* Public: alignment of row labels */ 286 unsigned char *column_label_alignments;/* Public: alignment of each column label */ 287 unsigned char *column_alignments; /* Public: alignment of each column */ 288 289 unsigned char *column_shadow_types; /* Public: 1D array of per col shadow types */ 290 unsigned char *row_shadow_types; /* Public: 1D array of per row shadow types */ 291 292 XmString *xmcolumn_labels; /* Public: array of xmlabels above each column */ 293 XmString *xmrow_labels; /* Public: array of xmlabels next to each row */ 294 String *column_labels; /* Public: array of labels above each column */ 295 String *row_labels; /* Public: array of labels next to each row */ 296 int column_label_maxlines; /* Private: max number of lines in column labels */ 297 int row_label_maxlength; /* Private: max line length of row labels */ 298 299 XtPointer *column_user_data; /* Public: 1D array of per column user data */ 300 XtPointer *row_user_data; /* Public: 1D array of per row user data */ 301 302 int columns; /* Public: number of cells per row */ 303 int rows; /* Public: number of rows per column */ 304 Dimension fixed_columns; /* Public: number of leading fixed columns */ 305 Dimension fixed_rows; /* Public: number of leading fixed rows */ 306 Dimension trailing_fixed_columns; /* Public: number of trailing fixed columns */ 307 Dimension trailing_fixed_rows; /* Public: number of trailing fixed rows */ 308 Dimension visible_columns; /* Public: number of columns to make visible */ 309 Dimension visible_rows; /* Public: number of rows to make visible */ 310 311 Dimension cell_margin_height; /* Public: margin height for textField */ 312 Dimension cell_margin_width; /* Public: margin width for textField */ 313 Dimension cell_highlight_thickness; /* Public: highlight thickness for textField */ 314 Dimension cell_shadow_thickness; /* Public: shadow thickness for each cell */ 315 Dimension text_shadow_thickness; /* Public: shadow thickness for text field */ 316 Dimension space; /* Public: spacing for scrollbars */ 317 Dimension underline_width; /* Public: number of pixels thick the underline is */ 318 319 int alt_row_count; /* Public: # of rows for e/o background */ 320 Pixel even_row_background; /* Public: even row background color */ 321 Pixel odd_row_background; /* Public: odd row background color */ 322 323 Pixel column_label_color; /* Public: color of column label */ 324 Pixel row_label_color; /* Public: color of row label */ 325 326 Pixel button_label_background; /* Public: color of button label background */ 327 Pixel grid_line_color; /* Public: color of grid, for XmGrid_LINE */ 328 Pixel selected_background; /* Public: background for selected cells */ 329 Pixel selected_foreground; /* Public: foreground for selected cells */ 330 Pixel scroll_background; /* Public: bacground for scrollbar */ 331 Pixel text_background; /* Public: background for the text field */ 332 Boolean text_background_is_cell; /* Public: background for the text field when text_background is undefined */ 333 334 Position underline_position; /* Public: number of pixels below the text baseline */ 335 336 XtTranslations text_translations; /* Public: translations for textField widget */ 337 338 XtCallbackList default_action_callback; /* Public: called for a double click */ 339 XtCallbackList draw_cell_callback; /* Public: called when a cell is drawn */ 340 XtCallbackList enter_cell_callback; /* Public: called when a cell is entered */ 341 XtCallbackList track_cell_callback; /* Public: called when a cell is crossed */ 342 XtCallbackList label_activate_callback; /* Public: called when label pressed */ 343 XtCallbackList leave_cell_callback; /* Public: called when a cell is left */ 344 XtCallbackList modify_verify_callback; /* Public: verify change to textField */ 345 /* Public: and a draw_cell_callback is set */ 346 XtCallbackList process_drag_callback; /* Public: called when a drag is initiated */ 347 XtCallbackList resize_callback; /* Public: called when Matrix is resized */ 348 XtCallbackList resize_row_callback; /* Public: called when row is resized */ 349 XtCallbackList resize_column_callback; /* Public: called when column is resized */ 350 XtCallbackList select_cell_callback; /* Public: called when cells are selected */ 351 XtCallbackList traverse_cell_callback; /* Public: next cell to traverse to */ 352 XtCallbackList value_changed_callback; /* Public: same as XmText(3) */ 353 XtCallbackList write_cell_callback; /* Public: called when a cell needs to be set */ 354 355 #if XmVERSION >= 2 356 XmRenderTable render_table; /* Public: renderTable from which we get the fonts used to draw cells/labels */ 357 #endif 358 359 XmFontList font_list; /* Public: fontList of widget and textField */ 360 XmFontList label_font_list; /* Public: fontList of labels */ 361 XbaeMatrixFontInfo cell_font; /* Private: Cashed info on the font used to draw cells with no tags */ 362 XbaeMatrixFontInfo label_font; /* Private: Cashed info on the font used to draw labels */ 363 XbaeMatrixFontInfo current_draw_font; /* Private: Cashed info on the font currently in draw_gc */ 364 XrmQuark current_draw_qtag; /* Private: The quarkified tag of the font in the draw_gc */ 365 XrmQuark current_text_qtag; /* Private: The quarkified tag of the rendition installed on the text field */ 366 367 /* 368 * private state 369 */ 370 Dimension desired_height; /* Private: height widget wants to be */ 371 Dimension desired_width; /* Private: width widget wants to be */ 372 373 int num_selected_cells; /* Private: The number selected cells */ 374 375 int horiz_origin; /* Private: horiz origin (in pixel space) */ 376 int vert_origin; /* Private: vert origin (in pixel space) */ 377 378 int row_label_baseline; /* Private: baseline of row labels */ 379 int cell_baseline; /* Private: baseline of text in each cell */ 380 381 Time last_click_time; /* Private: Used to detect double clicks */ 382 int double_click_interval; /* Public: interval between clicks */ 383 int last_column; /* Private: Used to detect double clicks */ 384 int last_row; /* Private: Used to detect double clicks */ 385 386 int prev_column; /* Private: Used to compare tracking callback */ 387 int prev_row; /* Private: Used to compare tracking callback */ 388 389 Widget text_field; /* Private: the text field */ 390 Widget horizontal_sb; /* Private: the horizontal scrollbar */ 391 Widget vertical_sb; /* Private: the vertical scrollbar */ 392 393 Widget center_clip; /* Private: the clips */ 394 Widget left_clip; 395 Widget right_clip; 396 Widget top_clip; 397 Widget bottom_clip; 398 Widget row_label_clip; 399 Widget column_label_clip; 400 401 GC grid_line_gc; /* Private: GC for grid line */ 402 GC draw_gc; /* Private: GC for drawing cells */ 403 GC label_gc; /* Private: GC for drawing labels */ 404 GC pixmap_gc; /* Private: GC for drawing pixmap cells */ 405 GC resize_bottom_shadow_gc; 406 GC resize_top_shadow_gc; 407 408 Cursor cursor; /* Used to be global static */ 409 410 XbaeMatrixPerCellRec **per_cell; /* Private: 2D array */ 411 412 /* Unused: */ 413 414 Pixmap *row_pixmaps; /* Private: array of pixmaps next to each row */ 415 Pixmap *column_pixmaps; /* Private: array of pixmaps next to each column */ 416 } XbaeMatrixPart; 417 418 /* 419 * Full instance record declaration 420 */ 421 typedef struct _XbaeMatrixRec { 422 CorePart core; 423 CompositePart composite; 424 ConstraintPart constraint; 425 XmManagerPart manager; 426 XbaeMatrixPart matrix; 427 } XbaeMatrixRec; 428 429 /* 430 * Constraint resources 431 */ 432 typedef struct { 433 int row; 434 int column; 435 } XbaeMatrixConstraintsRec; 436 437 /* 438 * End of array indicator for converters of strings 439 */ 440 extern char xbaeBadString; 441 442 /* 443 * Macro replacements 444 */ 445 Widget _XbaeGetShellAncestor(Widget w); 446 447 #ifdef __cplusplus 448 } 449 #endif 450 451 #endif /* _Xbae_MatrixP_h */ 452