UNIXworkcode

1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * 3 * ***** BEGIN LICENSE BLOCK ***** 4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 5 * 6 * The contents of this file are subject to the Mozilla Public License Version 7 * 1.1 (the "License"); you may not use this file except in compliance with 8 * the License. You may obtain a copy of the License at 9 * http://www.mozilla.org/MPL/ 10 * 11 * Software distributed under the License is distributed on an "AS IS" basis, 12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 13 * for the specific language governing rights and limitations under the 14 * License. 15 * 16 * The Original Code is the Microline Widget Library, originally made available under the NPL by Neuron Data <http://www.neurondata.com>. 17 * 18 * The Initial Developer of the Original Code is 19 * Netscape Communications Corporation. 20 * Portions created by the Initial Developer are Copyright (C) 1998 21 * the Initial Developer. All Rights Reserved. 22 * 23 * Contributor(s): 24 * 25 * Alternatively, the contents of this file may be used under the terms of 26 * either the GNU General Public License Version 2 or later (the "GPL"), or 27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 28 * in which case the provisions of the GPL or the LGPL are applicable instead 29 * of those above. If you wish to allow use of your version of this file only 30 * under the terms of either the GPL or the LGPL, and not to allow others to 31 * use your version of this file under the terms of the MPL, indicate your 32 * decision by deleting the provisions above and replace them with the notice 33 * and other provisions required by the GPL or the LGPL. If you do not delete 34 * the provisions above, a recipient may use your version of this file under 35 * the terms of any one of the MPL, the GPL or the LGPL. 36 * 37 * In addition, as a special exception to the GNU GPL, the copyright holders 38 * give permission to link the code of this program with the Motif and Open 39 * Motif libraries (or with modified versions of these that use the same 40 * license), and distribute linked combinations including the two. You 41 * must obey the GNU General Public License in all respects for all of 42 * the code used other than linking with Motif/Open Motif. If you modify 43 * this file, you may extend this exception to your version of the file, 44 * but you are not obligated to do so. If you do not wish to do so, 45 * delete this exception statement from your version. 46 * 47 * ***** END LICENSE BLOCK ***** */ 48 49 50 #ifndef XmLGridPH 51 #define XmLGridPH 52 53 #include <Xm/XmP.h> 54 #include <stdlib.h> 55 #ifndef MOTIF11 56 #include <Xm/ManagerP.h> 57 #include <Xm/DrawP.h> 58 #include <Xm/DragC.h> 59 #include <Xm/DropTrans.h> 60 #endif 61 62 #include "Grid.h" 63 64 #ifdef XmL_ANSIC 65 66 void _XmLGridLayout(XmLGridWidget g); 67 68 void _XmLGridCellDrawBackground(XmLGridCell cell, Widget w, 69 XRectangle *clipRect, XmLGridDrawStruct *ds); 70 void _XmLGridCellDrawBorders(XmLGridCell cell, Widget w, 71 XRectangle *clipRect, XmLGridDrawStruct *ds); 72 void _XmLGridCellDrawValue(XmLGridCell cell, Widget w, 73 XRectangle *clipRect, XmLGridDrawStruct *ds); 74 typedef int (*XmLGridPreLayoutProc)(XmLGridWidget g, int isVert); 75 76 typedef XmLGridRow (*XmLGridRowNewProc)(Widget grid); 77 typedef void (*XmLGridRowFreeProc)(XmLGridRow); 78 typedef void (*XmLGridGetRowValueMaskProc)(XmLGridWidget g, 79 char *s, long *mask); 80 typedef void (*XmLGridGetRowValueProc)(XmLGridWidget g, XmLGridRow row, 81 XtArgVal value, long mask); 82 typedef int (*XmLGridSetRowValuesProc)(XmLGridWidget g, 83 XmLGridRow row, long mask); 84 85 typedef XmLGridColumn (*XmLGridColumnNewProc)(Widget grid); 86 typedef void (*XmLGridColumnFreeProc)(XmLGridColumn); 87 typedef void (*XmLGridGetColumnValueMaskProc)(XmLGridWidget g, 88 char *s, long *mask); 89 typedef void (*XmLGridGetColumnValueProc)(XmLGridWidget g, XmLGridColumn col, 90 XtArgVal value, long mask); 91 typedef int (*XmLGridSetColumnValuesProc)(XmLGridWidget g, 92 XmLGridColumn col, long mask); 93 94 typedef int (*XmLGridSetCellValuesResizeProc)(XmLGridWidget g, 95 XmLGridRow row, XmLGridColumn col, XmLGridCell cell, long mask); 96 typedef int (*XmLGridCellActionProc)(XmLGridCell, Widget, 97 XmLGridCallbackStruct *); 98 99 #else 100 101 void _XmLGridLayout(); 102 103 void _XmLGridCellDrawBackground(); 104 void _XmLGridCellDrawBorders(); 105 void _XmLGridCellDrawValue(); 106 typedef int (*XmLGridPreLayoutProc)(); 107 108 typedef XmLGridRow (*XmLGridRowNewProc)(); 109 typedef void (*XmLGridRowFreeProc)() ; 110 typedef void (*XmLGridGetRowValueMaskProc)(); 111 typedef void (*XmLGridGetRowValueProc)(); 112 typedef int (*XmLGridSetRowValuesProc)(); 113 114 typedef XmLGridColumn (*XmLGridColumnNewProc)() ; 115 typedef void (*XmLGridColumnFreeProc)() ; 116 typedef void (*XmLGridGetColumnValueMaskProc)(); 117 typedef void (*XmLGridGetColumnValueProc)(); 118 typedef int (*XmLGridSetColumnValuesProc)(); 119 120 typedef int (*XmLGridSetCellValuesResizeProc)(); 121 typedef int (*XmLGridCellActionProc)(); 122 123 #endif 124 125 #define XmLGridClassPartOfWidget(w) \ 126 ((XmLGridWidgetClass)XtClass(w))->grid_class 127 128 #define XmInheritGridPreLayout ((XmLGridPreLayoutProc)_XtInherit) 129 130 #define XmInheritGridRowNew ((XmLGridRowNewProc)_XtInherit) 131 #define XmInheritGridRowFree ((XmLGridRowFreeProc)_XtInherit) 132 #define XmInheritGridGetRowValueMask ((XmLGridGetRowValueMaskProc)_XtInherit) 133 #define XmInheritGridGetRowValue ((XmLGridGetRowValueProc)_XtInherit) 134 #define XmInheritGridSetRowValues ((XmLGridSetRowValuesProc)_XtInherit) 135 136 #define XmInheritGridColumnNew ((XmLGridColumnNewProc)_XtInherit) 137 #define XmInheritGridColumnFree ((XmLGridColumnFreeProc)_XtInherit) 138 #define XmInheritGridGetColumnValueMask \ 139 ((XmLGridGetColumnValueMaskProc)_XtInherit) 140 #define XmInheritGridGetColumnValue ((XmLGridGetColumnValueProc)_XtInherit) 141 #define XmInheritGridSetColumnValues ((XmLGridSetColumnValuesProc)_XtInherit) 142 143 #define XmInheritGridSetCellValuesResize \ 144 ((XmLGridSetCellValuesResizeProc)_XtInherit) 145 #define XmInheritGridCellAction ((XmLGridCellActionProc)_XtInherit) 146 147 /* row value mask for get/set values */ 148 #define XmLGridRowHeight (1L<<0) 149 #define XmLGridRowSizePolicy (1L<<1) 150 #define XmLGridRowUserData (1L<<2) 151 #define XmLGridRowValueMaskLen 3 152 153 /* column value mask for get/set values */ 154 #define XmLGridColumnWidth (1L<<0) 155 #define XmLGridColumnSizePolicy (1L<<1) 156 #define XmLGridColumnUserData (1L<<2) 157 #define XmLGridColumnResizable (1L<<3) 158 #define XmLGridColumnHidden (1L<<4) 159 #define XmLGridColumnSortType (1L<<5) 160 #define XmLGridColumnValueMaskLen 6 161 162 /* flags for XmLGridCell flags member */ 163 #define XmLGridCellSelectedFlag (1 << 0) 164 #define XmLGridCellValueSetFlag (1 << 1) 165 #define XmLGridCellInRowSpanFlag (1 << 2) 166 #define XmLGridCellInColumnSpanFlag (1 << 3) 167 #define XmLGridCellDrawSortFlag (1 << 4) 168 #define XmLGridCellSortAscendingFlag (1 << 5) 169 170 /* cell value mask for get/set values */ 171 #define XmLGridCellAlignment (1L<<0) 172 #define XmLGridCellBackground (1L<<1) 173 #define XmLGridCellBottomBorderColor (1L<<2) 174 #define XmLGridCellBottomBorderType (1L<<3) 175 #define XmLGridCellColumnSpan (1L<<4) 176 #define XmLGridCellEditable (1L<<5) 177 #define XmLGridCellRenderTable (1L<<6) 178 #define XmLGridCellForeground (1L<<7) 179 #define XmLGridCellLeftBorderColor (1L<<8) 180 #define XmLGridCellLeftBorderType (1L<<9) 181 #define XmLGridCellMarginBottom (1L<<10) 182 #define XmLGridCellMarginLeft (1L<<11) 183 #define XmLGridCellMarginRight (1L<<12) 184 #define XmLGridCellMarginTop (1L<<13) 185 #define XmLGridCellPixmapF (1L<<14) 186 #define XmLGridCellPixmapMask (1L<<15) 187 #define XmLGridCellRightBorderColor (1L<<16) 188 #define XmLGridCellRightBorderType (1L<<17) 189 #define XmLGridCellRowSpan (1L<<18) 190 #define XmLGridCellString (1L<<19) 191 #define XmLGridCellToggleSet (1L<<20) 192 #define XmLGridCellTopBorderColor (1L<<21) 193 #define XmLGridCellTopBorderType (1L<<22) 194 #define XmLGridCellType (1L<<23) 195 #define XmLGridCellUserData (1L<<24) 196 197 /* This is now a resource */ 198 /* #define XmLICON_SPACING 4 */ 199 200 enum { DrawAll, DrawHScroll, DrawVScroll, DrawRow, DrawCol, DrawCell }; 201 enum { SelectRow, SelectCol, SelectCell }; 202 enum { CursorNormal, CursorHResize, CursorVResize }; 203 enum { InNormal, InSelect, InResize, InMove }; 204 enum { DragLeft = 1, DragRight = 2, DragUp = 4, DragDown = 8 }; 205 206 typedef struct 207 { 208 int x, y, width, height; 209 int row, col, nrow, ncol; 210 } GridReg; 211 212 typedef struct 213 { 214 int row, col; 215 } GridDropLoc; 216 217 typedef struct 218 { 219 unsigned char alignment; 220 Pixel background; 221 Pixel bottomBorderColor; 222 char bottomBorderType; 223 Dimension bottomMargin; 224 int columnSpan; 225 Boolean editable; 226 short fontHeight; 227 Bool check_set_render_table; 228 XmRenderTable renderTable; 229 short fontWidth; 230 Pixel foreground; 231 Pixel leftBorderColor; 232 char leftBorderType; 233 Dimension leftMargin; 234 int refCount; 235 Pixel rightBorderColor; 236 char rightBorderType; 237 Dimension rightMargin; 238 int rowSpan; 239 Pixel topBorderColor; 240 char topBorderType; 241 Dimension topMargin; 242 unsigned char type; 243 void *userData; 244 } XmLGridCellRefValues; 245 246 typedef struct 247 { 248 Pixmap pixmap, pixmask; 249 Dimension width, height; 250 } XmLGridCellPixmap; 251 252 typedef struct 253 { 254 XmString string; 255 XmLGridCellPixmap pix; 256 } XmLGridCellIcon; 257 258 typedef struct _XmLGridCellPart 259 { 260 XmLGridCellRefValues *refValues; 261 unsigned char flags; 262 void *value; 263 } XmLGridCellPart; 264 265 struct _XmLGridCellRec 266 { 267 XmLGridCellPart cell; 268 }; 269 270 typedef struct _XmLGridRowPart 271 { 272 int pos; /* required first for Array autonumber */ 273 Dimension height; 274 unsigned char sizePolicy; 275 Boolean selected; 276 XtPointer userData; 277 Dimension heightInPixels; 278 unsigned int heightInPixelsValid:1; 279 Widget grid; 280 int visPos; 281 XmLArray cellArray; 282 } XmLGridRowPart; 283 284 struct _XmLGridRowRec 285 { 286 XmLGridRowPart grid; 287 }; 288 289 typedef struct _XmLGridColumnPart 290 { 291 int pos; /* required first for Array autonumber */ 292 Dimension width; 293 unsigned char sizePolicy; 294 Boolean selected; 295 XtPointer userData; 296 XmLGridCellRefValues *defCellValues; 297 Widget grid; 298 Dimension widthInPixels; 299 unsigned int widthInPixelsValid:1; 300 Boolean resizable; 301 int visPos; 302 303 /* xfe additions */ 304 Boolean hidden; 305 unsigned char sort; 306 } XmLGridColumnPart; 307 308 struct _XmLGridColumnRec 309 { 310 XmLGridColumnPart grid; 311 }; 312 313 typedef struct _XmLGridPart 314 { 315 /* resource values */ 316 int leftFixedCount, rightFixedCount; 317 int headingRowCount, footerRowCount; 318 int topFixedCount, bottomFixedCount; 319 int headingColCount, footerColCount; 320 Dimension leftFixedMargin, rightFixedMargin; 321 Dimension topFixedMargin, bottomFixedMargin; 322 Dimension scrollBarMargin; 323 Dimension highlightThickness; 324 Dimension toggleSize; 325 Dimension globalPixmapWidth, globalPixmapHeight; 326 unsigned char selectionPolicy; 327 Boolean layoutFrozen, immediateDraw; 328 int debugLevel; 329 unsigned char vsPolicy, hsPolicy; 330 unsigned char hsbDisplayPolicy, vsbDisplayPolicy; 331 int rowCount, colCount; 332 int hiddenRowCount, hiddenColCount; 333 int shadowRegions; 334 unsigned char shadowType; 335 Widget hsb, vsb, text; 336 Bool check_set_render_table; 337 XmRenderTable renderTable; 338 Pixel blankBg, selectBg, selectFg; 339 Pixel defaultCellBg, defaultCellFg; 340 Pixel toggleTopColor, toggleBotColor; 341 int visibleCols, visibleRows; 342 char *simpleHeadings, *simpleWidths; 343 XtTranslations editTrans, traverseTrans; 344 Boolean allowRowHide, allowColHide; 345 Boolean allowRowResize, allowColResize; 346 Boolean allowDrag, allowDrop; 347 Boolean autoSelect; 348 Boolean highlightRowMode; 349 Boolean useAvgWidth; 350 int scrollRow, scrollCol, cScrollRow, cScrollCol; 351 XtCallbackList addCallback, deleteCallback; 352 XtCallbackList cellDrawCallback, cellFocusCallback; 353 XtCallbackList cellDropCallback, cellPasteCallback; 354 XtCallbackList activateCallback, editCallback; 355 XtCallbackList selectCallback, deselectCallback; 356 XtCallbackList resizeCallback, scrollCallback; 357 358 /* BEGIN XNEdit Addition */ 359 XtCallbackList headerClickCallback; 360 XtCallbackList keyPressedCallback; 361 /* END XNEdit Addition */ 362 363 XtCallbackList enterCellCallback; 364 XtCallbackList leaveCellCallback; 365 XtCallbackList enterGridCallback; 366 XtCallbackList leaveGridCallback; 367 368 /* XFE Additions */ 369 XtCallbackList popupCallback; 370 Boolean hideUnhideButtons; 371 Boolean singleClickActivation; 372 Widget hideButton; 373 Widget unhideButton; 374 XtTranslations hideButtonTrans; 375 XtTranslations unhideButtonTrans; 376 377 Boolean inResize; 378 379 Boolean useTextWidget; 380 381 Dimension iconSpacing; 382 383 Dimension minColWidth; 384 385 int lastCursorMotionRow; 386 int lastCursorMotionCol; 387 388 unsigned char colSortType; 389 390 /* private data */ 391 GC gc; 392 Cursor hResizeCursor, vResizeCursor; 393 XFontStruct *fallbackFont; 394 char ignoreModifyVerify; 395 char focusIn, inEdit, inMode; 396 char singleColScrollMode; 397 int singleColScrollPos; 398 char cursorDefined, textHidden, resizeIsVert; 399 char mayHaveRowSpans; 400 int layoutStack; 401 char needsHorizLayout, needsVertLayout; 402 char recalcHorizVisPos, recalcVertVisPos; 403 char vertVisChangedHint; 404 char dragTimerSet; 405 XtIntervalId dragTimerId; 406 int resizeRow, resizeCol, resizeLineXY; 407 int extendRow, extendCol, extendToRow, extendToCol; 408 Boolean extendSelect; 409 int lastSelectRow, lastSelectCol; 410 Time lastSelectTime; 411 int focusRow, focusCol; 412 XmLArray rowArray; 413 XmLArray colArray; 414 GridReg reg[9]; 415 GridDropLoc dropLoc; 416 417 /* resources use by SetSubValues and GetSubValues */ 418 Boolean cellDefaults; 419 int cellRow, cellCol; 420 int cellColRangeStart, cellColRangeEnd; 421 int cellRowRangeStart, cellRowRangeEnd; 422 int rowStep, colStep; 423 unsigned char rowType, colType; 424 Boolean colHidden; 425 426 /* cell resources */ 427 XmString cellString; 428 Boolean cellToggleSet; 429 Pixmap cellPixmap, cellPixmapMask; 430 Dimension cellPixmapWidth, cellPixmapHeight; 431 XmLGridCellRefValues cellValues, *defCellValues; 432 433 /* row resources */ 434 Dimension rowHeight; 435 unsigned char rowSizePolicy; 436 Boolean rowSelected; 437 XtPointer rowUserData; 438 439 /* column resources */ 440 Dimension colWidth; 441 unsigned char colSizePolicy; 442 Boolean colSelected; 443 XtPointer colUserData; 444 Boolean colResizable; 445 446 /* xfe additions */ 447 /* Edit timer is used for inplace editing */ 448 char editTimerSet; 449 XtIntervalId editTimerId; 450 } XmLGridPart; 451 452 typedef struct _XmLGridRec 453 { 454 CorePart core; 455 CompositePart composite; 456 ConstraintPart constraint; 457 XmManagerPart manager; 458 XmLGridPart grid; 459 } XmLGridRec; 460 461 typedef struct _XmLGridClassPart 462 { 463 int initialRows; 464 int initialCols; 465 XmLGridPreLayoutProc preLayoutProc; 466 int rowRecSize; 467 XmLGridRowNewProc rowNewProc; 468 XmLGridRowFreeProc rowFreeProc; 469 XmLGridGetRowValueMaskProc getRowValueMaskProc; 470 XmLGridGetRowValueProc getRowValueProc; 471 XmLGridSetRowValuesProc setRowValuesProc; 472 int columnRecSize; 473 XmLGridColumnNewProc columnNewProc; 474 XmLGridColumnFreeProc columnFreeProc; 475 XmLGridGetColumnValueMaskProc getColumnValueMaskProc; 476 XmLGridGetColumnValueProc getColumnValueProc; 477 XmLGridSetColumnValuesProc setColumnValuesProc; 478 XmLGridSetCellValuesResizeProc setCellValuesResizeProc; 479 XmLGridCellActionProc cellActionProc; 480 } XmLGridClassPart; 481 482 typedef struct _XmLGridClassRec 483 { 484 CoreClassPart core_class; 485 CompositeClassPart composite_class; 486 ConstraintClassPart constraint_class; 487 XmManagerClassPart manager_class; 488 XmLGridClassPart grid_class; 489 } XmLGridClassRec; 490 491 extern XmLGridClassRec xmlGridClassRec; 492 493 typedef struct _XmLGridConstraintPart 494 { 495 int unused; 496 } XmLGridConstraintPart; 497 498 typedef struct _XmLGridConstraintRec 499 { 500 XmManagerConstraintPart manager; 501 XmLGridConstraintPart grid; 502 } XmLGridConstraintRec, *XmLGridConstraintPtr; 503 504 #endif 505