1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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
16 * The Original Code is the Microline Widget Library, originally made available under the NPL by Neuron Data <http://www.neurondata.com>.
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.
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.
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.
47 * ***** END LICENSE BLOCK ***** */
56 #include <Xm/ManagerP.h>
59 #include <Xm/DropTrans.h>
66 void _XmLGridLayout(XmLGridWidget g
);
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
);
76 typedef XmLGridRow (*XmLGridRowNewProc
)(Widget grid
);
77 typedef void (*XmLGridRowFreeProc
)(XmLGridRow
);
78 typedef void (*XmLGridGetRowValueMaskProc
)(XmLGridWidget g
,
80 typedef void (*XmLGridGetRowValueProc
)(XmLGridWidget g
, XmLGridRow row
,
81 XtArgVal value
, long mask
);
82 typedef int (*XmLGridSetRowValuesProc
)(XmLGridWidget g
,
83 XmLGridRow row
, long mask
);
85 typedef XmLGridColumn (*XmLGridColumnNewProc
)(Widget grid
);
86 typedef void (*XmLGridColumnFreeProc
)(XmLGridColumn
);
87 typedef void (*XmLGridGetColumnValueMaskProc
)(XmLGridWidget g
,
89 typedef void (*XmLGridGetColumnValueProc
)(XmLGridWidget g
, XmLGridColumn col
,
90 XtArgVal value
, long mask
);
91 typedef int (*XmLGridSetColumnValuesProc
)(XmLGridWidget g
,
92 XmLGridColumn col
, long mask
);
94 typedef int (*XmLGridSetCellValuesResizeProc
)(XmLGridWidget g
,
95 XmLGridRow row
, XmLGridColumn col
, XmLGridCell cell
, long mask
);
96 typedef int (*XmLGridCellActionProc
)(XmLGridCell
, Widget
,
97 XmLGridCallbackStruct
*);
101 void _XmLGridLayout();
103 void _XmLGridCellDrawBackground();
104 void _XmLGridCellDrawBorders();
105 void _XmLGridCellDrawValue();
106 typedef int (*XmLGridPreLayoutProc
)();
108 typedef XmLGridRow (*XmLGridRowNewProc
)();
109 typedef void (*XmLGridRowFreeProc
)() ;
110 typedef void (*XmLGridGetRowValueMaskProc
)();
111 typedef void (*XmLGridGetRowValueProc
)();
112 typedef int (*XmLGridSetRowValuesProc
)();
114 typedef XmLGridColumn (*XmLGridColumnNewProc
)() ;
115 typedef void (*XmLGridColumnFreeProc
)() ;
116 typedef void (*XmLGridGetColumnValueMaskProc
)();
117 typedef void (*XmLGridGetColumnValueProc
)();
118 typedef int (*XmLGridSetColumnValuesProc
)();
120 typedef int (*XmLGridSetCellValuesResizeProc
)();
121 typedef int (*XmLGridCellActionProc
)();
125 #define XmLGridClassPartOfWidget(w) \
126 ((XmLGridWidgetClass)XtClass(w))->grid_class
128 #define XmInheritGridPreLayout ((XmLGridPreLayoutProc)_XtInherit)
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)
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)
143 #define XmInheritGridSetCellValuesResize \
144 ((XmLGridSetCellValuesResizeProc)_XtInherit)
145 #define XmInheritGridCellAction ((XmLGridCellActionProc)_XtInherit)
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
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
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)
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 XmLGridCellFontList (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)
197 /* This is now a resource */
198 /* #define XmLICON_SPACING 4 */
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 };
208 int x
, y
, width
, height
;
209 int row
, col
, nrow
, ncol
;
219 unsigned char alignment
;
221 Pixel bottomBorderColor
;
222 char bottomBorderType
;
223 Dimension bottomMargin
;
230 Pixel leftBorderColor
;
232 Dimension leftMargin
;
234 Pixel rightBorderColor
;
235 char rightBorderType
;
236 Dimension rightMargin
;
238 Pixel topBorderColor
;
243 } XmLGridCellRefValues
;
247 Pixmap pixmap
, pixmask
;
248 Dimension width
, height
;
254 XmLGridCellPixmap pix
;
257 typedef struct _XmLGridCellPart
259 XmLGridCellRefValues
*refValues
;
264 struct _XmLGridCellRec
266 XmLGridCellPart cell
;
269 typedef struct _XmLGridRowPart
271 int pos
; /* required first for Array autonumber */
273 unsigned char sizePolicy
;
276 Dimension heightInPixels
;
277 unsigned int heightInPixelsValid
:1;
283 struct _XmLGridRowRec
288 typedef struct _XmLGridColumnPart
290 int pos
; /* required first for Array autonumber */
292 unsigned char sizePolicy
;
295 XmLGridCellRefValues
*defCellValues
;
297 Dimension widthInPixels
;
298 unsigned int widthInPixelsValid
:1;
307 struct _XmLGridColumnRec
309 XmLGridColumnPart grid
;
312 typedef struct _XmLGridPart
314 /* resource values */
315 int leftFixedCount
, rightFixedCount
;
316 int headingRowCount
, footerRowCount
;
317 int topFixedCount
, bottomFixedCount
;
318 int headingColCount
, footerColCount
;
319 Dimension leftFixedMargin
, rightFixedMargin
;
320 Dimension topFixedMargin
, bottomFixedMargin
;
321 Dimension scrollBarMargin
;
322 Dimension highlightThickness
;
323 Dimension toggleSize
;
324 Dimension globalPixmapWidth
, globalPixmapHeight
;
325 unsigned char selectionPolicy
;
326 Boolean layoutFrozen
, immediateDraw
;
328 unsigned char vsPolicy
, hsPolicy
;
329 unsigned char hsbDisplayPolicy
, vsbDisplayPolicy
;
330 int rowCount
, colCount
;
331 int hiddenRowCount
, hiddenColCount
;
333 unsigned char shadowType
;
334 Widget hsb
, vsb
, text
;
336 Pixel blankBg
, selectBg
, selectFg
;
337 Pixel defaultCellBg
, defaultCellFg
;
338 Pixel toggleTopColor
, toggleBotColor
;
339 int visibleCols
, visibleRows
;
340 char *simpleHeadings
, *simpleWidths
;
341 XtTranslations editTrans
, traverseTrans
;
342 Boolean allowRowHide
, allowColHide
;
343 Boolean allowRowResize
, allowColResize
;
344 Boolean allowDrag
, allowDrop
;
346 Boolean highlightRowMode
;
348 int scrollRow
, scrollCol
, cScrollRow
, cScrollCol
;
349 XtCallbackList addCallback
, deleteCallback
;
350 XtCallbackList cellDrawCallback
, cellFocusCallback
;
351 XtCallbackList cellDropCallback
, cellPasteCallback
;
352 XtCallbackList activateCallback
, editCallback
;
353 XtCallbackList selectCallback
, deselectCallback
;
354 XtCallbackList resizeCallback
, scrollCallback
;
356 XtCallbackList enterCellCallback
;
357 XtCallbackList leaveCellCallback
;
358 XtCallbackList enterGridCallback
;
359 XtCallbackList leaveGridCallback
;
362 XtCallbackList popupCallback
;
363 Boolean hideUnhideButtons
;
364 Boolean singleClickActivation
;
367 XtTranslations hideButtonTrans
;
368 XtTranslations unhideButtonTrans
;
372 Boolean useTextWidget
;
374 Dimension iconSpacing
;
376 Dimension minColWidth
;
378 int lastCursorMotionRow
;
379 int lastCursorMotionCol
;
381 unsigned char colSortType
;
385 Cursor hResizeCursor
, vResizeCursor
;
386 XFontStruct
*fallbackFont
;
387 char ignoreModifyVerify
;
388 char focusIn
, inEdit
, inMode
;
389 char singleColScrollMode
;
390 int singleColScrollPos
;
391 char cursorDefined
, textHidden
, resizeIsVert
;
392 char mayHaveRowSpans
;
394 char needsHorizLayout
, needsVertLayout
;
395 char recalcHorizVisPos
, recalcVertVisPos
;
396 char vertVisChangedHint
;
398 XtIntervalId dragTimerId
;
399 int resizeRow
, resizeCol
, resizeLineXY
;
400 int extendRow
, extendCol
, extendToRow
, extendToCol
;
401 Boolean extendSelect
;
402 int lastSelectRow
, lastSelectCol
;
404 int focusRow
, focusCol
;
410 /* resources use by SetSubValues and GetSubValues */
411 Boolean cellDefaults
;
412 int cellRow
, cellCol
;
413 int cellColRangeStart
, cellColRangeEnd
;
414 int cellRowRangeStart
, cellRowRangeEnd
;
415 int rowStep
, colStep
;
416 unsigned char rowType
, colType
;
421 Boolean cellToggleSet
;
422 Pixmap cellPixmap
, cellPixmapMask
;
423 Dimension cellPixmapWidth
, cellPixmapHeight
;
424 XmLGridCellRefValues cellValues
, *defCellValues
;
428 unsigned char rowSizePolicy
;
430 XtPointer rowUserData
;
432 /* column resources */
434 unsigned char colSizePolicy
;
436 XtPointer colUserData
;
437 Boolean colResizable
;
440 /* Edit timer is used for inplace editing */
442 XtIntervalId editTimerId
;
445 typedef struct _XmLGridRec
448 CompositePart composite
;
449 ConstraintPart constraint
;
450 XmManagerPart manager
;
454 typedef struct _XmLGridClassPart
458 XmLGridPreLayoutProc preLayoutProc
;
460 XmLGridRowNewProc rowNewProc
;
461 XmLGridRowFreeProc rowFreeProc
;
462 XmLGridGetRowValueMaskProc getRowValueMaskProc
;
463 XmLGridGetRowValueProc getRowValueProc
;
464 XmLGridSetRowValuesProc setRowValuesProc
;
466 XmLGridColumnNewProc columnNewProc
;
467 XmLGridColumnFreeProc columnFreeProc
;
468 XmLGridGetColumnValueMaskProc getColumnValueMaskProc
;
469 XmLGridGetColumnValueProc getColumnValueProc
;
470 XmLGridSetColumnValuesProc setColumnValuesProc
;
471 XmLGridSetCellValuesResizeProc setCellValuesResizeProc
;
472 XmLGridCellActionProc cellActionProc
;
475 typedef struct _XmLGridClassRec
477 CoreClassPart core_class
;
478 CompositeClassPart composite_class
;
479 ConstraintClassPart constraint_class
;
480 XmManagerClassPart manager_class
;
481 XmLGridClassPart grid_class
;
484 extern XmLGridClassRec xmlGridClassRec
;
486 typedef struct _XmLGridConstraintPart
489 } XmLGridConstraintPart
;
491 typedef struct _XmLGridConstraintRec
493 XmManagerConstraintPart manager
;
494 XmLGridConstraintPart grid
;
495 } XmLGridConstraintRec
, *XmLGridConstraintPtr
;