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 ***** */
51 #include <Xm/ScrollBar.h>
53 #include <Xm/DrawnB.h>
54 #include <Xm/CutPaste.h>
56 #include <Xm/DropSMgr.h>
58 #include <X11/StringDefs.h>
59 #include <X11/cursorfont.h>
64 int fprintf(FILE *, char *, ...);
65 int fseek(FILE *, long, int);
66 int fread(char *, int, int, FILE *);
69 /* Create and Destroy */
70 static void ClassInitialize(void);
71 static void ClassPartInitialize(WidgetClass wc
);
72 static void Initialize(Widget req
, Widget newW
, ArgList args
, Cardinal
*nargs
);
73 static void Destroy(Widget w
);
75 /* Geometry, Drawing, Entry and Picking */
76 static void Realize(Widget w
, XtValueMask
*valueMask
,
77 XSetWindowAttributes
*attr
);
78 static void Redisplay(Widget w
, XExposeEvent
*event
, Region region
);
79 static void DrawResizeLine(XmLGridWidget g
, int xy
, int erase
);
80 static void DrawXORRect(XmLGridWidget g
, int xy
, int size
,
81 int isVert
, int erase
);
82 static void DefineCursor(XmLGridWidget g
, char defineCursor
);
83 static void DrawArea(XmLGridWidget g
, int type
, int row
, int col
);
84 static void ExtendSelectRange(XmLGridWidget g
, int *type
,
85 int *fr
, int *lr
, int *fc
, int *lc
);
86 static void ExtendSelect(XmLGridWidget g
, XEvent
*event
, Boolean set
,
88 static void SelectTypeArea(XmLGridWidget g
, int type
, XEvent
*event
,
89 int row
, int col
, Boolean select
, Boolean notify
);
90 static int GetSelectedArea(XmLGridWidget g
, int type
, int *rowPos
,
91 int *colPos
, int count
);
92 static void ChangeManaged(Widget w
);
93 static void Resize(Widget w
);
94 static void PlaceScrollbars(XmLGridWidget w
);
95 static void VertLayout(XmLGridWidget g
, int resizeIfNeeded
);
96 static void HorizLayout(XmLGridWidget g
, int resizeIfNeeded
);
97 static void ApplyVisibleRows(XmLGridWidget g
);
98 static void ApplyVisibleCols(XmLGridWidget g
);
99 static void VisPosChanged(XmLGridWidget g
, int isVert
);
100 static void RecalcVisPos(XmLGridWidget g
, int isVert
);
101 static int PosToVisPos(XmLGridWidget g
, int pos
, int isVert
);
102 static int VisPosToPos(XmLGridWidget g
, int visPos
, int isVert
);
103 static unsigned char ColPosToType(XmLGridWidget g
, int pos
);
104 static int ColPosToTypePos(XmLGridWidget g
, unsigned char type
, int pos
);
105 static unsigned char RowPosToType(XmLGridWidget g
, int pos
);
106 static int RowPosToTypePos(XmLGridWidget g
, unsigned char type
, int pos
);
107 static int ColTypePosToPos(XmLGridWidget g
, unsigned char type
,
108 int pos
, int allowNeg
);
109 static int RowTypePosToPos(XmLGridWidget g
, unsigned char type
,
110 int pos
, int allowNeg
);
111 static int ScrollRowBottomPos(XmLGridWidget g
, int row
);
112 static int ScrollColRightPos(XmLGridWidget g
, int col
);
113 static int PosIsResize(XmLGridWidget g
, int x
, int y
,
114 int *row
, int *col
, int *isVert
);
115 static int XYToRowCol(XmLGridWidget g
, int x
, int y
, int *row
, int *col
);
116 static int RowColToXY(XmLGridWidget g
, int row
, int col
,
117 Boolean clipped
, XRectangle
*rect
);
118 static int RowColFirstSpan(XmLGridWidget g
, int row
, int col
,
119 int *spanRow
, int *spanCol
, XRectangle
*rect
, Boolean lookLeft
,
121 static void RowColSpanRect(XmLGridWidget g
, int row
, int col
, XRectangle
*rect
);
122 static XmLGridCell
GetCell(XmLGridWidget g
, int row
, int col
);
123 static int GetColWidth(XmLGridWidget g
, int col
);
124 static int GetRowHeight(XmLGridWidget g
, int row
);
125 static int ColIsVisible(XmLGridWidget g
, int col
);
126 static int RowIsVisible(XmLGridWidget g
, int row
);
127 static XtGeometryResult
GeometryManager(Widget w
, XtWidgetGeometry
*request
,
129 static void ScrollCB(Widget w
, XtPointer
, XtPointer
);
130 static int FindNextFocus(XmLGridWidget g
, int row
, int col
,
131 int rowDir
, int colDir
, int *nextRow
, int *nextCol
);
132 static int SetFocus(XmLGridWidget g
, int row
, int col
, int rowDir
, int colDir
);
133 static void ChangeFocus(XmLGridWidget g
, int row
, int col
);
134 static void MakeColVisible(XmLGridWidget g
, int col
);
135 static void MakeRowVisible(XmLGridWidget g
, int row
);
136 static void TextAction(XmLGridWidget g
, int action
);
138 /* Getting and Setting Values */
139 static void GetSubValues(Widget w
, ArgList args
, Cardinal
*nargs
);
140 static void SetSubValues(Widget w
, ArgList args
, Cardinal
*nargs
);
141 static Boolean
SetValues(Widget curW
, Widget
, Widget newW
,
142 ArgList args
, Cardinal
*nargs
);
143 static void CopyFontList(XmLGridWidget g
);
144 static Boolean
CvtStringToSizePolicy(Display
*dpy
, XrmValuePtr args
,
145 Cardinal
*numArgs
, XrmValuePtr fromVal
, XrmValuePtr toVal
,
147 static Boolean
CvtStringToSelectionPolicy(Display
*dpy
, XrmValuePtr args
,
148 Cardinal
*numArgs
, XrmValuePtr fromVal
, XrmValuePtr toVal
,
150 static Boolean
CvtStringToRowColType(Display
*dpy
, XrmValuePtr args
,
151 Cardinal
*numArgs
, XrmValuePtr fromVal
, XrmValuePtr toVal
,
153 static Boolean
CvtStringToCellAlignment(Display
*dpy
, XrmValuePtr args
,
154 Cardinal
*numArgs
, XrmValuePtr fromVal
, XrmValuePtr toVal
,
156 static Boolean
CvtStringToCellType(Display
*dpy
, XrmValuePtr args
,
157 Cardinal
*numArgs
, XrmValuePtr fromVal
, XrmValuePtr toVal
,
159 static Boolean
CvtStringToCellBorderType(Display
*dpy
, XrmValuePtr args
,
160 Cardinal
*numArgs
, XrmValuePtr fromVal
, XrmValuePtr toVal
,
162 static void SetSimpleHeadings(XmLGridWidget g
, char *data
);
163 static void SetSimpleWidths(XmLGridWidget g
, char *data
);
165 /* Getting and Setting Row Values */
166 static void GetRowValueMask(XmLGridWidget g
, char *s
, long *mask
);
167 static void _GetRowValueMask(XmLGridWidget g
, char *s
, long *mask
);
168 static void GetRowValue(XmLGridWidget g
, XmLGridRow row
,
169 XtArgVal value
, long mask
);
170 static void _GetRowValue(XmLGridWidget g
, XmLGridRow row
,
171 XtArgVal value
, long mask
);
172 static int SetRowValues(XmLGridWidget g
, XmLGridRow row
, long mask
);
173 static int _SetRowValues(XmLGridWidget g
, XmLGridRow row
, long mask
);
175 /* Getting and Setting Column Values */
176 static void GetColumnValueMask(XmLGridWidget g
, char *s
, long *mask
);
177 static void _GetColumnValueMask(XmLGridWidget g
, char *s
, long *mask
);
178 static void GetColumnValue(XmLGridWidget g
, XmLGridColumn col
,
179 XtArgVal value
, long mask
);
180 static void _GetColumnValue(XmLGridWidget g
, XmLGridColumn col
,
181 XtArgVal value
, long mask
);
182 static int SetColumnValues(XmLGridWidget g
, XmLGridColumn col
, long mask
);
183 static int _SetColumnValues(XmLGridWidget g
, XmLGridColumn col
, long mask
);
185 /* Getting and Setting Cell Values */
186 static void CellValueGetMask(char *s
, long *mask
);
187 static void GetCellValue(XmLGridCell cell
, XtArgVal value
, long mask
);
188 static XmLGridCellRefValues
*CellRefValuesCreate(XmLGridWidget g
,
189 XmLGridCellRefValues
*copy
);
190 static void SetCellValuesPreprocess(XmLGridWidget g
, long mask
);
191 static int SetCellHasRefValues(long mask
);
192 static int SetCellValuesResize(XmLGridWidget g
, XmLGridRow row
,
193 XmLGridColumn col
, XmLGridCell cell
, long mask
);
194 static int _SetCellValuesResize(XmLGridWidget g
, XmLGridRow row
,
195 XmLGridColumn col
, XmLGridCell cell
, long mask
);
196 static void SetCellValues(XmLGridWidget g
, XmLGridCell cell
, long mask
);
197 static void SetCellRefValues(XmLGridWidget g
, XmLGridCellRefValues
*values
,
199 static int SetCellRefValuesCompare(void *, void **, void **);
200 static void SetCellRefValuesPreprocess(XmLGridWidget g
, int row
, int col
,
201 XmLGridCell cell
, long mask
);
203 /* Read, Write, Copy, Paste */
204 static int Read(XmLGridWidget g
, int format
, char delimiter
,
205 int row
, int col
, char *data
);
206 static void Write(XmLGridWidget g
, FILE *file
, int format
, char delimiter
,
207 Boolean skipHidden
, int row
, int col
, int nrow
, int ncol
);
208 static char *CopyDataCreate(XmLGridWidget g
, int selected
, int row
, int col
,
210 static Boolean
Copy(XmLGridWidget g
, Time time
, int selected
,
211 int row
, int col
, int nrow
, int ncol
);
212 static Boolean
Paste(XmLGridWidget g
, int row
, int col
);
215 static void GetCoreBackground(Widget w
, int, XrmValue
*value
);
216 static void GetManagerForeground(Widget w
, int, XrmValue
*value
);
217 static void ClipRectToReg(XmLGridWidget g
, XRectangle
*rect
, GridReg
*reg
);
218 static char *FileToString(FILE *file
);
219 static char *CvtXmStringToStr(XmString str
);
220 static XmLGridWidget
WidgetToGrid(Widget w
, char *funcname
);
222 /* Actions, Callbacks and Handlers */
223 static void ButtonMotion(Widget w
, XEvent
*event
, String
*, Cardinal
*);
224 static void DragTimer(XtPointer
, XtIntervalId
*);
225 static void CursorMotion(Widget w
, XEvent
*event
, String
*, Cardinal
*);
226 static void Edit(Widget w
, XEvent
*event
, String
*, Cardinal
*);
227 static void EditCancel(Widget w
, XEvent
*event
, String
*, Cardinal
*);
228 static void EditComplete(Widget w
, XEvent
*event
, String
*, Cardinal
*);
229 static void DragStart(Widget w
, XEvent
*event
, String
*, Cardinal
*);
230 static Boolean
DragConvert(Widget w
, Atom
*selection
, Atom
*target
,
231 Atom
*type
, XtPointer
*value
, unsigned long *length
, int *format
);
232 static void DragFinish(Widget w
, XtPointer clientData
, XtPointer callData
);
233 static void DropRegister(XmLGridWidget g
, Boolean set
);
234 static void DropStart(Widget w
, XtPointer clientData
, XtPointer callData
);
235 static void DropTransfer(Widget w
, XtPointer clientData
, Atom
*selType
,
236 Atom
*type
, XtPointer value
, unsigned long *length
, int *format
);
237 static void Select(Widget w
, XEvent
*event
, String
*, Cardinal
*);
238 static void PopupSelect(Widget w
, XEvent
*event
, String
*, Cardinal
*);
239 static void TextActivate(Widget w
, XtPointer clientData
, XtPointer callData
);
240 static void TextFocus(Widget w
, XtPointer clientData
, XtPointer callData
);
241 static void TextMapped(Widget w
, XtPointer closure
, XEvent
*event
,
243 static void TextModifyVerify(Widget w
, XtPointer clientData
,
245 static void Traverse(Widget w
, XEvent
*event
, String
*, Cardinal
*);
248 static void EditTimer(XtPointer
, XtIntervalId
*);
249 static void CreateHideUnhideButtons(XmLGridWidget g
);
250 static void HideAction(Widget w
, XEvent
*event
, String
*, Cardinal
*);
251 static void UnhideAction(Widget w
, XEvent
*event
, String
*, Cardinal
*);
252 static void setHideUnhideSensitivity(Widget w
);
253 static void MenuArm(Widget w
, XEvent
*event
, String
*, Cardinal
*);
254 static void MenuDisarm(Widget w
, XEvent
*event
, String
*, Cardinal
*);
255 static void ResizeColumnToFit(XmLGridWidget g
, int x
);
256 static int SizeColumnsToFit(XmLGridWidget g
, int start_at
);
257 static void GridCrossingEH(Widget w
, XtPointer closure
, XEvent
*event
,
259 static void GridInvokeCellCrossingCallbacks(Widget w
,XtCallbackList list
,
260 int reason
,XEvent
* event
,
262 static void GridCrossingEH(Widget w
,XtPointer closure
,XEvent
* event
,
267 static XmLGridRow
XmLGridRowNew(Widget grid
);
268 static void XmLGridRowFree(Widget grid
, XmLGridRow row
);
269 static XmLGridRow
_GridRowNew(Widget grid
);
270 static void _GridRowFree(XmLGridRow row
);
271 static XmLArray
XmLGridRowCells(XmLGridRow row
);
272 static int XmLGridRowGetPos(XmLGridRow row
);
273 static int XmLGridRowGetVisPos(XmLGridRow row
);
274 static Boolean
XmLGridRowIsHidden(XmLGridRow row
);
275 static Boolean
XmLGridRowIsSelected(XmLGridRow row
);
276 static void XmLGridRowSetSelected(XmLGridRow row
, Boolean selected
);
277 static void XmLGridRowSetVisPos(XmLGridRow row
, int visPos
);
278 static int XmLGridRowHeightInPixels(XmLGridRow row
);
279 static void XmLGridRowHeightChanged(XmLGridRow row
);
283 static XmLGridColumn
XmLGridColumnNew(Widget grid
);
284 static void XmLGridColumnFree(Widget grid
, XmLGridColumn column
);
285 static XmLGridColumn
_GridColumnNew(Widget grid
);
286 static void _GridColumnFree(XmLGridColumn column
);
287 static int XmLGridColumnGetPos(XmLGridColumn column
);
288 static int XmLGridColumnGetVisPos(XmLGridColumn column
);
289 static Boolean
XmLGridColumnIsHidden(XmLGridColumn column
);
290 static Boolean
XmLGridColumnIsSelected(XmLGridColumn column
);
291 static void XmLGridColumnSetSelected(XmLGridColumn column
, Boolean selected
);
292 static void XmLGridColumnSetVisPos(XmLGridColumn column
, int visPos
);
293 static int XmLGridColumnWidthInPixels(XmLGridColumn column
);
294 static void XmLGridColumnWidthChanged(XmLGridColumn column
);
298 static XmLGridCell
XmLGridCellNew();
299 static void XmLGridCellFree(Widget grid
, XmLGridCell cell
);
300 static int XmLGridCellAction(XmLGridCell cell
, Widget w
,
301 XmLGridCallbackStruct
*cbs
);
302 static int _GridCellAction(XmLGridCell cell
, Widget w
,
303 XmLGridCallbackStruct
*cbs
);
304 static XmLGridCellRefValues
*XmLGridCellGetRefValues(XmLGridCell cell
);
305 static void XmLGridCellSetRefValues(XmLGridCell cell
,
306 XmLGridCellRefValues
*values
);
307 static void XmLGridCellDerefValues(XmLGridCellRefValues
*values
);
308 static Boolean
XmLGridCellInRowSpan(XmLGridCell cell
);
309 static Boolean
XmLGridCellInColumnSpan(XmLGridCell cell
);
310 static Boolean
XmLGridCellIsSelected(XmLGridCell cell
);
311 static Boolean
XmLGridCellIsValueSet(XmLGridCell cell
);
312 static void XmLGridCellSetValueSet(XmLGridCell cell
, Boolean set
);
313 static void XmLGridCellSetInRowSpan(XmLGridCell cell
, Boolean set
);
314 static void XmLGridCellSetInColumnSpan(XmLGridCell cell
, Boolean set
);
315 static void XmLGridCellSetSelected(XmLGridCell cell
, Boolean selected
);
316 static void XmLGridCellAllocIcon(XmLGridCell cell
);
317 static void XmLGridCellAllocPixmap(XmLGridCell cell
);
318 static void XmLGridCellSetString(XmLGridCell cell
, XmString string
,
320 static XmString
XmLGridCellGetString(XmLGridCell cell
);
321 static void XmLGridCellSetToggle(XmLGridCell cell
, Boolean state
);
322 static Boolean
XmLGridCellGetToggle(XmLGridCell cell
);
323 static void XmLGridCellSetPixmap(XmLGridCell cell
, Pixmap pixmap
,
324 Dimension width
, Dimension height
);
325 static void XmLGridCellSetPixmask(XmLGridCell cell
, Pixmap pixmask
);
326 static XmLGridCellPixmap
*XmLGridCellGetPixmap(XmLGridCell cell
);
327 /* static void XmLGridCellClearTextString(XmLGridCell cell, Widget w); */
328 static int _XmLGridCellConfigureText(XmLGridCell cell
, Widget w
,
330 static int _XmLGridCellBeginTextEdit(XmLGridCell cell
, Widget w
,
331 XRectangle
*clipRect
);
332 static void _XmLGridCellCompleteTextEdit(XmLGridCell cell
, Widget w
);
333 static void _XmLGridCellInsertText(XmLGridCell cell
, Widget w
);
334 static int _XmLGridCellGetHeight(XmLGridCell cell
, Widget w
,XmLGridRow row
);
335 static int _XmLGridCellGetWidth(XmLGridCell cell
, Widget w
,XmLGridColumn col
);
336 static void _XmLGridCellFreeValue(XmLGridCell cell
);
339 static Boolean
XmLGridCellDrawSort(XmLGridCell cell
);
340 static Boolean
XmLGridCellSortAscending(XmLGridCell cell
);
341 static void XmLGridCellSetDrawSort(XmLGridCell cell
, Boolean drawSort
);
342 static void XmLGridCellSetSortAscending(XmLGridCell cell
, Boolean ascending
);
344 static XtActionsRec actions
[] =
346 { "XmLGridEditComplete", EditComplete
},
347 { "XmLGridButtonMotion", ButtonMotion
},
348 { "XmLGridCursorMotion", CursorMotion
},
349 { "XmLGridEditCancel", EditCancel
},
350 { "XmLGridEdit", Edit
},
351 { "XmLGridSelect", Select
},
352 { "XmLGridPopupSelect", PopupSelect
},
353 { "XmLGridDragStart", DragStart
},
354 { "XmLGridTraverse", Traverse
},
356 { "XmLGridHideColumn", HideAction
},
357 { "XmLGridUnhideColumn", UnhideAction
},
358 { "MenuArm", MenuArm
},
359 { "MenuDisarm", MenuDisarm
},
365 #define TEXT_EDIT_CANCEL 4
366 #define TEXT_EDIT_COMPLETE 5
367 #define TEXT_EDIT_INSERT 6
370 #define XmTOGGLE_CELL 240
372 /* backwards compatibility defines */
373 #define XmTEXT_CELL 250
374 #define XmLABEL_CELL 251
378 #define horizp_width 19
379 #define horizp_height 13
380 static unsigned char horizp_bits
[] = {
381 0x00, 0x00, 0x00, 0xff, 0x07, 0x00, 0xff, 0x07, 0x00, 0x00, 0x06, 0x00,
382 0x00, 0x06, 0x00, 0x20, 0x46, 0x00, 0x30, 0xc6, 0x00, 0x38, 0xc6, 0x01,
383 0xfc, 0xff, 0x03, 0x38, 0xc6, 0x01, 0x30, 0xc6, 0x00, 0x20, 0x46, 0x00,
386 #define horizm_width 19
387 #define horizm_height 13
388 static unsigned char horizm_bits
[] = {
389 0xff, 0x0f, 0x00, 0xff, 0x0f, 0x00, 0xff, 0x0f, 0x00, 0xff, 0x0f, 0x00,
390 0x60, 0x6f, 0x00, 0x70, 0xef, 0x00, 0x78, 0xef, 0x01, 0xfc, 0xff, 0x03,
391 0xfe, 0xff, 0x07, 0xfc, 0xff, 0x03, 0x78, 0xef, 0x01, 0x70, 0xef, 0x00,
394 #define vertp_width 13
395 #define vertp_height 19
396 static unsigned char vertp_bits
[] = {
397 0x06, 0x00, 0x06, 0x00, 0x06, 0x01, 0x86, 0x03, 0xc6, 0x07, 0xe6, 0x0f,
398 0x06, 0x01, 0x06, 0x01, 0x06, 0x01, 0xfe, 0x1f, 0xfe, 0x1f, 0x00, 0x01,
399 0x00, 0x01, 0x00, 0x01, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03, 0x00, 0x01,
402 #define vertm_width 13
403 #define vertm_height 19
404 static unsigned char vertm_bits
[] = {
405 0x0f, 0x00, 0x0f, 0x01, 0x8f, 0x03, 0xcf, 0x07, 0xef, 0x0f, 0xff, 0x1f,
406 0xff, 0x1f, 0x8f, 0x03, 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f,
407 0x80, 0x03, 0xf0, 0x1f, 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03,
410 /* Grid Translations */
412 static char translations
[] =
413 "<Btn1Motion>: XmLGridButtonMotion()\n\
414 <MotionNotify>: XmLGridCursorMotion()\n\
415 ~Ctrl ~Shift <Btn1Down>: XmLGridSelect(BEGIN)\n\
416 ~Ctrl Shift <Btn1Down>: XmLGridSelect(EXTEND)\n\
417 Ctrl ~Shift <Btn1Down>: XmLGridSelect(TOGGLE)\n\
418 <Btn1Up>: XmLGridSelect(END)\n\
419 <Btn2Down>: XmLGridDragStart()\n\
420 ~Ctrl ~Shift <Btn3Down>: XmLGridPopupSelect(BEGIN)\n\
421 ~Ctrl Shift <Btn3Down>: XmLGridPopupSelect(EXTEND)\n\
422 Ctrl ~Shift <Btn3Down>: XmLGridPopupSelect(TOGGLE)\n\
423 <EnterWindow>: ManagerEnter()\n\
424 <LeaveWindow>: ManagerLeave()\n\
425 <FocusOut>: ManagerFocusOut()\n\
426 <FocusIn>: ManagerFocusIn()";
428 /* Text Translations */
430 static char traverseTranslations
[] =
431 "~Ctrl ~Shift <Key>osfUp: XmLGridTraverse(UP)\n\
432 ~Ctrl Shift <Key>osfUp: XmLGridTraverse(EXTEND_UP)\n\
433 Ctrl ~Shift <Key>osfUp: XmLGridTraverse(PAGE_UP)\n\
434 ~Ctrl ~Shift <Key>osfDown: XmLGridTraverse(DOWN)\n\
435 ~Ctrl Shift <Key>osfDown: XmLGridTraverse(EXTEND_DOWN)\n\
436 Ctrl ~Shift <Key>osfDown: XmLGridTraverse(PAGE_DOWN)\n\
437 ~Ctrl ~Shift <Key>osfLeft: XmLGridTraverse(LEFT)\n\
438 ~Ctrl Shift <Key>osfLeft: XmLGridTraverse(EXTEND_LEFT)\n\
439 Ctrl ~Shift <Key>osfLeft: XmLGridTraverse(PAGE_LEFT)\n\
440 ~Ctrl ~Shift <Key>osfRight: XmLGridTraverse(RIGHT)\n\
441 ~Ctrl Shift <Key>osfRight: XmLGridTraverse(EXTEND_RIGHT)\n\
442 Ctrl ~Shift <Key>osfRight: XmLGridTraverse(PAGE_RIGHT)\n\
443 ~Ctrl ~Shift <Key>osfPageUp: XmLGridTraverse(PAGE_UP)\n\
444 ~Ctrl Shift <Key>osfPageUp: XmLGridTraverse(EXTEND_PAGE_UP)\n\
445 Ctrl ~Shift <Key>osfPageUp: XmLGridTraverse(PAGE_LEFT)\n\
446 Ctrl Shift <Key>osfPageUp: XmLGridTraverse(EXTEND_PAGE_LEFT)\n\
447 ~Ctrl Shift <Key>osfPageDown: XmLGridTraverse(EXTEND_PAGE_DOWN)\n\
448 Ctrl ~Shift <Key>osfPageDown: XmLGridTraverse(PAGE_RIGHT)\n\
449 ~Ctrl ~Shift <Key>osfPageDown: XmLGridTraverse(PAGE_DOWN)\n\
450 Ctrl Shift <Key>osfPageDown: XmLGridTraverse(EXTEND_PAGE_RIGHT)\n\
451 ~Ctrl ~Shift <Key>Tab: XmLGridTraverse(RIGHT)\n\
452 ~Ctrl Shift <Key>Tab: XmLGridTraverse(LEFT)\n\
453 ~Ctrl ~Shift <Key>Home: XmLGridTraverse(TO_TOP)\n\
454 ~Ctrl ~Shift <Key>osfBeginLine: XmLGridTraverse(TO_TOP)\n\
455 Ctrl ~Shift <Key>Home: XmLGridTraverse(TO_TOP_LEFT)\n\
456 ~Ctrl ~Shift <Key>End: XmLGridTraverse(TO_BOTTOM)\n\
457 ~Ctrl ~Shift <Key>osfEndLine: XmLGridTraverse(TO_BOTTOM)\n\
458 Ctrl ~Shift <Key>End: XmLGridTraverse(TO_BOTTOM_RIGHT)\n\
459 <Key>osfInsert: XmLGridEdit()\n\
460 <Key>F2: XmLGridEdit()\n\
461 ~Ctrl ~Shift <KeyDown>space: XmLGridSelect(BEGIN)\n\
462 ~Ctrl Shift <KeyDown>space: XmLGridSelect(EXTEND)\n\
463 Ctrl ~Shift <KeyDown>space: XmLGridSelect(TOGGLE)\n\
464 <KeyUp>space: XmLGridSelect(END)";
466 /* You can't put multiple actions for any translation
467 where one translation changes the translation table
468 XmLGridComplete() and XmLGridCancel() do this and these
469 actions can't be combined with others */
470 static char editTranslations
[] =
471 "~Ctrl ~Shift <Key>osfDown: XmLGridEditComplete(DOWN)\n\
472 ~Ctrl Shift <Key>Tab: XmLGridEditComplete(LEFT)\n\
473 ~Ctrl ~Shift <Key>Tab: XmLGridEditComplete(RIGHT)\n\
474 ~Ctrl ~Shift <Key>osfUp: XmLGridEditComplete(UP)\n\
475 <Key>osfCancel: XmLGridEditCancel()\n\
476 <Key>Escape: XmLGridEditCancel()";
479 static char hideButtonTranslations
[] =
480 "<BtnDown>,<BtnUp>: XmLGridHideColumn()";
482 static char unhideButtonTranslations
[] =
483 "<BtnDown>,<BtnUp>: XmLGridUnhideColumn()";
486 static XtResource resources
[] =
490 XmNactivateCallback
, XmCCallback
,
491 XmRCallback
, sizeof(XtCallbackList
),
492 XtOffset(XmLGridWidget
, grid
.activateCallback
),
493 XmRImmediate
, (XtPointer
)0,
496 XmNaddCallback
, XmCCallback
,
497 XmRCallback
, sizeof(XtCallbackList
),
498 XtOffset(XmLGridWidget
, grid
.addCallback
),
499 XmRImmediate
, (XtPointer
)0,
502 XmNallowColumnHide
, XmCAllowColumnHide
,
503 XmRBoolean
, sizeof(Boolean
),
504 XtOffset(XmLGridWidget
, grid
.allowColHide
),
505 XmRImmediate
, (XtPointer
)False
,
508 XmNallowColumnResize
, XmCAllowColumnResize
,
509 XmRBoolean
, sizeof(Boolean
),
510 XtOffset(XmLGridWidget
, grid
.allowColResize
),
511 XmRImmediate
, (XtPointer
)False
,
514 XmNallowDragSelected
, XmCAllowDragSelected
,
515 XmRBoolean
, sizeof(Boolean
),
516 XtOffset(XmLGridWidget
, grid
.allowDrag
),
517 XmRImmediate
, (XtPointer
)False
,
520 XmNallowDrop
, XmCAllowDrop
,
521 XmRBoolean
, sizeof(Boolean
),
522 XtOffset(XmLGridWidget
, grid
.allowDrop
),
523 XmRImmediate
, (XtPointer
)False
,
526 XmNallowRowHide
, XmCAllowRowHide
,
527 XmRBoolean
, sizeof(Boolean
),
528 XtOffset(XmLGridWidget
, grid
.allowRowHide
),
529 XmRImmediate
, (XtPointer
)False
,
532 XmNallowRowResize
, XmCAllowRowResize
,
533 XmRBoolean
, sizeof(Boolean
),
534 XtOffset(XmLGridWidget
, grid
.allowRowResize
),
535 XmRImmediate
, (XtPointer
)False
,
538 XmNautoSelect
, XmCAutoSelect
,
539 XmRBoolean
, sizeof(Boolean
),
540 XtOffset(XmLGridWidget
, grid
.autoSelect
),
541 XmRImmediate
, (XtPointer
)True
,
544 XmNblankBackground
, XmCBlankBackground
,
545 XmRPixel
, sizeof(Pixel
),
546 XtOffset(XmLGridWidget
, grid
.blankBg
),
547 XmRCallProc
, (XtPointer
)GetCoreBackground
,
550 XmNbottomFixedCount
, XmCBottomFixedCount
,
552 XtOffset(XmLGridWidget
, grid
.bottomFixedCount
),
553 XmRImmediate
, (XtPointer
)0,
556 XmNbottomFixedMargin
, XmCBottomFixedMargin
,
557 XmRDimension
, sizeof(Dimension
),
558 XtOffset(XmLGridWidget
, grid
.bottomFixedMargin
),
559 XmRImmediate
, (XtPointer
)0,
562 XmNcellDefaults
, XmCCellDefaults
,
563 XmRBoolean
, sizeof(Boolean
),
564 XtOffset(XmLGridWidget
, grid
.cellDefaults
),
565 XmRImmediate
, (XtPointer
)False
,
568 XmNcellDrawCallback
, XmCCallback
,
569 XmRCallback
, sizeof(XtCallbackList
),
570 XtOffset(XmLGridWidget
, grid
.cellDrawCallback
),
571 XmRImmediate
, (XtPointer
)0,
574 XmNcellDropCallback
, XmCCallback
,
575 XmRCallback
, sizeof(XtCallbackList
),
576 XtOffset(XmLGridWidget
, grid
.cellDropCallback
),
577 XmRImmediate
, (XtPointer
)0,
580 XmNcellFocusCallback
, XmCCallback
,
581 XmRCallback
, sizeof(XtCallbackList
),
582 XtOffset(XmLGridWidget
, grid
.cellFocusCallback
),
583 XmRImmediate
, (XtPointer
)0,
586 XmNcellPasteCallback
, XmCCallback
,
587 XmRCallback
, sizeof(XtCallbackList
),
588 XtOffset(XmLGridWidget
, grid
.cellPasteCallback
),
589 XmRImmediate
, (XtPointer
)0,
592 XmNcolumns
, XmCColumns
,
594 XtOffset(XmLGridWidget
, grid
.colCount
),
595 XmRImmediate
, (XtPointer
)0,
598 XmNdeleteCallback
, XmCCallback
,
599 XmRCallback
, sizeof(XtCallbackList
),
600 XtOffset(XmLGridWidget
, grid
.deleteCallback
),
601 XmRImmediate
, (XtPointer
)0,
604 XmNdeselectCallback
, XmCCallback
,
605 XmRCallback
, sizeof(XtCallbackList
),
606 XtOffset(XmLGridWidget
, grid
.deselectCallback
),
607 XmRImmediate
, (XtPointer
)0,
610 XmNdebugLevel
, XmCDebugLevel
,
612 XtOffset(XmLGridWidget
, grid
.debugLevel
),
613 XmRImmediate
, (XtPointer
)0,
616 XmNeditCallback
, XmCCallback
,
617 XmRCallback
, sizeof(XtCallbackList
),
618 XtOffset(XmLGridWidget
, grid
.editCallback
),
619 XmRImmediate
, (XtPointer
)0,
622 XmNeditTranslations
, XmCTranslations
,
623 XmRTranslationTable
, sizeof(XtTranslations
),
624 XtOffset(XmLGridWidget
, grid
.editTrans
),
625 XmRString
, (XtPointer
)editTranslations
,
628 XmNfontList
, XmCFontList
,
629 XmRFontList
, sizeof(XmFontList
),
630 XtOffset(XmLGridWidget
, grid
.fontList
),
631 XmRImmediate
, (XtPointer
)0
634 XmNfooterColumns
, XmCFooterColumns
,
636 XtOffset(XmLGridWidget
, grid
.footerColCount
),
637 XmRImmediate
, (XtPointer
)0,
640 XmNfooterRows
, XmCFooterRows
,
642 XtOffset(XmLGridWidget
, grid
.footerRowCount
),
643 XmRImmediate
, (XtPointer
)0,
646 XmNglobalPixmapHeight
, XmCGlobalPixmapHeight
,
647 XmRDimension
, sizeof(Dimension
),
648 XtOffset(XmLGridWidget
, grid
.globalPixmapHeight
),
649 XmRImmediate
, (XtPointer
)0,
652 XmNglobalPixmapWidth
, XmCGlobalPixmapWidth
,
653 XmRDimension
, sizeof(Dimension
),
654 XtOffset(XmLGridWidget
, grid
.globalPixmapWidth
),
655 XmRImmediate
, (XtPointer
)0,
658 XmNheadingColumns
, XmCHeadingColumns
,
660 XtOffset(XmLGridWidget
, grid
.headingColCount
),
661 XmRImmediate
, (XtPointer
)0,
664 XmNheadingRows
, XmCHeadingRows
,
666 XtOffset(XmLGridWidget
, grid
.headingRowCount
),
667 XmRImmediate
, (XtPointer
)0,
670 XmNhiddenColumns
, XmCHiddenColumns
,
672 XtOffset(XmLGridWidget
, grid
.hiddenColCount
),
673 XmRImmediate
, (XtPointer
)0,
676 XmNhiddenRows
, XmCHiddenRows
,
678 XtOffset(XmLGridWidget
, grid
.hiddenRowCount
),
679 XmRImmediate
, (XtPointer
)0,
682 XmNhighlightRowMode
, XmCHighlightRowMode
,
683 XmRBoolean
, sizeof(Boolean
),
684 XtOffset(XmLGridWidget
, grid
.highlightRowMode
),
685 XmRImmediate
, (XtPointer
)False
,
688 XmNhighlightThickness
, XmCHighlightThickness
,
689 XmRDimension
, sizeof(Dimension
),
690 XtOffset(XmLGridWidget
, grid
.highlightThickness
),
691 XmRImmediate
, (XtPointer
)2,
694 XmNhorizontalScrollBar
, XmCHorizontalScrollBar
,
695 XmRWidget
, sizeof(Widget
),
696 XtOffset(XmLGridWidget
, grid
.hsb
),
697 XmRImmediate
, (XtPointer
)0,
700 XmNhorizontalSizePolicy
, XmCHorizontalSizePolicy
,
701 XmRGridSizePolicy
, sizeof(unsigned char),
702 XtOffset(XmLGridWidget
, grid
.hsPolicy
),
703 XmRImmediate
, (XtPointer
)XmCONSTANT
,
706 XmNhsbDisplayPolicy
, XmCHsbDisplayPolicy
,
707 XmRScrollBarDisplayPolicy
, sizeof(unsigned char),
708 XtOffset(XmLGridWidget
, grid
.hsbDisplayPolicy
),
709 XmRImmediate
, (XtPointer
)XmAS_NEEDED
,
712 XmNimmediateDraw
, XmCImmediateDraw
,
713 XmRBoolean
, sizeof(Boolean
),
714 XtOffset(XmLGridWidget
, grid
.immediateDraw
),
715 XmRImmediate
, (XtPointer
)False
,
718 XmNlayoutFrozen
, XmCLayoutFrozen
,
719 XmRBoolean
, sizeof(Boolean
),
720 XtOffset(XmLGridWidget
, grid
.layoutFrozen
),
721 XmRImmediate
, (XtPointer
)False
,
724 XmNleftFixedCount
, XmCLeftFixedCount
,
726 XtOffset(XmLGridWidget
, grid
.leftFixedCount
),
727 XmRImmediate
, (XtPointer
)0,
730 XmNleftFixedMargin
, XmCLeftFixedMargin
,
731 XmRDimension
, sizeof(Dimension
),
732 XtOffset(XmLGridWidget
, grid
.leftFixedMargin
),
733 XmRImmediate
, (XtPointer
)0,
736 XmNminColumnWidth
, XmCMinColumnWidth
,
737 XmRDimension
, sizeof(Dimension
),
738 XtOffset(XmLGridWidget
, grid
.minColWidth
),
739 XmRImmediate
, (XtPointer
)0,
742 XmNrightFixedCount
, XmCRightFixedCount
,
744 XtOffset(XmLGridWidget
, grid
.rightFixedCount
),
745 XmRImmediate
, (XtPointer
)0,
748 XmNrightFixedMargin
, XmCRightFixedMargin
,
749 XmRDimension
, sizeof(Dimension
),
750 XtOffset(XmLGridWidget
, grid
.rightFixedMargin
),
751 XmRImmediate
, (XtPointer
)0,
754 XmNresizeCallback
, XmCCallback
,
755 XmRCallback
, sizeof(XtCallbackList
),
756 XtOffset(XmLGridWidget
, grid
.resizeCallback
),
757 XmRImmediate
, (XtPointer
)0,
762 XtOffset(XmLGridWidget
, grid
.rowCount
),
763 XmRImmediate
, (XtPointer
)0,
766 XmNscrollBarMargin
, XmCScrollBarMargin
,
767 XmRDimension
, sizeof(Dimension
),
768 XtOffset(XmLGridWidget
, grid
.scrollBarMargin
),
769 XmRImmediate
, (XtPointer
)2,
772 XmNscrollCallback
, XmCCallback
,
773 XmRCallback
, sizeof(XtCallbackList
),
774 XtOffset(XmLGridWidget
, grid
.scrollCallback
),
775 XmRImmediate
, (XtPointer
)0,
778 XmNscrollColumn
, XmCScrollColumn
,
780 XtOffset(XmLGridWidget
, grid
.cScrollCol
),
781 XmRImmediate
, (XtPointer
)0,
784 XmNscrollRow
, XmCScrollRow
,
786 XtOffset(XmLGridWidget
, grid
.cScrollRow
),
787 XmRImmediate
, (XtPointer
)0,
790 XmNselectCallback
, XmCCallback
,
791 XmRCallback
, sizeof(XtCallbackList
),
792 XtOffset(XmLGridWidget
, grid
.selectCallback
),
793 XmRImmediate
, (XtPointer
)0,
796 XmNselectionPolicy
, XmCGridSelectionPolicy
,
797 XmRGridSelectionPolicy
, sizeof(unsigned char),
798 XtOffset(XmLGridWidget
, grid
.selectionPolicy
),
799 XmRImmediate
, (XtPointer
)XmSELECT_BROWSE_ROW
,
802 XmNselectBackground
, XmCSelectBackground
,
803 XmRPixel
, sizeof(Pixel
),
804 XtOffset(XmLGridWidget
, grid
.selectBg
),
805 XmRCallProc
, (XtPointer
)GetManagerForeground
,
808 XmNselectForeground
, XmCSelectForeground
,
809 XmRPixel
, sizeof(Pixel
),
810 XtOffset(XmLGridWidget
, grid
.selectFg
),
811 XmRCallProc
, (XtPointer
)GetCoreBackground
,
814 XmNshadowRegions
, XmCShadowRegions
,
816 XtOffset(XmLGridWidget
, grid
.shadowRegions
),
817 XmRImmediate
, (XtPointer
)511,
820 XmNshadowType
, XmCShadowType
,
821 XmRShadowType
, sizeof(unsigned char),
822 XtOffset(XmLGridWidget
, grid
.shadowType
),
823 XmRImmediate
, (XtPointer
)XmSHADOW_IN
,
826 XmNsimpleHeadings
, XmCSimpleHeadings
,
827 XmRString
, sizeof(char *),
828 XtOffset(XmLGridWidget
, grid
.simpleHeadings
),
829 XmRImmediate
, (XtPointer
)0,
832 XmNsimpleWidths
, XmCSimpleWidths
,
833 XmRString
, sizeof(char *),
834 XtOffset(XmLGridWidget
, grid
.simpleWidths
),
835 XmRImmediate
, (XtPointer
)0,
838 XmNtextWidget
, XmCTextWidget
,
839 XmRWidget
, sizeof(Widget
),
840 XtOffset(XmLGridWidget
, grid
.text
),
841 XmRImmediate
, (XtPointer
)0,
844 XmNtoggleBottomColor
, XmCToggleBottomColor
,
845 XmRPixel
, sizeof(Pixel
),
846 XtOffset(XmLGridWidget
, grid
.toggleBotColor
),
847 XmRCallProc
, (XtPointer
)GetManagerForeground
,
850 XmNtoggleTopColor
, XmCToggleTopColor
,
851 XmRPixel
, sizeof(Pixel
),
852 XtOffset(XmLGridWidget
, grid
.toggleTopColor
),
853 XmRCallProc
, (XtPointer
)GetManagerForeground
,
856 XmNtoggleSize
, XmCToggleSize
,
857 XmRDimension
, sizeof(Dimension
),
858 XtOffset(XmLGridWidget
, grid
.toggleSize
),
859 XmRImmediate
, (XtPointer
)16,
862 XmNtraverseTranslations
, XmCTranslations
,
863 XmRTranslationTable
, sizeof(XtTranslations
),
864 XtOffset(XmLGridWidget
, grid
.traverseTrans
),
865 XmRString
, (XtPointer
)traverseTranslations
,
868 XmNtopFixedCount
, XmCTopFixedCount
,
870 XtOffset(XmLGridWidget
, grid
.topFixedCount
),
871 XmRImmediate
, (XtPointer
)0,
874 XmNtopFixedMargin
, XmCTopFixedMargin
,
875 XmRDimension
, sizeof(Dimension
),
876 XtOffset(XmLGridWidget
, grid
.topFixedMargin
),
877 XmRImmediate
, (XtPointer
)0,
880 XmNuseAverageFontWidth
, XmCUseAverageFontWidth
,
881 XmRBoolean
, sizeof(Boolean
),
882 XtOffset(XmLGridWidget
, grid
.useAvgWidth
),
883 XmRImmediate
, (XtPointer
)True
,
886 XmNverticalScrollBar
, XmCVerticalScrollBar
,
887 XmRWidget
, sizeof(Widget
),
888 XtOffset(XmLGridWidget
, grid
.vsb
),
889 XmRImmediate
, (XtPointer
)0,
892 XmNverticalSizePolicy
, XmCVerticalSizePolicy
,
893 XmRGridSizePolicy
, sizeof(unsigned char),
894 XtOffset(XmLGridWidget
, grid
.vsPolicy
),
895 XmRImmediate
, (XtPointer
)XmCONSTANT
,
898 XmNvisibleColumns
, XmCVisibleColumns
,
900 XtOffset(XmLGridWidget
, grid
.visibleCols
),
901 XmRImmediate
, (XtPointer
)0,
904 XmNvisibleRows
, XmCVisibleRows
,
906 XtOffset(XmLGridWidget
, grid
.visibleRows
),
907 XmRImmediate
, (XtPointer
)0,
910 XmNvsbDisplayPolicy
, XmCVsbDisplayPolicy
,
911 XmRScrollBarDisplayPolicy
, sizeof(unsigned char),
912 XtOffset(XmLGridWidget
, grid
.vsbDisplayPolicy
),
913 XmRImmediate
, (XtPointer
)XmAS_NEEDED
,
917 XmNpopupCallback
, XmCCallback
,
918 XmRCallback
, sizeof(XtCallbackList
),
919 XtOffset(XmLGridWidget
, grid
.popupCallback
),
920 XmRImmediate
, (XtPointer
)0,
923 XmNenterCellCallback
,
926 sizeof(XtCallbackList
),
927 XtOffset(XmLGridWidget
, grid
. enterCellCallback
),
932 XmNleaveCellCallback
,
935 sizeof(XtCallbackList
),
936 XtOffset(XmLGridWidget
, grid
. leaveCellCallback
),
941 XmNenterGridCallback
,
944 sizeof(XtCallbackList
),
945 XtOffset(XmLGridWidget
, grid
. enterGridCallback
),
950 XmNleaveGridCallback
,
953 sizeof(XtCallbackList
),
954 XtOffset(XmLGridWidget
, grid
. leaveGridCallback
),
963 XtOffset(XmLGridWidget
, grid
.cellRow
),
964 XmRImmediate
, (XtPointer
)-1,
967 XmNrowUserData
, XmCUserData
,
968 XmRPointer
, sizeof(XtPointer
),
969 XtOffset(XmLGridWidget
, grid
.rowUserData
),
970 XmRImmediate
, (XtPointer
)0,
973 XmNrowHeight
, XmCRowHeight
,
974 XmRDimension
, sizeof(Dimension
),
975 XtOffset(XmLGridWidget
, grid
.rowHeight
),
976 XmRImmediate
, (XtPointer
)0,
979 XmNrowRangeEnd
, XmCRowRangeEnd
,
981 XtOffset(XmLGridWidget
, grid
.cellRowRangeEnd
),
982 XmRImmediate
, (XtPointer
)-1,
985 XmNrowRangeStart
, XmCRowRangeStart
,
987 XtOffset(XmLGridWidget
, grid
.cellRowRangeStart
),
988 XmRImmediate
, (XtPointer
)-1,
991 XmNrowSizePolicy
, XmCRowSizePolicy
,
992 XmRGridSizePolicy
, sizeof(unsigned char),
993 XtOffset(XmLGridWidget
, grid
.rowSizePolicy
),
994 XmRImmediate
, (XtPointer
)0,
997 XmNrowStep
, XmCRowStep
,
999 XtOffset(XmLGridWidget
, grid
.rowStep
),
1000 XmRImmediate
, (XtPointer
)1,
1003 XmNrowType
, XmCRowType
,
1004 XmRRowType
, sizeof(unsigned char),
1005 XtOffset(XmLGridWidget
, grid
.rowType
),
1006 XmRImmediate
, (XtPointer
)XmINVALID_TYPE
,
1008 /* Column Resources */
1010 XmNcolumn
, XmCGridColumn
,
1011 XmRInt
, sizeof(int),
1012 XtOffset(XmLGridWidget
, grid
.cellCol
),
1013 XmRImmediate
, (XtPointer
)-1,
1016 XmNcolumnUserData
, XmCUserData
,
1017 XmRPointer
, sizeof(XtPointer
),
1018 XtOffset(XmLGridWidget
, grid
.colUserData
),
1019 XmRImmediate
, (XtPointer
)0,
1022 XmNcolumnResizable
, XmCColumnResizable
,
1023 XmRBoolean
, sizeof(Boolean
),
1024 XtOffset(XmLGridWidget
, grid
.colResizable
),
1025 XmRImmediate
, (XtPointer
)TRUE
,
1028 XmNcolumnWidth
, XmCColumnWidth
,
1029 XmRDimension
, sizeof(Dimension
),
1030 XtOffset(XmLGridWidget
, grid
.colWidth
),
1031 XmRImmediate
, (XtPointer
)0,
1034 XmNcolumnRangeEnd
, XmCColumnRangeEnd
,
1035 XmRInt
, sizeof(int),
1036 XtOffset(XmLGridWidget
, grid
.cellColRangeEnd
),
1037 XmRImmediate
, (XtPointer
)-1,
1040 XmNcolumnRangeStart
, XmCColumnRangeStart
,
1041 XmRInt
, sizeof(int),
1042 XtOffset(XmLGridWidget
, grid
.cellColRangeStart
),
1043 XmRImmediate
, (XtPointer
)-1,
1046 XmNcolumnSizePolicy
, XmCColumnSizePolicy
,
1047 XmRGridSizePolicy
, sizeof(unsigned char),
1048 XtOffset(XmLGridWidget
, grid
.colSizePolicy
),
1049 XmRImmediate
, (XtPointer
)0,
1052 XmNcolumnStep
, XmCColumnStep
,
1053 XmRInt
, sizeof(int),
1054 XtOffset(XmLGridWidget
, grid
.colStep
),
1055 XmRImmediate
, (XtPointer
)1,
1058 XmNcolumnType
, XmCColumnType
,
1059 XmRColumnType
, sizeof(unsigned char),
1060 XtOffset(XmLGridWidget
, grid
.colType
),
1061 XmRImmediate
, (XtPointer
)XmINVALID_TYPE
,
1063 /* xfe Column Resource additions */
1065 XmNcolumnHidden
, XmCColumnHidden
,
1066 XmRBoolean
, sizeof(Boolean
),
1067 XtOffset(XmLGridWidget
, grid
.colHidden
),
1068 XmRImmediate
, (XtPointer
)FALSE
,
1071 XmNcolumnSortType
, XmCColumnSortType
,
1072 XmRColumnSortType
, sizeof(unsigned char),
1073 XtOffset(XmLGridWidget
, grid
.colSortType
),
1074 XmRImmediate
, (XtPointer
)XmSORT_NONE
,
1076 /* Cell Resources */
1078 XmNcellAlignment
, XmCCellAlignment
,
1079 XmRCellAlignment
, sizeof(unsigned char),
1080 XtOffset(XmLGridWidget
, grid
.cellValues
.alignment
),
1081 XmRImmediate
, (XtPointer
)0,
1084 XmNcellBackground
, XmCCellBackground
,
1085 XmRPixel
, sizeof(Pixel
),
1086 XtOffset(XmLGridWidget
, grid
.cellValues
.background
),
1087 XmRImmediate
, (XtPointer
)0,
1090 XmNcellBottomBorderColor
, XmCCellBottomBorderColor
,
1091 XmRPixel
, sizeof(Pixel
),
1092 XtOffset(XmLGridWidget
, grid
.cellValues
.bottomBorderColor
),
1093 XmRImmediate
, (XtPointer
)0,
1096 XmNcellBottomBorderType
, XmCCellBottomBorderType
,
1097 XmRCellBorderType
, sizeof(unsigned char),
1098 XtOffset(XmLGridWidget
, grid
.cellValues
.bottomBorderType
),
1099 XmRImmediate
, (XtPointer
)0,
1102 XmNcellColumnSpan
, XmCCellColumnSpan
,
1103 XmRInt
, sizeof(int),
1104 XtOffset(XmLGridWidget
, grid
.cellValues
.columnSpan
),
1105 XmRImmediate
, (XtPointer
)0,
1108 XmNcellEditable
, XmCCellEditable
,
1109 XmRBoolean
, sizeof(Boolean
),
1110 XtOffset(XmLGridWidget
, grid
.cellValues
.editable
),
1111 XmRImmediate
, (XtPointer
)False
,
1114 XmNcellFontList
, XmCCellFontList
,
1115 XmRFontList
, sizeof(XmFontList
),
1116 XtOffset(XmLGridWidget
, grid
.cellValues
.fontList
),
1117 XmRImmediate
, (XtPointer
)0,
1120 XmNcellForeground
, XmCCellForeground
,
1121 XmRPixel
, sizeof(Pixel
),
1122 XtOffset(XmLGridWidget
, grid
.cellValues
.foreground
),
1123 XmRImmediate
, (XtPointer
)0,
1126 XmNcellLeftBorderColor
, XmCCellLeftBorderColor
,
1127 XmRPixel
, sizeof(Pixel
),
1128 XtOffset(XmLGridWidget
, grid
.cellValues
.leftBorderColor
),
1129 XmRImmediate
, (XtPointer
)0,
1132 XmNcellLeftBorderType
, XmCCellLeftBorderType
,
1133 XmRCellBorderType
, sizeof(unsigned char),
1134 XtOffset(XmLGridWidget
, grid
.cellValues
.leftBorderType
),
1135 XmRImmediate
, (XtPointer
)0,
1138 XmNcellMarginBottom
, XmCCellMarginBottom
,
1139 XmRDimension
, sizeof(Dimension
),
1140 XtOffset(XmLGridWidget
, grid
.cellValues
.bottomMargin
),
1141 XmRImmediate
, (XtPointer
)0,
1144 XmNcellMarginLeft
, XmCCellMarginLeft
,
1145 XmRDimension
, sizeof(Dimension
),
1146 XtOffset(XmLGridWidget
, grid
.cellValues
.leftMargin
),
1147 XmRImmediate
, (XtPointer
)0,
1150 XmNcellMarginRight
, XmCCellMarginRight
,
1151 XmRDimension
, sizeof(Dimension
),
1152 XtOffset(XmLGridWidget
, grid
.cellValues
.rightMargin
),
1153 XmRImmediate
, (XtPointer
)0,
1156 XmNcellMarginTop
, XmCCellMarginTop
,
1157 XmRDimension
, sizeof(Dimension
),
1158 XtOffset(XmLGridWidget
, grid
.cellValues
.topMargin
),
1159 XmRImmediate
, (XtPointer
)0,
1162 XmNcellPixmap
, XmCCellPixmap
,
1163 XmRManForegroundPixmap
, sizeof(Pixmap
),
1164 XtOffset(XmLGridWidget
, grid
.cellPixmap
),
1165 XmRImmediate
, (XtPointer
)XmUNSPECIFIED_PIXMAP
,
1168 XmNcellPixmapMask
, XmCCellPixmapMask
,
1169 XtRBitmap
, sizeof(Pixmap
),
1170 XtOffset(XmLGridWidget
, grid
.cellPixmapMask
),
1171 XmRImmediate
, (XtPointer
)XmUNSPECIFIED_PIXMAP
,
1174 XmNcellRightBorderColor
, XmCCellRightBorderColor
,
1175 XmRPixel
, sizeof(Pixel
),
1176 XtOffset(XmLGridWidget
, grid
.cellValues
.rightBorderColor
),
1177 XmRImmediate
, (XtPointer
)0,
1180 XmNcellRightBorderType
, XmCCellRightBorderType
,
1181 XmRCellBorderType
, sizeof(unsigned char),
1182 XtOffset(XmLGridWidget
, grid
.cellValues
.rightBorderType
),
1183 XmRImmediate
, (XtPointer
)0,
1186 XmNcellRowSpan
, XmCCellRowSpan
,
1187 XmRInt
, sizeof(int),
1188 XtOffset(XmLGridWidget
, grid
.cellValues
.rowSpan
),
1189 XmRImmediate
, (XtPointer
)0,
1192 XmNcellString
, XmCXmString
,
1193 XmRXmString
, sizeof(XmString
),
1194 XtOffset(XmLGridWidget
, grid
.cellString
),
1195 XmRImmediate
, (XtPointer
)0,
1198 XmNcellToggleSet
, XmCCellToggleSet
,
1199 XmRBoolean
, sizeof(Boolean
),
1200 XtOffset(XmLGridWidget
, grid
.cellToggleSet
),
1201 XmRImmediate
, (XtPointer
)False
,
1204 XmNcellTopBorderColor
, XmCCellTopBorderColor
,
1205 XmRPixel
, sizeof(Pixel
),
1206 XtOffset(XmLGridWidget
, grid
.cellValues
.topBorderColor
),
1207 XmRImmediate
, (XtPointer
)0,
1210 XmNcellTopBorderType
, XmCCellTopBorderType
,
1211 XmRCellBorderType
, sizeof(unsigned char),
1212 XtOffset(XmLGridWidget
, grid
.cellValues
.topBorderType
),
1213 XmRImmediate
, (XtPointer
)0,
1216 XmNcellType
, XmCCellType
,
1217 XmRCellType
, sizeof(unsigned char),
1218 XtOffset(XmLGridWidget
, grid
.cellValues
.type
),
1219 XmRImmediate
, (XtPointer
)XmSTRING_CELL
,
1222 XmNcellUserData
, XmCUserData
,
1223 XmRPointer
, sizeof(XtPointer
),
1224 XtOffset(XmLGridWidget
, grid
.cellValues
.userData
),
1225 XmRImmediate
, (XtPointer
)0,
1227 /* Overridden inherited resources */
1229 XmNshadowThickness
, XmCShadowThickness
,
1230 XmRHorizontalDimension
, sizeof(Dimension
),
1231 XtOffset(XmLGridWidget
, manager
.shadow_thickness
),
1232 XmRImmediate
, (XtPointer
)2,
1236 XmNhideUnhideButtons
, XmCHideUnhideButtons
,
1237 XmRBoolean
, sizeof(Boolean
),
1238 XtOffset(XmLGridWidget
, grid
.hideUnhideButtons
),
1239 XmRImmediate
, (XtPointer
)False
,
1242 XmNsingleClickActivation
, XmCSingleClickActivation
,
1243 XmRBoolean
, sizeof(Boolean
),
1244 XtOffset(XmLGridWidget
, grid
.singleClickActivation
),
1245 XmRImmediate
, (XtPointer
)False
,
1249 XmNhideButtonTranslations
, XmCTranslations
,
1250 XmRTranslationTable
, sizeof(XtTranslations
),
1251 XtOffset(XmLGridWidget
, grid
.hideButtonTrans
),
1252 XmRString
, (XtPointer
)hideButtonTranslations
,
1255 XmNunhideButtonTranslations
, XmCTranslations
,
1256 XmRTranslationTable
, sizeof(XtTranslations
),
1257 XtOffset(XmLGridWidget
, grid
.unhideButtonTrans
),
1258 XmRString
, (XtPointer
)unhideButtonTranslations
,
1262 XmNuseTextWidget
, XmCUseTextWidget
,
1263 XmRBoolean
, sizeof(Boolean
),
1264 XtOffset(XmLGridWidget
, grid
.useTextWidget
),
1265 XmRImmediate
, (XtPointer
)True
,
1268 XmNiconSpacing
, XmCIconSpacing
,
1269 XmRHorizontalDimension
, sizeof(Dimension
),
1270 XtOffset(XmLGridWidget
, grid
.iconSpacing
),
1271 XmRImmediate
, (XtPointer
) 4,
1275 XmLGridClassRec xmlGridClassRec
=
1278 (WidgetClass
)&xmManagerClassRec
, /* superclass */
1279 "XmLGrid", /* class_name */
1280 sizeof(XmLGridRec
), /* widget_size */
1281 ClassInitialize
, /* class_init */
1282 ClassPartInitialize
, /* class_part_init */
1283 FALSE
, /* class_inited */
1284 (XtInitProc
)Initialize
, /* initialize */
1285 0, /* initialize_hook */
1286 (XtRealizeProc
)Realize
, /* realize */
1287 (XtActionList
)actions
, /* actions */
1288 (Cardinal
)XtNumber(actions
), /* num_actions */
1289 (XtResource
*)resources
, /* resources */
1290 XtNumber(resources
), /* num_resources */
1291 NULLQUARK
, /* xrm_class */
1292 TRUE
, /* compress_motion */
1293 XtExposeCompressMaximal
, /* compress_exposure */
1294 TRUE
, /* compress_enterleav */
1295 TRUE
, /* visible_interest */
1296 (XtWidgetProc
)Destroy
, /* destroy */
1297 (XtWidgetProc
)Resize
, /* resize */
1298 (XtExposeProc
)Redisplay
, /* expose */
1299 (XtSetValuesFunc
)SetValues
, /* set_values */
1300 0, /* set_values_hook */
1301 XtInheritSetValuesAlmost
, /* set_values_almost */
1302 (XtArgsProc
)GetSubValues
, /* get_values_hook */
1303 0, /* accept_focus */
1304 XtVersion
, /* version */
1305 0, /* callback_private */
1306 translations
, /* tm_table */
1307 0, /* query_geometry */
1308 0, /* display_accelerato */
1311 { /* composite_class */
1312 (XtGeometryHandler
)GeometryManager
, /* geometry_manager */
1313 (XtWidgetProc
)ChangeManaged
, /* change_managed */
1314 XtInheritInsertChild
, /* insert_child */
1315 XtInheritDeleteChild
, /* delete_child */
1318 { /* constraint_class */
1319 0, /* subresources */
1320 0, /* subresource_count */
1321 sizeof(XmLGridConstraintRec
), /* constraint_size */
1327 { /* manager_class */
1328 XtInheritTranslations
, /* translations */
1329 0, /* syn resources */
1330 0, /* num syn_resources */
1331 0, /* get_cont_resources */
1332 0, /* num_get_cont_res */
1333 XmInheritParentProcess
, /* parent_process */
1337 0, /* initial rows */
1338 0, /* initial columns */
1339 XmInheritGridPreLayout
, /* pre layout */
1340 sizeof(struct _XmLGridRowRec
), /* row rec size */
1341 _GridRowNew
, /* row new */
1342 _GridRowFree
, /* row free */
1343 _GetRowValueMask
, /* get row value mask */
1344 _GetRowValue
, /* get row value */
1345 _SetRowValues
, /* set row values */
1346 sizeof(struct _XmLGridColumnRec
), /* column rec size */
1347 _GridColumnNew
, /* column new */
1348 _GridColumnFree
, /* column free */
1349 _GetColumnValueMask
, /* get col value mask */
1350 _GetColumnValue
, /* get column value */
1351 _SetColumnValues
, /* set column values */
1352 _SetCellValuesResize
, /* set cell vl resize */
1353 _GridCellAction
, /* cell action */
1357 WidgetClass xmlGridWidgetClass
= (WidgetClass
)&xmlGridClassRec
;
1364 ClassInitialize(void)
1370 XtSetTypeConverter(XmRString
, XmRGridSizePolicy
,
1371 CvtStringToSizePolicy
, 0, 0, XtCacheNone
, 0);
1372 XtSetTypeConverter(XmRString
, XmRColumnType
,
1373 CvtStringToRowColType
, 0, 0, XtCacheNone
, 0);
1374 XtSetTypeConverter(XmRString
, XmRRowType
,
1375 CvtStringToRowColType
, 0, 0, XtCacheNone
, 0);
1376 XtSetTypeConverter(XmRString
, XmRGridSelectionPolicy
,
1377 CvtStringToSelectionPolicy
, 0, 0, XtCacheNone
, 0);
1378 XtSetTypeConverter(XmRString
, XmRCellAlignment
,
1379 CvtStringToCellAlignment
, 0, 0, XtCacheNone
, 0);
1380 XtSetTypeConverter(XmRString
, XmRCellType
,
1381 CvtStringToCellType
, 0, 0, XtCacheNone
, 0);
1382 XtSetTypeConverter(XmRString
, XmRCellBorderType
,
1383 CvtStringToCellBorderType
, 0, 0, XtCacheNone
, 0);
1384 /* long must be > 2 bytes for cell mask to work */
1385 if (sizeof(long) < 3)
1386 fprintf(stderr
, "xmlGridClass: fatal error: long < 3 bytes\n");
1387 /* compiler sanity check - make sure array pos lines up */
1388 off1
= XtOffset(XmLArrayItem
*, pos
);
1389 off2
= XtOffset(XmLGridColumn
, grid
.pos
);
1391 fprintf(stderr
, "xmlGridClass: fatal error: column pos offset bad\n");
1392 off2
= XtOffset(XmLGridRow
, grid
.pos
);
1394 fprintf(stderr
, "xmlGridClass: fatal error: row pos offset bad\n");
1398 ClassPartInitialize(WidgetClass wc
)
1400 XmLGridWidgetClass c
, sc
;
1402 c
= (XmLGridWidgetClass
)wc
;
1403 sc
= (XmLGridWidgetClass
)c
->core_class
.superclass
;
1405 #define INHERIT_PROC(proc, inherit) \
1406 if (c->grid_class.proc == inherit) \
1407 c->grid_class.proc = sc->grid_class.proc;
1409 INHERIT_PROC(rowNewProc
, XmInheritGridRowNew
)
1410 INHERIT_PROC(rowFreeProc
, XmInheritGridRowFree
)
1411 INHERIT_PROC(getRowValueMaskProc
, XmInheritGridGetRowValueMask
)
1412 INHERIT_PROC(getRowValueProc
, XmInheritGridGetRowValue
)
1413 INHERIT_PROC(setRowValuesProc
, XmInheritGridSetRowValues
)
1415 INHERIT_PROC(columnNewProc
, XmInheritGridColumnNew
)
1416 INHERIT_PROC(columnFreeProc
, XmInheritGridColumnFree
)
1417 INHERIT_PROC(getColumnValueMaskProc
, XmInheritGridGetColumnValueMask
)
1418 INHERIT_PROC(getColumnValueProc
, XmInheritGridGetColumnValue
)
1419 INHERIT_PROC(setColumnValuesProc
, XmInheritGridSetColumnValues
)
1421 INHERIT_PROC(setCellValuesResizeProc
, XmInheritGridSetCellValuesResize
)
1422 INHERIT_PROC(cellActionProc
, XmInheritGridCellAction
)
1428 Initialize(Widget reqW
,
1433 XmLGridWidget g
, request
;
1435 Pixmap pix
, pixMask
;
1439 int i
, valid
, hc
, c
, fc
, hr
, r
, fr
;
1440 Boolean layoutFrozen
;
1441 #ifdef POINTER_FOCUS_CHECK
1446 g
= (XmLGridWidget
)newW
;
1447 dpy
= XtDisplay((Widget
)g
);
1448 request
= (XmLGridWidget
)reqW
;
1450 #ifdef POINTER_FOCUS_CHECK
1451 shell
= XmLShellOfWidget(newW
);
1452 if (shell
&& XmIsVendorShell(shell
))
1454 XtVaGetValues(shell
,
1455 XmNkeyboardFocusPolicy
, &kfp
,
1457 if (kfp
== XmPOINTER
)
1458 XmLWarning(newW
, "keyboardFocusPolicy of XmPOINTER not supported");
1462 black
= BlackPixelOfScreen(XtScreen((Widget
)g
));
1463 white
= WhitePixelOfScreen(XtScreen((Widget
)g
));
1465 g
->grid
.rowArray
= XmLArrayNew(1, 1);
1466 g
->grid
.colArray
= XmLArrayNew(1, 1);
1468 if (g
->core
.width
<= 0)
1469 g
->core
.width
= 100;
1470 if (g
->core
.height
<= 0)
1471 g
->core
.height
= 100;
1475 if (g
->grid
.useTextWidget
) {
1476 g
->grid
.text
= XtVaCreateManagedWidget("text", xmTextWidgetClass
, (Widget
)g
,
1479 XmNshadowThickness
, 0,
1480 XmNhighlightThickness
, 0,
1485 XmNbackground
, g
->core
.background_pixel
,
1486 XmNforeground
, g
->manager
.foreground
,
1488 XtOverrideTranslations(g
->grid
.text
, g
->grid
.traverseTrans
);
1489 XtAddEventHandler(g
->grid
.text
, StructureNotifyMask
,
1490 True
, (XtEventHandler
)TextMapped
, (XtPointer
)0);
1491 XtAddCallback(g
->grid
.text
, XmNactivateCallback
, TextActivate
, 0);
1492 XtAddCallback(g
->grid
.text
, XmNfocusCallback
, TextFocus
, 0);
1493 XtAddCallback(g
->grid
.text
, XmNlosingFocusCallback
, TextFocus
, 0);
1494 XtAddCallback(g
->grid
.text
, XmNmodifyVerifyCallback
, TextModifyVerify
, 0);
1497 g
->grid
.hsb
= XtVaCreateWidget(
1498 "hsb", xmScrollBarWidgetClass
, (Widget
)g
,
1500 XmNorientation
, XmHORIZONTAL
,
1501 XmNtraversalOn
, False
,
1502 XmNbackground
, g
->core
.background_pixel
,
1503 /* Don't force foreground on IRIX - it screws up the thumb color in sgiMode */
1505 XmNforeground
, g
->manager
.foreground
,
1507 XmNtopShadowColor
, g
->manager
.top_shadow_color
,
1508 XmNbottomShadowColor
, g
->manager
.bottom_shadow_color
,
1510 XtAddCallback(g
->grid
.hsb
, XmNdragCallback
, ScrollCB
, 0);
1511 XtAddCallback(g
->grid
.hsb
, XmNvalueChangedCallback
, ScrollCB
, 0);
1512 g
->grid
.vsb
= XtVaCreateWidget(
1513 "vsb", xmScrollBarWidgetClass
, (Widget
)g
,
1514 XmNorientation
, XmVERTICAL
,
1516 XmNtraversalOn
, False
,
1517 XmNbackground
, g
->core
.background_pixel
,
1518 /* Don't force foreground on IRIX - it screws up the thumb color in sgiMode */
1520 XmNforeground
, g
->manager
.foreground
,
1522 XmNtopShadowColor
, g
->manager
.top_shadow_color
,
1523 XmNbottomShadowColor
, g
->manager
.bottom_shadow_color
,
1525 XtAddCallback(g
->grid
.vsb
, XmNdragCallback
, ScrollCB
, 0);
1526 XtAddCallback(g
->grid
.vsb
, XmNvalueChangedCallback
, ScrollCB
, 0);
1528 if (g
->grid
.hideUnhideButtons
)
1530 CreateHideUnhideButtons(g
);
1534 g
->grid
.hideButton
= 0;
1535 g
->grid
.unhideButton
= 0;
1538 g
->grid
.inResize
= False
;
1545 fg
.flags
= DoRed
| DoGreen
| DoBlue
;
1550 bg
.flags
= DoRed
| DoGreen
| DoBlue
;
1551 pix
= XCreatePixmapFromBitmapData(dpy
, DefaultRootWindow(dpy
),
1552 (char *)horizp_bits
, horizp_width
, horizp_height
, 0, 1, 1);
1553 pixMask
= XCreatePixmapFromBitmapData(dpy
, DefaultRootWindow(dpy
),
1554 (char *)horizm_bits
, horizm_width
, horizm_height
, 1, 0, 1);
1555 g
->grid
.hResizeCursor
= XCreatePixmapCursor(dpy
, pix
, pixMask
,
1557 XFreePixmap(dpy
, pix
);
1558 XFreePixmap(dpy
, pixMask
);
1559 pix
= XCreatePixmapFromBitmapData(dpy
, DefaultRootWindow(dpy
),
1560 (char *)vertp_bits
, vertp_width
, vertp_height
, 0, 1, 1);
1561 pixMask
= XCreatePixmapFromBitmapData(dpy
, DefaultRootWindow(dpy
),
1562 (char *)vertm_bits
, vertm_width
, vertm_height
, 1, 0, 1);
1563 g
->grid
.vResizeCursor
= XCreatePixmapCursor(dpy
, pix
, pixMask
,
1565 XFreePixmap(dpy
, pix
);
1566 XFreePixmap(dpy
, pixMask
);
1568 g
->grid
.cursorDefined
= CursorNormal
;
1569 g
->grid
.focusIn
= 0;
1570 g
->grid
.focusRow
= -1;
1571 g
->grid
.focusCol
= -1;
1572 g
->grid
.mayHaveRowSpans
= 0;
1573 g
->grid
.scrollCol
= 0;
1574 g
->grid
.scrollRow
= 0;
1575 g
->grid
.textHidden
= 1;
1576 g
->grid
.inMode
= InNormal
;
1578 g
->grid
.singleColScrollMode
= 0;
1579 g
->grid
.layoutStack
= 0;
1580 g
->grid
.needsHorizLayout
= 0;
1581 g
->grid
.needsVertLayout
= 0;
1582 g
->grid
.recalcHorizVisPos
= 0;
1583 g
->grid
.recalcVertVisPos
= 0;
1584 g
->grid
.vertVisChangedHint
= 0;
1585 g
->grid
.defCellValues
= CellRefValuesCreate(g
, 0);
1586 g
->grid
.defCellValues
->refCount
= 1;
1587 g
->grid
.ignoreModifyVerify
= 0;
1588 g
->grid
.extendRow
= -1;
1589 g
->grid
.extendCol
= -1;
1590 g
->grid
.extendToRow
= -1;
1591 g
->grid
.extendToCol
= -1;
1592 g
->grid
.extendSelect
= True
;
1593 g
->grid
.lastSelectRow
= -1;
1594 g
->grid
.lastSelectCol
= -1;
1595 g
->grid
.lastSelectTime
= 0;
1596 g
->grid
.dragTimerSet
= 0;
1597 g
->grid
.editTimerSet
= 0;
1603 * XmNenterCellCallback
1604 * XmNenterCellCallback
1608 g
->grid
.lastCursorMotionRow
= -1;
1609 g
->grid
.lastCursorMotionCol
= -1;
1611 XtAddEventHandler(newW
,
1612 EnterWindowMask
| LeaveWindowMask
,
1614 (XtEventHandler
) GridCrossingEH
,
1618 for (i
= 0; i
< 9; i
++)
1630 layoutFrozen
= g
->grid
.layoutFrozen
;
1631 g
->grid
.layoutFrozen
= True
;
1633 if (g
->grid
.hiddenColCount
|| g
->grid
.hiddenRowCount
)
1635 XmLWarning(newW
, "Initialize() - can't set hidden rows or columns");
1636 g
->grid
.hiddenColCount
= 0;
1637 g
->grid
.hiddenRowCount
= 0;
1639 hc
= g
->grid
.headingColCount
;
1640 c
= XmLGridClassPartOfWidget(g
).initialCols
;
1641 if (c
< g
->grid
.colCount
)
1642 c
= g
->grid
.colCount
;
1643 fc
= g
->grid
.footerColCount
;
1644 hr
= g
->grid
.headingRowCount
;
1645 r
= XmLGridClassPartOfWidget(g
).initialRows
;
1646 if (r
< g
->grid
.rowCount
)
1647 r
= g
->grid
.rowCount
;
1648 fr
= g
->grid
.footerRowCount
;
1649 g
->grid
.headingColCount
= 0;
1650 g
->grid
.colCount
= 0;
1651 g
->grid
.footerColCount
= 0;
1652 g
->grid
.headingRowCount
= 0;
1653 g
->grid
.rowCount
= 0;
1654 g
->grid
.footerRowCount
= 0;
1655 XmLGridAddColumns(newW
, XmHEADING
, -1, hc
);
1656 XmLGridAddColumns(newW
, XmCONTENT
, -1, c
);
1657 XmLGridAddColumns(newW
, XmFOOTER
, -1, fc
);
1658 XmLGridAddRows(newW
, XmHEADING
, -1, hr
);
1659 XmLGridAddRows(newW
, XmCONTENT
, -1, r
);
1660 XmLGridAddRows(newW
, XmFOOTER
, -1, fr
);
1661 if (g
->grid
.simpleHeadings
)
1663 g
->grid
.simpleHeadings
= (char *)strdup(g
->grid
.simpleHeadings
);
1664 SetSimpleHeadings(g
, g
->grid
.simpleHeadings
);
1666 if (g
->grid
.simpleWidths
)
1668 g
->grid
.simpleWidths
= (char *)strdup(g
->grid
.simpleWidths
);
1669 SetSimpleWidths(g
, g
->grid
.simpleWidths
);
1671 if (g
->grid
.visibleRows
)
1672 ApplyVisibleRows(g
);
1673 if (g
->grid
.visibleCols
&& g
->grid
.hsPolicy
== XmCONSTANT
)
1674 ApplyVisibleCols(g
);
1676 g
->grid
.layoutFrozen
= layoutFrozen
;
1682 for (i
= 0; i
< *narg
; i
++)
1686 if (!strcmp(args
[i
].name
, XmNrows
) ||
1687 !strcmp(args
[i
].name
, XmNcolumns
))
1689 if (!strncmp(args
[i
].name
, "row", 3) ||
1690 !strncmp(args
[i
].name
, "column", 6) ||
1691 !strncmp(args
[i
].name
, "cell", 4))
1696 "Initialize() - can't set row,column or cell values in init");
1698 DropRegister(g
, g
->grid
.allowDrop
);
1708 g
= (XmLGridWidget
)w
;
1710 if (g
->grid
.dragTimerSet
)
1711 XtRemoveTimeOut(g
->grid
.dragTimerId
);
1712 if (g
->grid
.editTimerSet
)
1713 XtRemoveTimeOut(g
->grid
.editTimerId
);
1714 DefineCursor(g
, CursorNormal
);
1715 XFreeCursor(dpy
, g
->grid
.hResizeCursor
);
1716 XFreeCursor(dpy
, g
->grid
.vResizeCursor
);
1719 XFreeGC(dpy
, g
->grid
.gc
);
1720 XFreeFont(dpy
, g
->grid
.fallbackFont
);
1722 XmFontListFree(g
->grid
.fontList
);
1723 XmLGridCellDerefValues(g
->grid
.defCellValues
);
1724 ExtendSelect(g
, (XEvent
*)0, False
, -1, -1);
1725 count
= XmLArrayGetCount(g
->grid
.rowArray
);
1726 for (i
= 0; i
< count
; i
++)
1727 XmLGridRowFree(w
, (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, i
));
1728 XmLArrayFree(g
->grid
.rowArray
);
1729 count
= XmLArrayGetCount(g
->grid
.colArray
);
1730 for (i
= 0; i
< count
; i
++)
1731 XmLGridColumnFree(w
, (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, i
));
1732 XmLArrayFree(g
->grid
.colArray
);
1733 if (g
->grid
.simpleHeadings
)
1734 free((char *)g
->grid
.simpleHeadings
);
1735 if (g
->grid
.simpleWidths
)
1736 free((char *)g
->grid
.simpleWidths
);
1740 Geometry, Drawing, Entry and Picking
1745 XtValueMask
*valueMask
,
1746 XSetWindowAttributes
*attr
)
1750 WidgetClass superClass
;
1751 XtRealizeProc realize
;
1754 static char dashes
[2] = { 1, 1 };
1756 g
= (XmLGridWidget
)w
;
1758 superClass
= xmlGridWidgetClass
->core_class
.superclass
;
1759 realize
= superClass
->core_class
.realize
;
1760 (*realize
)(w
, valueMask
, attr
);
1764 g
->grid
.fallbackFont
= XLoadQueryFont(dpy
, "fixed");
1765 values
.foreground
= g
->manager
.foreground
;
1766 values
.font
= g
->grid
.fallbackFont
->fid
;
1767 mask
= GCForeground
| GCFont
;
1768 g
->grid
.gc
= XCreateGC(dpy
, XtWindow(g
), mask
, &values
);
1769 XSetDashes(dpy
, g
->grid
.gc
, 0, dashes
, 2);
1770 if (g
->grid
.selectionPolicy
== XmSELECT_BROWSE_ROW
&&
1771 g
->grid
.autoSelect
== True
&&
1773 XmLGridSelectRow(w
, 0, False
);
1779 XExposeEvent
*event
,
1788 XmLGridCellRefValues
*cellValues
;
1789 XmLGridDrawStruct ds
;
1790 XmLGridCallbackStruct cbs
;
1792 XRectangle eRect
, rRect
, clipRect
, rect
[6];
1793 int i
, n
, st
, c
, r
, sc
, sr
, width
, height
, rowHeight
;
1794 int lastVisPos
, visPos
, hasDrawCB
;
1795 Boolean spanUp
, spanLeft
;
1797 g
= (XmLGridWidget
)w
;
1798 if (!XtIsRealized((Widget
)g
))
1800 if (!g
->core
.visible
)
1802 if (g
->grid
.layoutFrozen
== True
)
1803 XmLWarning(w
, "Redisplay() - layout frozen is True during redraw");
1806 st
= g
->manager
.shadow_thickness
;
1812 eRect
.width
= event
->width
;
1813 eRect
.height
= event
->height
;
1814 if (g
->grid
.debugLevel
> 1)
1815 fprintf(stderr
, "XmLGrid: Redisplay x %d y %d w %d h %d\n",
1816 event
->x
, event
->y
, event
->width
, event
->height
);
1822 eRect
.width
= g
->core
.width
;
1823 eRect
.height
= g
->core
.height
;
1825 if (!eRect
.width
|| !eRect
.height
)
1827 /* Hide any XORed graphics */
1828 DrawResizeLine(g
, 0, 1);
1830 if (XtHasCallbacks(w
, XmNcellDrawCallback
) == XtCallbackHasSome
)
1833 /* Add extra shadow around the whole widget
1834 * if 512 is set for shadow regions
1836 if (g
->grid
.shadowRegions
== 512
1837 && g
->manager
.shadow_thickness
1838 && XmLRectIntersect(&eRect
, &rRect
) != XmLRectInside
)
1841 _XmDrawShadow(dpy
, win
,
1842 g
->manager
.bottom_shadow_GC
,
1843 g
->manager
.top_shadow_GC
,
1844 g
->manager
.shadow_thickness
,
1846 g
->core
.width
, g
->core
.height
);
1848 _XmDrawShadows(dpy
, win
,
1849 g
->manager
.top_shadow_GC
,
1850 g
->manager
.bottom_shadow_GC
,
1852 g
->core
.width
, g
->core
.height
,
1853 g
->manager
.shadow_thickness
,
1854 g
->grid
.shadowType
);
1857 /* end of extra shadow */
1858 for (i
= 0; i
< 9; i
++)
1860 if (!reg
[i
].width
|| !reg
[i
].height
)
1864 rRect
.width
= reg
[i
].width
;
1865 rRect
.height
= reg
[i
].height
;
1866 if (XmLRectIntersect(&eRect
, &rRect
) == XmLRectOutside
)
1868 if (g
->grid
.debugLevel
> 2)
1869 fprintf(stderr
, "XmLGrid: Redisplay region %d shadows\n", i
);
1871 rRect
.width
-= st
* 2;
1873 rRect
.height
-= st
* 2;
1874 if (XmLRectIntersect(&eRect
, &rRect
) != XmLRectInside
1875 && g
->manager
.shadow_thickness
1876 && g
->grid
.shadowRegions
!= 512)
1878 if (g
->grid
.shadowRegions
& (1 << i
))
1880 _XmDrawShadow(dpy
, win
,
1881 g
->manager
.bottom_shadow_GC
,
1882 g
->manager
.top_shadow_GC
,
1883 g
->manager
.shadow_thickness
,
1885 reg
[i
].width
, reg
[i
].height
);
1887 _XmDrawShadows(dpy
, win
,
1888 g
->manager
.top_shadow_GC
,
1889 g
->manager
.bottom_shadow_GC
,
1891 reg
[i
].width
, reg
[i
].height
,
1892 g
->manager
.shadow_thickness
,
1893 g
->grid
.shadowType
);
1897 _XmEraseShadow(dpy
, win
,
1898 g
->manager
.shadow_thickness
,
1900 reg
[i
].width
, reg
[i
].height
);
1902 _XmClearBorder(dpy
, win
,
1904 reg
[i
].width
, reg
[i
].height
,
1905 g
->manager
.shadow_thickness
);
1910 if (g
->grid
.debugLevel
> 2)
1911 fprintf(stderr
, "XmLGrid: Redisplay region %d content\n", i
);
1912 for (r
= reg
[i
].row
; r
< reg
[i
].row
+ reg
[i
].nrow
; r
++)
1914 rowHeight
= GetRowHeight(g
, r
);
1915 if (!rowHeight
&& !g
->grid
.mayHaveRowSpans
)
1918 for (c
= reg
[i
].col
; c
< reg
[i
].col
+ reg
[i
].ncol
; c
++)
1920 rRect
.x
= reg
[i
].x
+ st
+ width
;
1921 rRect
.y
= reg
[i
].y
+ st
+ height
;
1922 if (g
->grid
.singleColScrollMode
)
1923 rRect
.x
-= g
->grid
.singleColScrollPos
;
1924 rRect
.width
= GetColWidth(g
, c
);
1926 if (i
== 1 && r
== reg
[1].row
&& c
== reg
[1].col
- 1)
1931 rRect
.height
= rowHeight
;
1932 width
+= rRect
.width
;
1933 cell
= GetCell(g
, r
, c
);
1936 cellValues
= XmLGridCellGetRefValues(cell
);
1940 if (XmLGridCellInRowSpan(cell
))
1942 if (r
== reg
[i
].row
)
1945 if (c
== reg
[i
].col
)
1951 if (XmLGridCellInColumnSpan(cell
))
1953 if (c
== reg
[i
].col
)
1960 if (spanUp
== True
|| spanLeft
== True
||
1961 cellValues
->rowSpan
|| cellValues
->columnSpan
)
1963 if (RowColFirstSpan(g
, r
, c
, &sr
, &sc
, &rRect
,
1964 spanLeft
, spanUp
) == -1)
1966 RowColSpanRect(g
, sr
, sc
, &rRect
);
1968 if (!rRect
.width
|| !rRect
.height
)
1971 ClipRectToReg(g
, &clipRect
, ®
[i
]);
1972 if (!clipRect
.width
|| !clipRect
.height
)
1974 if (event
&& XRectInRegion(region
, clipRect
.x
, clipRect
.y
,
1975 clipRect
.width
, clipRect
.height
) == RectangleOut
)
1977 cell
= GetCell(g
, sr
, sc
);
1980 cellValues
= XmLGridCellGetRefValues(cell
);
1981 cbs
.reason
= XmCR_CELL_DRAW
;
1982 cbs
.event
= (XEvent
*)event
;
1983 cbs
.rowType
= RowPosToType(g
, sr
);
1984 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, sr
);
1985 cbs
.columnType
= ColPosToType(g
, sc
);
1986 cbs
.column
= ColPosToTypePos(g
, cbs
.columnType
, sc
);
1987 cbs
.clipRect
= &clipRect
;
1990 ds
.cellRect
= &rRect
;
1991 ds
.topMargin
= cellValues
->topMargin
;
1992 ds
.bottomMargin
= cellValues
->bottomMargin
;
1993 ds
.leftMargin
= cellValues
->leftMargin
;
1994 ds
.rightMargin
= cellValues
->rightMargin
;
1995 ds
.background
= cellValues
->background
;
1996 ds
.foreground
= cellValues
->foreground
;
1997 ds
.fontList
= cellValues
->fontList
;
1998 ds
.alignment
= cellValues
->alignment
;
1999 ds
.selectBackground
= g
->grid
.selectBg
;
2000 ds
.selectForeground
= g
->grid
.selectFg
;
2001 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, sr
);
2002 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, sc
);
2003 ds
.drawFocusType
= XmDRAW_FOCUS_NONE
;
2004 if (g
->grid
.focusRow
== sr
&&
2005 g
->grid
.highlightRowMode
== True
&&
2009 visPos
= XmLGridColumnGetVisPos(col
);
2010 lastVisPos
= XmLArrayGetCount(g
->grid
.colArray
) -
2011 g
->grid
.hiddenColCount
- 1;
2012 if (visPos
== 0 && visPos
== lastVisPos
)
2013 ds
.drawFocusType
= XmDRAW_FOCUS_CELL
;
2014 else if (visPos
== 0)
2015 ds
.drawFocusType
= XmDRAW_FOCUS_LEFT
;
2016 else if (visPos
== lastVisPos
)
2017 ds
.drawFocusType
= XmDRAW_FOCUS_RIGHT
;
2019 ds
.drawFocusType
= XmDRAW_FOCUS_MID
;
2021 if (g
->grid
.focusRow
== sr
&&
2022 g
->grid
.focusCol
== sc
&&
2023 g
->grid
.highlightRowMode
== False
&&
2025 ds
.drawFocusType
= XmDRAW_FOCUS_CELL
;
2026 if (XmLGridRowIsSelected(row
) == True
||
2027 XmLGridColumnIsSelected(col
) == True
||
2028 XmLGridCellIsSelected(cell
) == True
)
2029 ds
.drawSelected
= True
;
2031 ds
.drawSelected
= False
;
2032 if (g
->grid
.selectionPolicy
== XmSELECT_CELL
&&
2033 g
->grid
.focusIn
&& g
->grid
.focusRow
== sr
&&
2034 g
->grid
.focusCol
== sc
)
2035 ds
.drawSelected
= False
;
2036 ds
.stringDirection
= g
->manager
.string_direction
;
2037 XmLGridCellAction(cell
, (Widget
)g
, &cbs
);
2039 XtCallCallbackList(w
, g
->grid
.cellDrawCallback
,
2042 height
+= rowHeight
;
2045 if (g
->grid
.debugLevel
> 1)
2046 fprintf(stderr
, "XmLGrid: Redisplay non-cell areas\n");
2048 if (reg
[0].width
&& g
->grid
.leftFixedMargin
)
2050 rect
[n
].x
= reg
[0].width
;
2052 rect
[n
].width
= g
->grid
.leftFixedMargin
;
2053 rect
[n
].height
= g
->core
.height
;
2056 if (reg
[2].width
&& g
->grid
.rightFixedMargin
)
2060 width
+= reg
[0].width
+ g
->grid
.leftFixedMargin
;
2062 width
+= reg
[1].width
;
2065 rect
[n
].width
= g
->grid
.rightFixedMargin
;
2066 rect
[n
].height
= g
->core
.height
;
2069 if (reg
[0].height
&& g
->grid
.topFixedMargin
)
2072 rect
[n
].y
= reg
[0].height
;
2073 rect
[n
].width
= g
->core
.width
;
2074 rect
[n
].height
= g
->grid
.topFixedMargin
;
2077 if (reg
[6].height
&& g
->grid
.bottomFixedMargin
)
2082 height
+= reg
[0].height
+ g
->grid
.topFixedMargin
;
2084 height
+= reg
[3].height
;
2086 rect
[n
].width
= g
->core
.width
;
2087 rect
[n
].height
= g
->grid
.bottomFixedMargin
;
2090 width
= reg
[1].width
;
2092 width
+= reg
[0].width
+ g
->grid
.leftFixedMargin
;
2094 width
+= g
->grid
.rightFixedMargin
+ reg
[2].width
;
2095 if (width
< (int)g
->core
.width
)
2099 rect
[n
].width
= g
->core
.width
- width
;
2100 rect
[n
].height
= g
->core
.height
;
2103 height
= reg
[3].height
;
2105 height
+= reg
[0].height
+ g
->grid
.topFixedMargin
;
2107 height
+= g
->grid
.bottomFixedMargin
+ reg
[6].height
;
2108 if (height
< (int)g
->core
.height
)
2112 rect
[n
].width
= g
->core
.width
;
2113 rect
[n
].height
= g
->core
.height
- height
;
2116 for (i
= 0; i
< n
; i
++)
2118 if (XmLRectIntersect(&eRect
, &rect
[i
]) == XmLRectOutside
)
2120 XClearArea(dpy
, win
, rect
[i
].x
, rect
[i
].y
, rect
[i
].width
,
2121 rect
[i
].height
, False
);
2127 for (c
= reg
[1].col
; c
< reg
[1].col
+ reg
[1].ncol
; c
++)
2128 width
+= GetColWidth(g
, c
);
2129 for (i
= 1; i
< 9; i
+= 3)
2130 if (reg
[i
].height
&& width
< reg
[i
].width
- st
* 2)
2132 rect
[n
].x
= reg
[i
].x
+ st
+ width
;
2133 rect
[n
].y
= reg
[i
].y
+ st
;
2134 rect
[n
].width
= reg
[i
].x
+ reg
[i
].width
-
2136 rect
[n
].height
= reg
[i
].height
- st
* 2;
2143 for (r
= reg
[3].row
; r
< reg
[3].row
+ reg
[3].nrow
; r
++)
2144 height
+= GetRowHeight(g
, r
);
2145 for (i
= 3; i
< 6; i
++)
2146 if (reg
[i
].width
&& height
< reg
[i
].height
- st
* 2)
2148 rect
[n
].x
= reg
[i
].x
+ st
;
2149 rect
[n
].y
= reg
[i
].y
+ st
+ height
;
2150 rect
[n
].width
= reg
[i
].width
- st
* 2;
2151 rect
[n
].height
= reg
[i
].y
+ reg
[i
].height
-
2156 XSetForeground(dpy
, g
->grid
.gc
, g
->grid
.blankBg
);
2157 for (i
= 0; i
< n
; i
++)
2159 if (XmLRectIntersect(&eRect
, &rect
[i
]) == XmLRectOutside
)
2161 XFillRectangle(dpy
, win
, g
->grid
.gc
, rect
[i
].x
, rect
[i
].y
,
2162 rect
[i
].width
, rect
[i
].height
);
2164 /* Show any XORed graphics */
2165 DrawResizeLine(g
, 0, 1);
2169 DrawResizeLine(XmLGridWidget g
,
2173 if (g
->grid
.inMode
!= InResize
)
2175 if (g
->grid
.hsPolicy
== XmRESIZE_IF_POSSIBLE
&& !g
->grid
.resizeIsVert
)
2177 DrawXORRect(g
, xy
, 2, g
->grid
.resizeIsVert
, erase
);
2181 DrawXORRect(XmLGridWidget g
,
2191 int oldXY
, maxX
, maxY
;
2193 if (!XtIsRealized((Widget
)g
))
2195 /* erase is (0 == none) (1 == hide/show) (2 == permenent erase) */
2199 XSetFunction(dpy
, gc
, GXinvert
);
2200 black
= BlackPixelOfScreen(XtScreen((Widget
)g
));
2201 white
= WhitePixelOfScreen(XtScreen((Widget
)g
));
2202 XSetForeground(dpy
, gc
, black
^ white
);
2203 maxX
= g
->core
.width
;
2204 if (XtIsManaged(g
->grid
.vsb
))
2205 maxX
-= g
->grid
.vsb
->core
.width
+ g
->grid
.scrollBarMargin
;
2206 maxY
= g
->core
.height
;
2207 if (XtIsManaged(g
->grid
.hsb
))
2208 maxY
-= g
->grid
.hsb
->core
.height
+ g
->grid
.scrollBarMargin
;
2209 oldXY
= g
->grid
.resizeLineXY
;
2213 XFillRectangle(dpy
, win
, gc
, 0, oldXY
, maxX
, size
);
2218 XFillRectangle(dpy
, win
, gc
, oldXY
, 0, size
, maxY
);
2228 XFillRectangle(dpy
, win
, gc
, 0, xy
, maxX
, size
);
2236 XFillRectangle(dpy
, win
, gc
, xy
, 0, size
, maxY
);
2238 g
->grid
.resizeLineXY
= xy
;
2240 else if (erase
== 2)
2241 g
->grid
.resizeLineXY
= -1;
2242 XSetFunction(dpy
, gc
, GXcopy
);
2246 DefineCursor(XmLGridWidget g
,
2252 if (!XtIsRealized((Widget
)g
))
2256 if (defineCursor
!= g
->grid
.cursorDefined
)
2257 XUndefineCursor(dpy
, win
);
2258 if (defineCursor
== CursorVResize
)
2259 XDefineCursor(dpy
, win
, g
->grid
.vResizeCursor
);
2260 else if (defineCursor
== CursorHResize
)
2261 XDefineCursor(dpy
, win
, g
->grid
.hResizeCursor
);
2262 g
->grid
.cursorDefined
= defineCursor
;
2266 DrawArea(XmLGridWidget g
,
2278 Dimension width
, height
, st
;
2280 if (g
->grid
.layoutFrozen
== True
)
2282 if (!XtIsRealized((Widget
)g
))
2284 if (!g
->core
.visible
)
2289 st
= g
->manager
.shadow_thickness
;
2290 if (g
->grid
.debugLevel
> 1)
2291 fprintf(stderr
, "XmLGrid: DrawArea %d %d %d\n", type
, row
, col
);
2300 rect
[n
].width
= g
->core
.width
;
2301 rect
[n
].height
= g
->core
.height
;
2307 for (i
= 1; i
< 9; i
+= 3)
2309 if (!reg
[i
].width
|| !reg
[i
].height
)
2311 rect
[n
].x
= reg
[i
].x
+ st
;
2312 rect
[n
].y
= reg
[i
].y
+ st
;
2313 rect
[n
].width
= reg
[i
].width
- st
* 2;
2314 rect
[n
].height
= reg
[i
].height
- st
* 2;
2321 for (i
= 3; i
< 6; i
++)
2324 if (!reg
[i
].width
|| !reg
[i
].height
)
2326 rect
[n
].x
= reg
[i
].x
+ st
;
2327 rect
[n
].y
= reg
[i
].y
+ st
;
2328 rect
[n
].width
= reg
[i
].width
- st
* 2;
2329 rect
[n
].height
= reg
[i
].height
- st
* 2;
2336 for (i
= 0; i
< 9; i
++)
2338 if (!reg
[i
].width
|| !reg
[i
].height
)
2340 if (!(row
>= reg
[i
].row
&&
2341 row
< reg
[i
].row
+ reg
[i
].nrow
))
2344 for (j
= reg
[i
].row
; j
< row
; j
++)
2345 height
+= GetRowHeight(g
, j
);
2346 rect
[n
].x
= reg
[i
].x
+ st
;
2347 rect
[n
].y
= reg
[i
].y
+ st
+ height
;
2348 rect
[n
].width
= reg
[i
].width
- st
* 2;
2349 rect
[n
].height
= GetRowHeight(g
, row
);
2350 ClipRectToReg(g
, &rect
[n
], ®
[i
]);
2357 for (i
= 0; i
< 9; i
++)
2359 if (!reg
[i
].width
|| !reg
[i
].height
)
2361 if (!(col
>= reg
[i
].col
&&
2362 col
< reg
[i
].col
+ reg
[i
].ncol
))
2365 for (j
= reg
[i
].col
; j
< col
; j
++)
2366 width
+= GetColWidth(g
, j
);
2367 rect
[n
].x
= reg
[i
].x
+ st
+ width
;
2368 rect
[n
].y
= reg
[i
].y
+ st
;
2369 rect
[n
].width
= GetColWidth(g
, col
);
2370 rect
[n
].height
= reg
[i
].height
- st
* 2;
2371 ClipRectToReg(g
, &rect
[n
], ®
[i
]);
2378 if (!RowColToXY(g
, row
, col
, True
, &rect
[n
]))
2383 for (i
= 0; i
< n
; i
++)
2385 if (!rect
[i
].width
|| !rect
[i
].height
)
2387 event
.type
= Expose
;
2389 event
.display
= dpy
;
2390 event
.x
= rect
[i
].x
;
2391 event
.y
= rect
[i
].y
;
2392 event
.width
= rect
[i
].width
;
2393 event
.height
= rect
[i
].height
;
2394 event
.send_event
= True
;
2396 if (g
->grid
.immediateDraw
)
2398 region
= XCreateRegion();
2399 XUnionRectWithRegion(&rect
[i
], region
, region
);
2400 Redisplay((Widget
)g
, &event
, region
);
2401 XDestroyRegion(region
);
2404 XSendEvent(dpy
, win
, False
, ExposureMask
, (XEvent
*)&event
);
2405 if (g
->grid
.debugLevel
> 1)
2406 fprintf(stderr
, "XmLGrid: DrawArea expose x %d y %d w %d h %d\n",
2407 event
.x
, event
.y
, event
.width
, event
.height
);
2412 ExtendSelectRange(XmLGridWidget g
,
2421 if ((g
->grid
.selectionPolicy
== XmSELECT_MULTIPLE_ROW
) ||
2422 (ColPosToType(g
, g
->grid
.extendCol
) != XmCONTENT
))
2424 else if (RowPosToType(g
, g
->grid
.extendRow
) != XmCONTENT
)
2429 r
= g
->grid
.extendToRow
;
2430 if (r
< g
->grid
.headingRowCount
)
2431 r
= g
->grid
.headingRowCount
;
2432 if (r
>= g
->grid
.headingRowCount
+ g
->grid
.rowCount
)
2433 r
= g
->grid
.headingRowCount
+ g
->grid
.rowCount
- 1;
2434 if (*type
== SelectCol
)
2439 else if (g
->grid
.extendRow
< r
)
2441 *fr
= g
->grid
.extendRow
;
2447 *lr
= g
->grid
.extendRow
;
2449 c
= g
->grid
.extendToCol
;
2450 if (c
< g
->grid
.headingColCount
)
2451 c
= g
->grid
.headingColCount
;
2452 if (c
>= g
->grid
.headingColCount
+ g
->grid
.colCount
)
2453 c
= g
->grid
.headingColCount
+ g
->grid
.colCount
- 1;
2454 if (*type
== SelectRow
)
2459 else if (g
->grid
.extendCol
< c
)
2461 *fc
= g
->grid
.extendCol
;
2467 *lc
= g
->grid
.extendCol
;
2472 ExtendSelect(XmLGridWidget g
,
2482 if (row
== -1 || col
== -1)
2484 g
->grid
.extendRow
= -1;
2485 g
->grid
.extendCol
= -1;
2486 g
->grid
.extendToRow
= -1;
2487 g
->grid
.extendToCol
= -1;
2488 g
->grid
.extendSelect
= True
;
2491 if (RowPosToType(g
, row
) == XmFOOTER
|| ColPosToType(g
, col
) == XmFOOTER
)
2493 if ((g
->grid
.extendToRow
== row
&& g
->grid
.extendToCol
== col
) ||
2494 (g
->grid
.extendRow
== -1 && row
== g
->grid
.focusRow
&&
2495 g
->grid
.extendCol
== -1 && col
== g
->grid
.focusCol
))
2497 if (g
->grid
.extendRow
!= -1 && g
->grid
.extendCol
!= -1)
2499 /* clear previous extend */
2500 ExtendSelectRange(g
, &type
, &fr
, &lr
, &fc
, &lc
);
2501 for (r
= fr
; r
<= lr
; r
+= 1)
2502 for (c
= fc
; c
<= lc
; c
+= 1)
2503 SelectTypeArea(g
, type
, event
,
2504 RowPosToTypePos(g
, XmCONTENT
, r
),
2505 ColPosToTypePos(g
, XmCONTENT
, c
), False
, True
);
2509 g
->grid
.extendRow
= g
->grid
.focusRow
;
2510 g
->grid
.extendCol
= g
->grid
.focusCol
;
2514 g
->grid
.extendRow
= row
;
2515 g
->grid
.extendCol
= col
;
2517 if (g
->grid
.extendRow
< 0 || g
->grid
.extendCol
< 0)
2519 g
->grid
.extendToRow
= row
;
2520 g
->grid
.extendToCol
= col
;
2522 /* set new extend */
2523 ExtendSelectRange(g
, &type
, &fr
, &lr
, &fc
, &lc
);
2524 for (r
= fr
; r
<= lr
; r
+= 1)
2525 for (c
= fc
; c
<= lc
; c
+= 1)
2526 SelectTypeArea(g
, type
, event
,
2527 RowPosToTypePos(g
, XmCONTENT
, r
),
2528 ColPosToTypePos(g
, XmCONTENT
, c
),
2529 g
->grid
.extendSelect
, True
);
2533 SelectTypeArea(XmLGridWidget g
,
2548 XmLGridCallbackStruct cbs
;
2551 hrc
= g
->grid
.headingRowCount
;
2552 hcc
= g
->grid
.headingColCount
;
2554 cbs
.rowType
= XmCONTENT
;
2555 cbs
.columnType
= XmCONTENT
;
2559 if (type
== SelectRow
)
2560 cbs
.reason
= XmCR_SELECT_ROW
;
2561 else if (type
== SelectCol
)
2562 cbs
.reason
= XmCR_SELECT_COLUMN
;
2563 else if (type
== SelectCell
)
2564 cbs
.reason
= XmCR_SELECT_CELL
;
2565 if (XtHasCallbacks(w
, XmNselectCallback
) == XtCallbackHasSome
)
2570 if (type
== SelectRow
)
2571 cbs
.reason
= XmCR_DESELECT_ROW
;
2572 else if (type
== SelectCol
)
2573 cbs
.reason
= XmCR_DESELECT_COLUMN
;
2574 else if (type
== SelectCell
)
2575 cbs
.reason
= XmCR_DESELECT_CELL
;
2576 if (XtHasCallbacks(w
, XmNdeselectCallback
) == XtCallbackHasSome
)
2587 lr
= XmLArrayGetCount(g
->grid
.rowArray
) - g
->grid
.footerRowCount
;
2597 lc
= XmLArrayGetCount(g
->grid
.colArray
) - g
->grid
.footerColCount
;
2600 for (r
= fr
; r
< lr
; r
++)
2601 for (c
= fc
; c
< lc
; c
++)
2603 if (type
== SelectRow
)
2605 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, r
);
2611 if (XmLGridRowIsSelected(rowp
) == select
)
2613 if (select
== True
&&
2614 (g
->grid
.selectionPolicy
== XmSELECT_BROWSE_ROW
||
2615 g
->grid
.selectionPolicy
== XmSELECT_SINGLE_ROW
))
2616 SelectTypeArea(g
, SelectRow
, event
, -1, 0, False
, notify
);
2617 XmLGridRowSetSelected(rowp
, select
);
2618 if (RowIsVisible(g
, r
))
2619 DrawArea(g
, DrawRow
, r
, 0);
2620 if (notify
&& hasCB
)
2624 XtCallCallbackList(w
, g
->grid
.selectCallback
,
2627 XtCallCallbackList(w
, g
->grid
.deselectCallback
,
2631 else if (type
== SelectCol
)
2633 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, c
);
2639 if (XmLGridColumnIsSelected(colp
) == select
)
2641 XmLGridColumnSetSelected(colp
, select
);
2642 if (ColIsVisible(g
, c
))
2643 DrawArea(g
, DrawCol
, 0, c
);
2644 if (notify
&& hasCB
)
2646 cbs
.column
= c
- hcc
;
2648 XtCallCallbackList(w
, g
->grid
.selectCallback
,
2651 XtCallCallbackList(w
, g
->grid
.deselectCallback
,
2655 else if (type
== SelectCell
)
2657 cellp
= GetCell(g
, r
, c
);
2663 if (XmLGridCellIsSelected(cellp
) == select
)
2665 XmLGridCellSetSelected(cellp
, select
);
2666 DrawArea(g
, DrawCell
, r
, c
);
2667 if (notify
&& hasCB
)
2669 cbs
.column
= c
- hcc
;
2672 XtCallCallbackList(w
, g
->grid
.selectCallback
,
2675 XtCallCallbackList(w
, g
->grid
.deselectCallback
,
2681 XmLWarning((Widget
)g
, "SelectTypeArea() - bad position");
2685 GetSelectedArea(XmLGridWidget g
,
2698 if (type
== SelectCol
)
2705 fr
= g
->grid
.headingRowCount
;
2706 lr
= XmLArrayGetCount(g
->grid
.rowArray
) - g
->grid
.footerRowCount
;
2708 if (type
== SelectRow
)
2715 fc
= g
->grid
.headingColCount
;
2716 lc
= XmLArrayGetCount(g
->grid
.colArray
) - g
->grid
.footerColCount
;
2719 for (r
= fr
; r
< lr
; r
++)
2720 for (c
= fc
; c
< lc
; c
++)
2722 if (type
== SelectRow
)
2724 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, r
);
2725 if (row
&& XmLGridRowIsSelected(row
) == True
)
2727 if (rowPos
&& n
< count
)
2732 else if (type
== SelectCol
)
2734 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, c
);
2735 if (col
&& XmLGridColumnIsSelected(col
) == True
)
2737 if (colPos
&& n
< count
)
2742 else if (type
== SelectCell
)
2744 cell
= GetCell(g
, r
, c
);
2745 if (cell
&& XmLGridCellIsSelected(cell
) == True
)
2747 if (rowPos
&& colPos
&& n
< count
)
2760 ChangeManaged(Widget w
)
2762 _XmNavigChangeManaged(w
);
2769 XmLGridCallbackStruct cbs
;
2771 g
= (XmLGridWidget
)w
;
2773 if (!g
->grid
.inResize
)
2775 cbs
.reason
= XmCR_RESIZE_GRID
;
2777 g
->grid
.inResize
= True
;
2778 XtCallCallbackList((Widget
)g
, g
->grid
.resizeCallback
,
2780 g
->grid
.inResize
= False
;
2786 DrawArea(g
, DrawAll
, 0, 0);
2790 PlaceScrollbars(XmLGridWidget g
)
2795 Dimension st
, headingRowHeight
= 0;
2797 st
= g
->manager
.shadow_thickness
;
2800 width
= g
->core
.width
;
2801 if (XtIsManaged(vsb
))
2802 width
-= vsb
->core
.width
;
2805 y
= g
->core
.height
- hsb
->core
.height
;
2806 XtConfigureWidget(hsb
, 0, y
, width
, hsb
->core
.height
, 0);
2808 height
= g
->core
.height
;
2809 if (XtIsManaged(hsb
))
2810 height
-= hsb
->core
.height
;
2814 if (g
->grid
.headingRowCount
> 0)
2818 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, 0);
2820 headingRowHeight
= XmLGridRowHeightInPixels(rowp
) + st
;
2823 if (g
->grid
.hideUnhideButtons
2824 && g
->grid
.hideButton
&& g
->grid
.unhideButton
)
2826 int buttonWidth
= vsb
->core
.width
- 4;
2828 if (headingRowHeight
== 0)
2829 headingRowHeight
= 20;
2831 /* if there is at least heading row, we make the
2832 height of the button the height of the first
2835 This is pretty braindead... */
2837 XtConfigureWidget(g
->grid
.unhideButton
,
2838 g
->core
.width
- buttonWidth
*2 - st
,
2841 headingRowHeight
- st
, 0);
2842 XtConfigureWidget(g
->grid
.hideButton
,
2843 g
->core
.width
- buttonWidth
- st
,
2846 headingRowHeight
- st
, 0);
2848 setHideUnhideSensitivity((Widget
)g
);
2850 /* once we've positioned it, make sure it's managed.
2851 Doing it in this order (position, then manage) reduces
2852 screen flickering -- the button doesn't flash on in the
2853 upper left corner for an instant. */
2854 if (!XtIsManaged(g
->grid
.hideButton
))
2855 XtManageChild(g
->grid
.hideButton
);
2856 if (!XtIsManaged(g
->grid
.unhideButton
))
2857 XtManageChild(g
->grid
.unhideButton
);
2862 x
= g
->core
.width
- vsb
->core
.width
;
2863 XtConfigureWidget(vsb
,
2864 x
, y
+ headingRowHeight
+ g
->manager
.shadow_thickness
,
2865 vsb
->core
.width
, height
- headingRowHeight
- g
->manager
.shadow_thickness
,
2870 _XmLGridLayout(XmLGridWidget g
)
2877 VertLayout(XmLGridWidget g
,
2881 int i
, j
, st2
, height
, rowCount
;
2882 int topNRow
, topHeight
;
2883 int midRow
, midY
, midNRow
, midHeight
;
2884 int botRow
, botY
, botNRow
, botHeight
;
2885 int scrollChanged
, needsSB
, needsResize
, cRow
;
2886 int maxRow
, maxPos
, maxHeight
, newHeight
, sliderSize
;
2887 int horizSizeChanged
;
2888 XtWidgetGeometry req
;
2889 XmLGridCallbackStruct cbs
;
2890 XmLGridPreLayoutProc preLayoutProc
;
2892 if (g
->grid
.layoutFrozen
== True
)
2894 g
->grid
.needsVertLayout
= 1;
2898 maxRow
= maxPos
= maxHeight
= newHeight
= horizSizeChanged
= 0;
2899 preLayoutProc
= XmLGridClassPartOfWidget(g
).preLayoutProc
;
2900 if (g
->grid
.layoutStack
< 2 && preLayoutProc
!= XmInheritGridPreLayout
)
2901 horizSizeChanged
= preLayoutProc(g
, 1);
2906 rowCount
= XmLArrayGetCount(g
->grid
.rowArray
);
2908 st2
= g
->manager
.shadow_thickness
* 2;
2909 TextAction(g
, TEXT_HIDE
);
2912 topNRow
= g
->grid
.topFixedCount
;
2913 if (topNRow
> g
->grid
.rowCount
+ g
->grid
.headingRowCount
)
2914 topNRow
= g
->grid
.rowCount
+ g
->grid
.headingRowCount
;
2918 for (i
= 0; i
< topNRow
; i
++)
2919 topHeight
+= GetRowHeight(g
, i
);
2922 botNRow
= g
->grid
.bottomFixedCount
;
2923 if (topNRow
+ botNRow
> rowCount
)
2924 botNRow
= rowCount
- topNRow
;
2925 botRow
= rowCount
- botNRow
;
2929 for (i
= botRow
; i
< rowCount
; i
++)
2930 botHeight
+= GetRowHeight(g
, i
);
2934 height
+= topHeight
+ g
->grid
.topFixedMargin
;
2937 height
+= botHeight
+ g
->grid
.bottomFixedMargin
;
2938 if (XtIsManaged(g
->grid
.hsb
))
2940 height
+= g
->grid
.hsb
->core
.height
;
2941 height
+= g
->grid
.scrollBarMargin
;
2943 maxHeight
= g
->core
.height
- height
;
2944 if (g
->grid
.vsPolicy
!= XmCONSTANT
)
2946 if (rowCount
== topNRow
+ botNRow
)
2950 for (i
= topNRow
; i
< rowCount
- botNRow
; i
++)
2951 midHeight
+= GetRowHeight(g
, i
);
2953 midNRow
= rowCount
- topNRow
- botNRow
;
2955 newHeight
= midHeight
+ height
;
2956 if (g
->grid
.debugLevel
)
2957 fprintf(stderr
, "XmLGrid: VertLayout VARIABLE height\n");
2961 if (maxHeight
< st2
)
2964 j
= rowCount
- botNRow
- 1;
2965 for (i
= j
; i
>= topNRow
; i
--)
2967 height
+= GetRowHeight(g
, i
);
2968 if (height
> maxHeight
)
2975 if (maxRow
< topNRow
)
2977 if (g
->grid
.debugLevel
)
2978 fprintf(stderr
, "XmLGrid: VertLayout max scroll row %d\n", i
);
2979 if (maxRow
== topNRow
)
2981 if (g
->grid
.scrollRow
!= topNRow
)
2984 g
->grid
.scrollRow
= topNRow
;
2987 midHeight
= maxHeight
;
2988 midNRow
= rowCount
- topNRow
- botNRow
;
2989 if (g
->grid
.debugLevel
)
2990 fprintf(stderr
, "XmLGrid: VertLayout everything fits\n");
2994 if (g
->grid
.scrollRow
< topNRow
)
2997 g
->grid
.scrollRow
= topNRow
;
2998 if (g
->grid
.debugLevel
)
2999 fprintf(stderr
, "XmLGrid: VertLayout scrolled < topRow\n");
3001 if (g
->grid
.scrollRow
> maxRow
)
3003 if (g
->grid
.debugLevel
)
3004 fprintf(stderr
, "XmLGrid: VertLayout scrolled > maxRow\n");
3006 g
->grid
.scrollRow
= maxRow
;
3010 for (i
= g
->grid
.scrollRow
; i
< rowCount
- botNRow
; i
++)
3013 height
+= GetRowHeight(g
, i
);
3014 if (height
>= maxHeight
)
3018 midRow
= g
->grid
.scrollRow
;
3019 midHeight
= maxHeight
;
3022 botY
= midY
+ midHeight
;
3024 botY
+= g
->grid
.bottomFixedMargin
;
3025 for (i
= 0; i
< 3; i
++)
3028 reg
[i
].height
= topHeight
;
3030 reg
[i
].nrow
= topNRow
;
3032 for (i
= 3; i
< 6; i
++)
3035 reg
[i
].height
= midHeight
;
3036 reg
[i
].row
= midRow
;
3037 reg
[i
].nrow
= midNRow
;
3039 for (i
= 6; i
< 9; i
++)
3042 reg
[i
].height
= botHeight
;
3043 reg
[i
].row
= botRow
;
3044 reg
[i
].nrow
= botNRow
;
3046 if (g
->grid
.debugLevel
)
3048 fprintf(stderr
, "XmLGrid: VertLayout TOP %3dy %3dh %3dr %3dnr\n",
3049 reg
[0].y
, reg
[0].height
, reg
[0].row
, reg
[0].nrow
);
3050 fprintf(stderr
, "XmLGrid: VertLayout MID %3dy %3dh %3dr %3dnr\n",
3051 reg
[3].y
, reg
[3].height
, reg
[3].row
, reg
[3].nrow
);
3052 fprintf(stderr
, "XmLGrid: VertLayout BOT %3dy %3dh %3dr %3dnr\n",
3053 reg
[6].y
, reg
[6].height
, reg
[6].row
, reg
[6].nrow
);
3057 if (!XtIsManaged(g
->grid
.vsb
))
3059 XtManageChild(g
->grid
.vsb
);
3060 horizSizeChanged
= 1;
3062 if (g
->grid
.debugLevel
)
3063 fprintf(stderr
, "XmLGrid: VertLayout set sb values\n");
3064 maxPos
= PosToVisPos(g
, maxRow
, 1);
3065 sliderSize
= PosToVisPos(g
, rowCount
- botNRow
- 1, 1) - maxPos
+ 1;
3066 XtVaSetValues(g
->grid
.vsb
,
3067 XmNminimum
, PosToVisPos(g
, topNRow
, 1),
3068 XmNmaximum
, maxPos
+ sliderSize
,
3069 XmNsliderSize
, sliderSize
,
3070 XmNpageIncrement
, sliderSize
,
3071 XmNvalue
, PosToVisPos(g
, g
->grid
.scrollRow
, 1),
3074 else if (g
->grid
.vsPolicy
== XmCONSTANT
&&
3075 g
->grid
.vsbDisplayPolicy
== XmSTATIC
)
3077 if (!XtIsManaged(g
->grid
.vsb
))
3079 XtManageChild(g
->grid
.vsb
);
3080 horizSizeChanged
= 1;
3082 if (g
->grid
.debugLevel
)
3083 fprintf(stderr
, "XmLGrid: VertLayout vsb not needed but static\n");
3084 XtVaSetValues(g
->grid
.vsb
,
3088 XmNpageIncrement
, 1,
3094 if (XtIsManaged(g
->grid
.vsb
))
3096 XtUnmanageChild(g
->grid
.vsb
);
3097 horizSizeChanged
= 1;
3100 if (needsResize
&& resizeIfNeeded
)
3104 req
.request_mode
= CWHeight
;
3105 req
.height
= newHeight
;
3106 if (g
->grid
.debugLevel
)
3107 fprintf(stderr
, "XmLGrid: VertLayout Req h %d\n", (int)newHeight
);
3108 XtMakeGeometryRequest((Widget
)g
, &req
, NULL
);
3112 DrawArea(g
, DrawVScroll
, 0, 0);
3113 TextAction(g
, TEXT_SHOW
);
3114 cRow
= g
->grid
.scrollRow
- g
->grid
.headingRowCount
;
3115 if (cRow
!= g
->grid
.cScrollRow
)
3117 g
->grid
.cScrollRow
= cRow
;
3118 cbs
.reason
= XmCR_SCROLL_ROW
;
3119 cbs
.rowType
= XmCONTENT
;
3121 XtCallCallbackList((Widget
)g
, g
->grid
.scrollCallback
, (XtPointer
)&cbs
);
3123 if (horizSizeChanged
)
3125 if (g
->grid
.layoutStack
> 2)
3126 XmLWarning((Widget
)g
, "VertLayout() - recursion error");
3129 g
->grid
.layoutStack
++;
3130 HorizLayout(g
, resizeIfNeeded
);
3131 g
->grid
.layoutStack
--;
3138 HorizLayout(XmLGridWidget g
,
3142 int i
, j
, st2
, width
, colCount
;
3143 int leftNCol
, leftWidth
;
3144 int midCol
, midX
, midNCol
, midWidth
;
3145 int rightCol
, rightX
, rightNCol
, rightWidth
;
3146 int scrollChanged
, needsSB
, needsResize
, cCol
;
3147 int maxCol
, maxPos
, maxWidth
, newWidth
, sliderSize
;
3148 int vertSizeChanged
;
3149 XtWidgetGeometry req
;
3150 XmLGridCallbackStruct cbs
;
3151 XmLGridPreLayoutProc preLayoutProc
;
3153 if (g
->grid
.layoutFrozen
== True
)
3155 g
->grid
.needsHorizLayout
= 1;
3159 maxCol
= maxPos
= newWidth
= vertSizeChanged
= 0;
3160 preLayoutProc
= XmLGridClassPartOfWidget(g
).preLayoutProc
;
3161 if (g
->grid
.layoutStack
< 2 && preLayoutProc
!= XmInheritGridPreLayout
)
3162 vertSizeChanged
= preLayoutProc(g
, 0);
3168 if (g
->grid
.hsPolicy
== XmRESIZE_IF_POSSIBLE
&& g
->grid
.visibleCols
)
3169 colCount
= g
->grid
.visibleCols
;
3171 colCount
= g
->grid
.colCount
+ g
->grid
.headingColCount
3172 + g
->grid
.footerColCount
;
3174 if (g
->grid
.hsPolicy
== XmRESIZE_IF_POSSIBLE
)
3176 SizeColumnsToFit(g
, 0);
3180 st2
= g
->manager
.shadow_thickness
* 2;
3181 TextAction(g
, TEXT_HIDE
);
3184 leftNCol
= g
->grid
.leftFixedCount
;
3185 if (leftNCol
> g
->grid
.colCount
+ g
->grid
.headingColCount
)
3186 leftNCol
= g
->grid
.colCount
+ g
->grid
.headingColCount
;
3190 for (i
= 0; i
< leftNCol
; i
++)
3191 leftWidth
+= GetColWidth(g
, i
);
3194 rightNCol
= g
->grid
.rightFixedCount
;
3195 if (rightNCol
+ leftNCol
> colCount
)
3196 rightNCol
= colCount
- leftNCol
;
3197 rightCol
= colCount
- rightNCol
;
3201 for (i
= rightCol
; i
< colCount
; i
++)
3202 rightWidth
+= GetColWidth(g
, i
);
3206 width
+= leftWidth
+ g
->grid
.leftFixedMargin
;
3209 width
+= rightWidth
+ g
->grid
.rightFixedMargin
;
3210 if (XtIsManaged(g
->grid
.vsb
))
3212 width
+= g
->grid
.vsb
->core
.width
;
3213 width
+= g
->grid
.scrollBarMargin
;
3215 maxWidth
= g
->core
.width
- width
;
3216 if (g
->grid
.hsPolicy
== XmVARIABLE
||
3217 g
->grid
.hsPolicy
== XmRESIZE_IF_POSSIBLE
)
3219 if (colCount
== leftNCol
+ rightNCol
)
3224 /* This assumes the show/hide buttons will be wider
3225 than the vertical scrollbar
3227 if (g
->grid
.hsPolicy
== XmRESIZE_IF_POSSIBLE
)
3229 if (g
->grid
.hideUnhideButtons
)
3230 midWidth
+= XtWidth(g
->grid
.hideButton
) * 2;
3231 else if (XtIsManaged(g
->grid
.vsb
))
3232 midWidth
+= XtWidth(g
->grid
.vsb
);
3236 for (i
= leftNCol
; i
< colCount
- rightNCol
; i
++)
3237 midWidth
+= GetColWidth(g
, i
);
3239 midNCol
= colCount
- leftNCol
- rightNCol
;
3241 newWidth
= midWidth
+ width
;
3242 if (g
->grid
.debugLevel
)
3244 if (g
->grid
.hsPolicy
== XmVARIABLE
)
3245 fprintf(stderr
, "XmLGrid: HorizLayout VARIABLE width\n");
3247 fprintf(stderr
, "XmLGrid: HorizLayout REZISE_IF_POSSIBLE\n");
3255 j
= colCount
- rightNCol
- 1;
3256 for (i
= j
; i
>= leftNCol
; i
--)
3258 width
+= GetColWidth(g
, i
);
3259 if (width
> maxWidth
)
3266 if (maxCol
< leftNCol
)
3268 if (g
->grid
.debugLevel
)
3269 fprintf(stderr
, "XmLGrid: HorizLayout max scroll col %d\n", i
);
3270 if (maxCol
== leftNCol
)
3272 if (g
->grid
.scrollCol
!= leftNCol
)
3275 g
->grid
.scrollCol
= leftNCol
;
3278 midWidth
= maxWidth
;
3279 midNCol
= colCount
- leftNCol
- rightNCol
;
3280 if (g
->grid
.debugLevel
)
3281 fprintf(stderr
, "XmLGrid: HorizLayout everything fits\n");
3285 if (g
->grid
.scrollCol
< leftNCol
)
3288 g
->grid
.scrollCol
= leftNCol
;
3289 if (g
->grid
.debugLevel
)
3290 fprintf(stderr
, "XmLGrid: HorizLayout scroll < leftCol\n");
3292 if (g
->grid
.scrollCol
> maxCol
)
3294 if (g
->grid
.debugLevel
)
3295 fprintf(stderr
, "XmLGrid: HorizLayout scroll > maxCol\n");
3297 g
->grid
.scrollCol
= maxCol
;
3301 for (i
= g
->grid
.scrollCol
; i
< colCount
- rightNCol
; i
++)
3304 width
+= GetColWidth(g
, i
);
3305 if (width
>= maxWidth
)
3309 midCol
= g
->grid
.scrollCol
;
3310 midWidth
= maxWidth
;
3313 rightX
= midX
+ midWidth
;
3315 rightX
+= g
->grid
.rightFixedMargin
;
3316 for (i
= 0; i
< 9; i
+= 3)
3319 reg
[i
].width
= leftWidth
;
3321 reg
[i
].ncol
= leftNCol
;
3323 for (i
= 1; i
< 9; i
+= 3)
3326 reg
[i
].width
= midWidth
;
3327 reg
[i
].col
= midCol
;
3328 reg
[i
].ncol
= midNCol
;
3330 for (i
= 2; i
< 9; i
+= 3)
3333 reg
[i
].width
= rightWidth
;
3334 reg
[i
].col
= rightCol
;
3335 reg
[i
].ncol
= rightNCol
;
3338 if (g
->grid
.debugLevel
)
3340 fprintf(stderr
, "XmLGrid: HorizLayout LFT %3dx %3dw %3dc %3dnc\n",
3341 reg
[0].x
, reg
[0].width
, reg
[0].col
, reg
[0].ncol
);
3342 fprintf(stderr
, "XmLGrid: HorizLayout MID %3dx %3dw %3dc %3dnc\n",
3343 reg
[1].x
, reg
[1].width
, reg
[1].col
, reg
[1].ncol
);
3344 fprintf(stderr
, "XmLGrid: HorizLayout RHT %3dx %3dw %3dc %3dnc\n",
3345 reg
[2].x
, reg
[2].width
, reg
[2].col
, reg
[2].ncol
);
3347 if (g
->grid
.hsPolicy
== XmCONSTANT
&& colCount
== 1 &&
3348 g
->grid
.colCount
== 1 && width
> maxWidth
)
3350 /* Single Column Pixel Scroll Mode */
3351 if (g
->grid
.singleColScrollMode
)
3353 i
= g
->grid
.singleColScrollPos
;
3356 else if (i
> width
- maxWidth
)
3357 i
= width
- maxWidth
;
3361 XtVaSetValues(g
->grid
.hsb
,
3363 XmNmaximum
, width
- maxWidth
+ 1,
3365 XmNpageIncrement
, ((width
- maxWidth
) / 4) + 1,
3368 if (!XtIsManaged(g
->grid
.hsb
))
3370 XtManageChild(g
->grid
.hsb
);
3371 vertSizeChanged
= 1;
3373 g
->grid
.singleColScrollMode
= 1;
3374 g
->grid
.singleColScrollPos
= i
;
3377 g
->grid
.singleColScrollMode
= 0;
3378 if (g
->grid
.singleColScrollMode
)
3382 if (g
->grid
.debugLevel
)
3383 fprintf(stderr
, "XmLGrid: HorizLayout set sb values\n");
3384 if (!XtIsManaged(g
->grid
.hsb
))
3386 XtManageChild(g
->grid
.hsb
);
3387 vertSizeChanged
= 1;
3389 maxPos
= PosToVisPos(g
, maxCol
, 0);
3390 sliderSize
= PosToVisPos(g
, colCount
- rightNCol
- 1, 0) - maxPos
+ 1;
3391 XtVaSetValues(g
->grid
.hsb
,
3392 XmNminimum
, PosToVisPos(g
, leftNCol
, 0),
3393 XmNmaximum
, maxPos
+ sliderSize
,
3394 XmNsliderSize
, sliderSize
,
3395 XmNpageIncrement
, sliderSize
,
3396 XmNvalue
, PosToVisPos(g
, g
->grid
.scrollCol
, 0),
3399 else if (g
->grid
.hsPolicy
== XmCONSTANT
&&
3400 g
->grid
.hsbDisplayPolicy
== XmSTATIC
)
3402 if (!XtIsManaged(g
->grid
.hsb
))
3404 XtManageChild(g
->grid
.hsb
);
3405 vertSizeChanged
= 1;
3407 if (g
->grid
.debugLevel
)
3408 fprintf(stderr
, "XmLGrid: HorizLayout hsb not needed - static\n");
3409 XtVaSetValues(g
->grid
.hsb
,
3413 XmNpageIncrement
, 1,
3419 if (XtIsManaged(g
->grid
.hsb
))
3421 XtUnmanageChild(g
->grid
.hsb
);
3422 vertSizeChanged
= 1;
3425 if (needsResize
&& resizeIfNeeded
)
3429 req
.request_mode
= CWWidth
;
3430 req
.width
= newWidth
;
3431 if (g
->grid
.debugLevel
)
3432 fprintf(stderr
, "XmLGrid: HorizLayout Req w %d\n", (int)newWidth
);
3433 XtMakeGeometryRequest((Widget
)g
, &req
, NULL
);
3437 DrawArea(g
, DrawHScroll
, 0, 0);
3438 TextAction(g
, TEXT_SHOW
);
3439 cCol
= g
->grid
.scrollCol
- g
->grid
.headingColCount
;
3440 if (cCol
!= g
->grid
.cScrollCol
)
3442 g
->grid
.cScrollCol
= cCol
;
3443 cbs
.reason
= XmCR_SCROLL_COLUMN
;
3444 cbs
.columnType
= XmCONTENT
;
3446 XtCallCallbackList((Widget
)g
, g
->grid
.scrollCallback
, (XtPointer
)&cbs
);
3448 if (vertSizeChanged
)
3450 if (g
->grid
.layoutStack
> 2)
3451 XmLWarning((Widget
)g
, "HorizLayout() - recursion error");
3454 g
->grid
.layoutStack
++;
3455 VertLayout(g
, resizeIfNeeded
);
3456 g
->grid
.layoutStack
--;
3463 ApplyVisibleRows(XmLGridWidget g
)
3465 XtWidgetGeometry req
;
3466 XmLGridCellRefValues
*cellValues
;
3468 if (g
->grid
.vsPolicy
!= XmCONSTANT
)
3470 XmLWarning((Widget
)g
,
3471 "verticalSizePolicy must be XmCONSTANT to set visibleRows");
3474 cellValues
= g
->grid
.defCellValues
;
3475 req
.request_mode
= CWHeight
;
3476 req
.height
= g
->manager
.shadow_thickness
* 2 + g
->grid
.visibleRows
*
3477 (4 + cellValues
->fontHeight
+ cellValues
->topMargin
+
3478 cellValues
->bottomMargin
);
3479 if (g
->grid
.hsPolicy
== XmCONSTANT
&&
3480 g
->grid
.hsbDisplayPolicy
== XmSTATIC
)
3481 req
.height
+= g
->grid
.scrollBarMargin
+ XtHeight(g
->grid
.hsb
);
3482 XtMakeGeometryRequest((Widget
)g
, &req
, NULL
);
3486 ApplyVisibleCols(XmLGridWidget g
)
3488 XtWidgetGeometry req
;
3489 XmLGridCellRefValues
*cellValues
;
3491 if (g
->grid
.hsPolicy
!= XmCONSTANT
)
3493 XmLWarning((Widget
)g
,
3494 "horizontalSizePolicy must be XmCONSTANT to set visibleColumns");
3497 cellValues
= g
->grid
.defCellValues
;
3498 req
.request_mode
= CWWidth
;
3499 req
.width
= g
->manager
.shadow_thickness
* 2 + g
->grid
.visibleCols
*
3500 (4 + 8 * cellValues
->fontWidth
+ cellValues
->leftMargin
+
3501 cellValues
->rightMargin
);
3502 if (g
->grid
.vsPolicy
== XmCONSTANT
&&
3503 g
->grid
.vsbDisplayPolicy
== XmSTATIC
)
3504 req
.width
+= g
->grid
.scrollBarMargin
+ XtWidth(g
->grid
.vsb
);
3505 XtMakeGeometryRequest((Widget
)g
, &req
, NULL
);
3509 VisPosChanged(XmLGridWidget g
,
3514 g
->grid
.recalcVertVisPos
= 1;
3515 g
->grid
.vertVisChangedHint
= 1;
3518 g
->grid
.recalcHorizVisPos
= 1;
3522 RecalcVisPos(XmLGridWidget g
,
3527 int i
, count
, visPos
;
3529 if (g
->grid
.layoutFrozen
== True
)
3530 XmLWarning((Widget
)g
, "RecalcVisPos() - layout is frozen");
3534 if (!g
->grid
.recalcVertVisPos
)
3536 count
= XmLArrayGetCount(g
->grid
.rowArray
);
3537 for (i
= 0; i
< count
; i
++)
3539 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, i
);
3540 XmLGridRowSetVisPos(row
, visPos
);
3541 if (!XmLGridRowIsHidden(row
))
3544 g
->grid
.recalcVertVisPos
= 0;
3548 if (!g
->grid
.recalcHorizVisPos
)
3550 count
= XmLArrayGetCount(g
->grid
.colArray
);
3551 for (i
= 0; i
< count
; i
++)
3553 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, i
);
3554 XmLGridColumnSetVisPos(col
, visPos
);
3555 if (!XmLGridColumnIsHidden(col
))
3558 g
->grid
.recalcHorizVisPos
= 0;
3563 PosToVisPos(XmLGridWidget g
,
3573 if (!g
->grid
.hiddenRowCount
)
3577 RecalcVisPos(g
, isVert
);
3578 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, pos
);
3580 visPos
= XmLGridRowGetVisPos(row
);
3587 if (!g
->grid
.hiddenColCount
)
3591 RecalcVisPos(g
, isVert
);
3592 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, pos
);
3594 visPos
= XmLGridColumnGetVisPos(col
);
3600 XmLWarning((Widget
)g
, "PosToVisPos() - invalid pos");
3605 VisPosToPos(XmLGridWidget g
,
3611 int i1
, i2
, vp1
, vp2
, ic
, mid
, val
, count
;
3615 if (!g
->grid
.hiddenRowCount
)
3617 count
= XmLArrayGetCount(g
->grid
.rowArray
);
3620 XmLWarning((Widget
)g
, "VisPosToPos() - called when no rows exist");
3623 RecalcVisPos(g
, isVert
);
3624 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, 0);
3625 vp1
= XmLGridRowGetVisPos(row
);
3626 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, count
- 1);
3627 vp2
= XmLGridRowGetVisPos(row
);
3628 if (visPos
< vp1
|| visPos
> vp2
)
3630 XmLWarning((Widget
)g
, "VisPosToPos() - invalid Vert visPos");
3636 if (!g
->grid
.hiddenColCount
)
3638 count
= XmLArrayGetCount(g
->grid
.colArray
);
3641 XmLWarning((Widget
)g
, "VisPosToPos() - called when no cols exist");
3644 RecalcVisPos(g
, isVert
);
3645 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, 0);
3646 vp1
= XmLGridColumnGetVisPos(col
);
3647 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, count
- 1);
3648 vp2
= XmLGridColumnGetVisPos(col
);
3649 if (visPos
< vp1
|| visPos
> vp2
)
3651 XmLWarning((Widget
)g
, "VisPosToPos() - invalid Horiz visPos");
3660 mid
= i1
+ (i2
- i1
) / 2;
3663 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, mid
);
3664 val
= XmLGridRowGetVisPos(row
);
3668 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, mid
);
3669 val
= XmLGridColumnGetVisPos(col
);
3673 else if (visPos
< val
)
3678 return -1; /* inf loop */
3683 static unsigned char
3684 ColPosToType(XmLGridWidget g
,
3689 if (pos
< g
->grid
.headingColCount
)
3691 else if (pos
< g
->grid
.headingColCount
+ g
->grid
.colCount
)
3699 ColPosToTypePos(XmLGridWidget g
,
3705 if (type
== XmHEADING
)
3707 else if (type
== XmCONTENT
)
3708 c
= pos
- g
->grid
.headingColCount
;
3710 c
= pos
- g
->grid
.headingColCount
- g
->grid
.colCount
;
3714 static unsigned char
3715 RowPosToType(XmLGridWidget g
,
3720 if (pos
< g
->grid
.headingRowCount
)
3722 else if (pos
< g
->grid
.headingRowCount
+ g
->grid
.rowCount
)
3730 RowPosToTypePos(XmLGridWidget g
,
3736 if (type
== XmHEADING
)
3738 else if (type
== XmCONTENT
)
3739 r
= pos
- g
->grid
.headingRowCount
;
3741 r
= pos
- g
->grid
.headingRowCount
- g
->grid
.rowCount
;
3746 ColTypePosToPos(XmLGridWidget g
,
3755 if (type
== XmHEADING
)
3756 pos
= g
->grid
.headingColCount
;
3757 else if (type
== XmFOOTER
|| type
== XmALL_TYPES
)
3758 pos
= g
->grid
.headingColCount
+ g
->grid
.colCount
+
3759 g
->grid
.footerColCount
;
3760 else /* XmCONTENT */
3761 pos
= g
->grid
.headingColCount
+ g
->grid
.colCount
;
3765 if (type
== XmALL_TYPES
)
3767 else if (type
== XmHEADING
)
3769 if (pos
>= g
->grid
.headingColCount
)
3772 else if (type
== XmFOOTER
)
3774 if (pos
>= g
->grid
.footerColCount
)
3776 pos
+= g
->grid
.headingColCount
+ g
->grid
.colCount
;
3778 else /* XmCONTENT */
3780 if (pos
>= g
->grid
.colCount
)
3782 pos
+= g
->grid
.headingColCount
;
3789 RowTypePosToPos(XmLGridWidget g
,
3798 if (type
== XmHEADING
)
3799 pos
= g
->grid
.headingRowCount
;
3800 else if (type
== XmFOOTER
|| type
== XmALL_TYPES
)
3801 pos
= g
->grid
.headingRowCount
+ g
->grid
.rowCount
+
3802 g
->grid
.footerRowCount
;
3803 else /* XmCONTENT */
3804 pos
= g
->grid
.headingRowCount
+ g
->grid
.rowCount
;
3808 if (type
== XmALL_TYPES
)
3810 else if (type
== XmHEADING
)
3812 if (pos
>= g
->grid
.headingRowCount
)
3815 else if (type
== XmFOOTER
)
3817 if (pos
>= g
->grid
.footerRowCount
)
3819 pos
+= g
->grid
.headingRowCount
+ g
->grid
.rowCount
;
3821 else /* XmCONTENT */
3823 if (pos
>= g
->grid
.rowCount
)
3825 pos
+= g
->grid
.headingRowCount
;
3832 ScrollRowBottomPos(XmLGridWidget g
,
3837 if (g
->grid
.vsPolicy
== XmVARIABLE
)
3839 height
= g
->grid
.reg
[4].height
;
3844 h
+= GetRowHeight(g
, r
);
3855 ScrollColRightPos(XmLGridWidget g
,
3860 if (g
->grid
.hsPolicy
== XmVARIABLE
)
3862 width
= g
->grid
.reg
[4].width
;
3867 w
+= GetColWidth(g
, c
);
3878 PosIsResize(XmLGridWidget g
,
3886 int i
, nx
, ny
, margin
;
3888 /* check for bottom resize */
3889 if (g
->grid
.allowRowResize
== True
)
3890 for (i
= 0; i
< 2; i
++)
3895 if (XYToRowCol(g
, nx
, ny
, row
, col
) != -1
3896 && RowColToXY(g
, *row
, *col
, False
, &rect
) != -1
3897 && ColPosToType(g
, *col
) == XmHEADING
)
3899 margin
= ny
- (rect
.y
+ rect
.height
);
3900 if (margin
> -5 && margin
< 5)
3907 /* check for right resize */
3908 if (g
->grid
.allowColResize
== True
)
3909 for (i
= 0; i
< 2; i
++)
3917 if (XYToRowCol(g
, nx
, ny
, row
, col
) != -1
3918 && RowColToXY(g
, *row
, *col
, False
, &rect
) != -1
3919 && RowPosToType(g
, *row
) == XmHEADING
3920 && *col
!= XmLArrayGetCount(g
->grid
.colArray
) - 1)
3922 Boolean foundResizable
= 0;
3924 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, *col
);
3926 if (!colp
->grid
.resizable
)
3930 c
< XmLArrayGetCount(g
->grid
.colArray
);
3933 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, c
);
3935 if (colp
->grid
.resizable
3936 && (g
->grid
.hsPolicy
!= XmRESIZE_IF_POSSIBLE
3937 || (g
->grid
.visibleCols
== 0
3938 || c
< g
->grid
.visibleCols
))
3941 foundResizable
= True
;
3945 if (!foundResizable
) return 0;
3947 margin
= nx
- (rect
.x
+ rect
.width
);
3948 if (margin
> -5 && margin
< 5)
3959 XmLGridPosIsResize(Widget g
,
3965 return PosIsResize((XmLGridWidget
) g
, x
, y
, &row
, &col
, &isVert
);
3969 XYToRowCol(XmLGridWidget g
,
3975 XRectangle xyRect
, rect
;
3982 st
= g
->manager
.shadow_thickness
;
3987 for (i
= 0; i
< 9; i
++)
3989 if (!reg
[i
].width
|| !reg
[i
].height
)
3991 rect
.x
= reg
[i
].x
+ st
;
3992 rect
.y
= reg
[i
].y
+ st
;
3993 rect
.width
= reg
[i
].width
- st
* 2;
3994 rect
.height
= reg
[i
].height
- st
* 2;
3995 if (XmLRectIntersect(&xyRect
, &rect
) == XmLRectOutside
)
3998 for (r
= reg
[i
].row
; r
< reg
[i
].row
+ reg
[i
].nrow
; r
++)
4001 for (c
= reg
[i
].col
; c
< reg
[i
].col
+ reg
[i
].ncol
; c
++)
4003 rect
.x
= reg
[i
].x
+ st
+ width
;
4004 rect
.y
= reg
[i
].y
+ st
+ height
;
4005 rect
.width
= GetColWidth(g
, c
);
4006 rect
.height
= GetRowHeight(g
, r
);
4007 if (g
->grid
.singleColScrollMode
)
4008 rect
.x
-= g
->grid
.singleColScrollPos
;
4009 ClipRectToReg(g
, &rect
, ®
[i
]);
4010 if (XmLRectIntersect(&xyRect
, &rect
) != XmLRectOutside
)
4012 if (!RowColFirstSpan(g
, r
, c
, row
, col
, 0, True
, True
))
4013 return 0; /* SUCCESS */
4017 width
+= GetColWidth(g
, c
);
4019 height
+= GetRowHeight(g
, r
);
4026 RowColToXY(XmLGridWidget g
,
4033 XmLGridCellRefValues
*cellValues
;
4039 st
= g
->manager
.shadow_thickness
;
4040 cell
= GetCell(g
, row
, col
);
4043 cellValues
= XmLGridCellGetRefValues(cell
);
4045 if (!cellValues
) return -1;
4047 for (i
= 0; i
< 9; i
++)
4049 if (!reg
[i
].width
|| !reg
[i
].height
)
4051 if (!(col
>= reg
[i
].col
&&
4052 col
< reg
[i
].col
+ reg
[i
].ncol
&&
4053 row
>= reg
[i
].row
&&
4054 row
< reg
[i
].row
+ reg
[i
].nrow
))
4057 for (r
= reg
[i
].row
; r
< row
; r
++)
4058 off
+= GetRowHeight(g
, r
);
4059 rect
->y
= reg
[i
].y
+ st
+ off
;
4060 rect
->height
= GetRowHeight(g
, row
);
4061 if (cellValues
->rowSpan
)
4062 for (r
= row
+ 1; r
<= row
+ cellValues
->rowSpan
; r
++)
4063 rect
->height
+= GetRowHeight(g
, r
);
4065 for (c
= reg
[i
].col
; c
< col
; c
++)
4066 off
+= GetColWidth(g
, c
);
4067 rect
->x
= reg
[i
].x
+ st
+ off
;
4068 rect
->width
= GetColWidth(g
, col
);
4069 if (cellValues
->columnSpan
)
4070 for (c
= col
+ 1; c
<= col
+ cellValues
->columnSpan
; c
++)
4071 rect
->width
+= GetColWidth(g
, c
);
4072 if (g
->grid
.singleColScrollMode
)
4073 rect
->x
-= g
->grid
.singleColScrollPos
;
4074 if (clipped
== True
)
4075 ClipRectToReg(g
, rect
, ®
[i
]);
4082 RowColFirstSpan(XmLGridWidget g
,
4097 cell
= GetCell(g
, row
, col
);
4100 if (XmLGridCellInRowSpan(cell
) == True
)
4106 rect
->y
-= GetRowHeight(g
, row
);
4113 else if (XmLGridCellInColumnSpan(cell
) == True
)
4115 if (lookLeft
== True
)
4119 rect
->x
-= GetColWidth(g
, col
);
4129 if (row
< 0 || col
< 0)
4137 RowColSpanRect(XmLGridWidget g
,
4143 XmLGridCellRefValues
*cellValues
;
4146 cell
= GetCell(g
, row
, col
);
4147 cellValues
= XmLGridCellGetRefValues(cell
);
4150 for (r
= row
; r
<= row
+ cellValues
->rowSpan
; r
++)
4151 rect
->height
+= GetRowHeight(g
, r
);
4152 for (c
= col
; c
<= col
+ cellValues
->columnSpan
; c
++)
4153 rect
->width
+= GetColWidth(g
, c
);
4157 GetCell(XmLGridWidget g
,
4163 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, row
);
4166 return (XmLGridCell
)XmLArrayGet(XmLGridRowCells(rowp
), col
);
4170 GetColWidth(XmLGridWidget g
,
4175 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, col
);
4178 return XmLGridColumnWidthInPixels(colp
);
4182 GetRowHeight(XmLGridWidget g
,
4187 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, row
);
4190 return XmLGridRowHeightInPixels(rowp
);
4194 ColIsVisible(XmLGridWidget g
,
4200 c
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, col
);
4203 XmLWarning((Widget
)g
, "ColumnIsVisible() - invalid column");
4206 if (XmLGridColumnIsHidden(c
) == True
)
4208 if (g
->grid
.hsPolicy
!= XmCONSTANT
)
4210 for (i
= 0; i
< 3; i
++)
4212 c1
= g
->grid
.reg
[i
].col
;
4213 c2
= c1
+ g
->grid
.reg
[i
].ncol
;
4214 if (col
>= c1
&& col
< c2
)
4221 RowIsVisible(XmLGridWidget g
,
4227 r
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, row
);
4230 XmLWarning((Widget
)g
, "RowIsVisible() - invalid row");
4233 if (XmLGridRowIsHidden(r
) == True
)
4235 if (g
->grid
.vsPolicy
!= XmCONSTANT
)
4237 for (i
= 0; i
< 9; i
+= 3)
4239 r1
= g
->grid
.reg
[i
].row
;
4240 r2
= r1
+ g
->grid
.reg
[i
].nrow
;
4241 if (row
>= r1
&& row
< r2
)
4247 static XtGeometryResult
4248 GeometryManager(Widget w
,
4249 XtWidgetGeometry
*request
,
4250 XtWidgetGeometry
*allow
)
4252 if (request
->request_mode
& CWWidth
)
4253 w
->core
.width
= request
->width
;
4254 if (request
->request_mode
& CWHeight
)
4255 w
->core
.height
= request
->height
;
4256 if (request
->request_mode
& CWX
)
4257 w
->core
.x
= request
->x
;
4258 if (request
->request_mode
& CWY
)
4259 w
->core
.y
= request
->y
;
4260 if (request
->request_mode
& CWBorderWidth
)
4261 w
->core
.border_width
= request
->border_width
;
4262 return XtGeometryYes
;
4267 XtPointer clientData
,
4271 XmScrollBarCallbackStruct
*cbs
;
4272 unsigned char orientation
;
4275 g
= (XmLGridWidget
)(XtParent(w
));
4276 cbs
= (XmScrollBarCallbackStruct
*)callData
;
4277 visPos
= cbs
->value
;
4278 XtVaGetValues(w
, XmNorientation
, &orientation
, NULL
);
4279 if (orientation
== XmHORIZONTAL
&& g
->grid
.singleColScrollMode
)
4281 g
->grid
.singleColScrollPos
= visPos
;
4282 DrawArea(g
, DrawHScroll
, 0, 0);
4284 else if (orientation
== XmVERTICAL
)
4286 if (visPos
== PosToVisPos(g
, g
->grid
.scrollRow
, 1))
4288 g
->grid
.scrollRow
= VisPosToPos(g
, visPos
, 1);
4290 DrawArea(g
, DrawVScroll
, 0, 0);
4294 if (visPos
== PosToVisPos(g
, g
->grid
.scrollCol
, 0))
4296 g
->grid
.scrollCol
= VisPosToPos(g
, visPos
, 0);
4298 DrawArea(g
, DrawHScroll
, 0, 0);
4303 FindNextFocus(XmLGridWidget g
,
4312 int hrc
, hcc
, rc
, cc
;
4317 hcc
= g
->grid
.headingColCount
;
4318 cc
= g
->grid
.colCount
;
4319 hrc
= g
->grid
.headingRowCount
;
4320 rc
= g
->grid
.rowCount
;
4325 else if (col
>= hcc
+ cc
)
4329 else if (row
>= hrc
+ rc
)
4334 if (row
< hrc
|| row
>= hrc
+ rc
)
4336 if (col
< hcc
|| col
>= hcc
+ cc
)
4338 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, row
);
4339 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, col
);
4340 cell
= GetCell(g
, row
, col
);
4342 RowPosToType(g
, row
) == XmCONTENT
&&
4343 ColPosToType(g
, col
) == XmCONTENT
&&
4344 XmLGridCellInRowSpan(cell
) == False
&&
4345 XmLGridCellInColumnSpan(cell
) == False
&&
4346 XmLGridRowIsHidden(rowp
) == False
&&
4347 XmLGridColumnIsHidden(colp
) == False
)
4352 if (!rowDir
&& !colDir
)
4365 SetFocus(XmLGridWidget g
,
4371 if (FindNextFocus(g
, row
, col
, rowDir
, colDir
, &row
, &col
) == -1)
4373 ChangeFocus(g
, row
, col
);
4378 ChangeFocus(XmLGridWidget g
,
4383 XmLGridCallbackStruct cbs
;
4384 int focusRow
, focusCol
;
4386 focusRow
= g
->grid
.focusRow
;
4387 focusCol
= g
->grid
.focusCol
;
4388 g
->grid
.focusRow
= row
;
4389 g
->grid
.focusCol
= col
;
4390 if (focusRow
!= -1 && focusCol
!= -1)
4392 cell
= GetCell(g
, focusRow
, focusCol
);
4395 if (g
->grid
.highlightRowMode
== True
)
4396 DrawArea(g
, DrawRow
, focusRow
, 0);
4398 DrawArea(g
, DrawCell
, focusRow
, focusCol
);
4399 cbs
.reason
= XmCR_CELL_FOCUS_OUT
;
4400 cbs
.columnType
= ColPosToType(g
, focusCol
);
4401 cbs
.column
= ColPosToTypePos(g
, cbs
.columnType
, focusCol
);
4402 cbs
.rowType
= RowPosToType(g
, focusRow
);
4403 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, focusRow
);
4404 XmLGridCellAction(cell
, (Widget
)g
, &cbs
);
4405 XtCallCallbackList((Widget
)g
, g
->grid
.cellFocusCallback
,
4409 if (row
!= -1 && col
!= -1)
4411 cell
= GetCell(g
, row
, col
);
4414 if (g
->grid
.highlightRowMode
== True
)
4415 DrawArea(g
, DrawRow
, row
, 0);
4417 DrawArea(g
, DrawCell
, row
, col
);
4418 cbs
.reason
= XmCR_CELL_FOCUS_IN
;
4419 cbs
.columnType
= ColPosToType(g
, col
);
4420 cbs
.column
= ColPosToTypePos(g
, cbs
.columnType
, col
);
4421 cbs
.rowType
= RowPosToType(g
, row
);
4422 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, row
);
4423 XmLGridCellAction(cell
, (Widget
)g
, &cbs
);
4424 XtCallCallbackList((Widget
)g
, g
->grid
.cellFocusCallback
,
4429 if (!XmLArrayGet(g
->grid
.rowArray
, row
))
4430 g
->grid
.focusRow
= -1;
4431 if (!XmLArrayGet(g
->grid
.colArray
, col
))
4432 g
->grid
.focusCol
= -1;
4438 MakeColVisible(XmLGridWidget g
,
4441 int st
, width
, scrollWidth
, scrollCol
, prevScrollCol
;
4443 if (g
->grid
.hsPolicy
!= XmCONSTANT
)
4445 if (col
< g
->grid
.leftFixedCount
||
4446 col
>= XmLArrayGetCount(g
->grid
.colArray
) - g
->grid
.rightFixedCount
)
4448 st
= g
->manager
.shadow_thickness
;
4450 if (col
> g
->grid
.scrollCol
)
4452 scrollWidth
= g
->grid
.reg
[4].width
- st
* 2;
4456 width
+= GetColWidth(g
, scrollCol
);
4457 if (width
> scrollWidth
)
4459 if (scrollCol
< g
->grid
.leftFixedCount
)
4464 if (scrollCol
> col
)
4466 /* only scroll if needed */
4467 if (scrollCol
< g
->grid
.scrollCol
)
4468 scrollCol
= g
->grid
.scrollCol
;
4470 if (scrollCol
== g
->grid
.scrollCol
)
4472 prevScrollCol
= g
->grid
.scrollCol
;
4473 g
->grid
.scrollCol
= scrollCol
;
4475 if (g
->grid
.scrollCol
!= prevScrollCol
)
4476 DrawArea(g
, DrawHScroll
, 0, 0);
4480 MakeRowVisible(XmLGridWidget g
,
4483 int st
, height
, scrollHeight
, scrollRow
, prevScrollRow
;
4485 if (g
->grid
.vsPolicy
!= XmCONSTANT
)
4487 if (row
< g
->grid
.topFixedCount
||
4488 row
>= XmLArrayGetCount(g
->grid
.rowArray
) - g
->grid
.bottomFixedCount
)
4490 st
= g
->manager
.shadow_thickness
;
4492 if (row
> g
->grid
.scrollRow
)
4494 scrollHeight
= g
->grid
.reg
[4].height
- st
* 2;
4498 height
+= GetRowHeight(g
, scrollRow
);
4499 if (height
> scrollHeight
)
4501 if (scrollRow
< g
->grid
.topFixedCount
)
4506 if (scrollRow
> row
)
4508 /* only scroll if needed */
4509 if (scrollRow
< g
->grid
.scrollRow
)
4510 scrollRow
= g
->grid
.scrollRow
;
4512 if (scrollRow
== g
->grid
.scrollRow
)
4514 prevScrollRow
= g
->grid
.scrollRow
;
4515 g
->grid
.scrollRow
= scrollRow
;
4517 if (g
->grid
.scrollRow
!= prevScrollRow
)
4518 DrawArea(g
, DrawVScroll
, 0, 0);
4522 TextAction(XmLGridWidget g
,
4525 int row
, col
, reason
, ret
, isVisible
;
4527 XtTranslations trans
;
4530 XmLGridCallbackStruct cbs
;
4532 if (!g
->grid
.text
|| !XtIsRealized(g
->grid
.text
))
4534 row
= g
->grid
.focusRow
;
4535 col
= g
->grid
.focusCol
;
4536 if (row
== -1 || col
== -1)
4539 if (RowColToXY(g
, row
, col
, True
, &rect
) != -1)
4541 cellp
= GetCell(g
, row
, col
);
4544 cbs
.rowType
= XmCONTENT
;
4545 cbs
.row
= RowPosToTypePos(g
, XmCONTENT
, row
);
4546 cbs
.columnType
= XmCONTENT
;
4547 cbs
.column
= ColPosToTypePos(g
, XmCONTENT
, col
);
4548 cbs
.clipRect
= &rect
;
4552 case TEXT_EDIT_INSERT
:
4554 if (g
->grid
.inEdit
|| !isVisible
)
4557 if (action
== TEXT_EDIT
)
4558 cbs
.reason
= XmCR_EDIT_BEGIN
;
4560 cbs
.reason
= XmCR_EDIT_INSERT
;
4561 ret
= XmLGridCellAction(cellp
, (Widget
)g
, &cbs
);
4564 reason
= cbs
.reason
;
4565 cbs
.reason
= XmCR_CONF_TEXT
;
4566 XmLGridCellAction(cellp
, (Widget
)g
, &cbs
);
4567 cbs
.reason
= reason
;
4568 wc
= g
->grid
.text
->core
.widget_class
;
4569 trans
= (XtTranslations
)wc
->core_class
.tm_table
;
4570 XtVaSetValues(g
->grid
.text
, XmNtranslations
, trans
, NULL
);
4571 XtOverrideTranslations(g
->grid
.text
, g
->grid
.editTrans
);
4572 XtMapWidget(g
->grid
.text
);
4573 g
->grid
.textHidden
= 0;
4574 XtCallCallbackList((Widget
)g
, g
->grid
.editCallback
,
4581 case TEXT_EDIT_CANCEL
:
4582 case TEXT_EDIT_COMPLETE
:
4584 if (!g
->grid
.inEdit
)
4586 if (action
== TEXT_EDIT_COMPLETE
)
4587 cbs
.reason
= XmCR_EDIT_COMPLETE
;
4589 cbs
.reason
= XmCR_EDIT_CANCEL
;
4590 XmLGridCellAction(cellp
, (Widget
)g
, &cbs
);
4591 wc
= g
->grid
.text
->core
.widget_class
;
4592 trans
= (XtTranslations
)wc
->core_class
.tm_table
;
4593 XtVaSetValues(g
->grid
.text
, XmNtranslations
, trans
, NULL
);
4594 XtOverrideTranslations(g
->grid
.text
, g
->grid
.traverseTrans
);
4595 XtCallCallbackList((Widget
)g
, g
->grid
.editCallback
,
4597 XmTextSetString(g
->grid
.text
, "");
4598 XmTextSetInsertionPosition(g
->grid
.text
, 0);
4600 XtUnmapWidget(g
->grid
.text
);
4601 g
->grid
.textHidden
= 1;
4602 XtConfigureWidget(g
->grid
.text
, 0, 0, 30, 10, 0);
4607 if (g
->grid
.textHidden
|| !isVisible
)
4609 XtUnmapWidget(g
->grid
.text
);
4610 g
->grid
.textHidden
= 1;
4615 if (!g
->grid
.textHidden
|| !g
->grid
.inEdit
|| !isVisible
)
4617 if (rect
.width
== 0 || rect
.height
== 0)
4618 TextAction(g
, TEXT_EDIT_CANCEL
);
4621 cbs
.reason
= XmCR_CONF_TEXT
;
4622 XmLGridCellAction(cellp
, (Widget
)g
, &cbs
);
4623 XtMapWidget(g
->grid
.text
);
4624 g
->grid
.textHidden
= 0;
4632 Getting and Setting Values
4636 GetSubValues(Widget w
,
4647 g
= (XmLGridWidget
)w
;
4650 for (i
= 0; i
< *nargs
; i
++)
4654 if (!strncmp(args
[i
].name
, "row", 3))
4656 if (!strcmp(args
[i
].name
, XmNrowPtr
))
4658 row
= (XmLGridRow
)args
[i
].value
;
4662 GetRowValueMask(g
, args
[i
].name
, &mask
);
4667 XmLWarning(w
, "GetValues() - invalid row");
4670 GetRowValue(g
, row
, args
[i
].value
, mask
);
4672 else if (!strncmp(args
[i
].name
, "column", 6))
4674 if (!strcmp(args
[i
].name
, XmNcolumnPtr
))
4676 col
= (XmLGridColumn
)args
[i
].value
;
4680 GetColumnValueMask(g
, args
[i
].name
, &mask
);
4685 XmLWarning(w
, "GetValues() - invalid column");
4688 GetColumnValue(g
, col
, args
[i
].value
, mask
);
4690 else if (!strncmp(args
[i
].name
, "cell", 4))
4693 CellValueGetMask(args
[i
].name
, &mask
);
4698 XmLWarning(w
, "GetValues() - invalid cell");
4701 c
= XmLGridColumnGetPos(col
);
4702 cell
= (XmLGridCell
)XmLArrayGet(XmLGridRowCells(row
), c
);
4703 GetCellValue(cell
, args
[i
].value
, mask
);
4709 SetSubValues(Widget w
,
4717 XmLGridCellRefValues
*values
, *newValues
, *prevValues
;
4719 int r
, r1
, r2
, rowsValid
;
4720 int c
, c1
, c2
, cd1
, cd2
, colsValid
;
4721 unsigned char rowType
, colType
;
4722 long rowMask
, colMask
, cellMask
;
4723 int i
, nRefValues
, allCols
;
4724 int needsHorizResize
, needsVertResize
;
4727 newValues
= (XmLGridCellRefValues
*)NULL
;
4728 g
= (XmLGridWidget
)w
;
4729 needsHorizResize
= 0;
4730 needsVertResize
= 0;
4734 for (i
= 0; i
< *nargs
; i
++)
4738 if (!strncmp(args
[i
].name
, "row", 3))
4740 if (!strcmp(args
[i
].name
, XmNrowPtr
))
4741 XmLWarning(w
, "SetValues() - can't use XmNrowPtr");
4742 GetRowValueMask(g
, args
[i
].name
, &rowMask
);
4744 else if (!strncmp(args
[i
].name
, "column", 6))
4746 if (!strcmp(args
[i
].name
, XmNcolumnPtr
))
4747 XmLWarning(w
, "SetValues() - can't use XmNcolumnPtr");
4748 GetColumnValueMask(g
, args
[i
].name
, &colMask
);
4750 else if (!strncmp(args
[i
].name
, "cell", 4))
4751 CellValueGetMask(args
[i
].name
, &cellMask
);
4752 else if (rowMask
|| colMask
|| cellMask
)
4754 sprintf(buf
, "SetValues() - %s is not a row/column/cell resource",
4759 if (rowMask
|| colMask
|| cellMask
)
4761 if (g
->grid
.rowType
== XmINVALID_TYPE
)
4762 rowType
= XmCONTENT
;
4764 rowType
= g
->grid
.rowType
;
4766 if (g
->grid
.cellRowRangeStart
!= -1 && g
->grid
.cellRowRangeEnd
!= -1)
4768 r1
= RowTypePosToPos(g
, rowType
, g
->grid
.cellRowRangeStart
, 0);
4769 r2
= RowTypePosToPos(g
, rowType
, g
->grid
.cellRowRangeEnd
, 0);
4770 if (r1
< 0 || r2
< 0 || r1
> r2
)
4774 else if (g
->grid
.cellRow
!= -1)
4776 r1
= RowTypePosToPos(g
, rowType
, g
->grid
.cellRow
, 0);
4783 r1
= RowTypePosToPos(g
, rowType
, 0, 0);
4786 r2
= RowTypePosToPos(g
, rowType
, -1, 1);
4790 XmLWarning(w
, "SetValues() - invalid row(s) specified");
4794 if (g
->grid
.colType
== XmINVALID_TYPE
)
4795 colType
= XmCONTENT
;
4797 colType
= g
->grid
.colType
;
4799 if (g
->grid
.cellColRangeStart
!= -1 && g
->grid
.cellColRangeEnd
!= -1)
4801 c1
= ColTypePosToPos(g
, colType
, g
->grid
.cellColRangeStart
, 0);
4802 c2
= ColTypePosToPos(g
, colType
, g
->grid
.cellColRangeEnd
, 0);
4803 if (c1
< 0 || c2
< 0 || c1
> c2
)
4807 else if (g
->grid
.cellCol
!= -1)
4809 c1
= ColTypePosToPos(g
, colType
, g
->grid
.cellCol
, 0);
4816 c1
= ColTypePosToPos(g
, colType
, 0, 0);
4819 c2
= ColTypePosToPos(g
, colType
, -1, 1);
4823 XmLWarning(w
, "SetValues() - invalid column(s) specified");
4827 if (g
->grid
.debugLevel
)
4829 fprintf(stderr
, "XmLGrid: SetValues for rows %d to %d\n", r1
, r2
);
4830 fprintf(stderr
, "XmLGrid: & columns %d to %d\n", c1
, c2
);
4833 for (r
= r1
; r
< r2
; r
+= g
->grid
.rowStep
)
4835 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, r
);
4838 if (SetRowValues(g
, row
, rowMask
))
4839 needsVertResize
= 1;
4840 DrawArea(g
, DrawRow
, r
, 0);
4843 for (c
= c1
; c
< c2
; c
+= g
->grid
.colStep
)
4845 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, c
);
4848 if (SetColumnValues(g
, col
, colMask
))
4849 needsHorizResize
= 1;
4850 DrawArea(g
, DrawCol
, 0, c
);
4853 SetCellValuesPreprocess(g
, cellMask
);
4854 if (cellMask
&& g
->grid
.cellDefaults
== True
)
4857 if (g
->grid
.colType
== XmINVALID_TYPE
&&
4858 g
->grid
.cellCol
== -1 &&
4859 g
->grid
.cellColRangeStart
== -1 &&
4860 g
->grid
.cellColRangeEnd
== -1 &&
4861 g
->grid
.colStep
== 1)
4866 /* set cell default values */
4867 newValues
= CellRefValuesCreate(g
, g
->grid
.defCellValues
);
4868 newValues
->refCount
= 1;
4869 SetCellRefValues(g
, newValues
, cellMask
);
4870 if (newValues
->rowSpan
|| newValues
->columnSpan
)
4872 newValues
->rowSpan
= 0;
4873 newValues
->columnSpan
= 0;
4874 XmLWarning((Widget
)g
,
4875 "SetValues() - can't set default cell spans");
4877 XmLGridCellDerefValues(g
->grid
.defCellValues
);
4878 g
->grid
.defCellValues
= newValues
;
4880 cd2
= XmLArrayGetCount(g
->grid
.colArray
);
4887 /* set column cell default values */
4888 for (c
= cd1
; c
< cd2
; c
+= g
->grid
.colStep
)
4890 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, c
);
4893 if (allCols
&& !col
->grid
.defCellValues
)
4895 if (col
->grid
.defCellValues
)
4896 newValues
= CellRefValuesCreate(g
, col
->grid
.defCellValues
);
4898 newValues
= CellRefValuesCreate(g
, g
->grid
.defCellValues
);
4899 newValues
->refCount
= 1;
4900 SetCellRefValues(g
, newValues
, cellMask
);
4901 if (newValues
->rowSpan
|| newValues
->columnSpan
)
4903 newValues
->rowSpan
= 0;
4904 newValues
->columnSpan
= 0;
4905 XmLWarning((Widget
)g
,
4906 "SetValues() - can't set default cell spans");
4908 if (col
->grid
.defCellValues
)
4909 XmLGridCellDerefValues(col
->grid
.defCellValues
);
4910 col
->grid
.defCellValues
= newValues
;
4915 /* set cell values */
4916 if (SetCellHasRefValues(cellMask
))
4918 cellArray
= XmLArrayNew(0, 0);
4919 XmLArrayAdd(cellArray
, -1, (r2
- r1
) * (c2
- c1
));
4921 for (r
= r1
; r
< r2
; r
+= g
->grid
.rowStep
)
4922 for (c
= c1
; c
< c2
; c
+= g
->grid
.colStep
)
4924 cell
= GetCell(g
, r
, c
);
4927 SetCellRefValuesPreprocess(g
, r
, c
, cell
, cellMask
);
4928 XmLArraySet(cellArray
, nRefValues
, cell
);
4931 XmLArraySort(cellArray
, SetCellRefValuesCompare
,
4932 (void *)&cellMask
, 0, nRefValues
);
4934 for (i
= 0; i
< nRefValues
; i
++)
4936 cell
= (XmLGridCell
)XmLArrayGet(cellArray
, i
);
4937 values
= XmLGridCellGetRefValues(cell
);
4938 if (values
!= prevValues
)
4940 newValues
= CellRefValuesCreate(g
, values
);
4941 SetCellRefValues(g
, newValues
, cellMask
);
4943 XmLGridCellSetRefValues(cell
, newValues
);
4944 prevValues
= values
;
4946 XmLArrayFree(cellArray
);
4948 for (r
= r1
; r
< r2
; r
+= g
->grid
.rowStep
)
4949 for (c
= c1
; c
< c2
; c
+= g
->grid
.colStep
)
4951 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, r
);
4952 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, c
);
4953 cell
= GetCell(g
, r
, c
);
4954 if (!row
|| !col
|| !cell
)
4956 if (SetCellValuesResize(g
, row
, col
, cell
, cellMask
))
4958 needsHorizResize
= 1;
4959 needsVertResize
= 1;
4961 SetCellValues(g
, cell
, cellMask
);
4962 if (!needsHorizResize
&& !needsVertResize
)
4963 DrawArea(g
, DrawCell
, r
, c
);
4967 if (needsHorizResize
)
4969 if (needsVertResize
)
4971 if (needsHorizResize
|| needsVertResize
)
4972 DrawArea(g
, DrawAll
, 0, 0);
4973 g
->grid
.rowType
= XmINVALID_TYPE
;
4974 g
->grid
.colType
= XmINVALID_TYPE
;
4975 g
->grid
.rowStep
= 1;
4976 g
->grid
.colStep
= 1;
4977 g
->grid
.cellRow
= -1;
4978 g
->grid
.cellRowRangeStart
= -1;
4979 g
->grid
.cellRowRangeEnd
= -1;
4980 g
->grid
.cellCol
= -1;
4981 g
->grid
.cellColRangeStart
= -1;
4982 g
->grid
.cellColRangeEnd
= -1;
4983 g
->grid
.cellDefaults
= False
;
4987 SetValues(Widget curW
,
4993 XmLGridWidget g
, cur
;
4994 int hc
, c
, fc
, hr
, r
, fr
;
4995 int tfc
, bfc
, lfc
, rfc
;
4996 int needsVertLayout
, needsHorizLayout
, needsRedraw
;
4997 XmLGridCellRefValues
*cellValues
;
4999 g
= (XmLGridWidget
)newW
;
5000 cur
= (XmLGridWidget
)curW
;
5002 needsVertLayout
= 0;
5003 needsHorizLayout
= 0;
5005 #define NE(value) (g->value != cur->value)
5006 if (NE(grid
.cScrollCol
))
5008 g
->grid
.scrollCol
= g
->grid
.cScrollCol
+ g
->grid
.headingColCount
;
5009 needsHorizLayout
= 1;
5012 if (NE(grid
.cScrollRow
))
5014 g
->grid
.scrollRow
= g
->grid
.cScrollRow
+ g
->grid
.headingRowCount
;
5015 needsVertLayout
= 1;
5018 if (NE(grid
.bottomFixedCount
) ||
5019 NE(grid
.bottomFixedMargin
) ||
5020 NE(grid
.topFixedCount
) ||
5021 NE(grid
.topFixedMargin
) ||
5022 NE(grid
.vsbDisplayPolicy
))
5024 needsVertLayout
= 1;
5027 if (NE(grid
.leftFixedCount
) ||
5028 NE(grid
.leftFixedMargin
) ||
5029 NE(grid
.rightFixedCount
) ||
5030 NE(grid
.rightFixedMargin
) ||
5031 NE(grid
.hsbDisplayPolicy
))
5033 needsHorizLayout
= 1;
5036 if (NE(grid
.layoutFrozen
))
5038 if (g
->grid
.layoutFrozen
== False
)
5040 if (g
->grid
.needsVertLayout
== True
)
5042 needsVertLayout
= 1;
5043 g
->grid
.needsVertLayout
= False
;
5045 if (g
->grid
.needsHorizLayout
== True
)
5047 needsHorizLayout
= 1;
5048 g
->grid
.needsHorizLayout
= False
;
5053 if (NE(grid
.scrollBarMargin
) ||
5054 NE(manager
.shadow_thickness
) ||
5055 NE(core
.border_width
) ||
5056 NE(grid
.vsPolicy
) ||
5059 needsVertLayout
= 1;
5060 needsHorizLayout
= 1;
5063 if (NE(grid
.blankBg
) ||
5064 NE(grid
.highlightThickness
) ||
5065 NE(grid
.selectBg
) ||
5066 NE(grid
.selectFg
) ||
5067 NE(grid
.toggleTopColor
) ||
5068 NE(grid
.toggleBotColor
) ||
5069 NE(grid
.shadowRegions
) ||
5070 NE(grid
.shadowType
))
5072 if (NE(grid
.fontList
))
5074 XmFontListFree(cur
->grid
.fontList
);
5076 cellValues
= CellRefValuesCreate(g
, g
->grid
.defCellValues
);
5077 cellValues
->refCount
= 1;
5078 XmFontListFree(cellValues
->fontList
);
5079 cellValues
->fontList
= XmFontListCopy(g
->grid
.fontList
);
5080 XmLFontListGetDimensions(cellValues
->fontList
,
5081 &cellValues
->fontWidth
, &cellValues
->fontHeight
,
5082 g
->grid
.useAvgWidth
);
5083 XmLGridCellDerefValues(g
->grid
.defCellValues
);
5084 g
->grid
.defCellValues
= cellValues
;
5086 if (NE(grid
.allowDrop
))
5087 DropRegister(g
, g
->grid
.allowDrop
);
5088 if (g
->grid
.rowStep
< 1)
5090 XmLWarning(newW
, "SetValues() - rowStep can't be < 1");
5091 g
->grid
.rowStep
= 1;
5093 if (g
->grid
.colStep
< 1)
5095 XmLWarning(newW
, "SetValues() - colStep can't be < 1");
5096 g
->grid
.colStep
= 1;
5102 XmLWarning(newW
, "SetValues() - child Widgets are read-only");
5103 g
->grid
.hsb
= cur
->grid
.hsb
;
5104 g
->grid
.vsb
= cur
->grid
.vsb
;
5105 g
->grid
.text
= cur
->grid
.text
;
5107 if (NE(grid
.useTextWidget
))
5109 XmLWarning(newW
, "SetValues() - can't set use of text widget");
5110 g
->grid
.useTextWidget
= cur
->grid
.useTextWidget
;
5112 if (NE(grid
.hiddenColCount
) ||
5113 NE(grid
.hiddenRowCount
))
5115 XmLWarning(newW
, "SetValues() - can't set hidden rows or columns");
5116 g
->grid
.hiddenColCount
= cur
->grid
.hiddenColCount
;
5117 g
->grid
.hiddenRowCount
= cur
->grid
.hiddenRowCount
;
5120 /* store fixed counts, add/removing rows/columns can change these */
5125 if (NE(grid
.topFixedCount
))
5126 tfc
= g
->grid
.topFixedCount
;
5127 if (NE(grid
.bottomFixedCount
))
5128 bfc
= g
->grid
.bottomFixedCount
;
5129 if (NE(grid
.leftFixedCount
))
5130 lfc
= g
->grid
.leftFixedCount
;
5131 if (NE(grid
.rightFixedCount
))
5132 rfc
= g
->grid
.rightFixedCount
;
5133 g
->grid
.topFixedCount
= cur
->grid
.topFixedCount
;
5134 g
->grid
.bottomFixedCount
= cur
->grid
.bottomFixedCount
;
5135 g
->grid
.leftFixedCount
= cur
->grid
.leftFixedCount
;
5136 g
->grid
.rightFixedCount
= cur
->grid
.rightFixedCount
;
5138 hc
= g
->grid
.headingColCount
- cur
->grid
.headingColCount
;
5139 c
= g
->grid
.colCount
- cur
->grid
.colCount
;
5140 fc
= g
->grid
.footerColCount
- cur
->grid
.footerColCount
;
5141 hr
= g
->grid
.headingRowCount
- cur
->grid
.headingRowCount
;
5142 r
= g
->grid
.rowCount
- cur
->grid
.rowCount
;
5143 fr
= g
->grid
.footerRowCount
- cur
->grid
.footerRowCount
;
5144 g
->grid
.headingColCount
= cur
->grid
.headingColCount
;
5145 g
->grid
.colCount
= cur
->grid
.colCount
;
5146 g
->grid
.footerColCount
= cur
->grid
.footerColCount
;
5147 g
->grid
.headingRowCount
= cur
->grid
.headingRowCount
;
5148 g
->grid
.rowCount
= cur
->grid
.rowCount
;
5149 g
->grid
.footerRowCount
= cur
->grid
.footerRowCount
;
5151 XmLGridAddColumns((Widget
)g
, XmHEADING
, -1, hc
);
5153 XmLGridDeleteColumns((Widget
)g
, XmHEADING
,
5154 g
->grid
.headingColCount
+ hc
, -(hc
));
5156 XmLGridAddColumns((Widget
)g
, XmCONTENT
, -1, c
);
5158 XmLGridDeleteColumns((Widget
)g
, XmCONTENT
,
5159 g
->grid
.colCount
+ c
, -(c
));
5161 XmLGridAddColumns((Widget
)g
, XmFOOTER
, -1, fc
);
5163 XmLGridDeleteColumns((Widget
)g
, XmFOOTER
,
5164 g
->grid
.footerColCount
+ fc
, -(fc
));
5166 XmLGridAddRows((Widget
)g
, XmHEADING
, -1, hr
);
5168 XmLGridDeleteRows((Widget
)g
, XmHEADING
,
5169 g
->grid
.headingRowCount
+ hr
, -(hr
));
5171 XmLGridAddRows((Widget
)g
, XmCONTENT
, -1, r
);
5173 XmLGridDeleteRows((Widget
)g
, XmCONTENT
,
5174 g
->grid
.rowCount
+ r
, -(r
));
5176 XmLGridAddRows((Widget
)g
, XmFOOTER
, -1, fr
);
5178 XmLGridDeleteRows((Widget
)g
, XmFOOTER
,
5179 g
->grid
.footerRowCount
+ fr
, -(fr
));
5181 /* restore fixed counts if user specified */
5183 g
->grid
.topFixedCount
= tfc
;
5185 g
->grid
.bottomFixedCount
= bfc
;
5187 g
->grid
.leftFixedCount
= lfc
;
5189 g
->grid
.rightFixedCount
= rfc
;
5191 if (g
->grid
.topFixedCount
< g
->grid
.headingRowCount
)
5194 "SetValues() - can't set topFixedCount < headingRowCount");
5195 g
->grid
.topFixedCount
= cur
->grid
.topFixedCount
;
5197 if (g
->grid
.bottomFixedCount
< g
->grid
.footerRowCount
)
5200 "SetValues() - can't set bottomFixedCount < footerRowCount");
5201 g
->grid
.bottomFixedCount
= cur
->grid
.bottomFixedCount
;
5203 if (g
->grid
.leftFixedCount
< g
->grid
.headingColCount
)
5206 "SetValues() - can't set leftFixedCount < headingColumnCount");
5207 g
->grid
.leftFixedCount
= cur
->grid
.leftFixedCount
;
5209 if (g
->grid
.rightFixedCount
< g
->grid
.footerColCount
)
5212 "SetValues() - can't set rightFixedCount < footerColumnCount");
5213 g
->grid
.rightFixedCount
= cur
->grid
.rightFixedCount
;
5216 if (NE(grid
.simpleHeadings
))
5218 if (cur
->grid
.simpleHeadings
)
5219 free((char *)cur
->grid
.simpleHeadings
);
5220 if (g
->grid
.simpleHeadings
)
5222 g
->grid
.simpleHeadings
= (char *)strdup(g
->grid
.simpleHeadings
);
5223 SetSimpleHeadings(g
, g
->grid
.simpleHeadings
);
5226 if (NE(grid
.simpleWidths
))
5228 if (cur
->grid
.simpleWidths
)
5229 free((char *)cur
->grid
.simpleWidths
);
5230 if (g
->grid
.simpleWidths
)
5232 g
->grid
.simpleWidths
= (char *)strdup(g
->grid
.simpleWidths
);
5233 SetSimpleWidths(g
, g
->grid
.simpleWidths
);
5236 if (NE(grid
.visibleRows
))
5238 ApplyVisibleRows(g
);
5239 needsVertLayout
= 1;
5242 if (NE(grid
.visibleCols
))
5244 if (g
->grid
.hsPolicy
== XmRESIZE_IF_POSSIBLE
)
5245 XmLGridSetVisibleColumnCount((Widget
)g
, g
->grid
.visibleCols
);
5247 ApplyVisibleCols(g
);
5248 needsHorizLayout
= 1;
5252 /* for the hidden columns stuff */
5253 if (NE(grid
.hideUnhideButtons
))
5255 if (g
->grid
.hideUnhideButtons
)
5257 CreateHideUnhideButtons(g
);
5261 XtDestroyWidget(g
->grid
.hideButton
);
5262 XtDestroyWidget(g
->grid
.unhideButton
);
5263 g
->grid
.hideButton
= 0;
5264 g
->grid
.unhideButton
= 0;
5267 needsVertLayout
= 1;
5268 needsHorizLayout
= 1;
5273 SetSubValues(newW
, args
, nargs
);
5275 if (needsVertLayout
)
5277 if (needsHorizLayout
)
5280 DrawArea(g
, DrawAll
, 0, 0);
5285 CopyFontList(XmLGridWidget g
)
5287 if (!g
->grid
.fontList
)
5288 g
->grid
.fontList
= XmLFontListCopyDefault((Widget
)g
);
5290 g
->grid
.fontList
= XmFontListCopy(g
->grid
.fontList
);
5291 if (!g
->grid
.fontList
)
5292 XmLWarning((Widget
)g
, "- fatal error - font list NULL");
5296 CvtStringToSizePolicy(Display
*dpy
,
5299 XrmValuePtr fromVal
,
5303 static XmLStringToUCharMap map
[] =
5305 { "CONSTANT", XmCONSTANT
},
5306 { "VARIABLE", XmVARIABLE
},
5307 { "RESIZE_IF_POSSIBLE", XmRESIZE_IF_POSSIBLE
},
5311 return XmLCvtStringToUChar(dpy
, "XmRGridSizePolicy", map
, fromVal
, toVal
);
5315 CvtStringToRowColType(Display
*dpy
,
5318 XrmValuePtr fromVal
,
5322 static XmLStringToUCharMap map
[] =
5324 { "HEADING", XmHEADING
},
5325 { "CONTENT", XmCONTENT
},
5326 { "FOOTER", XmFOOTER
},
5327 { "ALL_TYPES", XmALL_TYPES
},
5331 return XmLCvtStringToUChar(dpy
, "XmRRowColType", map
, fromVal
, toVal
);
5335 CvtStringToSelectionPolicy(Display
*dpy
,
5338 XrmValuePtr fromVal
,
5342 static XmLStringToUCharMap map
[] =
5344 { "SELECT_NONE", XmSELECT_NONE
},
5345 { "SELECT_SINGLE_ROW", XmSELECT_SINGLE_ROW
},
5346 { "SELECT_BROWSE_ROW", XmSELECT_BROWSE_ROW
},
5347 { "SELECT_MULTIPLE_ROW", XmSELECT_MULTIPLE_ROW
},
5348 { "SELECT_CELL", XmSELECT_CELL
},
5352 return XmLCvtStringToUChar(dpy
, "XmRGridSelectionPolicy", map
,
5357 CvtStringToCellAlignment(Display
*dpy
,
5360 XrmValuePtr fromVal
,
5364 static XmLStringToUCharMap map
[] =
5366 { "ALIGNMENT_LEFT", XmALIGNMENT_LEFT
},
5367 { "ALIGNMENT_CENTER", XmALIGNMENT_CENTER
},
5368 { "ALIGNMENT_RIGHT", XmALIGNMENT_RIGHT
},
5369 { "ALIGNMENT_TOP_LEFT", XmALIGNMENT_TOP_LEFT
},
5370 { "ALIGNMENT_TOP", XmALIGNMENT_TOP
},
5371 { "ALIGNMENT_TOP_RIGHT", XmALIGNMENT_TOP_RIGHT
},
5372 { "ALIGNMENT_BOTTOM_LEFT", XmALIGNMENT_BOTTOM_LEFT
},
5373 { "ALIGNMENT_BOTTOM", XmALIGNMENT_BOTTOM
},
5374 { "ALIGNMENT_BOTTOM_RIGHT", XmALIGNMENT_BOTTOM_RIGHT
},
5378 return XmLCvtStringToUChar(dpy
, "XmRGridCellAlignment", map
,
5383 CvtStringToCellBorderType(Display
*dpy
,
5386 XrmValuePtr fromVal
,
5390 static XmLStringToUCharMap map
[] =
5392 { "BORDER_NONE", XmBORDER_NONE
},
5393 { "BORDER_LINE", XmBORDER_LINE
},
5394 { "BORDER_DASH", XmBORDER_DASH
},
5398 return XmLCvtStringToUChar(dpy
, "XmRGridCellBorderType", map
,
5403 CvtStringToCellType(Display
*dpy
,
5406 XrmValuePtr fromVal
,
5410 static XmLStringToUCharMap map
[] =
5412 { "ICON_CELL", XmICON_CELL
},
5413 { "STRING_CELL", XmSTRING_CELL
},
5414 { "PIXMAP_CELL", XmPIXMAP_CELL
},
5415 { "TOGGLE_CELL", XmTOGGLE_CELL
},
5419 return XmLCvtStringToUChar(dpy
, "XmRGridCellType", map
, fromVal
, toVal
);
5423 SetSimpleHeadings(XmLGridWidget g
,
5429 if (!data
|| !*data
)
5439 count
= XmLArrayGetCount(g
->grid
.colArray
);
5442 XmLWarning((Widget
)g
,
5443 "SetSimpleHeadings() - headings given for non-existing columns");
5446 if (g
->grid
.headingRowCount
< 1)
5448 XmLWarning((Widget
)g
, "SetSimpleHeadings() - no heading row exists");
5451 XmLGridSetStrings((Widget
)g
, data
);
5455 SetSimpleWidths(XmLGridWidget g
,
5459 int i
, n
, colCount
, valid
;
5460 Dimension prevWidth
;
5461 unsigned char prevSizePolicy
;
5466 unsigned char sizePolicy
;
5471 i
= ((int)strlen(data
) / 2) + 1;
5472 widths
= (struct WidthRec
*)malloc(i
* sizeof(struct WidthRec
));
5477 if (*data
>= '0' && *data
<= '9')
5479 widths
[n
].width
= atoi(data
);
5480 while (*data
>= '0' && *data
<= '9')
5488 if (*data
== 'c' || *data
== 'C')
5490 widths
[n
].sizePolicy
= XmVARIABLE
;
5493 else if (*data
== 'p' || *data
== 'P')
5495 widths
[n
].sizePolicy
= XmCONSTANT
;
5503 while (*data
== ' ')
5509 free((char *)widths
);
5510 XmLWarning((Widget
)g
, "SetSimpleWidths() - invalid widths string");
5513 colCount
= XmLArrayGetCount(g
->grid
.colArray
);
5516 free((char *)widths
);
5517 XmLWarning((Widget
)g
,
5518 "SetSimpleWidths() - widths given for non-existing columns");
5521 prevWidth
= g
->grid
.colWidth
;
5522 prevSizePolicy
= g
->grid
.colSizePolicy
;
5523 for (i
= 0; i
< n
; i
++)
5525 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, i
);
5528 GetColumnValueMask(g
, XmNcolumnWidth
, &mask
);
5529 GetColumnValueMask(g
, XmNcolumnSizePolicy
, &mask
);
5530 g
->grid
.colWidth
= widths
[i
].width
;
5531 g
->grid
.colSizePolicy
= widths
[i
].sizePolicy
;
5532 SetColumnValues(g
, colp
, mask
);
5534 free((char *)widths
);
5535 g
->grid
.colWidth
= prevWidth
;
5536 g
->grid
.colSizePolicy
= prevSizePolicy
;
5538 DrawArea(g
, DrawAll
, 0, 0);
5542 Getting and Setting Row Values
5546 GetRowValueMask(XmLGridWidget g
,
5550 XmLGridClassPartOfWidget(g
).getRowValueMaskProc(g
, s
, mask
);
5553 /* Only to be called through Grid class */
5555 _GetRowValueMask(XmLGridWidget g
,
5559 static XrmQuark qHeight
, qSizePolicy
, qUserData
;
5560 static int quarksValid
= 0;
5565 qHeight
= XrmStringToQuark(XmNrowHeight
);
5566 qSizePolicy
= XrmStringToQuark(XmNrowSizePolicy
);
5567 qUserData
= XrmStringToQuark(XmNrowUserData
);
5570 q
= XrmStringToQuark(s
);
5572 *mask
|= XmLGridRowHeight
;
5573 else if (q
== qSizePolicy
)
5574 *mask
|= XmLGridRowSizePolicy
;
5575 else if (q
== qUserData
)
5576 *mask
|= XmLGridRowUserData
;
5580 GetRowValue(XmLGridWidget g
,
5585 XmLGridClassPartOfWidget(g
).getRowValueProc(g
, row
, value
, mask
);
5588 /* Only to be called through Grid class */
5590 _GetRowValue(XmLGridWidget g
,
5597 case XmLGridRowHeight
:
5598 *((Dimension
*)value
) = row
->grid
.height
;
5600 case XmLGridRowSizePolicy
:
5601 *((unsigned char *)value
) = row
->grid
.sizePolicy
;
5603 case XmLGridRowUserData
:
5604 *((XtPointer
*)value
) = (XtPointer
)row
->grid
.userData
;
5610 SetRowValues(XmLGridWidget g
,
5614 return XmLGridClassPartOfWidget(g
).setRowValuesProc(g
, row
, mask
);
5617 /* Only to be called through Grid class */
5619 _SetRowValues(XmLGridWidget g
, XmLGridRow row
, long mask
)
5621 int needsResize
= 0, visible
= 0;
5622 Boolean newIsHidden
;
5624 if (mask
& XmLGridRowHeight
|| mask
& XmLGridRowSizePolicy
)
5626 visible
= RowIsVisible(g
, XmLGridRowGetPos(row
));
5627 XmLGridRowHeightChanged(row
);
5629 if (mask
& XmLGridRowHeight
)
5631 if (g
->grid
.rowHeight
> 0)
5632 newIsHidden
= False
;
5635 if (XmLGridRowIsHidden(row
) != newIsHidden
)
5637 if (newIsHidden
== True
)
5638 g
->grid
.hiddenRowCount
++;
5640 g
->grid
.hiddenRowCount
--;
5641 VisPosChanged(g
, 1);
5644 if (visible
&& !g
->grid
.inResize
)
5646 row
->grid
.height
= g
->grid
.rowHeight
;
5648 if (mask
& XmLGridRowSizePolicy
)
5650 row
->grid
.sizePolicy
= g
->grid
.rowSizePolicy
;
5651 if (visible
&& !g
->grid
.inResize
)
5654 if (mask
& XmLGridRowUserData
)
5655 row
->grid
.userData
= g
->grid
.rowUserData
;
5660 Getting and Setting Column Values
5664 GetColumnValueMask(XmLGridWidget g
,
5668 XmLGridClassPartOfWidget(g
).getColumnValueMaskProc(g
, s
, mask
);
5671 /* Only to be called through Grid class */
5673 _GetColumnValueMask(XmLGridWidget g
,
5677 static XrmQuark qWidth
, qSizePolicy
, qUserData
, qResizable
;
5678 static XrmQuark qHidden
, qSortType
;
5679 static int quarksValid
= 0;
5684 qWidth
= XrmStringToQuark(XmNcolumnWidth
);
5685 qSizePolicy
= XrmStringToQuark(XmNcolumnSizePolicy
);
5686 qUserData
= XrmStringToQuark(XmNcolumnUserData
);
5687 qResizable
= XrmStringToQuark(XmNcolumnResizable
);
5688 qHidden
= XrmStringToQuark(XmNcolumnHidden
);
5689 qSortType
= XrmStringToQuark(XmNcolumnSortType
);
5692 q
= XrmStringToQuark(s
);
5694 *mask
|= XmLGridColumnWidth
;
5695 else if (q
== qSizePolicy
)
5696 *mask
|= XmLGridColumnSizePolicy
;
5697 else if (q
== qUserData
)
5698 *mask
|= XmLGridColumnUserData
;
5699 else if (q
== qResizable
)
5700 *mask
|= XmLGridColumnResizable
;
5701 else if (q
== qHidden
)
5702 *mask
|= XmLGridColumnHidden
;
5703 else if (q
== qSortType
)
5704 *mask
|= XmLGridColumnSortType
;
5708 GetColumnValue(XmLGridWidget g
,
5713 XmLGridClassPartOfWidget(g
).getColumnValueProc(g
, col
, value
, mask
);
5716 /* Only to be called through Grid class */
5718 _GetColumnValue(XmLGridWidget g
,
5725 case XmLGridColumnWidth
:
5726 *((Dimension
*)value
) = col
->grid
.width
;
5728 case XmLGridColumnSizePolicy
:
5729 *((unsigned char *)value
) = col
->grid
.sizePolicy
;
5731 case XmLGridColumnUserData
:
5732 *((XtPointer
*)value
) = col
->grid
.userData
;
5734 case XmLGridColumnResizable
:
5735 *((Boolean
*)value
) = col
->grid
.resizable
;
5737 case XmLGridColumnHidden
:
5738 *((Boolean
*)value
) = col
->grid
.hidden
;
5740 case XmLGridColumnSortType
:
5741 *((unsigned char *)value
) = col
->grid
.sort
;
5748 SetColumnValues(XmLGridWidget g
,
5752 return XmLGridClassPartOfWidget(g
).setColumnValuesProc(g
, col
, mask
);
5755 /* Only to be called through Grid class */
5757 _SetColumnValues(XmLGridWidget g
, XmLGridColumn col
, long mask
)
5759 int needsResize
= 0, visible
= 0;
5760 Boolean newIsHidden
;
5762 if (mask
& XmLGridColumnWidth
|| mask
& XmLGridColumnSizePolicy
)
5764 visible
= ColIsVisible(g
, XmLGridColumnGetPos(col
));
5765 XmLGridColumnWidthChanged(col
);
5767 if (mask
& XmLGridColumnWidth
)
5769 if (g
->grid
.colWidth
> 0)
5770 newIsHidden
= False
;
5773 if (XmLGridColumnIsHidden(col
) != newIsHidden
)
5775 if (newIsHidden
== True
)
5776 g
->grid
.hiddenColCount
++;
5778 g
->grid
.hiddenRowCount
--;
5779 VisPosChanged(g
, 0);
5782 if (visible
&& !g
->grid
.inResize
)
5784 col
->grid
.width
= g
->grid
.colWidth
;
5786 if (mask
& XmLGridColumnSizePolicy
)
5788 col
->grid
.sizePolicy
= g
->grid
.colSizePolicy
;
5789 if (visible
&& !g
->grid
.inResize
)
5791 if (col
->grid
.sizePolicy
!= XmCONSTANT
5792 && g
->grid
.hsPolicy
== XmRESIZE_IF_POSSIBLE
)
5794 XmLWarning((Widget
)g
, "XmNcolumnSizePolicy must equal XmCONSTANT");
5797 if (mask
& XmLGridColumnUserData
)
5798 col
->grid
.userData
= g
->grid
.colUserData
;
5799 if (mask
& XmLGridColumnResizable
)
5800 col
->grid
.resizable
= g
->grid
.colResizable
;
5801 if (mask
& XmLGridColumnHidden
)
5802 col
->grid
.hidden
= g
->grid
.colHidden
;
5803 if (mask
& XmLGridColumnSortType
)
5804 XmLGridSetSort((Widget
)g
, XmLGridColumnGetPos(col
), g
->grid
.colSortType
);
5809 Getting and Setting Cell Values
5813 CellValueGetMask(char *s
,
5816 static XrmQuark qAlignment
, qBackground
, qBottomBorderColor
;
5817 static XrmQuark qBottomBorderType
, qColumnSpan
;
5818 static XrmQuark qEditable
, qFontList
, qForeground
;
5819 static XrmQuark qLeftBorderColor
, qLeftBorderType
;
5820 static XrmQuark qMarginBottom
, qMarginLeft
, qMarginRight
;
5821 static XrmQuark qMarginTop
, qPixmap
, qPixmapMask
;
5822 static XrmQuark qRightBorderColor
, qRightBorderType
;
5823 static XrmQuark qRowSpan
, qString
, qToggleSet
;
5824 static XrmQuark qTopBorderColor
, qTopBorderType
, qType
;
5825 static XrmQuark qUserData
;
5826 static int quarksValid
= 0;
5831 qAlignment
= XrmStringToQuark(XmNcellAlignment
);
5832 qBackground
= XrmStringToQuark(XmNcellBackground
);
5833 qBottomBorderColor
= XrmStringToQuark(XmNcellBottomBorderColor
);
5834 qBottomBorderType
= XrmStringToQuark(XmNcellBottomBorderType
);
5835 qColumnSpan
= XrmStringToQuark(XmNcellColumnSpan
);
5836 qEditable
= XrmStringToQuark(XmNcellEditable
);
5837 qFontList
= XrmStringToQuark(XmNcellFontList
);
5838 qForeground
= XrmStringToQuark(XmNcellForeground
);
5839 qLeftBorderColor
= XrmStringToQuark(XmNcellLeftBorderColor
);
5840 qLeftBorderType
= XrmStringToQuark(XmNcellLeftBorderType
);
5841 qMarginBottom
= XrmStringToQuark(XmNcellMarginBottom
);
5842 qMarginLeft
= XrmStringToQuark(XmNcellMarginLeft
);
5843 qMarginRight
= XrmStringToQuark(XmNcellMarginRight
);
5844 qMarginTop
= XrmStringToQuark(XmNcellMarginTop
);
5845 qPixmap
= XrmStringToQuark(XmNcellPixmap
);
5846 qPixmapMask
= XrmStringToQuark(XmNcellPixmapMask
);
5847 qRightBorderColor
= XrmStringToQuark(XmNcellRightBorderColor
);
5848 qRightBorderType
= XrmStringToQuark(XmNcellRightBorderType
);
5849 qRowSpan
= XrmStringToQuark(XmNcellRowSpan
);
5850 qString
= XrmStringToQuark(XmNcellString
);
5851 qToggleSet
= XrmStringToQuark(XmNcellToggleSet
);
5852 qTopBorderColor
= XrmStringToQuark(XmNcellTopBorderColor
);
5853 qTopBorderType
= XrmStringToQuark(XmNcellTopBorderType
);
5854 qType
= XrmStringToQuark(XmNcellType
);
5855 qUserData
= XrmStringToQuark(XmNcellUserData
);
5858 q
= XrmStringToQuark(s
);
5859 if (q
== qAlignment
)
5860 *mask
|= XmLGridCellAlignment
;
5861 else if (q
== qBackground
)
5862 *mask
|= XmLGridCellBackground
;
5863 else if (q
== qBottomBorderColor
)
5864 *mask
|= XmLGridCellBottomBorderColor
;
5865 else if (q
== qBottomBorderType
)
5866 *mask
|= XmLGridCellBottomBorderType
;
5867 else if (q
== qColumnSpan
)
5868 *mask
|= XmLGridCellColumnSpan
;
5869 else if (q
== qEditable
)
5870 *mask
|= XmLGridCellEditable
;
5871 else if (q
== qFontList
)
5872 *mask
|= XmLGridCellFontList
;
5873 else if (q
== qForeground
)
5874 *mask
|= XmLGridCellForeground
;
5875 else if (q
== qLeftBorderColor
)
5876 *mask
|= XmLGridCellLeftBorderColor
;
5877 else if (q
== qLeftBorderType
)
5878 *mask
|= XmLGridCellLeftBorderType
;
5879 else if (q
== qMarginBottom
)
5880 *mask
|= XmLGridCellMarginBottom
;
5881 else if (q
== qMarginLeft
)
5882 *mask
|= XmLGridCellMarginLeft
;
5883 else if (q
== qMarginRight
)
5884 *mask
|= XmLGridCellMarginRight
;
5885 else if (q
== qMarginTop
)
5886 *mask
|= XmLGridCellMarginTop
;
5887 else if (q
== qPixmap
)
5888 *mask
|= XmLGridCellPixmapF
;
5889 else if (q
== qPixmapMask
)
5890 *mask
|= XmLGridCellPixmapMask
;
5891 else if (q
== qRightBorderColor
)
5892 *mask
|= XmLGridCellRightBorderColor
;
5893 else if (q
== qRightBorderType
)
5894 *mask
|= XmLGridCellRightBorderType
;
5895 else if (q
== qRowSpan
)
5896 *mask
|= XmLGridCellRowSpan
;
5897 else if (q
== qString
)
5898 *mask
|= XmLGridCellString
;
5899 else if (q
== qToggleSet
)
5900 *mask
|= XmLGridCellToggleSet
;
5901 else if (q
== qTopBorderColor
)
5902 *mask
|= XmLGridCellTopBorderColor
;
5903 else if (q
== qTopBorderType
)
5904 *mask
|= XmLGridCellTopBorderType
;
5905 else if (q
== qType
)
5906 *mask
|= XmLGridCellType
;
5907 else if (q
== qUserData
)
5908 *mask
|= XmLGridCellUserData
;
5912 GetCellValue(XmLGridCell cell
,
5916 XmLGridCellRefValues
*values
;
5917 XmLGridCellPixmap
*pix
;
5920 values
= XmLGridCellGetRefValues(cell
);
5923 case XmLGridCellAlignment
:
5924 *((unsigned char *)value
) = values
->alignment
;
5926 case XmLGridCellBackground
:
5927 *((Pixel
*)value
) = values
->background
;
5929 case XmLGridCellBottomBorderColor
:
5930 *((Pixel
*)value
) = values
->bottomBorderColor
;
5932 case XmLGridCellBottomBorderType
:
5933 *((unsigned char *)value
) = values
->bottomBorderType
;
5935 case XmLGridCellColumnSpan
:
5936 *((int *)value
) = values
->columnSpan
;
5938 case XmLGridCellEditable
:
5939 *((Boolean
*)value
) = values
->editable
;
5941 case XmLGridCellFontList
:
5942 *((XmFontList
*)value
) = values
->fontList
;
5944 case XmLGridCellForeground
:
5945 *((Pixel
*)value
) = values
->foreground
;
5947 case XmLGridCellLeftBorderColor
:
5948 *((Pixel
*)value
) = values
->leftBorderColor
;
5950 case XmLGridCellLeftBorderType
:
5951 *((unsigned char *)value
) = values
->leftBorderType
;
5953 case XmLGridCellMarginBottom
:
5954 *((Dimension
*)value
) = values
->bottomMargin
;
5956 case XmLGridCellMarginLeft
:
5957 *((Dimension
*)value
) = values
->leftMargin
;
5959 case XmLGridCellMarginRight
:
5960 *((Dimension
*)value
) = values
->rightMargin
;
5962 case XmLGridCellMarginTop
:
5963 *((Dimension
*)value
) = values
->topMargin
;
5965 case XmLGridCellPixmapF
:
5966 pix
= XmLGridCellGetPixmap(cell
);
5968 *((Pixmap
*)value
) = pix
->pixmap
;
5970 *((Pixmap
*)value
) = (Pixmap
)XmUNSPECIFIED_PIXMAP
;
5972 case XmLGridCellPixmapMask
:
5973 pix
= XmLGridCellGetPixmap(cell
);
5975 *((Pixmap
*)value
) = pix
->pixmask
;
5977 *((Pixmap
*)value
) = (Pixmap
)XmUNSPECIFIED_PIXMAP
;
5979 case XmLGridCellRightBorderColor
:
5980 *((Pixel
*)value
) = values
->rightBorderColor
;
5982 case XmLGridCellRightBorderType
:
5983 *((unsigned char *)value
) = values
->rightBorderType
;
5985 case XmLGridCellRowSpan
:
5986 *((int *)value
) = values
->rowSpan
;
5988 case XmLGridCellString
:
5989 str
= XmLGridCellGetString(cell
);
5991 *((XmString
*)value
) = XmStringCopy(str
);
5993 *((XmString
*)value
) = 0;
5995 case XmLGridCellToggleSet
:
5996 *((Boolean
*)value
) = XmLGridCellGetToggle(cell
);
5998 case XmLGridCellTopBorderColor
:
5999 *((Pixel
*)value
) = values
->topBorderColor
;
6001 case XmLGridCellTopBorderType
:
6002 *((unsigned char *)value
) = values
->topBorderType
;
6004 case XmLGridCellType
:
6005 *((unsigned char *)value
) = values
->type
;
6007 case XmLGridCellUserData
:
6008 *((XtPointer
*)value
) = (XtPointer
)values
->userData
;
6013 static XmLGridCellRefValues
*
6014 CellRefValuesCreate(XmLGridWidget g
,
6015 XmLGridCellRefValues
*copy
)
6017 short width
, height
;
6018 XmLGridCellRefValues
*values
;
6020 values
= (XmLGridCellRefValues
*)malloc(sizeof(XmLGridCellRefValues
));
6023 /* default values */
6024 values
->bottomBorderType
= XmBORDER_LINE
;
6025 values
->leftBorderType
= XmBORDER_LINE
;
6026 values
->rightBorderType
= XmBORDER_LINE
;
6027 values
->topBorderType
= XmBORDER_LINE
;
6028 XmLFontListGetDimensions(g
->grid
.fontList
, &width
, &height
,
6029 g
->grid
.useAvgWidth
);
6030 values
->alignment
= XmALIGNMENT_CENTER
;
6031 values
->background
= g
->core
.background_pixel
;
6032 values
->bottomBorderColor
= g
->manager
.bottom_shadow_color
;
6033 values
->bottomMargin
= 0;
6034 values
->columnSpan
= 0;
6035 values
->editable
= False
;
6036 values
->fontHeight
= height
;
6037 values
->fontList
= XmFontListCopy(g
->grid
.fontList
);
6038 values
->fontWidth
= width
;
6039 values
->foreground
= g
->manager
.foreground
;
6040 values
->leftBorderColor
= g
->manager
.top_shadow_color
;
6041 values
->leftMargin
= 0;
6042 values
->refCount
= 0;
6043 values
->rightBorderColor
= g
->manager
.bottom_shadow_color
;
6044 values
->rightMargin
= 0;
6045 values
->rowSpan
= 0;
6046 values
->topBorderColor
= g
->manager
.top_shadow_color
;
6047 values
->topMargin
= 0;
6048 values
->type
= XmSTRING_CELL
;
6049 values
->userData
= 0;
6055 values
->fontList
= XmFontListCopy(copy
->fontList
);
6056 values
->refCount
= 0;
6062 SetCellValuesPreprocess(XmLGridWidget g
,
6065 XmLGridCellRefValues
*newValues
;
6067 short width
, height
;
6070 unsigned int pixWidth
, pixHeight
;
6071 unsigned int pixBW
, pixDepth
;
6073 /* calculate font width and height if set */
6074 newValues
= &g
->grid
.cellValues
;
6075 if (mask
& XmLGridCellFontList
)
6077 XmLFontListGetDimensions(newValues
->fontList
, &width
, &height
,
6078 g
->grid
.useAvgWidth
);
6079 newValues
->fontWidth
= width
;
6080 newValues
->fontHeight
= height
;
6082 if (mask
& XmLGridCellPixmapF
)
6084 if (g
->grid
.cellPixmap
!= XmUNSPECIFIED_PIXMAP
&&
6085 g
->grid
.globalPixmapWidth
&&
6086 g
->grid
.globalPixmapHeight
)
6088 g
->grid
.cellPixmapWidth
= g
->grid
.globalPixmapWidth
;
6089 g
->grid
.cellPixmapHeight
= g
->grid
.globalPixmapHeight
;
6091 else if (g
->grid
.cellPixmap
!= XmUNSPECIFIED_PIXMAP
)
6094 XGetGeometry(dpy
, g
->grid
.cellPixmap
, &pixRoot
,
6095 &x
, &y
, &pixWidth
, &pixHeight
, &pixBW
, &pixDepth
);
6096 g
->grid
.cellPixmapWidth
= (Dimension
)pixWidth
;
6097 g
->grid
.cellPixmapHeight
= (Dimension
)pixHeight
;
6101 g
->grid
.cellPixmapWidth
= 0;
6102 g
->grid
.cellPixmapHeight
= 0;
6108 SetCellHasRefValues(long mask
)
6112 /* return 1 if mask contains any reference counted values */
6113 unrefMask
= XmLGridCellPixmapF
| XmLGridCellPixmapMask
|
6114 XmLGridCellString
| XmLGridCellToggleSet
;
6115 mask
= mask
| unrefMask
;
6116 mask
= mask
^ unrefMask
;
6123 SetCellValuesResize(XmLGridWidget g
,
6129 return XmLGridClassPartOfWidget(g
).setCellValuesResizeProc(g
, row
, col
,
6134 _SetCellValuesResize(XmLGridWidget g
,
6140 XmLGridCellPixmap
*cellPix
;
6141 int pixResize
, needsResize
, rowVisible
, colVisible
;
6145 if (mask
& XmLGridCellPixmapF
)
6148 if (!(mask
& XmLGridCellType
))
6150 /* no resize needed if we replace with an equal size pixmap */
6151 cellPix
= XmLGridCellGetPixmap(cell
);
6152 if (cellPix
&& cellPix
->pixmap
!= XmUNSPECIFIED_PIXMAP
&&
6153 g
->grid
.cellPixmap
!= XmUNSPECIFIED_PIXMAP
)
6155 if (cellPix
->width
== g
->grid
.cellPixmapWidth
&&
6156 cellPix
->height
== g
->grid
.cellPixmapHeight
)
6161 if (mask
& XmLGridCellType
|| mask
& XmLGridCellFontList
|| pixResize
||
6162 mask
& XmLGridCellRowSpan
|| mask
& XmLGridCellColumnSpan
||
6163 mask
& XmLGridCellMarginLeft
|| mask
& XmLGridCellMarginRight
||
6164 mask
& XmLGridCellMarginTop
|| mask
& XmLGridCellMarginBottom
)
6166 XmLGridRowHeightChanged(row
);
6167 XmLGridColumnWidthChanged(col
);
6168 rowVisible
= RowIsVisible(g
, XmLGridRowGetPos(row
));
6169 colVisible
= ColIsVisible(g
, XmLGridColumnGetPos(col
));
6170 if (rowVisible
| colVisible
)
6177 SetCellValues(XmLGridWidget g
,
6181 /* set non-reference counted cell values */
6182 if (mask
& XmLGridCellPixmapF
)
6183 XmLGridCellSetPixmap(cell
, g
->grid
.cellPixmap
,
6184 g
->grid
.cellPixmapWidth
, g
->grid
.cellPixmapHeight
);
6185 if (mask
& XmLGridCellPixmapMask
)
6186 XmLGridCellSetPixmask(cell
, g
->grid
.cellPixmapMask
);
6187 if (mask
& XmLGridCellString
)
6188 XmLGridCellSetString(cell
, g
->grid
.cellString
, True
);
6189 if (mask
& XmLGridCellToggleSet
)
6190 XmLGridCellSetToggle(cell
, g
->grid
.cellToggleSet
);
6194 SetCellRefValues(XmLGridWidget g
,
6195 XmLGridCellRefValues
*values
,
6198 XmLGridCellRefValues
*newValues
;
6200 /* set reference counted cell values */
6201 newValues
= &g
->grid
.cellValues
;
6202 if (mask
& XmLGridCellAlignment
)
6203 values
->alignment
= newValues
->alignment
;
6204 if (mask
& XmLGridCellBackground
)
6205 values
->background
= newValues
->background
;
6206 if (mask
& XmLGridCellBottomBorderColor
)
6207 values
->bottomBorderColor
= newValues
->bottomBorderColor
;
6208 if (mask
& XmLGridCellBottomBorderType
)
6209 values
->bottomBorderType
= newValues
->bottomBorderType
;
6210 if (mask
& XmLGridCellColumnSpan
)
6211 values
->columnSpan
= newValues
->columnSpan
;
6212 if (mask
& XmLGridCellEditable
)
6213 values
->editable
= newValues
->editable
;
6214 if (mask
& XmLGridCellFontList
)
6216 XmFontListFree(values
->fontList
);
6217 values
->fontList
= XmFontListCopy(newValues
->fontList
);
6218 values
->fontWidth
= newValues
->fontWidth
;
6219 values
->fontHeight
= newValues
->fontHeight
;
6221 if (mask
& XmLGridCellForeground
)
6222 values
->foreground
= newValues
->foreground
;
6223 if (mask
& XmLGridCellLeftBorderColor
)
6224 values
->leftBorderColor
= newValues
->leftBorderColor
;
6225 if (mask
& XmLGridCellLeftBorderType
)
6226 values
->leftBorderType
= newValues
->leftBorderType
;
6227 if (mask
& XmLGridCellRightBorderColor
)
6228 values
->rightBorderColor
= newValues
->rightBorderColor
;
6229 if (mask
& XmLGridCellRightBorderType
)
6230 values
->rightBorderType
= newValues
->rightBorderType
;
6231 if (mask
& XmLGridCellMarginBottom
)
6232 values
->bottomMargin
= newValues
->bottomMargin
;
6233 if (mask
& XmLGridCellMarginLeft
)
6234 values
->leftMargin
= newValues
->leftMargin
;
6235 if (mask
& XmLGridCellMarginRight
)
6236 values
->rightMargin
= newValues
->rightMargin
;
6237 if (mask
& XmLGridCellMarginTop
)
6238 values
->topMargin
= newValues
->topMargin
;
6239 if (mask
& XmLGridCellRowSpan
)
6240 values
->rowSpan
= newValues
->rowSpan
;
6241 if (mask
& XmLGridCellTopBorderColor
)
6242 values
->topBorderColor
= newValues
->topBorderColor
;
6243 if (mask
& XmLGridCellTopBorderType
)
6244 values
->topBorderType
= newValues
->topBorderType
;
6245 if (mask
& XmLGridCellType
)
6247 values
->type
= newValues
->type
;
6248 /* backwards compatibility cell types */
6249 if (values
->type
== XmLABEL_CELL
)
6251 values
->type
= XmSTRING_CELL
;
6252 values
->editable
= False
;
6254 else if (values
->type
== XmTEXT_CELL
)
6256 values
->type
= XmSTRING_CELL
;
6257 values
->editable
= True
;
6260 if (mask
& XmLGridCellUserData
)
6261 values
->userData
= newValues
->userData
;
6265 SetCellRefValuesCompare(void *userData
,
6269 XmLGridCell cell1
, cell2
;
6270 XmLGridCellRefValues
*values1
, *values2
;
6273 mask
= *((long *)userData
);
6274 cell1
= (XmLGridCell
)*item1
;
6275 cell2
= (XmLGridCell
)*item2
;
6276 values1
= XmLGridCellGetRefValues(cell1
);
6277 values2
= XmLGridCellGetRefValues(cell2
);
6278 if (values1
== values2
)
6281 #define RVCOMPARE(res, var) \
6282 if (!(mask & res)) \
6284 if (values1->var < values2->var) \
6286 if (values1->var > values2->var) \
6289 RVCOMPARE(XmLGridCellAlignment
, alignment
)
6290 RVCOMPARE(XmLGridCellBackground
, background
)
6291 RVCOMPARE(XmLGridCellBottomBorderColor
, bottomBorderColor
)
6292 RVCOMPARE(XmLGridCellBottomBorderType
, bottomBorderType
)
6293 RVCOMPARE(XmLGridCellColumnSpan
, columnSpan
)
6294 RVCOMPARE(XmLGridCellEditable
, editable
)
6295 RVCOMPARE(XmLGridCellFontList
, fontList
)
6296 RVCOMPARE(XmLGridCellForeground
, foreground
)
6297 RVCOMPARE(XmLGridCellLeftBorderColor
, leftBorderColor
)
6298 RVCOMPARE(XmLGridCellLeftBorderType
, leftBorderType
)
6299 RVCOMPARE(XmLGridCellMarginBottom
, bottomMargin
)
6300 RVCOMPARE(XmLGridCellMarginLeft
, leftMargin
)
6301 RVCOMPARE(XmLGridCellMarginRight
, rightMargin
)
6302 RVCOMPARE(XmLGridCellMarginTop
, topMargin
)
6303 RVCOMPARE(XmLGridCellRightBorderColor
, rightBorderColor
)
6304 RVCOMPARE(XmLGridCellRightBorderType
, rightBorderType
)
6305 RVCOMPARE(XmLGridCellRowSpan
, rowSpan
)
6306 RVCOMPARE(XmLGridCellTopBorderColor
, topBorderColor
)
6307 RVCOMPARE(XmLGridCellTopBorderType
, topBorderType
)
6308 RVCOMPARE(XmLGridCellType
, type
)
6309 RVCOMPARE(XmLGridCellUserData
, userData
)
6312 /* If the two cell values are equal, we merge them
6313 into one record here. This speeds up the sort
6314 and will allow the merge to compare just the values
6315 pointers to test equality. Note that this will not
6316 merge every possible item that could be merged, we
6317 don't want to do that because of the performance impact */
6318 if (values1
< values2
)
6319 XmLGridCellSetRefValues(cell1
, values2
);
6321 XmLGridCellSetRefValues(cell2
, values1
);
6326 SetCellRefValuesPreprocess(XmLGridWidget g
,
6332 int r
, c
, rowSpan
, colSpan
;
6333 XmLGridCell spanCell
;
6334 XmLGridCellRefValues
*oldValues
, *newValues
;
6335 unsigned char oldType
, newType
;
6336 XmLGridCallbackStruct cbs
;
6338 if (mask
& XmLGridCellType
)
6340 oldType
= XmLGridCellGetRefValues(cell
)->type
;
6341 newType
= g
->grid
.cellValues
.type
;
6342 if (oldType
!= newType
)
6344 cbs
.reason
= XmCR_FREE_VALUE
;
6345 XmLGridCellAction(cell
, (Widget
)g
, &cbs
);
6348 if (mask
& XmLGridCellRowSpan
|| mask
& XmLGridCellColumnSpan
)
6350 /* expose old cell area in case the span area shrinks */
6351 DrawArea(g
, DrawCell
, row
, col
);
6352 oldValues
= XmLGridCellGetRefValues(cell
);
6353 newValues
= &g
->grid
.cellValues
;
6354 if (mask
& XmLGridCellRowSpan
)
6356 g
->grid
.mayHaveRowSpans
= 1;
6357 if (newValues
->rowSpan
< 0)
6359 XmLWarning((Widget
)g
,
6360 "SetValues() - row span can't be < 0");
6361 newValues
->rowSpan
= 0;
6363 rowSpan
= newValues
->rowSpan
;
6366 rowSpan
= oldValues
->rowSpan
;
6367 if (mask
& XmLGridCellColumnSpan
)
6369 if (newValues
->columnSpan
< 0)
6371 XmLWarning((Widget
)g
,
6372 "SetValues() - column span can't be < 0");
6373 newValues
->columnSpan
= 0;
6375 colSpan
= newValues
->columnSpan
;
6378 colSpan
= oldValues
->columnSpan
;
6379 /* clear old span */
6380 for (c
= col
; c
<= col
+ oldValues
->columnSpan
; c
++)
6381 for (r
= row
; r
<= row
+ oldValues
->rowSpan
; r
++)
6383 /* skip the cell itself */
6384 if (c
== col
&& r
== row
)
6386 spanCell
= GetCell(g
, r
, c
);
6389 XmLGridCellSetInRowSpan(spanCell
, False
);
6390 XmLGridCellSetInColumnSpan(spanCell
, False
);
6393 for (c
= col
; c
<= col
+ colSpan
; c
++)
6394 for (r
= row
; r
<= row
+ rowSpan
; r
++)
6396 /* skip the cell itself */
6397 if (c
== col
&& r
== row
)
6399 spanCell
= GetCell(g
, r
, c
);
6403 XmLGridCellSetInColumnSpan(spanCell
, True
);
6405 XmLGridCellSetInRowSpan(spanCell
, True
);
6411 Read, Write, Copy, Paste
6415 Read(XmLGridWidget g
,
6422 char *c1
, *c2
, buf
[256], *bufp
;
6423 int r
, c
, i
, j
, len
, n
, needsResize
, allowSet
, done
;
6428 XmLGridCellRefValues
*cellValues
;
6429 XmLGridCallbackStruct cbs
;
6431 if (format
== XmFORMAT_PAD
)
6433 XmLWarning((Widget
)g
, "Read() - FORMAT_PAD not supported");
6436 if (format
== XmFORMAT_XL
||
6437 format
== XmFORMAT_DROP
||
6438 format
== XmFORMAT_PASTE
)
6449 if (!(*c2
) || *c2
== delimiter
|| *c2
== '\n')
6455 bufp
= (char *)malloc(len
+ 1);
6456 if (format
== XmFORMAT_XL
)
6458 /* strip leading and trailing double-quotes */
6459 if (len
&& c1
[0] == '"')
6464 if (len
&& c1
[len
- 1] == '"')
6468 for (i
= 0; i
< len
; i
++)
6470 if (c1
[0] == '\\' && c1
[1] == 'n')
6481 str
= XmStringCreateLtoR(bufp
, XmSTRING_DEFAULT_CHARSET
);
6484 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, r
);
6485 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, c
);
6486 cell
= GetCell(g
, r
, c
);
6488 if (cell
&& (format
== XmFORMAT_PASTE
|| format
== XmFORMAT_DROP
))
6490 cellValues
= XmLGridCellGetRefValues(cell
);
6491 if (cellValues
->type
!= XmSTRING_CELL
||
6492 cellValues
->editable
!= True
||
6493 RowPosToType(g
, r
) != XmCONTENT
||
6494 ColPosToType(g
, c
) != XmCONTENT
)
6497 if (cell
&& allowSet
)
6499 XmLGridCellSetString(cell
, str
, False
);
6500 if (SetCellValuesResize(g
, rowp
, colp
, cell
, XmLGridCellString
))
6503 DrawArea(g
, DrawCell
, r
, c
);
6504 cbs
.columnType
= ColPosToType(g
, c
);
6505 cbs
.column
= ColPosToTypePos(g
, cbs
.columnType
, c
);
6506 cbs
.rowType
= RowPosToType(g
, r
);
6507 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, r
);
6508 if (format
== XmFORMAT_PASTE
)
6510 cbs
.reason
= XmCR_CELL_PASTE
;
6511 XtCallCallbackList((Widget
)g
, g
->grid
.cellPasteCallback
,
6514 else if (format
== XmFORMAT_DROP
)
6516 cbs
.reason
= XmCR_CELL_DROP
;
6517 XtCallCallbackList((Widget
)g
, g
->grid
.cellDropCallback
,
6527 else if (*c2
== delimiter
)
6532 else if (*c2
== '\n')
6544 DrawArea(g
, DrawAll
, 0, 0);
6550 Write(XmLGridWidget g
,
6560 int r
, c
, i
, first
, last
;
6569 for (r
= row
; r
< row
+ nrow
; r
++)
6571 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, r
);
6574 if (skipHidden
== True
&& XmLGridRowIsHidden(rowp
) == True
)
6579 fprintf(file
, "\n");
6580 for (c
= col
; c
< col
+ ncol
; c
++)
6582 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, c
);
6585 if (skipHidden
== True
&& XmLGridColumnIsHidden(colp
) == True
)
6587 cell
= GetCell(g
, r
, c
);
6590 str
= XmLGridCellGetString(cell
);
6594 cs
= CvtXmStringToStr(str
);
6600 fprintf(file
, "%s", cs
);
6603 if (c
== col
+ ncol
- 1)
6605 if (!last
&& format
== XmFORMAT_DELIMITED
)
6606 fprintf(file
, "%c", delimiter
);
6607 else if (!last
&& format
== XmFORMAT_XL
)
6608 fprintf(file
, "\t");
6609 else if (format
== XmFORMAT_PAD
)
6611 if (colp
->grid
.sizePolicy
== XmVARIABLE
)
6612 for (i
= 0; i
< (int)(colp
->grid
.width
- strlen(cs
)); i
++)
6623 CopyDataCreate(XmLGridWidget g
, int selected
, int row
, int col
, int nrow
, int ncol
)
6628 char *buf
, *cs
= NULL
;
6631 int r
, c
, wroteStr
, bufsize
, buflen
, len
;
6636 nrow
= XmLArrayGetCount(g
->grid
.rowArray
);
6638 ncol
= XmLArrayGetCount(g
->grid
.colArray
);
6642 buf
= (char *)malloc(bufsize
);
6644 for (r
= row
; r
< row
+ nrow
; r
++)
6647 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, r
);
6650 for (c
= col
; c
< col
+ ncol
; c
++)
6652 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, c
);
6655 cell
= GetCell(g
, r
, c
);
6659 XmLGridRowIsSelected(rowp
) == False
&&
6660 XmLGridColumnIsSelected(colp
) == False
&&
6661 XmLGridCellIsSelected(cell
) == False
)
6663 str
= XmLGridCellGetString(cell
);
6667 cs
= CvtXmStringToStr(str
);
6674 buf
[buflen
++] = '\t';
6677 /* allocate if string plus tab plus new-line plus 0 if too large */
6678 while (len
+ buflen
+ 3 > bufsize
)
6680 buf
= (char *)realloc(buf
, bufsize
);
6681 strcpy(&buf
[buflen
], cs
);
6688 buf
[buflen
++] = '\n';
6695 buf
[buflen
- 1] = 0;
6700 Copy(XmLGridWidget g
,
6720 if (!XtIsRealized((Widget
)g
))
6722 XmLWarning((Widget
)g
, "Copy() - widget not realized");
6725 dpy
= XtDisplay((Widget
)g
);
6726 win
= XtWindow((Widget
)g
);
6727 buf
= CopyDataCreate(g
, selected
, row
, col
, nrow
, ncol
);
6730 clipStr
= XmStringCreateSimple("Grid Copy");
6731 for (i
= 0; i
< 10000; i
++)
6732 if (XmClipboardStartCopy(dpy
, win
, clipStr
, time
, NULL
,
6733 NULL
, &itemID
) == ClipboardSuccess
)
6735 XmStringFree(clipStr
);
6738 XmLWarning((Widget
)g
, "Copy() - start clipboard copy failed");
6741 for (i
= 0; i
< 10000; i
++)
6743 if (XmClipboardCopy(dpy
, win
, itemID
, "STRING", buf
,
6744 (long)strlen(buf
) + 1, 0, &dataID
) == ClipboardSuccess
)
6746 if (XmClipboardCopy(dpy
, win
, itemID
, "STRING", buf
,
6747 (long)strlen(buf
) + 1, 0, &ldataID
) == ClipboardSuccess
)
6753 XmLWarning((Widget
)g
, "Copy() - clipboard copy transfer failed");
6756 for (i
= 0; i
< 10000; i
++)
6757 if (XmClipboardEndCopy(dpy
, win
, itemID
) == ClipboardSuccess
)
6761 XmLWarning((Widget
)g
, "Copy() - end clipboard copy failed");
6768 Paste(XmLGridWidget g
,
6775 unsigned long len
, reclen
;
6778 if (!XtIsRealized((Widget
)g
))
6780 XmLWarning((Widget
)g
, "Paste() - widget not realized");
6783 dpy
= XtDisplay((Widget
)g
);
6784 win
= XtWindow((Widget
)g
);
6785 for (i
= 0; i
< 10000; i
++)
6786 if (XmClipboardInquireLength(dpy
, win
, "STRING", &len
) ==
6791 XmLWarning((Widget
)g
, "Paste() - can't retrieve clipboard length");
6796 buf
= (char *)malloc((int)len
);
6800 res
= XmClipboardRetrieve(dpy
, win
, "STRING", buf
, len
,
6804 case ClipboardSuccess
:
6807 case ClipboardTruncate
:
6808 case ClipboardNoData
:
6811 case ClipboardLocked
:
6815 if (done
!= 2 || reclen
!= len
)
6818 XmLWarning((Widget
)g
, "Paste() - retrieve from clipboard failed");
6821 Read(g
, XmFORMAT_PASTE
, 0, row
, col
, buf
);
6831 GetCoreBackground(Widget w
,
6835 value
->addr
= (caddr_t
)&w
->core
.background_pixel
;
6839 GetManagerForeground(Widget w
,
6845 g
= (XmLGridWidget
)w
;
6846 value
->addr
= (caddr_t
)&g
->manager
.foreground
;
6850 ClipRectToReg(XmLGridWidget g
,
6857 st
= g
->manager
.shadow_thickness
;
6858 if (!reg
->width
|| !reg
->height
)
6862 regRect
.x
= reg
->x
+ st
;
6863 regRect
.y
= reg
->y
+ st
;
6864 regRect
.width
= reg
->width
- st
* 2;
6865 regRect
.height
= reg
->height
- st
* 2;
6866 i
= XmLRectIntersect(rect
, ®Rect
);
6868 if (i
== XmLRectInside
)
6870 if (i
== XmLRectOutside
)
6876 if (rect
->y
+ (int)rect
->height
- 1 >= reg
->y
+ (int)reg
->height
- st
)
6877 rect
->height
= reg
->y
+ reg
->height
- rect
->y
- st
;
6878 if (rect
->x
+ (int)rect
->width
- 1 >= reg
->x
+ (int)reg
->width
- st
)
6879 rect
->width
= reg
->x
+ reg
->width
- rect
->x
- st
;
6880 if (rect
->y
< reg
->y
+ st
)
6882 rect
->height
-= (reg
->y
+ st
) - rect
->y
;
6883 rect
->y
= reg
->y
+ st
;
6885 if (rect
->x
< reg
->x
+ st
)
6887 rect
->width
-= (reg
->x
+ st
) - rect
->x
;
6888 rect
->x
= reg
->x
+ st
;
6893 FileToString(FILE *file
)
6902 s
= (char *)malloc((int)len
+ 1);
6907 n
= fread(s
, 1, (int)len
, file
);
6917 CvtXmStringToStr(XmString str
)
6919 XmStringContext context
;
6920 XmStringCharSet charset
;
6921 XmStringDirection dir
;
6926 if (!XmStringInitContext(&context
, str
))
6930 while (XmStringGetNextSegment(context
, &text
, &charset
, &dir
, &sep
))
6936 c
= (char *)malloc(size
);
6940 c
= (char *)realloc(c
, size
);
6952 XmStringFreeContext(context
);
6956 static XmLGridWidget
6957 WidgetToGrid(Widget w
,
6964 sprintf(buf
, "%s - widget not an XmLGrid", funcname
);
6968 return (XmLGridWidget
)w
;
6972 Actions, Callbacks and Handlers
6976 ButtonMotion(Widget w
,
6986 if (event
->type
!= MotionNotify
)
6988 g
= (XmLGridWidget
)w
;
6989 me
= (XMotionEvent
*)event
;
6990 if (g
->grid
.inMode
== InResize
)
6992 if (g
->grid
.resizeIsVert
)
6993 DrawResizeLine(g
, me
->y
, 0);
6996 DrawResizeLine(g
, me
->x
, 0);
6997 if (g
->grid
.hsPolicy
== XmRESIZE_IF_POSSIBLE
)
6998 ResizeColumnToFit(g
, me
->x
);
7002 /* drag scrolling */
7004 if (g
->grid
.inMode
== InSelect
)
7006 if (g
->grid
.vsPolicy
== XmCONSTANT
)
7008 y
= g
->grid
.reg
[4].y
;
7009 if (g
->grid
.selectionPolicy
== XmSELECT_CELL
&&
7010 g
->grid
.extendRow
!= -1 &&
7011 g
->grid
.extendCol
!= -1 &&
7012 RowPosToType(g
, g
->grid
.extendRow
) == XmHEADING
)
7015 dragTimerSet
|= DragUp
;
7016 y
+= g
->grid
.reg
[4].height
;
7018 dragTimerSet
|= DragDown
;
7020 if (g
->grid
.hsPolicy
== XmCONSTANT
)
7022 x
= g
->grid
.reg
[4].x
;
7023 if (g
->grid
.selectionPolicy
== XmSELECT_CELL
&&
7024 g
->grid
.extendCol
!= -1 &&
7025 g
->grid
.extendRow
!= -1 &&
7026 ColPosToType(g
, g
->grid
.extendCol
) == XmHEADING
)
7029 dragTimerSet
|= DragLeft
;
7030 x
+= g
->grid
.reg
[4].width
;
7032 dragTimerSet
|= DragRight
;
7035 if (!g
->grid
.dragTimerSet
&& dragTimerSet
)
7036 g
->grid
.dragTimerId
= XtAppAddTimeOut(XtWidgetToApplicationContext(w
),
7037 80, DragTimer
, (caddr_t
)g
);
7038 else if (g
->grid
.dragTimerSet
&& !dragTimerSet
)
7039 XtRemoveTimeOut(g
->grid
.dragTimerId
);
7040 g
->grid
.dragTimerSet
= dragTimerSet
;
7042 /* Extend Selection */
7043 if (g
->grid
.inMode
== InSelect
&& XYToRowCol(g
, me
->x
, me
->y
,
7046 TextAction(g
, TEXT_EDIT_CANCEL
);
7047 if (g
->grid
.selectionPolicy
== XmSELECT_MULTIPLE_ROW
&&
7048 RowPosToType(g
, row
) == XmCONTENT
)
7049 ExtendSelect(g
, event
, False
, row
, col
);
7050 else if (g
->grid
.selectionPolicy
== XmSELECT_CELL
)
7051 ExtendSelect(g
, event
, False
, row
, col
);
7054 if (g
->grid
.inMode
== InSelect
&&
7055 g
->grid
.selectionPolicy
== XmSELECT_BROWSE_ROW
&&
7056 XYToRowCol(g
, me
->x
, me
->y
, &row
, &col
) != -1)
7058 if (RowPosToType(g
, row
) == XmCONTENT
)
7060 if (!SetFocus(g
, row
, col
, 0, 1))
7061 SelectTypeArea(g
, SelectRow
, event
,
7062 RowPosToTypePos(g
, XmCONTENT
,
7063 g
->grid
.focusRow
), 0, True
, True
);
7069 DragTimer(XtPointer clientData
,
7070 XtIntervalId
*intervalId
)
7077 int r
, c
, min
, max
, inc
, pi
, ss
, value
, newValue
;
7080 g
= (XmLGridWidget
)clientData
;
7084 if (g
->grid
.vsPolicy
== XmCONSTANT
&& ((g
->grid
.dragTimerSet
& DragUp
) ||
7085 (g
->grid
.dragTimerSet
& DragDown
)))
7087 XtVaGetValues(g
->grid
.vsb
,
7093 XmNpageIncrement
, &pi
,
7096 if (g
->grid
.dragTimerSet
& DragUp
)
7100 if (newValue
!= value
&& newValue
>= min
&& newValue
<= (max
- ss
))
7102 XmScrollBarSetValues(g
->grid
.vsb
, newValue
, ss
, inc
, pi
, True
);
7103 r
= g
->grid
.reg
[4].row
;
7104 if (g
->grid
.dragTimerSet
& DragDown
)
7105 r
+= g
->grid
.reg
[4].nrow
- 1;
7106 /* simple check to make sure row selected is totally visible */
7107 if (g
->grid
.reg
[4].nrow
)
7109 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, r
);
7110 if (rowp
&& !RowColToXY(g
, r
, 0, True
, &rect
))
7112 if (GetRowHeight(g
, r
) != rect
.height
)
7116 if (g
->grid
.selectionPolicy
== XmSELECT_BROWSE_ROW
)
7118 if (!SetFocus(g
, r
, g
->grid
.focusCol
, -1, 1))
7119 SelectTypeArea(g
, SelectRow
, (XEvent
*)0,
7120 RowPosToTypePos(g
, XmCONTENT
, g
->grid
.focusRow
),
7123 else if (g
->grid
.selectionPolicy
== XmSELECT_MULTIPLE_ROW
)
7124 ExtendSelect(g
, (XEvent
*)0, False
, r
, g
->grid
.focusCol
);
7125 else if (g
->grid
.selectionPolicy
== XmSELECT_CELL
)
7128 extCol
= g
->grid
.extendToCol
;
7132 if (g
->grid
.hsPolicy
== XmCONSTANT
&& ((g
->grid
.dragTimerSet
& DragLeft
) ||
7133 (g
->grid
.dragTimerSet
& DragRight
)))
7135 XtVaGetValues(g
->grid
.hsb
,
7141 XmNpageIncrement
, &pi
,
7144 if (g
->grid
.dragTimerSet
& DragLeft
)
7148 if (newValue
!= value
&& newValue
>= min
&& newValue
<= (max
- ss
))
7150 XmScrollBarSetValues(g
->grid
.hsb
, newValue
, ss
, inc
, pi
, True
);
7151 c
= g
->grid
.reg
[4].col
;
7152 if (g
->grid
.dragTimerSet
& DragRight
)
7153 c
+= g
->grid
.reg
[4].ncol
- 1;
7154 if (g
->grid
.selectionPolicy
== XmSELECT_CELL
)
7156 /* simple check to make sure col selected is totally visible */
7157 if (g
->grid
.reg
[4].ncol
)
7159 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, c
);
7160 if (colp
&& !RowColToXY(g
, c
, 0, True
, &rect
))
7162 if (GetColWidth(g
, c
) != rect
.width
)
7167 extRow
= g
->grid
.extendToRow
;
7172 if (extRow
!= -1 && extCol
!= -1)
7173 ExtendSelect(g
, (XEvent
*)0, False
, extRow
, extCol
);
7174 g
->grid
.dragTimerId
= XtAppAddTimeOut(XtWidgetToApplicationContext(w
),
7175 80, DragTimer
, (caddr_t
)g
);
7178 /*----------------------------------------------------------------------*/
7180 CursorMotion(Widget w
,
7187 int isVert
, row
, col
;
7190 if (event
->type
!= MotionNotify
)
7192 g
= (XmLGridWidget
)w
;
7193 me
= (XMotionEvent
*)event
;
7194 defineCursor
= CursorNormal
;
7199 int newMotionRow
= -1;
7200 int newMotionCol
= -1;
7201 Boolean invokeEnterCellCallback
= False
;
7203 if (XYToRowCol(g
,me
->x
,me
->y
,&motionRow
,&motionCol
) != -1)
7205 if (motionRow
!= g
->grid
.lastCursorMotionRow
||
7206 motionCol
!= g
->grid
.lastCursorMotionCol
)
7208 newMotionRow
= motionRow
;
7209 newMotionCol
= motionCol
;
7211 invokeEnterCellCallback
= True
;
7215 if (g
->grid
.lastCursorMotionRow
!= -1 &&
7216 g
->grid
.lastCursorMotionCol
!= -1)
7218 /* Invoke XmNleaveCellCallback */
7219 GridInvokeCellCrossingCallbacks(w
,
7220 g
->grid
.leaveCellCallback
,
7223 g
->grid
.lastCursorMotionRow
,
7224 g
->grid
.lastCursorMotionCol
);
7227 if (invokeEnterCellCallback
)
7229 /* Invoke XmNenterCellCallback */
7230 GridInvokeCellCrossingCallbacks(w
,
7231 g
->grid
.enterCellCallback
,
7238 g
->grid
.lastCursorMotionRow
= newMotionRow
;
7239 g
->grid
.lastCursorMotionCol
= newMotionCol
;
7242 if (PosIsResize(g
, me
->x
, me
->y
, &row
, &col
, &isVert
))
7245 defineCursor
= CursorVResize
;
7247 defineCursor
= CursorHResize
;
7250 DefineCursor(g
, defineCursor
);
7252 /*----------------------------------------------------------------------*/
7261 g
= (XmLGridWidget
)XtParent(w
);
7262 TextAction(g
, TEXT_EDIT_INSERT
);
7266 EditCancel(Widget w
,
7273 g
= (XmLGridWidget
)XtParent(w
);
7274 TextAction(g
, TEXT_EDIT_CANCEL
);
7278 EditComplete(Widget w
,
7285 g
= (XmLGridWidget
)XtParent(w
);
7286 TextAction(g
, TEXT_EDIT_COMPLETE
);
7288 Traverse(w
, event
, params
, nparam
);
7292 extern Widget
_XmGetTextualDragIcon(Widget
);
7304 Atom exportTargets
[1];
7312 static XtCallbackRec dragFinish
[2] =
7313 { { DragFinish
, NULL
}, { NULL
, NULL
} };
7315 g
= (XmLGridWidget
)w
;
7316 be
= (XButtonEvent
*)event
;
7317 if (!g
->grid
.allowDrag
|| !be
)
7319 if (XYToRowCol(g
, be
->x
, be
->y
, &row
, &col
) == -1)
7321 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, row
);
7322 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, col
);
7323 cell
= GetCell(g
, row
, col
);
7324 if (!rowp
|| !colp
|| !cell
)
7326 if (XmLGridRowIsSelected(rowp
) == False
&&
7327 XmLGridColumnIsSelected(colp
) == False
&&
7328 XmLGridCellIsSelected(cell
) == False
)
7330 data
= CopyDataCreate(g
, 1, 0, 0, 0, 0);
7333 dragIcon
= _XmGetTextualDragIcon((Widget
)w
);
7334 exportTargets
[0] = XA_STRING
;
7335 dragFinish
[0].closure
= (XtPointer
)data
;
7336 XtSetArg(args
[0], XmNconvertProc
, DragConvert
);
7337 XtSetArg(args
[1], XmNexportTargets
, exportTargets
);
7338 XtSetArg(args
[2], XmNnumExportTargets
, 1);
7339 XtSetArg(args
[3], XmNdragOperations
, XmDROP_COPY
);
7340 XtSetArg(args
[4], XmNsourceCursorIcon
, dragIcon
);
7341 XtSetArg(args
[4], XmNclientData
, (XtPointer
)data
);
7342 XtSetArg(args
[5], XmNdragDropFinishCallback
, dragFinish
);
7343 XmDragStart(w
, event
, args
, 6);
7348 DragConvert(Widget w
,
7353 unsigned long *length
,
7359 Atom targetsA
, timestampA
, multipleA
, *exportTargets
;
7361 char *data
, *dataCopy
;
7363 if (!XmIsDragContext(w
))
7365 targetsA
= XInternAtom(XtDisplay(w
), "TARGETS", FALSE
);
7366 timestampA
= XInternAtom(XtDisplay(w
), "TIMESTAMP", FALSE
);
7367 multipleA
= XInternAtom(XtDisplay(w
), "MULTIPLE", FALSE
);
7368 if (*target
== targetsA
)
7371 exportTargets
= (Atom
*)XtMalloc(sizeof(Atom
) * n
);
7372 exportTargets
[0] = XA_STRING
;
7373 exportTargets
[1] = targetsA
;
7374 exportTargets
[2] = multipleA
;
7375 exportTargets
[3] = timestampA
;
7377 *value
= (XtPointer
)exportTargets
;
7379 *length
= (n
* sizeof(Atom
)) >> 2;
7382 else if (*target
== XA_STRING
)
7384 XtVaGetValues(w
, XmNclientData
, &data
, NULL
);
7386 dataCopy
= XtMalloc(strlen(data
));
7387 strncpy(dataCopy
, data
, strlen(data
));
7388 *value
= (XtPointer
)dataCopy
;
7389 *length
= strlen(data
);
7398 DragFinish(Widget w
,
7399 XtPointer clientData
,
7402 free ((char *)clientData
);
7406 DropRegister(XmLGridWidget g
, Boolean set
)
7409 Atom importTargets
[1];
7414 importTargets
[0] = XA_STRING
;
7415 XtSetArg(args
[0], XmNdropSiteOperations
, XmDROP_COPY
);
7416 XtSetArg(args
[1], XmNimportTargets
, importTargets
);
7417 XtSetArg(args
[2], XmNnumImportTargets
, 1);
7418 XtSetArg(args
[3], XmNdropProc
, DropStart
);
7419 XmDropSiteRegister((Widget
)g
, args
, 4);
7422 XmDropSiteUnregister((Widget
)g
);
7428 XtPointer clientData
,
7433 XmDropProcCallbackStruct
*cbs
;
7434 XmDropTransferEntryRec te
[2];
7435 Atom
*exportTargets
;
7437 int row
, col
, i
, n
, valid
;
7439 g
= (XmLGridWidget
)w
;
7440 cbs
= (XmDropProcCallbackStruct
*)callData
;
7441 if (g
->grid
.allowDrop
== False
|| cbs
->dropAction
== XmDROP_HELP
)
7443 cbs
->dropSiteStatus
= XmINVALID_DROP_SITE
;
7447 if (XYToRowCol(g
, cbs
->x
, cbs
->y
, &row
, &col
) != -1 &&
7448 cbs
->dropAction
== XmDROP
&& cbs
->operation
== XmDROP_COPY
)
7450 XtVaGetValues(cbs
->dragContext
,
7451 XmNexportTargets
, &exportTargets
,
7452 XmNnumExportTargets
, &n
,
7454 for (i
= 0; i
< n
; i
++)
7455 if (exportTargets
[i
] == XA_STRING
)
7460 cbs
->operation
= (long)XmDROP_NOOP
;
7461 cbs
->dropSiteStatus
= XmINVALID_DROP_SITE
;
7462 XtSetArg(args
[0], XmNtransferStatus
, XmTRANSFER_FAILURE
);
7463 XtSetArg(args
[1], XmNnumDropTransfers
, 0);
7464 XmDropTransferStart(cbs
->dragContext
, args
, 2);
7467 g
->grid
.dropLoc
.row
= row
;
7468 g
->grid
.dropLoc
.col
= col
;
7469 cbs
->operation
= (long)XmDROP_COPY
;
7470 te
[0].target
= XA_STRING
;
7471 te
[0].client_data
= (XtPointer
)g
;
7472 XtSetArg(args
[0], XmNdropTransfers
, te
);
7473 XtSetArg(args
[1], XmNnumDropTransfers
, 1);
7474 XtSetArg(args
[2], XmNtransferProc
, DropTransfer
);
7475 XmDropTransferStart(cbs
->dragContext
, args
, 3);
7480 DropTransfer(Widget w
,
7481 XtPointer clientData
,
7485 unsigned long *length
,
7495 g
= (XmLGridWidget
)clientData
;
7499 buf
= (char *)malloc(len
+ 1);
7500 strncpy(buf
, (char *)value
, len
);
7501 XtFree((char *)value
);
7503 Read(g
, XmFORMAT_DROP
, 0, g
->grid
.dropLoc
.row
, g
->grid
.dropLoc
.col
, buf
);
7517 static XrmQuark qACTIVATE
, qBEGIN
, qEXTEND
, qEND
;
7518 static XrmQuark qTOGGLE
;
7519 static int quarksValid
= 0;
7522 int row
, col
, resizeRow
, resizeCol
;
7528 XmLGridCallbackStruct cbs
;
7535 g
= (XmLGridWidget
)w
;
7537 g
= (XmLGridWidget
)XtParent(w
);
7542 qACTIVATE
= XrmStringToQuark("ACTIVATE");
7543 qBEGIN
= XrmStringToQuark("BEGIN");
7544 qEXTEND
= XrmStringToQuark("EXTEND");
7545 qEND
= XrmStringToQuark("END");
7546 qTOGGLE
= XrmStringToQuark("TOGGLE");
7548 q
= XrmStringToQuark(params
[0]);
7550 if (event
->type
== KeyPress
|| event
->type
== KeyRelease
)
7552 row
= g
->grid
.focusRow
;
7553 col
= g
->grid
.focusCol
;
7557 be
= (XButtonEvent
*)event
;
7558 if (XYToRowCol(g
, be
->x
, be
->y
, &row
, &col
) == -1)
7565 /* double click activate check */
7566 if (q
== qBEGIN
&& be
)
7568 if (row
!= -1 && col
!= -1
7569 && row
== g
->grid
.focusRow
&& col
== g
->grid
.focusCol
7572 int doubleClickTime
= XtGetMultiClickTime(dpy
);
7573 Time timeSinceLastClick
= be
->time
- g
->grid
.lastSelectTime
;
7574 if (timeSinceLastClick
< doubleClickTime
)
7576 /* Clear inplace editing if some other event happens */
7577 if (g
->grid
.editTimerSet
)
7579 XtRemoveTimeOut(g
->grid
.editTimerId
);
7580 g
->grid
.editTimerSet
= 0;
7583 /* Second click came within double click time */
7586 else if (!g
->grid
.editTimerSet
&& g
->grid
.lastSelectTime
!= 0)
7588 /* Only begin an edit when we are sure we don't
7589 * have a double click
7591 if (!g
->grid
.singleClickActivation
) {
7592 g
->grid
.editTimerId
=
7593 XtAppAddTimeOut(XtWidgetToApplicationContext(w
),
7594 doubleClickTime
*2, EditTimer
, (caddr_t
)g
);
7595 g
->grid
.editTimerSet
= 1;
7599 g
->grid
.lastSelectRow
= row
;
7600 g
->grid
.lastSelectCol
= col
;
7601 g
->grid
.lastSelectTime
= be
->time
;
7603 else if (q
== qBEGIN
)
7604 g
->grid
.lastSelectTime
= 0;
7606 if (q
== qBEGIN
&& be
&& PosIsResize(g
, be
->x
, be
->y
,
7607 &resizeRow
, &resizeCol
, &isVert
))
7609 g
->grid
.resizeIsVert
= isVert
;
7610 g
->grid
.inMode
= InResize
;
7611 g
->grid
.resizeLineXY
= -1;
7612 g
->grid
.resizeRow
= resizeRow
;
7613 g
->grid
.resizeCol
= resizeCol
;
7616 DrawResizeLine(g
, be
->y
, 0);
7617 DefineCursor(g
, CursorVResize
);
7621 DrawResizeLine(g
, be
->x
, 0);
7622 DefineCursor(g
, CursorHResize
);
7625 else if (q
== qBEGIN
|| q
== qEXTEND
|| q
== qTOGGLE
)
7627 if (g
->grid
.inMode
!= InNormal
)
7629 if (row
== -1 || col
== -1)
7631 if (RowPosToType(g
, row
) == XmCONTENT
&&
7632 ColPosToType(g
, col
) == XmCONTENT
)
7634 TextAction(g
, TEXT_EDIT_COMPLETE
);
7637 SetFocus(g
, row
, col
, 0, 1);
7638 ExtendSelect(g
, event
, False
, -1, -1);
7640 XmProcessTraversal(g
->grid
.text
, XmTRAVERSE_CURRENT
);
7642 if (g
->grid
.selectionPolicy
== XmSELECT_MULTIPLE_ROW
&&
7643 RowPosToType(g
, row
) == XmCONTENT
)
7646 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, row
);
7648 /* Don't want single click to unselect something. -slamm */
7649 if (q
== qBEGIN
&& rowp
&& XmLGridRowIsSelected(rowp
) == True
)
7651 #endif /* 0 -slamm */
7652 if (q
== qTOGGLE
&& rowp
&& XmLGridRowIsSelected(rowp
) == True
)
7655 SelectTypeArea(g
, SelectRow
, event
, -1, 0, False
, True
);
7656 if (be
&& q
== qEXTEND
)
7657 ExtendSelect(g
, event
, False
, row
, col
);
7659 SelectTypeArea(g
, SelectRow
, event
,
7660 RowPosToTypePos(g
, XmCONTENT
, row
), 0, flag
, True
);
7662 if (g
->grid
.selectionPolicy
== XmSELECT_CELL
)
7666 SelectTypeArea(g
, SelectCell
, event
, -1, -1, False
, True
);
7667 SelectTypeArea(g
, SelectRow
, event
, -1, 0, False
, True
);
7668 SelectTypeArea(g
, SelectCol
, event
, 0, -1, False
, True
);
7670 else if (q
== qTOGGLE
)
7671 ExtendSelect(g
, event
, False
, -1, -1);
7672 if (RowPosToType(g
, row
) == XmFOOTER
||
7673 ColPosToType(g
, col
) == XmFOOTER
)
7674 ExtendSelect(g
, event
, False
, -1, -1);
7675 if (be
&& q
== qEXTEND
)
7676 ExtendSelect(g
, event
, False
, row
, col
);
7677 else if (RowPosToType(g
, row
) == XmCONTENT
&&
7678 ColPosToType(g
, col
) == XmCONTENT
)
7681 cellp
= GetCell(g
, row
, col
);
7682 if (q
== qTOGGLE
&& cellp
&&
7683 XmLGridCellIsSelected(cellp
) == True
)
7685 SelectTypeArea(g
, SelectCell
, event
,
7686 RowPosToTypePos(g
, XmCONTENT
, row
),
7687 ColPosToTypePos(g
, XmCONTENT
, col
), flag
, True
);
7689 else if (RowPosToType(g
, row
) == XmHEADING
&&
7690 ColPosToType(g
, col
) == XmCONTENT
)
7694 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, col
);
7695 if (colp
&& XmLGridColumnIsSelected(colp
) == True
)
7696 g
->grid
.extendSelect
= False
;
7698 ExtendSelect(g
, event
, True
, row
, col
);
7700 else if (ColPosToType(g
, col
) == XmHEADING
&&
7701 RowPosToType(g
, row
) == XmCONTENT
)
7705 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, row
);
7706 if (rowp
&& XmLGridRowIsSelected(rowp
) == True
)
7707 g
->grid
.extendSelect
= False
;
7709 ExtendSelect(g
, event
, True
, row
, col
);
7712 if (g
->grid
.selectionPolicy
== XmSELECT_SINGLE_ROW
&&
7713 RowPosToType(g
, row
) == XmCONTENT
)
7716 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, row
);
7717 if (rowp
&& XmLGridRowIsSelected(rowp
) == True
)
7719 SelectTypeArea(g
, SelectRow
, event
,
7720 RowPosToTypePos(g
, XmCONTENT
, row
), 0, flag
, True
);
7722 if (g
->grid
.selectionPolicy
== XmSELECT_BROWSE_ROW
&&
7723 RowPosToType(g
, row
) == XmCONTENT
)
7724 SelectTypeArea(g
, SelectRow
, event
,
7725 RowPosToTypePos(g
, XmCONTENT
, row
), 0, True
, True
);
7726 if (g
->grid
.selectionPolicy
== XmSELECT_NONE
||
7727 (g
->grid
.selectionPolicy
== XmSELECT_BROWSE_ROW
&&
7728 RowPosToType(g
, row
) != XmCONTENT
) ||
7729 (g
->grid
.selectionPolicy
== XmSELECT_SINGLE_ROW
&&
7730 RowPosToType(g
, row
) != XmCONTENT
) ||
7731 (g
->grid
.selectionPolicy
== XmSELECT_MULTIPLE_ROW
&&
7732 RowPosToType(g
, row
) != XmCONTENT
) )
7734 cbs
.reason
= XmCR_SELECT_CELL
;
7736 cbs
.columnType
= ColPosToType(g
, col
);
7737 cbs
.column
= ColPosToTypePos(g
, cbs
.columnType
, col
);
7738 cbs
.rowType
= RowPosToType(g
, row
);
7739 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, row
);
7740 XtCallCallbackList((Widget
)g
, g
->grid
.selectCallback
,
7743 g
->grid
.inMode
= InSelect
;
7745 else if (q
== qEND
&& g
->grid
.inMode
== InResize
)
7747 int r
, c
, width
, height
;
7748 r
= g
->grid
.resizeRow
;
7749 c
= g
->grid
.resizeCol
;
7750 g
->grid
.resizeRow
= -1;
7751 g
->grid
.resizeCol
= -1;
7752 if (!RowColToXY(g
, r
, c
, False
, &rect
))
7754 if (g
->grid
.resizeIsVert
)
7756 cbs
.rowType
= RowPosToType(g
, r
);
7757 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, r
);
7759 if (g
->grid
.resizeLineXY
> rect
.y
)
7760 height
= g
->grid
.resizeLineXY
- rect
.y
-
7761 (rect
.height
- GetRowHeight(g
, r
));
7762 if (height
< 6 && g
->grid
.allowRowHide
== False
)
7764 XtVaSetValues((Widget
)g
,
7765 XmNrowType
, cbs
.rowType
,
7767 XmNrowHeight
, height
,
7768 XmNrowSizePolicy
, XmCONSTANT
,
7770 cbs
.reason
= XmCR_RESIZE_ROW
;
7774 cbs
.columnType
= ColPosToType(g
, c
);
7775 cbs
.column
= ColPosToTypePos(g
, cbs
.columnType
, c
);
7777 if (g
->grid
.resizeLineXY
> rect
.x
)
7778 width
= g
->grid
.resizeLineXY
- rect
.x
-
7779 (rect
.width
- GetColWidth(g
, c
));
7780 if (width
< 6 && g
->grid
.allowColHide
== False
)
7782 XtVaSetValues((Widget
)g
,
7783 XmNcolumnType
, cbs
.columnType
,
7784 XmNcolumn
, cbs
.column
,
7785 XmNcolumnWidth
, width
,
7786 XmNcolumnSizePolicy
, XmCONSTANT
,
7788 cbs
.reason
= XmCR_RESIZE_COLUMN
;
7791 XtCallCallbackList((Widget
)g
, g
->grid
.resizeCallback
,
7794 DrawResizeLine(g
, 0, 2);
7795 DefineCursor(g
, CursorNormal
);
7796 g
->grid
.inMode
= InNormal
;
7800 g
->grid
.inMode
= InNormal
;
7801 if (g
->grid
.dragTimerSet
)
7802 XtRemoveTimeOut(g
->grid
.dragTimerId
);
7803 g
->grid
.dragTimerSet
= 0;
7805 /* XFE Additions to handle button up events in menus - they generate activate events */
7807 if (XmIsMenuShell(XmLShellOfWidget((Widget
)g
)))
7809 cbs
.reason
= XmCR_ACTIVATE
;
7811 cbs
.columnType
= ColPosToType(g
, col
);
7812 cbs
.column
= ColPosToTypePos(g
, cbs
.columnType
, col
);
7813 cbs
.rowType
= RowPosToType(g
, row
);
7814 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, row
);
7815 XtCallCallbackList((Widget
)g
, g
->grid
.activateCallback
,
7820 if (q
== qBEGIN
&& g
->grid
.singleClickActivation
) {
7821 cbs
.reason
= XmCR_ACTIVATE
;
7823 cbs
.columnType
= ColPosToType(g
, col
);
7824 cbs
.column
= ColPosToTypePos(g
, cbs
.columnType
, col
);
7825 cbs
.rowType
= RowPosToType(g
, row
);
7826 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, row
);
7827 XtCallCallbackList((Widget
)g
, g
->grid
.activateCallback
,
7832 cbs
.reason
= XmCR_ACTIVATE
;
7834 cbs
.columnType
= ColPosToType(g
, col
);
7835 cbs
.column
= ColPosToTypePos(g
, cbs
.columnType
, col
);
7836 cbs
.rowType
= RowPosToType(g
, row
);
7837 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, row
);
7838 XtCallCallbackList((Widget
)g
, g
->grid
.activateCallback
,
7844 * Selection policy when posting a context menu.
7845 * If over a current selection, leave the selection alone.
7846 * Otherwise, change the selection the same as Select(),
7847 * except do not allow dragging to extend the selection.
7850 PopupSelect(Widget w
,
7859 XmLGridCallbackStruct cbs
;
7865 g
= (XmLGridWidget
)w
;
7867 g
= (XmLGridWidget
)XtParent(w
);
7870 if (event
->type
== KeyPress
|| event
->type
== KeyRelease
)
7872 row
= g
->grid
.focusRow
;
7873 col
= g
->grid
.focusCol
;
7877 be
= (XButtonEvent
*)event
;
7878 if (XYToRowCol(g
, be
->x
, be
->y
, &row
, &col
) == -1)
7884 if (RowPosToType(g
, row
) == XmCONTENT
)
7887 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, row
);
7888 if (rowp
&& !XmLGridRowIsSelected(rowp
))
7890 String end_params
[1];
7891 end_params
[0] = "END";
7892 Select(w
, event
, params
, nparam
);
7893 Select(w
, event
, end_params
, nparam
);
7896 if (XtHasCallbacks(w
, XmNpopupCallback
) == XtCallbackHasSome
)
7898 cbs
.reason
= XmCR_SHOW_POPUP
;
7900 cbs
.columnType
= ColPosToType(g
, col
);
7901 cbs
.column
= ColPosToTypePos(g
, cbs
.columnType
, col
);
7902 cbs
.rowType
= RowPosToType(g
, row
);
7903 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, row
);
7904 XtCallCallbackList((Widget
)g
, g
->grid
.popupCallback
,
7916 static XrmQuark qDOWN
, qEXTEND_DOWN
, qEXTEND_LEFT
;
7917 static XrmQuark qEXTEND_PAGE_DOWN
, qEXTEND_PAGE_LEFT
;
7918 static XrmQuark qEXTEND_PAGE_RIGHT
, qEXTEND_PAGE_UP
;
7919 static XrmQuark qEXTEND_RIGHT
, qEXTEND_UP
, qLEFT
, qPAGE_DOWN
;
7920 static XrmQuark qPAGE_LEFT
, qPAGE_RIGHT
, qPAGE_UP
, qRIGHT
;
7921 static XrmQuark qTO_BOTTOM
, qTO_BOTTOM_RIGHT
, qTO_LEFT
;
7922 static XrmQuark qTO_RIGHT
, qTO_TOP
, qTO_TOP_LEFT
, qUP
;
7923 static int quarksValid
= 0;
7924 int extend
, focusRow
, focusCol
, rowDir
, colDir
;
7925 int rowLoc
, colLoc
, prevRowLoc
, prevColLoc
;
7926 int scrollRow
, scrollCol
, prevScrollRow
, prevScrollCol
;
7929 g
= (XmLGridWidget
)XtParent(w
);
7934 qDOWN
= XrmStringToQuark("DOWN");
7935 qEXTEND_DOWN
= XrmStringToQuark("EXTEND_DOWN");
7936 qEXTEND_LEFT
= XrmStringToQuark("EXTEND_LEFT");
7937 qEXTEND_PAGE_DOWN
= XrmStringToQuark("EXTEND_PAGE_DOWN");
7938 qEXTEND_PAGE_LEFT
= XrmStringToQuark("EXTEND_PAGE_LEFT");
7939 qEXTEND_PAGE_RIGHT
= XrmStringToQuark("EXTEND_PAGE_RIGHT");
7940 qEXTEND_PAGE_UP
= XrmStringToQuark("EXTEND_PAGE_UP");
7941 qEXTEND_RIGHT
= XrmStringToQuark("EXTEND_RIGHT");
7942 qEXTEND_UP
= XrmStringToQuark("EXTEND_UP");
7943 qLEFT
= XrmStringToQuark("LEFT");
7944 qPAGE_DOWN
= XrmStringToQuark("PAGE_DOWN");
7945 qPAGE_LEFT
= XrmStringToQuark("PAGE_LEFT");
7946 qPAGE_RIGHT
= XrmStringToQuark("PAGE_RIGHT");
7947 qPAGE_UP
= XrmStringToQuark("PAGE_UP");
7948 qRIGHT
= XrmStringToQuark("RIGHT");
7949 qTO_BOTTOM
= XrmStringToQuark("TO_BOTTOM");
7950 qTO_BOTTOM_RIGHT
= XrmStringToQuark("TO_BOTTOM_RIGHT");
7951 qTO_LEFT
= XrmStringToQuark("TO_LEFT");
7952 qTO_RIGHT
= XrmStringToQuark("TO_RIGHT");
7953 qTO_TOP
= XrmStringToQuark("TO_TOP");
7954 qTO_TOP_LEFT
= XrmStringToQuark("TO_TOP_LEFT");
7955 qUP
= XrmStringToQuark("UP");
7958 q
= XrmStringToQuark(params
[0]);
7960 /* map the extends to their counterparts and set extend flag */
7961 if (q
== qEXTEND_DOWN
)
7966 else if (q
== qEXTEND_LEFT
)
7971 else if (q
== qEXTEND_PAGE_DOWN
)
7976 else if (q
== qEXTEND_PAGE_LEFT
)
7981 else if (q
== qEXTEND_PAGE_RIGHT
)
7986 else if (q
== qEXTEND_PAGE_UP
)
7991 else if (q
== qEXTEND_RIGHT
)
7996 else if (q
== qEXTEND_UP
)
8001 if (extend
&& g
->grid
.selectionPolicy
!= XmSELECT_MULTIPLE_ROW
&&
8002 g
->grid
.selectionPolicy
!= XmSELECT_CELL
)
8004 if (extend
&& g
->grid
.extendRow
!= -1 && g
->grid
.extendCol
!= -1)
8006 focusRow
= g
->grid
.extendToRow
;
8007 focusCol
= g
->grid
.extendToCol
;
8011 focusRow
= g
->grid
.focusRow
;
8012 focusCol
= g
->grid
.focusCol
;
8016 if (focusRow
< g
->grid
.topFixedCount
)
8018 else if (focusRow
>= XmLArrayGetCount(g
->grid
.rowArray
) -
8019 g
->grid
.bottomFixedCount
)
8023 if (focusCol
< g
->grid
.leftFixedCount
)
8025 else if (focusCol
>= XmLArrayGetCount(g
->grid
.colArray
) -
8026 g
->grid
.rightFixedCount
)
8030 /* calculate new focus row, col and walk direction */
8036 else if (q
== qLEFT
)
8041 else if (q
== qPAGE_DOWN
)
8043 if (prevRowLoc
== 1)
8044 focusRow
= g
->grid
.reg
[4].row
+ g
->grid
.reg
[4].nrow
- 1;
8045 if (focusRow
== g
->grid
.focusRow
)
8049 else if (q
== qPAGE_LEFT
)
8051 if (prevColLoc
== 1)
8052 focusCol
= g
->grid
.reg
[4].col
- 1;
8053 if (focusCol
== g
->grid
.focusCol
)
8057 else if (q
== qPAGE_RIGHT
)
8059 if (prevColLoc
== 1)
8060 focusCol
= g
->grid
.reg
[4].col
+ g
->grid
.reg
[4].ncol
- 1;
8061 if (focusCol
== g
->grid
.focusCol
)
8065 else if (q
== qPAGE_UP
)
8067 if (prevRowLoc
== 1)
8068 focusRow
= g
->grid
.reg
[4].row
- 1;
8069 if (focusRow
== g
->grid
.focusRow
)
8073 else if (q
== qRIGHT
)
8078 else if (q
== qTO_BOTTOM
)
8080 focusRow
= XmLArrayGetCount(g
->grid
.rowArray
) - 1;
8083 else if (q
== qTO_BOTTOM_RIGHT
)
8085 focusCol
= XmLArrayGetCount(g
->grid
.colArray
) - 1;
8086 focusRow
= XmLArrayGetCount(g
->grid
.rowArray
) - 1;
8090 else if (q
== qTO_LEFT
)
8095 else if (q
== qTO_RIGHT
)
8097 focusCol
= XmLArrayGetCount(g
->grid
.colArray
) - 1;
8100 else if (q
== qTO_TOP
)
8105 else if (q
== qTO_TOP_LEFT
)
8117 if (!rowDir
&& !colDir
)
8121 if (FindNextFocus(g
, focusRow
, focusCol
, rowDir
, colDir
,
8122 &focusRow
, &focusCol
) == -1)
8124 ExtendSelect(g
, event
, False
, focusRow
, focusCol
);
8128 if (SetFocus(g
, focusRow
, focusCol
, rowDir
, colDir
) == -1)
8130 ExtendSelect(g
, event
, False
, -1, -1);
8131 focusRow
= g
->grid
.focusRow
;
8132 focusCol
= g
->grid
.focusCol
;
8133 if (g
->grid
.selectionPolicy
== XmSELECT_CELL
)
8135 SelectTypeArea(g
, SelectRow
, event
, -1, 0, False
, True
);
8136 SelectTypeArea(g
, SelectCol
, event
, 0, -1, False
, True
);
8137 SelectTypeArea(g
, SelectCell
, event
, -1, -1, False
, True
);
8138 SelectTypeArea(g
, SelectCell
, event
,
8139 RowPosToTypePos(g
, XmCONTENT
, focusRow
),
8140 ColPosToTypePos(g
, XmCONTENT
, focusCol
),
8143 else if (g
->grid
.selectionPolicy
== XmSELECT_BROWSE_ROW
)
8144 SelectTypeArea(g
, SelectRow
, event
,
8145 RowPosToTypePos(g
, XmCONTENT
, focusRow
), 0, True
, True
);
8150 scrollRow
= ScrollRowBottomPos(g
, focusRow
);
8151 else if (q
== qPAGE_DOWN
)
8152 scrollRow
= focusRow
;
8153 else if (q
== qPAGE_LEFT
)
8154 scrollCol
= ScrollColRightPos(g
, focusCol
);
8155 else if (q
== qPAGE_RIGHT
)
8156 scrollCol
= focusCol
;
8159 if (focusRow
< g
->grid
.topFixedCount
)
8161 else if (focusRow
>= XmLArrayGetCount(g
->grid
.rowArray
) -
8162 g
->grid
.bottomFixedCount
)
8166 if (prevRowLoc
!= 0 && rowLoc
== 0)
8167 scrollRow
= g
->grid
.reg
[0].nrow
;
8168 else if (prevRowLoc
!= 2 && rowLoc
== 2)
8169 scrollRow
= g
->grid
.reg
[6].row
- 1;
8171 if (focusCol
< g
->grid
.leftFixedCount
)
8173 else if (focusCol
>= XmLArrayGetCount(g
->grid
.colArray
) -
8174 g
->grid
.rightFixedCount
)
8178 if (prevColLoc
!= 0 && colLoc
== 0)
8179 scrollCol
= g
->grid
.reg
[0].ncol
;
8180 else if (prevColLoc
!= 2 && colLoc
== 2)
8181 scrollCol
= g
->grid
.reg
[2].col
- 1;
8183 if (g
->grid
.vsPolicy
== XmVARIABLE
)
8185 else if (scrollRow
!= -1)
8187 prevScrollRow
= g
->grid
.scrollRow
;
8188 g
->grid
.scrollRow
= scrollRow
;
8190 if (g
->grid
.scrollRow
!= prevScrollRow
)
8191 DrawArea(g
, DrawVScroll
, 0, 0);
8194 MakeRowVisible(g
, focusRow
);
8195 if (g
->grid
.hsPolicy
== XmVARIABLE
)
8197 else if (scrollCol
!= -1)
8199 prevScrollCol
= g
->grid
.scrollCol
;
8200 g
->grid
.scrollCol
= scrollCol
;
8202 if (g
->grid
.scrollCol
!= prevScrollCol
)
8203 DrawArea(g
, DrawHScroll
, 0, 0);
8206 MakeColVisible(g
, focusCol
);
8210 TextActivate(Widget w
,
8211 XtPointer clientData
,
8215 XmAnyCallbackStruct
*cbs
;
8219 cbs
= (XmAnyCallbackStruct
*)callData
;
8220 g
= (XmLGridWidget
)XtParent(w
);
8224 EditComplete(w
, cbs
->event
, params
, &nparam
);
8228 params
[0] = "ACTIVATE";
8230 Select(XtParent(w
), cbs
->event
, params
, &nparam
);
8236 XtPointer clientData
,
8240 XmAnyCallbackStruct
*cbs
;
8241 int focusRow
, focusCol
;
8243 cbs
= (XmAnyCallbackStruct
*)callData
;
8244 g
= (XmLGridWidget
)XtParent(w
);
8245 if (cbs
->reason
== XmCR_FOCUS
)
8246 g
->grid
.focusIn
= 1;
8248 g
->grid
.focusIn
= 0;
8249 focusRow
= g
->grid
.focusRow
;
8250 focusCol
= g
->grid
.focusCol
;
8251 if (focusRow
!= -1 && focusCol
!= -1)
8253 if (g
->grid
.highlightRowMode
== True
)
8254 DrawArea(g
, DrawRow
, focusRow
, 0);
8256 DrawArea(g
, DrawCell
, focusRow
, focusCol
);
8261 TextMapped(Widget w
,
8262 XtPointer clientData
,
8268 g
= (XmLGridWidget
)(XtParent(w
));
8269 if (event
->type
!= MapNotify
)
8271 if (g
->grid
.textHidden
)
8272 XtUnmapWidget(g
->grid
.text
);
8276 TextModifyVerify(Widget w
,
8277 XtPointer clientData
,
8281 XmTextVerifyCallbackStruct
*cbs
;
8283 g
= (XmLGridWidget
)XtParent(w
);
8284 cbs
= (XmTextVerifyCallbackStruct
*)callData
;
8285 if (!cbs
->event
|| g
->grid
.ignoreModifyVerify
|| g
->grid
.inEdit
)
8287 TextAction(g
, TEXT_EDIT
);
8288 if (!g
->grid
.inEdit
)
8297 XmLGridRow
XmLGridRowNew(Widget grid
)
8299 return XmLGridClassPartOfWidget(grid
).rowNewProc(grid
);
8302 /* Only to be called through Grid class */
8304 _GridRowNew(Widget grid
)
8310 g
= (XmLGridWidget
)grid
;
8311 size
= XmLGridClassPartOfWidget(grid
).rowRecSize
;
8312 row
= (XmLGridRow
)malloc(size
);
8313 row
->grid
.grid
= grid
;
8314 row
->grid
.heightInPixels
= 0;
8315 row
->grid
.heightInPixelsValid
= 0;
8316 row
->grid
.height
= 1;
8317 row
->grid
.selected
= False
;
8318 row
->grid
.sizePolicy
= XmVARIABLE
;
8319 row
->grid
.userData
= 0;
8320 row
->grid
.cellArray
= XmLArrayNew(0, 0);
8325 XmLGridRowFree(Widget grid
,
8328 XmLGridClassPartOfWidget(grid
).rowFreeProc(row
);
8331 /* Only to be called through Grid class */
8333 _GridRowFree(XmLGridRow row
)
8337 count
= XmLArrayGetCount(row
->grid
.cellArray
);
8338 for (i
= 0; i
< count
; i
++)
8339 XmLGridCellFree(row
->grid
.grid
,
8340 (XmLGridCell
)XmLArrayGet(row
->grid
.cellArray
, i
));
8341 XmLArrayFree(row
->grid
.cellArray
);
8346 XmLArray
XmLGridRowCells(XmLGridRow row
)
8348 return row
->grid
.cellArray
;
8352 XmLGridRowGetPos(XmLGridRow row
)
8354 return row
->grid
.pos
;
8358 XmLGridRowGetVisPos(XmLGridRow row
)
8360 return row
->grid
.visPos
;
8364 XmLGridRowIsHidden(XmLGridRow row
)
8366 if (!row
->grid
.height
)
8372 XmLGridRowIsSelected(XmLGridRow row
)
8374 return row
->grid
.selected
;
8378 XmLGridRowSetSelected(XmLGridRow row
,
8381 row
->grid
.selected
= selected
;
8385 XmLGridRowSetVisPos(XmLGridRow row
,
8388 row
->grid
.visPos
= visPos
;
8392 XmLGridRowHeightInPixels(XmLGridRow row
)
8395 Dimension height
, maxHeight
;
8398 XmLGridCallbackStruct cbs
;
8399 XmLGridCellRefValues
*cellValues
;
8401 if (row
->grid
.sizePolicy
== XmCONSTANT
)
8402 return row
->grid
.height
;
8403 if (!row
->grid
.height
)
8405 if (!row
->grid
.heightInPixelsValid
)
8407 g
= (XmLGridWidget
)row
->grid
.grid
;
8408 count
= XmLArrayGetCount(row
->grid
.cellArray
);
8411 cellValues
= g
->grid
.defCellValues
;
8412 maxHeight
= 4 + row
->grid
.height
* cellValues
->fontHeight
+
8413 cellValues
->topMargin
+ cellValues
->bottomMargin
;
8417 for (i
= 0; i
< count
; i
++)
8419 cell
= (XmLGridCell
)XmLArrayGet(row
->grid
.cellArray
, i
);
8420 cbs
.reason
= XmCR_PREF_HEIGHT
;
8421 cbs
.rowType
= RowPosToType(g
, row
->grid
.pos
);
8422 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, row
->grid
.pos
);
8423 cbs
.columnType
= ColPosToType(g
, i
);
8424 cbs
.column
= ColPosToTypePos(g
, cbs
.columnType
, i
);
8425 cbs
.object
= (void *)row
;
8426 height
= XmLGridCellAction(cell
, (Widget
)g
, &cbs
);
8427 if (height
> maxHeight
)
8430 row
->grid
.heightInPixels
= maxHeight
;
8431 row
->grid
.heightInPixelsValid
= 1;
8433 return row
->grid
.heightInPixels
;
8437 XmLGridRowHeightChanged(XmLGridRow row
)
8439 row
->grid
.heightInPixelsValid
= 0;
8446 static XmLGridColumn
8447 XmLGridColumnNew(Widget grid
)
8449 return XmLGridClassPartOfWidget(grid
).columnNewProc(grid
);
8452 /* Only to be called through Grid class */
8453 static XmLGridColumn
8454 _GridColumnNew(Widget grid
)
8457 XmLGridColumn column
;
8460 g
= (XmLGridWidget
)grid
;
8461 size
= XmLGridClassPartOfWidget(grid
).columnRecSize
;
8462 column
= (XmLGridColumn
)malloc(size
);
8463 column
->grid
.grid
= grid
;
8464 column
->grid
.widthInPixels
= 0;
8465 column
->grid
.widthInPixelsValid
= 0;
8466 column
->grid
.defCellValues
= 0;
8467 column
->grid
.selected
= False
;
8468 column
->grid
.sizePolicy
= XmVARIABLE
;
8469 column
->grid
.width
= 8;
8470 column
->grid
.userData
= 0;
8471 column
->grid
.resizable
= True
;
8472 column
->grid
.hidden
= 0;
8477 XmLGridColumnFree(Widget grid
,
8478 XmLGridColumn column
)
8480 XmLGridClassPartOfWidget(grid
).columnFreeProc(column
);
8483 /* Only to be called through Grid class */
8485 _GridColumnFree(XmLGridColumn column
)
8487 if (column
->grid
.defCellValues
)
8488 XmLGridCellDerefValues(column
->grid
.defCellValues
);
8489 free((char *)column
);
8493 XmLGridColumnGetPos(XmLGridColumn column
)
8495 return column
->grid
.pos
;
8499 XmLGridColumnGetVisPos(XmLGridColumn column
)
8501 return column
->grid
.visPos
;
8505 XmLGridColumnIsHidden(XmLGridColumn column
)
8507 return column
->grid
.width
== 0
8508 || column
->grid
.hidden
;
8512 XmLGridColumnIsSelected(XmLGridColumn column
)
8514 return column
->grid
.selected
;
8518 XmLGridColumnSetSelected(XmLGridColumn column
,
8521 column
->grid
.selected
= selected
;
8525 XmLGridColumnSetVisPos(XmLGridColumn column
,
8528 column
->grid
.visPos
= visPos
;
8532 XmLGridColumnWidthInPixels(XmLGridColumn column
)
8535 Dimension width
, maxWidth
;
8538 XmLGridCallbackStruct cbs
;
8539 XmLGridCellRefValues
*cellValues
;
8541 if (column
->grid
.sizePolicy
== XmCONSTANT
)
8542 return column
->grid
.width
;
8543 if (!column
->grid
.width
)
8545 if (!column
->grid
.widthInPixelsValid
)
8547 g
= (XmLGridWidget
)column
->grid
.grid
;
8548 count
= XmLArrayGetCount(g
->grid
.rowArray
);
8551 cellValues
= g
->grid
.defCellValues
;
8552 maxWidth
= 4 + column
->grid
.width
* cellValues
->fontWidth
+
8553 cellValues
->leftMargin
+ cellValues
->rightMargin
;
8557 for (i
= 0; i
< count
; i
++)
8559 cell
= GetCell(g
, i
, column
->grid
.pos
);
8560 cbs
.reason
= XmCR_PREF_WIDTH
;
8561 cbs
.rowType
= RowPosToType(g
, i
);
8562 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, i
);
8563 cbs
.columnType
= ColPosToType(g
, column
->grid
.pos
);
8564 cbs
.column
= ColPosToTypePos(g
, cbs
.columnType
, column
->grid
.pos
);
8565 cbs
.object
= (void *)column
;
8566 width
= XmLGridCellAction(cell
, (Widget
)g
, &cbs
);
8567 if (width
> maxWidth
)
8570 column
->grid
.widthInPixels
= maxWidth
;
8571 column
->grid
.widthInPixelsValid
= 1;
8573 return column
->grid
.widthInPixels
;
8577 XmLGridColumnWidthChanged(XmLGridColumn column
)
8579 column
->grid
.widthInPixelsValid
= 0;
8587 XmLGridCellNew(void)
8591 c
= (XmLGridCell
)malloc(sizeof(struct _XmLGridCellRec
));
8592 c
->cell
.refValues
= 0;
8598 XmLGridCellFree(Widget grid
,
8601 XmLGridCallbackStruct cbs
;
8603 cbs
.reason
= XmCR_FREE_VALUE
;
8604 XmLGridCellAction(cell
, grid
, &cbs
);
8605 XmLGridCellDerefValues(cell
->cell
.refValues
);
8610 XmLGridCellAction(XmLGridCell cell
,
8612 XmLGridCallbackStruct
*cbs
)
8614 return XmLGridClassPartOfWidget(w
).cellActionProc(cell
, w
, cbs
);
8617 /* Only to be called through Grid class */
8619 _GridCellAction(XmLGridCell cell
,
8621 XmLGridCallbackStruct
*cbs
)
8626 switch (cbs
->reason
)
8628 case XmCR_CELL_DRAW
:
8629 _XmLGridCellDrawBackground(cell
, w
, cbs
->clipRect
, cbs
->drawInfo
);
8630 _XmLGridCellDrawValue(cell
, w
, cbs
->clipRect
, cbs
->drawInfo
);
8631 _XmLGridCellDrawBorders(cell
, w
, cbs
->clipRect
, cbs
->drawInfo
);
8633 case XmCR_CELL_FOCUS_IN
:
8635 case XmCR_CELL_FOCUS_OUT
:
8637 case XmCR_CONF_TEXT
:
8638 _XmLGridCellConfigureText(cell
, w
, cbs
->clipRect
);
8640 case XmCR_EDIT_BEGIN
:
8641 ret
= _XmLGridCellBeginTextEdit(cell
, w
, cbs
->clipRect
);
8643 case XmCR_EDIT_CANCEL
:
8645 case XmCR_EDIT_COMPLETE
:
8646 _XmLGridCellCompleteTextEdit(cell
, w
);
8648 case XmCR_EDIT_INSERT
:
8649 ret
= _XmLGridCellBeginTextEdit(cell
, w
, cbs
->clipRect
);
8651 _XmLGridCellInsertText(cell
, w
);
8653 case XmCR_FREE_VALUE
:
8654 _XmLGridCellFreeValue(cell
);
8656 case XmCR_PREF_HEIGHT
:
8657 ret
= _XmLGridCellGetHeight(cell
, w
,(XmLGridRow
)cbs
->object
);
8659 case XmCR_PREF_WIDTH
:
8660 ret
= _XmLGridCellGetWidth(cell
, w
,(XmLGridColumn
)cbs
->object
);
8666 static XmLGridCellRefValues
*
8667 XmLGridCellGetRefValues(XmLGridCell cell
)
8669 return cell
->cell
.refValues
;
8673 XmLGridCellSetRefValues(XmLGridCell cell
,
8674 XmLGridCellRefValues
*values
)
8677 XmLGridCellDerefValues(cell
->cell
.refValues
);
8678 cell
->cell
.refValues
= values
;
8682 XmLGridCellDerefValues(XmLGridCellRefValues
*values
)
8687 if (!values
->refCount
)
8689 XmFontListFree(values
->fontList
);
8690 free((char *)values
);
8695 XmLGridCellInRowSpan(XmLGridCell cell
)
8697 if (cell
->cell
.flags
& XmLGridCellInRowSpanFlag
)
8703 XmLGridCellInColumnSpan(XmLGridCell cell
)
8705 if (cell
->cell
.flags
& XmLGridCellInColumnSpanFlag
)
8711 XmLGridCellIsSelected(XmLGridCell cell
)
8713 if (cell
->cell
.flags
& XmLGridCellSelectedFlag
)
8719 XmLGridCellIsValueSet(XmLGridCell cell
)
8721 if (cell
->cell
.flags
& XmLGridCellValueSetFlag
)
8727 XmLGridCellSetValueSet(XmLGridCell cell
,
8730 cell
->cell
.flags
|= XmLGridCellValueSetFlag
;
8732 cell
->cell
.flags
^= XmLGridCellValueSetFlag
;
8736 XmLGridCellSetInRowSpan(XmLGridCell cell
,
8739 cell
->cell
.flags
|= XmLGridCellInRowSpanFlag
;
8741 cell
->cell
.flags
^= XmLGridCellInRowSpanFlag
;
8745 XmLGridCellSetInColumnSpan(XmLGridCell cell
,
8748 cell
->cell
.flags
|= XmLGridCellInColumnSpanFlag
;
8750 cell
->cell
.flags
^= XmLGridCellInColumnSpanFlag
;
8754 XmLGridCellSetSelected(XmLGridCell cell
,
8757 cell
->cell
.flags
|= XmLGridCellSelectedFlag
;
8758 if (selected
!= True
)
8759 cell
->cell
.flags
^= XmLGridCellSelectedFlag
;
8764 XmLGridCellDrawSort(XmLGridCell cell
)
8766 if (cell
->cell
.flags
& XmLGridCellDrawSortFlag
)
8771 XmLGridCellSortAscending(XmLGridCell cell
)
8773 if (cell
->cell
.flags
& XmLGridCellSortAscendingFlag
)
8778 XmLGridCellSetDrawSort(XmLGridCell cell
, Boolean drawSort
)
8780 cell
->cell
.flags
|= XmLGridCellDrawSortFlag
;
8781 if (drawSort
!= True
)
8782 cell
->cell
.flags
^= XmLGridCellDrawSortFlag
;
8785 XmLGridCellSetSortAscending(XmLGridCell cell
, Boolean ascending
)
8787 cell
->cell
.flags
|= XmLGridCellSortAscendingFlag
;
8788 if (ascending
!= True
)
8789 cell
->cell
.flags
^= XmLGridCellSortAscendingFlag
;
8794 XmLGridCellAllocIcon(XmLGridCell cell
)
8796 XmLGridCellIcon
*icon
;
8798 icon
= (XmLGridCellIcon
*)malloc(sizeof(XmLGridCellIcon
));
8799 icon
->pix
.pixmap
= XmUNSPECIFIED_PIXMAP
;
8800 icon
->pix
.pixmask
= XmUNSPECIFIED_PIXMAP
;
8801 icon
->pix
.width
= 0;
8802 icon
->pix
.height
= 0;
8804 cell
->cell
.value
= (void *)icon
;
8805 XmLGridCellSetValueSet(cell
, True
);
8809 XmLGridCellAllocPixmap(XmLGridCell cell
)
8811 XmLGridCellPixmap
*pix
;
8813 pix
= (XmLGridCellPixmap
*)malloc(sizeof(XmLGridCellPixmap
));
8816 pix
->pixmap
= XmUNSPECIFIED_PIXMAP
;
8817 pix
->pixmask
= XmUNSPECIFIED_PIXMAP
;
8818 cell
->cell
.value
= (void *)pix
;
8819 XmLGridCellSetValueSet(cell
, True
);
8823 XmLGridCellSetString(XmLGridCell cell
,
8827 XmLGridCellIcon
*icon
;
8829 if (cell
->cell
.refValues
->type
== XmSTRING_CELL
)
8831 _XmLGridCellFreeValue(cell
);
8835 cell
->cell
.value
= (void *)XmStringCopy(string
);
8837 cell
->cell
.value
= (void *)string
;
8838 XmLGridCellSetValueSet(cell
, True
);
8841 XmLGridCellSetValueSet(cell
, False
);
8843 else if (cell
->cell
.refValues
->type
== XmICON_CELL
)
8845 if (XmLGridCellIsValueSet(cell
) == False
)
8846 XmLGridCellAllocIcon(cell
);
8847 icon
= (XmLGridCellIcon
*)cell
->cell
.value
;
8849 XmStringFree(icon
->string
);
8850 if (string
&& copy
== True
)
8851 icon
->string
= XmStringCopy(string
);
8853 icon
->string
= string
;
8855 else if (string
&& copy
== False
)
8856 XmStringFree(string
);
8860 XmLGridCellGetString(XmLGridCell cell
)
8865 if (cell
->cell
.refValues
->type
== XmSTRING_CELL
)
8867 if (XmLGridCellIsValueSet(cell
) == True
)
8868 str
= (XmString
)cell
->cell
.value
;
8870 else if (cell
->cell
.refValues
->type
== XmICON_CELL
)
8872 if (XmLGridCellIsValueSet(cell
) == True
)
8873 str
= ((XmLGridCellIcon
*)cell
->cell
.value
)->string
;
8879 XmLGridCellSetToggle(XmLGridCell cell
,
8882 if (cell
->cell
.refValues
->type
== XmTOGGLE_CELL
)
8885 cell
->cell
.value
= (void *)1;
8887 cell
->cell
.value
= (void *)0;
8888 XmLGridCellSetValueSet(cell
, True
);
8893 XmLGridCellGetToggle(XmLGridCell cell
)
8898 if (cell
->cell
.refValues
->type
== XmTOGGLE_CELL
)
8900 if (XmLGridCellIsValueSet(cell
) == True
&&
8901 cell
->cell
.value
== (void *)1)
8908 XmLGridCellSetPixmap(XmLGridCell cell
,
8913 XmLGridCellPixmap
*pix
;
8916 if (cell
->cell
.refValues
->type
== XmPIXMAP_CELL
)
8918 if (XmLGridCellIsValueSet(cell
) == False
)
8919 XmLGridCellAllocPixmap(cell
);
8920 pix
= (XmLGridCellPixmap
*)cell
->cell
.value
;
8922 else if (cell
->cell
.refValues
->type
== XmICON_CELL
)
8924 if (XmLGridCellIsValueSet(cell
) == False
)
8925 XmLGridCellAllocIcon(cell
);
8926 pix
= &((XmLGridCellIcon
*)cell
->cell
.value
)->pix
;
8930 pix
->pixmap
= pixmap
;
8931 pix
->height
= height
;
8936 XmLGridCellSetPixmask(XmLGridCell cell
,
8939 XmLGridCellPixmap
*pix
;
8941 if (XmLGridCellIsValueSet(cell
) == False
)
8943 fprintf(stderr
, "XmLGridCellSetPixmask: pixmap must be set ");
8944 fprintf(stderr
, "before pixmask\n");
8948 if (cell
->cell
.refValues
->type
== XmPIXMAP_CELL
)
8949 pix
= (XmLGridCellPixmap
*)cell
->cell
.value
;
8950 else if (cell
->cell
.refValues
->type
== XmICON_CELL
)
8951 pix
= &((XmLGridCellIcon
*)cell
->cell
.value
)->pix
;
8954 pix
->pixmask
= pixmask
;
8957 static XmLGridCellPixmap
*
8958 XmLGridCellGetPixmap(XmLGridCell cell
)
8960 XmLGridCellPixmap
*pix
;
8963 if (cell
->cell
.refValues
->type
== XmPIXMAP_CELL
)
8965 if (XmLGridCellIsValueSet(cell
) == True
)
8966 pix
= (XmLGridCellPixmap
*)cell
->cell
.value
;
8968 else if (cell
->cell
.refValues
->type
== XmICON_CELL
)
8970 if (XmLGridCellIsValueSet(cell
) == True
)
8971 pix
= &((XmLGridCellIcon
*)cell
->cell
.value
)->pix
;
8976 /* Only to be called by XmLGridCellAction() */
8978 _XmLGridCellDrawBackground(XmLGridCell cell
,
8980 XRectangle
*clipRect
,
8981 XmLGridDrawStruct
*ds
)
8988 if (ds
->drawSelected
== True
)
8989 XSetForeground(dpy
, ds
->gc
, ds
->selectBackground
);
8991 XSetForeground(dpy
, ds
->gc
, ds
->background
);
8992 XFillRectangle(dpy
, win
, ds
->gc
, clipRect
->x
, clipRect
->y
,
8993 clipRect
->width
, clipRect
->height
);
8996 /* Only to be called by XmLGridCellAction() */
8998 _XmLGridCellDrawBorders(XmLGridCell cell
,
9000 XRectangle
*clipRect
,
9001 XmLGridDrawStruct
*ds
)
9008 int x1
, x2
, y1
, y2
, loff
, roff
;
9009 int drawLeft
, drawRight
, drawBot
, drawTop
;
9010 XRectangle
*cellRect
;
9011 unsigned char borderType
;
9013 g
= (XmLGridWidget
)w
;
9017 cellRect
= ds
->cellRect
;
9018 black
= BlackPixelOfScreen(XtScreen(w
));
9019 white
= WhitePixelOfScreen(XtScreen(w
));
9021 x2
= clipRect
->x
+ clipRect
->width
- 1;
9023 y2
= clipRect
->y
+ clipRect
->height
- 1;
9028 if (cellRect
->x
!= clipRect
->x
)
9030 if (cellRect
->x
+ cellRect
->width
!= clipRect
->x
+ clipRect
->width
)
9032 if (cellRect
->y
!= clipRect
->y
)
9034 if (cellRect
->y
+ cellRect
->height
!= clipRect
->y
+ clipRect
->height
)
9036 borderType
= cell
->cell
.refValues
->rightBorderType
;
9037 if (borderType
!= XmBORDER_NONE
&& drawRight
)
9039 if (borderType
== XmBORDER_DASH
)
9040 XSetLineAttributes(dpy
, gc
, 0, LineOnOffDash
, CapButt
, JoinMiter
);
9041 XSetForeground(dpy
, gc
, cell
->cell
.refValues
->rightBorderColor
);
9042 XDrawLine(dpy
, win
, gc
, x2
, y1
, x2
, y2
);
9043 if (borderType
== XmBORDER_DASH
)
9044 XSetLineAttributes(dpy
, gc
, 0, LineSolid
, CapButt
, JoinMiter
);
9046 borderType
= cell
->cell
.refValues
->bottomBorderType
;
9047 if (borderType
!= XmBORDER_NONE
&& drawBot
)
9049 if (borderType
== XmBORDER_DASH
)
9050 XSetLineAttributes(dpy
, gc
, 0, LineOnOffDash
, CapButt
, JoinMiter
);
9051 XSetForeground(dpy
, gc
, cell
->cell
.refValues
->bottomBorderColor
);
9052 XDrawLine(dpy
, win
, gc
, x1
, y2
, x2
, y2
);
9053 if (borderType
== XmBORDER_DASH
)
9054 XSetLineAttributes(dpy
, gc
, 0, LineSolid
, CapButt
, JoinMiter
);
9056 borderType
= cell
->cell
.refValues
->topBorderType
;
9057 if (borderType
!= XmBORDER_NONE
&& drawTop
)
9059 if (borderType
== XmBORDER_DASH
)
9060 XSetLineAttributes(dpy
, gc
, 0, LineOnOffDash
, CapButt
, JoinMiter
);
9061 XSetForeground(dpy
, gc
, cell
->cell
.refValues
->topBorderColor
);
9062 XDrawLine(dpy
, win
, gc
, x1
, y1
, x2
, y1
);
9063 if (borderType
== XmBORDER_DASH
)
9064 XSetLineAttributes(dpy
, gc
, 0, LineSolid
, CapButt
, JoinMiter
);
9066 borderType
= cell
->cell
.refValues
->leftBorderType
;
9067 if (borderType
!= XmBORDER_NONE
&& drawLeft
)
9069 if (borderType
== XmBORDER_DASH
)
9070 XSetLineAttributes(dpy
, gc
, 0, LineOnOffDash
, CapButt
, JoinMiter
);
9071 XSetForeground(dpy
, gc
, cell
->cell
.refValues
->leftBorderColor
);
9072 XDrawLine(dpy
, win
, gc
, x1
, y1
, x1
, y2
);
9073 if (borderType
== XmBORDER_DASH
)
9074 XSetLineAttributes(dpy
, gc
, 0, LineSolid
, CapButt
, JoinMiter
);
9076 if (ds
->drawFocusType
== XmDRAW_FOCUS_NONE
)
9078 if (ds
->drawFocusType
== XmDRAW_FOCUS_LEFT
)
9080 else if (ds
->drawFocusType
== XmDRAW_FOCUS_RIGHT
)
9082 else if (ds
->drawFocusType
== XmDRAW_FOCUS_MID
)
9095 if (g
->grid
.highlightThickness
< 2)
9097 XSetForeground(dpy
, gc
, g
->manager
.highlight_color
);
9099 XDrawLine(dpy
, win
, gc
, x1
, y1
, x2
, y1
);
9101 XDrawLine(dpy
, win
, gc
, x1
, y1
+ 2, x1
, y2
);
9103 XDrawLine(dpy
, win
, gc
, x2
, y1
+ 2, x2
, y2
);
9105 XDrawLine(dpy
, win
, gc
, x1
+ loff
, y2
, x2
- roff
, y2
);
9106 if (drawTop
&& clipRect
->height
> 1)
9107 XDrawLine(dpy
, win
, gc
, x1
, y1
+ 1, x2
, y1
+ 1);
9108 if (drawBot
&& (int)clipRect
->height
> 1 &&
9109 (int)clipRect
->width
> roff
&&
9110 (int)clipRect
->width
> loff
)
9111 XDrawLine(dpy
, win
, gc
, x1
+ loff
, y2
- 1, x2
- roff
, y2
- 1);
9112 if (clipRect
->width
> 1 && clipRect
->height
> 2)
9115 XDrawLine(dpy
, win
, gc
, x1
+ 1, y1
+ 2, x1
+ 1, y2
);
9117 XDrawLine(dpy
, win
, gc
, x2
- 1, y1
+ 2, x2
- 1, y2
);
9121 /* Only to be called by XmLGridCellAction() */
9123 _XmLGridCellDrawValue(XmLGridCell cell
,
9125 XRectangle
*clipRect
,
9126 XmLGridDrawStruct
*ds
)
9130 XmLGridCellPixmap
*pix
;
9131 XmLGridCellIcon
*icon
;
9132 XRectangle cellRect
;
9133 XmLGridCellRefValues
*cellValues
;
9134 int type
, horizMargin
, vertMargin
, xoff
;
9136 g
= (XmLGridWidget
)w
;
9137 cellRect
= *ds
->cellRect
;
9138 cellValues
= cell
->cell
.refValues
;
9139 horizMargin
= ds
->leftMargin
+ ds
->rightMargin
;
9140 vertMargin
= ds
->topMargin
+ ds
->bottomMargin
;
9141 if (horizMargin
>= (int)cellRect
.width
||
9142 vertMargin
>= (int)cellRect
.height
)
9144 type
= cellValues
->type
;
9145 cellRect
.x
+= ds
->leftMargin
;
9146 cellRect
.y
+= ds
->topMargin
;
9147 cellRect
.width
-= horizMargin
;
9148 cellRect
.height
-= vertMargin
;
9150 if (type
== XmSTRING_CELL
&& XmLGridCellIsValueSet(cell
) == True
)
9152 if (ds
->drawSelected
== True
)
9153 XSetForeground(dpy
, ds
->gc
, ds
->selectForeground
);
9155 XSetForeground(dpy
, ds
->gc
, ds
->foreground
);
9156 XmLStringDraw(w
, (XmString
)cell
->cell
.value
, ds
->stringDirection
,
9157 ds
->fontList
, ds
->alignment
, ds
->gc
,
9158 &cellRect
, clipRect
);
9160 if (type
== XmPIXMAP_CELL
&& XmLGridCellIsValueSet(cell
) == True
)
9162 pix
= (XmLGridCellPixmap
*)cell
->cell
.value
;
9163 XmLPixmapDraw(w
, pix
->pixmap
, pix
->pixmask
,
9164 pix
->width
, pix
->height
, ds
->alignment
,
9165 ds
->gc
, &cellRect
, clipRect
);
9167 if (type
== XmICON_CELL
&& XmLGridCellIsValueSet(cell
) == True
)
9169 icon
= (XmLGridCellIcon
*)cell
->cell
.value
;
9170 if (icon
->pix
.pixmap
!= XmUNSPECIFIED_PIXMAP
)
9172 XmLPixmapDraw(w
, icon
->pix
.pixmap
, icon
->pix
.pixmask
,
9173 icon
->pix
.width
, icon
->pix
.height
, ds
->alignment
,
9174 ds
->gc
, &cellRect
, clipRect
);
9175 xoff
= icon
->pix
.width
+ g
->grid
.iconSpacing
;
9177 if (xoff
< (int)cellRect
.width
)
9178 cellRect
.width
-= xoff
;
9182 if (cellRect
.width
&& icon
->string
)
9184 if (ds
->drawSelected
== True
)
9185 XSetForeground(dpy
, ds
->gc
, ds
->selectForeground
);
9187 XSetForeground(dpy
, ds
->gc
, ds
->foreground
);
9188 XmLStringDraw(w
, icon
->string
, ds
->stringDirection
,
9189 ds
->fontList
, ds
->alignment
, ds
->gc
,
9190 &cellRect
, clipRect
);
9193 if (type
== XmTOGGLE_CELL
)
9194 XmLDrawToggle(w
, XmLGridCellGetToggle(cell
),
9195 g
->grid
.toggleSize
, ds
->alignment
, ds
->gc
,
9196 ds
->background
, g
->grid
.toggleTopColor
,
9197 g
->grid
.toggleBotColor
, ds
->foreground
,
9198 &cellRect
, clipRect
);
9200 if (cellRect
.width
> cellRect
.height
- 4 && XmLGridCellDrawSort(cell
))
9202 int arrow_direction
= XmLGridCellSortAscending(cell
);
9203 int arrow_size
= cellRect
.height
* 0.75;
9207 XSetForeground(dpy
, ds
->gc
, ds
->background
);
9209 _XmDrawArrow(dpy
, XtWindow(w
),
9210 ((XmManagerWidget
)g
)->manager
.bottom_shadow_GC
,
9211 ((XmManagerWidget
)g
)->manager
.top_shadow_GC
,
9213 cellRect
.x
+ cellRect
.width
- arrow_size
- 2,
9214 cellRect
.y
+ (cellRect
.height
/ 2 - arrow_size
/ 2),
9224 /* Only to be called by XmLGridCellAction() */
9226 _XmLGridCellConfigureText(XmLGridCell cell
, Widget w
, XRectangle
*rect
)
9230 g
= (XmLGridWidget
)w
;
9231 XtConfigureWidget(g
->grid
.text
, rect
->x
, rect
->y
,
9232 rect
->width
, rect
->height
, 0);
9236 /* Only to be called by XmLGridCellAction() */
9238 _XmLGridCellBeginTextEdit(XmLGridCell cell
,
9240 XRectangle
*clipRect
)
9242 XmLGridWidget g
= (XmLGridWidget
)w
;
9245 if ((cell
->cell
.refValues
->type
!= XmSTRING_CELL
&&
9246 cell
->cell
.refValues
->type
!= XmICON_CELL
)
9247 || cell
->cell
.refValues
->editable
!= True
9248 || g
->grid
.useTextWidget
!= True
)
9251 XmNtextWidget
, &text
,
9254 XmNfontList
, cell
->cell
.refValues
->fontList
,
9259 /* Only to be called by XmLGridCellAction() */
9261 _XmLGridCellCompleteTextEdit(XmLGridCell cell
,
9264 XmLGridWidget g
= (XmLGridWidget
)w
;
9269 if ((cell
->cell
.refValues
->type
!= XmSTRING_CELL
&&
9270 cell
->cell
.refValues
->type
!= XmICON_CELL
)
9271 || cell
->cell
.refValues
->editable
!= True
9272 || g
->grid
.useTextWidget
!= True
)
9275 XmNtextWidget
, &text
,
9277 s
= XmTextGetString(text
);
9279 for (i
= 0; i
< len
- 1; i
++)
9280 if (s
[i
] == '\\' && s
[i
+ 1] == 'n')
9283 strcpy(&s
[i
+ 1], &s
[i
+ 2]);
9285 XmLGridCellSetString(cell
,
9286 XmStringCreateLtoR(s
, XmSTRING_DEFAULT_CHARSET
),
9289 if (XmLGridCellIsValueSet(cell
) == True
)
9290 XmStringFree((XmString
)cell
->cell
.value
);
9293 cell
->cell
.value
= (void *)XmStringCreateLtoR(s
,
9294 XmSTRING_DEFAULT_CHARSET
);
9295 XmLGridCellSetValueSet(cell
, True
);
9298 XmLGridCellSetValueSet(cell
, False
);
9303 /* Only to be called by XmLGridCellAction() */
9305 _XmLGridCellInsertText(XmLGridCell cell
,
9308 XmLGridWidget g
= (XmLGridWidget
)w
;
9312 if ((cell
->cell
.refValues
->type
!= XmSTRING_CELL
&&
9313 cell
->cell
.refValues
->type
!= XmICON_CELL
)
9314 || cell
->cell
.refValues
->editable
!= True
9315 || g
->grid
.useTextWidget
!= True
)
9318 XmNtextWidget
, &text
,
9321 if (XmLGridCellIsValueSet(cell
) == True
)
9322 s
= CvtXmStringToStr(XmLGridCellGetString(cell
));
9325 XmTextSetString(text
, s
);
9329 XmTextSetString(text
, "");
9330 XmTextSetInsertionPosition(text
, XmTextGetLastPosition(text
));
9331 XmProcessTraversal(text
, XmTRAVERSE_CURRENT
);
9334 /* Only to be called by XmLGridCellAction() */
9336 _XmLGridCellGetHeight(XmLGridCell cell
,
9340 XmLGridCellPixmap
*pix
;
9341 XmLGridCellIcon
*icon
;
9342 XmLGridCellRefValues
*cellValues
;
9343 int height
, pixHeight
;
9345 cellValues
= cell
->cell
.refValues
;
9347 if (cellValues
->type
== XmPIXMAP_CELL
)
9349 if (XmLGridCellIsValueSet(cell
) == True
)
9351 pix
= (XmLGridCellPixmap
*)cell
->cell
.value
;
9353 height
= 4 + pix
->height
+ cellValues
->topMargin
+
9354 cellValues
->bottomMargin
;
9357 else if (cellValues
->type
== XmICON_CELL
)
9360 if (XmLGridCellIsValueSet(cell
) == True
)
9362 icon
= (XmLGridCellIcon
*)cell
->cell
.value
;
9363 if (icon
->pix
.pixmap
!= XmUNSPECIFIED_PIXMAP
&& icon
->pix
.height
)
9364 pixHeight
= 4 + icon
->pix
.height
+
9365 cellValues
->topMargin
+ cellValues
->bottomMargin
;
9367 height
= 4 + row
->grid
.height
* cellValues
->fontHeight
+
9368 cellValues
->topMargin
+ cellValues
->bottomMargin
;
9369 if (pixHeight
> height
)
9372 else if (cellValues
->type
== XmTOGGLE_CELL
)
9373 height
= 4 + 16 + cellValues
->topMargin
+
9374 cellValues
->bottomMargin
;
9375 else if (cellValues
->type
== XmSTRING_CELL
)
9377 height
= 4 + row
->grid
.height
* cellValues
->fontHeight
+
9378 cellValues
->topMargin
+ cellValues
->bottomMargin
;
9380 if (height
< 0 || cellValues
->rowSpan
)
9385 /* Only to be called by XmLGridCellAction() */
9387 _XmLGridCellGetWidth(XmLGridCell cell
,
9391 XmLGridWidget g
= (XmLGridWidget
)w
;
9392 XmLGridCellPixmap
*pix
;
9393 XmLGridCellIcon
*icon
;
9394 XmLGridCellRefValues
*cellValues
;
9397 cellValues
= cell
->cell
.refValues
;
9399 if (cellValues
->type
== XmPIXMAP_CELL
)
9401 if (XmLGridCellIsValueSet(cell
) == True
)
9403 pix
= (XmLGridCellPixmap
*)cell
->cell
.value
;
9405 width
= 4 + pix
->width
+ cellValues
->leftMargin
+
9406 cellValues
->rightMargin
;
9409 else if (cellValues
->type
== XmICON_CELL
)
9411 width
= 4 + col
->grid
.width
* cellValues
->fontWidth
+
9412 cellValues
->leftMargin
+ cellValues
->rightMargin
;
9413 if (XmLGridCellIsValueSet(cell
) == True
)
9415 icon
= (XmLGridCellIcon
*)cell
->cell
.value
;
9416 if (icon
->pix
.pixmap
!= XmUNSPECIFIED_PIXMAP
&& icon
->pix
.width
)
9417 width
+= icon
->pix
.width
+ g
->grid
.iconSpacing
;
9420 else if (cellValues
->type
== XmTOGGLE_CELL
)
9421 width
= 4 + 16 + cellValues
->leftMargin
+
9422 cellValues
->rightMargin
;
9423 else if (cellValues
->type
== XmSTRING_CELL
)
9424 width
= 4 + col
->grid
.width
* cellValues
->fontWidth
+
9425 cellValues
->leftMargin
+ cellValues
->rightMargin
;
9426 if (width
< 0 || cellValues
->columnSpan
)
9431 /* Only to be called by XmLGridCellAction() */
9433 _XmLGridCellFreeValue(XmLGridCell cell
)
9436 XmLGridCellIcon
*icon
;
9438 if (XmLGridCellIsValueSet(cell
) == False
)
9440 type
= cell
->cell
.refValues
->type
;
9441 if (type
== XmSTRING_CELL
)
9442 XmStringFree((XmString
)cell
->cell
.value
);
9443 else if (type
== XmPIXMAP_CELL
)
9444 free((char *)cell
->cell
.value
);
9445 else if (type
== XmICON_CELL
)
9447 icon
= (XmLGridCellIcon
*)cell
->cell
.value
;
9449 XmStringFree(icon
->string
);
9452 XmLGridCellSetValueSet(cell
, False
);
9460 XmLCreateGrid(Widget parent
,
9465 return XtCreateWidget(name
, xmlGridWidgetClass
, parent
,
9470 XmLGridAddColumns(Widget w
,
9479 XmLGridCallbackStruct cbs
;
9480 int i
, j
, rowCount
, hasAddCB
, redraw
;
9482 g
= WidgetToGrid(w
, "AddColumns()");
9488 position
= ColTypePosToPos(g
, type
, position
, 1);
9490 position
= ColTypePosToPos(g
, type
, -1, 1);
9492 if (type
== XmHEADING
)
9494 g
->grid
.headingColCount
+= count
;
9495 g
->grid
.leftFixedCount
+= count
;
9498 else if (type
== XmFOOTER
)
9500 g
->grid
.footerColCount
+= count
;
9501 g
->grid
.rightFixedCount
+= count
;
9504 else /* XmCONTENT */
9505 g
->grid
.colCount
+= count
;
9508 if (XtHasCallbacks(w
, XmNaddCallback
) == XtCallbackHasSome
)
9511 XmLArrayAdd(g
->grid
.colArray
, position
, count
);
9512 for (i
= 0; i
< count
; i
++)
9517 cbs
.reason
= XmCR_ADD_COLUMN
;
9518 cbs
.columnType
= type
;
9520 XtCallCallbackList(w
, g
->grid
.addCallback
, (XtPointer
)&cbs
);
9521 col
= (XmLGridColumn
)cbs
.object
;
9524 col
= XmLGridColumnNew(w
);
9525 XmLArraySet(g
->grid
.colArray
, position
+ i
, col
);
9528 rowCount
= XmLArrayGetCount(g
->grid
.rowArray
);
9529 for (j
= 0; j
< rowCount
; j
++)
9531 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, j
);
9532 XmLArrayAdd(XmLGridRowCells(row
), position
, count
);
9533 for (i
= position
; i
< position
+ count
; i
++)
9538 cbs
.reason
= XmCR_ADD_CELL
;
9539 cbs
.rowType
= RowPosToType(g
, j
);
9540 cbs
.columnType
= type
;
9542 XtCallCallbackList(w
, g
->grid
.addCallback
, (XtPointer
)&cbs
);
9543 cell
= (XmLGridCell
)cbs
.object
;
9546 cell
= XmLGridCellNew();
9547 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, i
);
9548 if (col
->grid
.defCellValues
)
9549 XmLGridCellSetRefValues(cell
, col
->grid
.defCellValues
);
9551 XmLGridCellSetRefValues(cell
, g
->grid
.defCellValues
);
9552 XmLArraySet(XmLGridRowCells(row
), i
, cell
);
9554 XmLGridRowHeightChanged(row
);
9556 for (i
= position
; i
< position
+ count
; i
++)
9558 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, i
);
9559 XmLGridColumnWidthChanged(col
);
9562 if (XmLArrayGetCount(g
->grid
.colArray
) != g
->grid
.headingColCount
+
9563 g
->grid
.colCount
+ g
->grid
.footerColCount
)
9564 XmLWarning(w
, "AddColumns() - count sanity check failed");
9566 /* maintain scroll and focus position */
9567 if (g
->grid
.hsPolicy
== XmCONSTANT
)
9569 if (type
== XmCONTENT
&& g
->grid
.colCount
== count
)
9570 g
->grid
.scrollCol
= 0;
9571 else if (position
<= g
->grid
.scrollCol
)
9572 g
->grid
.scrollCol
+= count
;
9574 if (position
<= g
->grid
.focusCol
)
9575 g
->grid
.focusCol
+= count
;
9576 VisPosChanged(g
, 0);
9579 if (g
->grid
.focusCol
== -1 && type
== XmCONTENT
)
9581 if (g
->grid
.focusRow
!= -1)
9582 SetFocus(g
, g
->grid
.focusRow
, position
, 0, 0);
9584 g
->grid
.focusCol
= position
;
9586 for (i
= position
; i
< position
+ count
; i
++)
9587 redraw
|= ColIsVisible(g
, i
);
9589 DrawArea(g
, DrawAll
, 0, 0);
9593 XmLGridAddRows(Widget w
,
9602 XmLGridCallbackStruct cbs
;
9603 int i
, j
, hasAddCB
, redraw
, colCount
;
9605 g
= WidgetToGrid(w
, "AddRows()");
9611 position
= RowTypePosToPos(g
, type
, position
, 1);
9613 position
= RowTypePosToPos(g
, type
, -1, 1);
9615 if (type
== XmHEADING
)
9617 g
->grid
.headingRowCount
+= count
;
9618 g
->grid
.topFixedCount
+= count
;
9621 else if (type
== XmFOOTER
)
9623 g
->grid
.footerRowCount
+= count
;
9624 g
->grid
.bottomFixedCount
+= count
;
9627 else /* XmCONTENT */
9628 g
->grid
.rowCount
+= count
;
9630 /* add rows and cells */
9631 XmLArrayAdd(g
->grid
.rowArray
, position
, count
);
9632 colCount
= XmLArrayGetCount(g
->grid
.colArray
);
9634 if (XtHasCallbacks(w
, XmNaddCallback
) == XtCallbackHasSome
)
9636 for (i
= 0; i
< count
; i
++)
9641 cbs
.reason
= XmCR_ADD_ROW
;
9644 XtCallCallbackList(w
, g
->grid
.addCallback
, (XtPointer
)&cbs
);
9645 row
= (XmLGridRow
)cbs
.object
;
9648 row
= XmLGridRowNew(w
);
9649 XmLArraySet(g
->grid
.rowArray
, position
+ i
, row
);
9650 XmLArrayAdd(XmLGridRowCells(row
), 0, colCount
);
9651 for (j
= 0; j
< colCount
; j
++)
9656 cbs
.reason
= XmCR_ADD_CELL
;
9658 cbs
.columnType
= ColPosToType(g
, j
);
9660 XtCallCallbackList(w
, g
->grid
.addCallback
, (XtPointer
)&cbs
);
9661 cell
= (XmLGridCell
)cbs
.object
;
9664 cell
= XmLGridCellNew();
9665 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, j
);
9666 if (col
->grid
.defCellValues
)
9667 XmLGridCellSetRefValues(cell
, col
->grid
.defCellValues
);
9669 XmLGridCellSetRefValues(cell
, g
->grid
.defCellValues
);
9670 XmLArraySet(XmLGridRowCells(row
), j
, cell
);
9672 XmLGridRowHeightChanged(row
);
9674 for (j
= 0; j
< colCount
; j
++)
9676 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, j
);
9677 XmLGridColumnWidthChanged(col
);
9680 if (XmLArrayGetCount(g
->grid
.rowArray
) != g
->grid
.headingRowCount
+
9681 g
->grid
.rowCount
+ g
->grid
.footerRowCount
)
9682 XmLWarning(w
, "AddRows() - count sanity check failed");
9684 /* maintain scroll and focus position */
9685 if (g
->grid
.vsPolicy
== XmCONSTANT
)
9687 if (type
== XmCONTENT
&& g
->grid
.rowCount
== count
)
9688 g
->grid
.scrollRow
= 0;
9689 else if (position
<= g
->grid
.scrollRow
)
9690 g
->grid
.scrollRow
+= count
;
9692 if (position
<= g
->grid
.focusRow
)
9693 g
->grid
.focusRow
+= count
;
9694 VisPosChanged(g
, 1);
9697 if (g
->grid
.focusRow
== -1 && type
== XmCONTENT
)
9699 if (g
->grid
.focusCol
!= -1)
9700 SetFocus(g
, position
, g
->grid
.focusCol
, 0, 0);
9702 g
->grid
.focusRow
= position
;
9704 for (i
= position
; i
< position
+ count
; i
++)
9705 redraw
|= RowIsVisible(g
, i
);
9707 DrawArea(g
, DrawAll
, 0, 0);
9710 if (g
->grid
.rowCount
> 100)
9712 fprintf(stderr
, "XmL: evaluation version only supports <= 100 rows\n");
9719 XmLGridDeleteAllColumns(Widget w
,
9725 g
= WidgetToGrid(w
, "DeleteAllColumns()");
9728 if (type
== XmHEADING
)
9729 n
= g
->grid
.headingColCount
;
9730 else if (type
== XmCONTENT
)
9731 n
= g
->grid
.colCount
;
9732 else if (type
== XmFOOTER
)
9733 n
= g
->grid
.footerColCount
;
9736 XmLWarning(w
, "DeleteAllColumns() - invalid type");
9741 XmLGridDeleteColumns(w
, type
, 0, n
);
9745 XmLGridDeleteAllRows(Widget w
,
9751 g
= WidgetToGrid(w
, "DeleteAllRows()");
9754 if (type
== XmHEADING
)
9755 n
= g
->grid
.headingRowCount
;
9756 else if (type
== XmCONTENT
)
9757 n
= g
->grid
.rowCount
;
9758 else if (type
== XmFOOTER
)
9759 n
= g
->grid
.footerRowCount
;
9762 XmLWarning(w
, "DeleteAllRows() - invalid type");
9767 XmLGridDeleteRows(w
, type
, 0, n
);
9771 XmLGridDeselectAllRows(Widget w
,
9776 g
= WidgetToGrid(w
, "DeselectAllRows()");
9779 SelectTypeArea(g
, SelectRow
, (XEvent
*)0, -1, 0, False
, notify
);
9783 XmLGridDeselectAllColumns(Widget w
,
9788 g
= WidgetToGrid(w
, "DeselectAllColumns()");
9791 SelectTypeArea(g
, SelectCol
, (XEvent
*)0, 0, -1, False
, notify
);
9795 XmLGridDeselectAllCells(Widget w
,
9800 g
= WidgetToGrid(w
, "DeselectAllCells()");
9803 SelectTypeArea(g
, SelectCell
, (XEvent
*)0, -1, -1, False
, notify
);
9807 XmLGridDeselectCell(Widget w
,
9814 g
= WidgetToGrid(w
, "DeselectCell()");
9817 SelectTypeArea(g
, SelectCell
, (XEvent
*)0, row
, column
, False
, notify
);
9821 XmLGridDeselectColumn(Widget w
,
9827 g
= WidgetToGrid(w
, "DeselectColumn()");
9830 SelectTypeArea(g
, SelectCol
, (XEvent
*)0, 0, column
, False
, notify
);
9834 XmLGridDeselectRow(Widget w
,
9840 g
= WidgetToGrid(w
, "DeselectRow()");
9843 SelectTypeArea(g
, SelectRow
, (XEvent
*)0, row
, 0, False
, notify
);
9847 XmLGridDeleteColumns(Widget w
,
9855 XmLGridCallbackStruct cbs
;
9856 int changeFocus
, i
, j
, rowCount
, lastPos
, redraw
;
9858 g
= WidgetToGrid(w
, "DeleteColumns()");
9863 lastPos
= ColTypePosToPos(g
, type
, position
+ count
- 1, 0);
9864 position
= ColTypePosToPos(g
, type
, position
, 0);
9865 if (position
< 0 || lastPos
< 0)
9867 XmLWarning(w
, "DeleteColumns() - invalid position");
9871 if (position
<= g
->grid
.focusCol
&& lastPos
>= g
->grid
.focusCol
)
9873 /* deleting focus col */
9874 TextAction(g
, TEXT_EDIT_CANCEL
);
9875 ChangeFocus(g
, g
->grid
.focusRow
, -1);
9880 if (XtHasCallbacks(w
, XmNdeleteCallback
) == XtCallbackHasSome
)
9881 for (i
= position
; i
< position
+ count
; i
++)
9883 rowCount
= XmLArrayGetCount(g
->grid
.rowArray
);
9884 for (j
= 0; j
< rowCount
; j
++)
9886 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, j
);
9887 cbs
.reason
= XmCR_DELETE_CELL
;
9888 cbs
.rowType
= RowPosToType(g
, j
);
9889 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, i
);
9890 cbs
.columnType
= type
;
9891 cbs
.column
= RowPosToTypePos(g
, cbs
.columnType
, j
);
9892 cbs
.object
= XmLArrayGet(XmLGridRowCells(row
), i
);
9893 XtCallCallbackList(w
, g
->grid
.deleteCallback
, (XtPointer
)&cbs
);
9895 cbs
.reason
= XmCR_DELETE_COLUMN
;
9896 cbs
.columnType
= type
;
9897 cbs
.column
= RowPosToTypePos(g
, cbs
.columnType
, i
);
9898 cbs
.object
= XmLArrayGet(g
->grid
.colArray
, i
);
9899 XtCallCallbackList(w
, g
->grid
.deleteCallback
, (XtPointer
)&cbs
);
9903 if (type
== XmHEADING
)
9905 g
->grid
.headingColCount
-= count
;
9906 g
->grid
.leftFixedCount
-= count
;
9909 else if (type
== XmFOOTER
)
9911 g
->grid
.footerColCount
-= count
;
9912 g
->grid
.rightFixedCount
-= count
;
9915 else /* XmCONTENT */
9916 g
->grid
.colCount
-= count
;
9918 for (i
= position
; i
< position
+ count
; i
++)
9920 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, i
);
9921 if (XmLGridColumnIsHidden(col
) == True
)
9922 g
->grid
.hiddenColCount
--;
9923 redraw
|= ColIsVisible(g
, i
);
9926 /* delete columns */
9927 for (i
= position
; i
< position
+ count
; i
++)
9929 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, i
);
9930 XmLGridColumnFree(w
, col
);
9932 XmLArrayDel(g
->grid
.colArray
, position
, count
);
9934 rowCount
= XmLArrayGetCount(g
->grid
.rowArray
);
9935 for (i
= 0; i
< rowCount
; i
++)
9937 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, i
);
9938 for (j
= position
; j
< position
+ count
; j
++)
9940 (XmLGridCell
)XmLArrayGet(XmLGridRowCells(row
), j
));
9941 XmLArrayDel(XmLGridRowCells(row
), position
, count
);
9942 XmLGridRowHeightChanged(row
);
9945 if (XmLArrayGetCount(g
->grid
.colArray
) != g
->grid
.headingColCount
+
9946 g
->grid
.colCount
+ g
->grid
.footerColCount
)
9947 XmLWarning(w
, "DeleteColumns() - count sanity check failed");
9949 /* maintain scroll and focus position */
9950 if (g
->grid
.hsPolicy
== XmCONSTANT
)
9952 if (lastPos
< g
->grid
.scrollCol
)
9953 g
->grid
.scrollCol
-= count
;
9954 else if (position
<= g
->grid
.scrollCol
)
9955 g
->grid
.scrollCol
= position
;
9957 if (lastPos
< g
->grid
.focusCol
)
9958 g
->grid
.focusCol
-= count
;
9959 VisPosChanged(g
, 0);
9964 SetFocus(g
, g
->grid
.focusRow
, position
, 0, 1);
9965 if (g
->grid
.focusCol
== -1)
9966 SetFocus(g
, g
->grid
.focusRow
, position
, 0, -1);
9969 DrawArea(g
, DrawAll
, 0, 0);
9973 XmLGridDeleteRows(Widget w
,
9981 XmLGridCallbackStruct cbs
;
9982 int changeFocus
, i
, j
, colCount
, lastPos
, redraw
;
9984 g
= WidgetToGrid(w
, "DeleteRows()");
9989 lastPos
= RowTypePosToPos(g
, type
, position
+ count
- 1, 0);
9990 position
= RowTypePosToPos(g
, type
, position
, 0);
9991 if (position
< 0 || lastPos
< 0)
9993 XmLWarning(w
, "DeleteRows() - invalid position");
9997 if (position
<= g
->grid
.focusRow
&& lastPos
>= g
->grid
.focusRow
)
9999 /* deleting focus row */
10000 TextAction(g
, TEXT_EDIT_CANCEL
);
10001 ChangeFocus(g
, -1, g
->grid
.focusCol
);
10006 if (XtHasCallbacks(w
, XmNdeleteCallback
) == XtCallbackHasSome
)
10007 for (i
= position
; i
< position
+ count
; i
++)
10009 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, i
);
10010 colCount
= XmLArrayGetCount(g
->grid
.colArray
);
10011 for (j
= 0; j
< colCount
; j
++)
10013 cbs
.reason
= XmCR_DELETE_CELL
;
10014 cbs
.rowType
= type
;
10015 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, i
);
10016 cbs
.columnType
= ColPosToType(g
, j
);
10017 cbs
.column
= ColPosToTypePos(g
, cbs
.columnType
, j
);
10018 cbs
.object
= XmLArrayGet(XmLGridRowCells(row
), j
);
10019 XtCallCallbackList(w
, g
->grid
.deleteCallback
, (XtPointer
)&cbs
);
10021 cbs
.reason
= XmCR_DELETE_ROW
;
10022 cbs
.rowType
= type
;
10023 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, i
);
10024 cbs
.object
= (void *)row
;
10025 XtCallCallbackList(w
, g
->grid
.deleteCallback
, (XtPointer
)&cbs
);
10029 if (type
== XmHEADING
)
10031 g
->grid
.headingRowCount
-= count
;
10032 g
->grid
.topFixedCount
-= count
;
10035 else if (type
== XmFOOTER
)
10037 g
->grid
.footerRowCount
-= count
;
10038 g
->grid
.bottomFixedCount
-= count
;
10041 else /* XmCONTENT */
10042 g
->grid
.rowCount
-= count
;
10044 for (i
= position
; i
< position
+ count
; i
++)
10046 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, i
);
10047 if (XmLGridRowIsHidden(row
) == True
)
10048 g
->grid
.hiddenRowCount
--;
10049 redraw
|= RowIsVisible(g
, i
);
10052 /* delete rows and cells */
10053 for (i
= position
; i
< position
+ count
; i
++)
10055 row
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, i
);
10056 XmLGridRowFree(w
, row
);
10058 XmLArrayDel(g
->grid
.rowArray
, position
, count
);
10059 colCount
= XmLArrayGetCount(g
->grid
.colArray
);
10060 for (i
= 0; i
< colCount
; i
++)
10062 col
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, i
);
10063 XmLGridColumnWidthChanged(col
);
10066 if (XmLArrayGetCount(g
->grid
.rowArray
) != g
->grid
.headingRowCount
+
10067 g
->grid
.rowCount
+ g
->grid
.footerRowCount
)
10068 XmLWarning(w
, "DeleteRows() - count sanity check failed");
10070 /* maintain scroll and focus position */
10071 if (g
->grid
.vsPolicy
== XmCONSTANT
)
10073 if (lastPos
< g
->grid
.scrollRow
)
10074 g
->grid
.scrollRow
-= count
;
10075 else if (position
<= g
->grid
.scrollRow
)
10076 g
->grid
.scrollRow
= position
;
10078 if (lastPos
< g
->grid
.focusRow
)
10079 g
->grid
.focusRow
-= count
;
10080 VisPosChanged(g
, 1);
10085 SetFocus(g
, position
, g
->grid
.focusCol
, 1, 0);
10086 if (g
->grid
.focusRow
== -1)
10087 SetFocus(g
, position
, g
->grid
.focusCol
, -1, 0);
10090 DrawArea(g
, DrawAll
, 0, 0);
10094 XmLGridGetFocus(Widget w
,
10100 unsigned char rowType
, colType
;
10102 g
= WidgetToGrid(w
, "GetFocus()");
10105 if (g
->grid
.focusIn
)
10109 if (g
->grid
.focusRow
< 0 || g
->grid
.focusCol
< 0)
10115 rowType
= RowPosToType(g
, g
->grid
.focusRow
);
10116 colType
= ColPosToType(g
, g
->grid
.focusCol
);
10117 if (rowType
!= XmCONTENT
|| colType
!= XmCONTENT
)
10121 XmLWarning(w
, "GetFocus() - focus row/column invalid\n");
10124 *row
= RowPosToTypePos(g
, XmCONTENT
, g
->grid
.focusRow
);
10125 *column
= ColPosToTypePos(g
, XmCONTENT
, g
->grid
.focusCol
);
10129 XmLGridGetRow(Widget w
,
10130 unsigned char rowType
,
10138 g
= WidgetToGrid(w
, "GetRow()");
10141 pos
= RowTypePosToPos(g
, rowType
, row
, 0);
10142 r
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, pos
);
10144 XmLWarning(w
, "GetRow() - invalid row");
10149 XmLGridEditBegin(Widget w
,
10158 g
= WidgetToGrid(w
, "EditBegin()");
10161 if (column
< 0 || column
>= g
->grid
.colCount
)
10163 XmLWarning(w
, "EditBegin() - invalid column");
10166 if (row
< 0 || row
>= g
->grid
.rowCount
)
10168 XmLWarning(w
, "EditBegin() - invalid row");
10171 r
= RowTypePosToPos(g
, XmCONTENT
, row
, 0);
10172 c
= ColTypePosToPos(g
, XmCONTENT
, column
, 0);
10173 if (RowColToXY(g
, r
, c
, True
, &rect
) == -1)
10175 XmLWarning(w
, "EditBegin() - cell must be visible to begin edit");
10178 if (SetFocus(g
, r
, c
, 0, 0) == -1)
10180 XmLWarning(w
, "EditBegin() - can't set focus to cell");
10183 if (insert
== False
)
10184 TextAction(g
, TEXT_EDIT
);
10186 TextAction(g
, TEXT_EDIT_INSERT
);
10191 XmLGridEditCancel(Widget w
)
10195 g
= WidgetToGrid(w
, "EditCancel()");
10198 TextAction(g
, TEXT_EDIT_CANCEL
);
10202 XmLGridEditComplete(Widget w
)
10206 g
= WidgetToGrid(w
, "EditComplete()");
10209 TextAction(g
, TEXT_EDIT_COMPLETE
);
10213 XmLGridGetColumn(Widget w
,
10214 unsigned char columnType
,
10221 g
= WidgetToGrid(w
, "GetColumn()");
10224 pos
= ColTypePosToPos(g
, columnType
, column
, 0);
10225 c
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, pos
);
10227 XmLWarning(w
, "GetColumn() - invalid column");
10232 XmLGridGetSelectedCellCount(Widget w
)
10236 g
= WidgetToGrid(w
, "GetSelectedCellCount()");
10239 return GetSelectedArea(g
, SelectCell
, 0, 0, 0);
10243 XmLGridGetSelectedCells(Widget w
,
10245 int *columnPositions
,
10251 g
= WidgetToGrid(w
, "GetSelectedCells()");
10254 n
= GetSelectedArea(g
, SelectCell
, rowPositions
, columnPositions
, count
);
10257 XmLWarning(w
, "GetSelectedCells() - count is incorrect");
10264 XmLGridGetSelectedColumnCount(Widget w
)
10268 g
= WidgetToGrid(w
, "GetSelectedColumnCount()");
10271 return GetSelectedArea(g
, SelectCol
, 0, 0, 0);
10275 XmLGridGetSelectedColumns(Widget w
,
10282 g
= WidgetToGrid(w
, "GetSelectedColumns()");
10285 n
= GetSelectedArea(g
, SelectCol
, 0, positions
, count
);
10288 XmLWarning(w
, "GetSelectedColumns() - count is incorrect");
10295 XmLGridGetSelectedRow(Widget w
)
10300 g
= WidgetToGrid(w
, "GetSelectedRow()");
10303 n
= GetSelectedArea(g
, SelectRow
, &pos
, 0, 1);
10310 XmLGridGetSelectedRowCount(Widget w
)
10314 g
= WidgetToGrid(w
, "GetSelectedRowCount()");
10317 return GetSelectedArea(g
, SelectRow
, 0, 0, 0);
10321 XmLGridGetSelectedRows(Widget w
,
10328 g
= WidgetToGrid(w
, "GetSelectedRows()");
10331 n
= GetSelectedArea(g
, SelectRow
, positions
, 0, count
);
10334 XmLWarning(w
, "GetSelectedRows() - count is incorrect");
10341 XmLGridColumnIsVisible(Widget w
,
10346 g
= WidgetToGrid(w
, "ColumnIsVisible()");
10349 if (!ColIsVisible(g
, g
->grid
.headingColCount
+ col
))
10355 XmLGridMoveColumns(Widget w
,
10362 int i
, np
, p
, rowCount
;
10364 g
= WidgetToGrid(w
, "MoveColumns()");
10367 np
= ColTypePosToPos(g
, XmCONTENT
, newPosition
, 0);
10368 p
= ColTypePosToPos(g
, XmCONTENT
, position
, 0);
10369 if (XmLArrayMove(g
->grid
.colArray
, np
, p
, count
) == -1)
10371 XmLWarning(w
, "MoveColumns() - invalid position");
10374 rowCount
= XmLArrayGetCount(g
->grid
.rowArray
);
10375 for (i
= 0; i
< rowCount
; i
++)
10377 row
= XmLArrayGet(g
->grid
.rowArray
, i
);
10378 XmLArrayMove(XmLGridRowCells(row
), np
, p
, count
);
10380 VisPosChanged(g
, 0);
10382 DrawArea(g
, DrawAll
, 0, 0);
10386 XmLGridMoveRows(Widget w
,
10394 g
= WidgetToGrid(w
, "MoveRows()");
10397 np
= RowTypePosToPos(g
, XmCONTENT
, newPosition
, 0);
10398 p
= RowTypePosToPos(g
, XmCONTENT
, position
, 0);
10399 if (XmLArrayMove(g
->grid
.rowArray
, np
, p
, count
) == -1)
10401 XmLWarning(w
, "MoveRows() - invalid position/count");
10404 VisPosChanged(g
, 1);
10406 DrawArea(g
, DrawAll
, 0, 0);
10410 XmLGridReorderColumns(Widget w
,
10417 int i
, *np
, p
, rowCount
, status
;
10419 g
= WidgetToGrid(w
, "ReorderColumns()");
10424 p
= ColTypePosToPos(g
, XmCONTENT
, position
, 0);
10425 np
= (int *)malloc(sizeof(int) * count
);
10426 for (i
= 0; i
< count
; i
++)
10427 np
[i
] = ColTypePosToPos(g
, XmCONTENT
, newPositions
[i
], 0);
10428 status
= XmLArrayReorder(g
->grid
.colArray
, np
, p
, count
);
10432 XmLWarning(w
, "ReorderColumns() - invalid position/count");
10435 rowCount
= XmLArrayGetCount(g
->grid
.rowArray
);
10436 for (i
= 0; i
< rowCount
; i
++)
10438 row
= XmLArrayGet(g
->grid
.rowArray
, i
);
10439 XmLArrayReorder(XmLGridRowCells(row
), np
, p
, count
);
10442 VisPosChanged(g
, 0);
10444 DrawArea(g
, DrawAll
, 0, 0);
10448 XmLGridReorderRows(Widget w
,
10454 int i
, *np
, p
, status
;
10456 g
= WidgetToGrid(w
, "ReorderRows()");
10461 p
= RowTypePosToPos(g
, XmCONTENT
, position
, 0);
10462 np
= (int *)malloc(sizeof(int) * count
);
10463 for (i
= 0; i
< count
; i
++)
10464 np
[i
] = RowTypePosToPos(g
, XmCONTENT
, newPositions
[i
], 0);
10465 status
= XmLArrayReorder(g
->grid
.rowArray
, np
, p
, count
);
10469 XmLWarning(w
, "ReorderRows() - invalid position/count");
10472 VisPosChanged(g
, 1);
10474 DrawArea(g
, DrawAll
, 0, 0);
10478 XmLGridRowColumnToXY(Widget w
,
10479 unsigned char rowType
,
10481 unsigned char columnType
,
10489 g
= WidgetToGrid(w
, "RowColumnToXY()");
10492 r
= RowTypePosToPos(g
, rowType
, row
, 0);
10493 c
= ColTypePosToPos(g
, columnType
, column
, 0);
10494 if (r
< 0 || r
>= XmLArrayGetCount(g
->grid
.rowArray
) ||
10495 c
< 0 || c
>= XmLArrayGetCount(g
->grid
.colArray
))
10497 /* XmLWarning(w, "RowColumnToXY() - invalid position");*/
10500 return RowColToXY(g
, r
, c
, clipped
, rect
);
10504 XmLGridRowIsVisible(Widget w
, int row
)
10508 g
= WidgetToGrid(w
, "RowIsVisible()");
10511 if (!RowIsVisible(g
, g
->grid
.headingRowCount
+ row
))
10517 XmLGridSelectAllRows(Widget w
,
10522 g
= WidgetToGrid(w
, "SelectAllRows()");
10525 SelectTypeArea(g
, SelectRow
, (XEvent
*)0, -1, 0, True
, notify
);
10529 XmLGridSelectAllColumns(Widget w
,
10534 g
= WidgetToGrid(w
, "SelectAllColumns()");
10537 SelectTypeArea(g
, SelectCol
, (XEvent
*)0, 0, -1, True
, notify
);
10541 XmLGridSelectAllCells(Widget w
,
10546 g
= WidgetToGrid(w
, "SelectAllCells()");
10549 SelectTypeArea(g
, SelectCell
, (XEvent
*)0, -1, -1, True
, notify
);
10553 XmLGridSelectCell(Widget w
,
10560 g
= WidgetToGrid(w
, "SelectCell()");
10563 SelectTypeArea(g
, SelectCell
, (XEvent
*)0, row
, column
, True
, notify
);
10567 XmLGridSelectColumn(Widget w
,
10573 g
= WidgetToGrid(w
, "SelectColumn()");
10576 SelectTypeArea(g
, SelectCol
, (XEvent
*)0, 0, column
, True
, notify
);
10580 XmLGridSelectRow(Widget w
,
10586 g
= WidgetToGrid(w
, "SelectRow()");
10589 SelectTypeArea(g
, SelectRow
, (XEvent
*)0, row
, 0, True
, notify
);
10593 XmLGridSetFocus(Widget w
,
10600 g
= WidgetToGrid(w
, "SetFocus()");
10603 if (row
< 0 || row
>= g
->grid
.rowCount
)
10605 XmLWarning(w
, "SetFocus() - invalid row");
10608 if (column
< 0 || column
>= g
->grid
.colCount
)
10610 XmLWarning(w
, "SetFocus() - invalid column");
10613 r
= RowTypePosToPos(g
, XmCONTENT
, row
, 0);
10614 c
= ColTypePosToPos(g
, XmCONTENT
, column
, 0);
10615 return SetFocus(g
, r
, c
, 0, 0);
10619 XmLGridXYToRowColumn(Widget w
,
10622 unsigned char *rowType
,
10624 unsigned char *columnType
,
10630 g
= WidgetToGrid(w
, "XYToRowColumn()");
10633 if (XYToRowCol(g
, x
, y
, &r
, &c
) == -1)
10635 *rowType
= RowPosToType(g
, r
);
10636 *row
= RowPosToTypePos(g
, *rowType
, r
);
10637 *columnType
= ColPosToType(g
, c
);
10638 *column
= ColPosToTypePos(g
, *columnType
, c
);
10643 XmLGridRedrawAll(Widget w
)
10647 g
= WidgetToGrid(w
, "RedrawAll()");
10650 DrawArea(g
, DrawAll
, 0, 0);
10654 XmLGridRedrawCell(Widget w
,
10655 unsigned char rowType
,
10657 unsigned char columnType
,
10663 g
= WidgetToGrid(w
, "RedrawCell()");
10666 r
= RowTypePosToPos(g
, rowType
, row
, 0);
10667 c
= ColTypePosToPos(g
, columnType
, column
, 0);
10668 DrawArea(g
, DrawCell
, r
, c
);
10672 XmLGridRedrawColumn(Widget w
,
10673 unsigned char type
,
10679 g
= WidgetToGrid(w
, "RedrawColumn()");
10682 c
= ColTypePosToPos(g
, type
, column
, 0);
10683 DrawArea(g
, DrawCol
, 0, c
);
10687 XmLGridRedrawRow(Widget w
,
10688 unsigned char type
,
10694 g
= WidgetToGrid(w
, "RedrawRow()");
10697 r
= RowTypePosToPos(g
, type
, row
, 0);
10698 DrawArea(g
, DrawRow
, r
, 0);
10702 XmLGridRead(Widget w
,
10711 g
= WidgetToGrid(w
, "Read()");
10716 XmLWarning(w
, "Read() - file is NULL");
10719 data
= FileToString(file
);
10722 XmLWarning(w
, "Read() - error loading file");
10725 n
= Read(g
, format
, delimiter
, 0, 0, data
);
10726 free((char *)data
);
10731 XmLGridReadPos(Widget w
,
10735 unsigned char rowType
,
10737 unsigned char columnType
,
10744 g
= WidgetToGrid(w
, "ReadPos()");
10749 XmLWarning(w
, "ReadPos() - file is NULL");
10752 data
= FileToString(file
);
10755 XmLWarning(w
, "ReadPos() - error loading file");
10758 r
= RowTypePosToPos(g
, rowType
, row
, 0);
10759 c
= ColTypePosToPos(g
, columnType
, column
, 0);
10760 n
= Read(g
, format
, delimiter
, r
, c
, data
);
10761 free((char *)data
);
10766 XmLGridSetStrings(Widget w
,
10771 g
= WidgetToGrid(w
, "SetStrings()");
10774 return Read(g
, XmFORMAT_DELIMITED
, '|', 0, 0, data
);
10778 XmLGridSetStringsPos(Widget w
,
10779 unsigned char rowType
,
10781 unsigned char columnType
,
10788 g
= WidgetToGrid(w
, "SetStringsPos()");
10791 r
= RowTypePosToPos(g
, rowType
, row
, 0);
10792 c
= ColTypePosToPos(g
, columnType
, column
, 0);
10793 return Read(g
, XmFORMAT_DELIMITED
, '|', r
, c
, data
);
10797 XmLGridWrite(Widget w
,
10801 Boolean skipHidden
)
10806 g
= WidgetToGrid(w
, "Write()");
10809 nrow
= XmLArrayGetCount(g
->grid
.rowArray
);
10810 ncol
= XmLArrayGetCount(g
->grid
.colArray
);
10811 Write(g
, file
, format
, delimiter
, skipHidden
, 0, 0, nrow
, ncol
);
10816 XmLGridWritePos(Widget w
,
10820 Boolean skipHidden
,
10821 unsigned char rowType
,
10823 unsigned char columnType
,
10831 g
= WidgetToGrid(w
, "WritePos()");
10834 r
= RowTypePosToPos(g
, rowType
, row
, 0);
10835 c
= ColTypePosToPos(g
, columnType
, column
, 0);
10836 Write(g
, file
, format
, delimiter
, skipHidden
, r
, c
, nrow
, ncolumn
);
10841 XmLGridCopyPos(Widget w
,
10843 unsigned char rowType
,
10845 unsigned char columnType
,
10853 g
= WidgetToGrid(w
, "CopyPos()");
10856 r
= RowTypePosToPos(g
, rowType
, row
, 0);
10857 c
= ColTypePosToPos(g
, columnType
, column
, 0);
10858 return Copy(g
, time
, 0, r
, c
, nrow
, ncolumn
);
10862 XmLGridCopySelected(Widget w
,
10867 g
= WidgetToGrid(w
, "CopySelected()");
10870 return Copy(g
, time
, 1, 0, 0, 0, 0);
10874 XmLGridPaste(Widget w
)
10879 g
= WidgetToGrid(w
, "Paste()");
10882 r
= g
->grid
.focusRow
;
10883 c
= g
->grid
.focusCol
;
10884 if (r
< 0 || c
< 0)
10886 XmLWarning(w
, "Paste() - no cell has focus");
10889 return Paste(g
, r
, c
);
10893 XmLGridPastePos(Widget w
,
10894 unsigned char rowType
,
10896 unsigned char columnType
,
10902 g
= WidgetToGrid(w
, "PastePos()");
10905 r
= RowTypePosToPos(g
, rowType
, row
, 0);
10906 c
= ColTypePosToPos(g
, columnType
, column
, 0);
10907 return Paste(g
, r
, c
);
10910 /* XFE Additions below here */
10912 EditTimer(XtPointer clientData
,
10913 XtIntervalId
*intervalId
)
10917 g
= (XmLGridWidget
)clientData
;
10919 g
->grid
.editTimerSet
= 0;
10920 g
->grid
.lastSelectTime
= 0;
10921 TextAction(g
,TEXT_EDIT_INSERT
);
10925 XmLGridSetVisibleColumnCount(Widget w
, int new_num_visible
)
10927 XmLGridWidget g
= (XmLGridWidget
)w
;
10928 int ii
, num_columns
, visible_count
;
10929 XmLGridColumn colp
;
10933 num_columns
= XmLArrayGetCount(g
->grid
.colArray
);
10935 if (new_num_visible
== 0)
10937 for (ii
= 0; ii
< num_columns
; ii
++)
10939 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, ii
);
10941 if (colp
->grid
.hidden
&& visible_count
< new_num_visible
)
10943 colp
->grid
.hidden
= False
;
10945 else if (!colp
->grid
.hidden
&& visible_count
>= new_num_visible
)
10947 colp
->grid
.hidden
= True
;
10949 if (!colp
->grid
.hidden
)
10952 if (visible_count
< num_columns
)
10953 g
->grid
.visibleCols
= visible_count
;
10955 g
->grid
.visibleCols
= 0;
10957 setHideUnhideSensitivity(w
);
10960 DrawArea(g
, DrawAll
, 0, 0);
10964 HideColumn(Widget w
, XtPointer clientData
, XtPointer callData
)
10966 Widget g
= (Widget
) clientData
;
10968 XmLGridHideRightColumn(g
);
10971 UnhideColumn(Widget w
, XtPointer clientData
, XtPointer callData
)
10973 Widget g
= (Widget
) clientData
;
10975 XmLGridUnhideRightColumn(g
);
10979 CreateHideUnhideButtons(XmLGridWidget g
)
10981 if (!g
->grid
.hideUnhideButtons
)
10983 XmLWarning((Widget
)g
,"CreateHideUnhideButtons - Creating buttons when XmNhideUnhideButtons is False.");
10987 g
->grid
.hideButton
= XtVaCreateWidget(
10988 "hide", xmDrawnButtonWidgetClass
,
10989 (Widget
)g
, XmNhighlightThickness
, 0,
10990 XmNshadowThickness
, 1,
10991 XmNtraversalOn
, False
,
10992 XmNbackground
, g
->core
.background_pixel
,
10993 XmNforeground
, g
->manager
.foreground
,
10994 XmNtopShadowColor
, g
->manager
.top_shadow_color
,
10995 XmNbottomShadowColor
, g
->manager
.bottom_shadow_color
,
10998 g
->grid
.unhideButton
= XtVaCreateWidget(
10999 "unhide", xmDrawnButtonWidgetClass
,
11000 (Widget
)g
, XmNhighlightThickness
, 0,
11001 XmNshadowThickness
, 1,
11002 XmNtraversalOn
, False
,
11003 XmNbackground
, g
->core
.background_pixel
,
11004 XmNforeground
, g
->manager
.foreground
,
11005 XmNtopShadowColor
, g
->manager
.top_shadow_color
,
11006 XmNbottomShadowColor
, g
->manager
.bottom_shadow_color
,
11009 XmLDrawnButtonSetType(g
->grid
.hideButton
, XmDRAWNB_SMALLARROW
,
11011 XmLDrawnButtonSetType(g
->grid
.unhideButton
, XmDRAWNB_SMALLARROW
,
11015 XtAddCallback(g
->grid
.hideButton
, XmNactivateCallback
,
11016 HideColumn
, (XtPointer
)g
);
11017 XtAddCallback(g
->grid
.unhideButton
, XmNactivateCallback
,
11018 UnhideColumn
, (XtPointer
)g
);
11020 XtOverrideTranslations(g
->grid
.unhideButton
,
11021 g
->grid
.unhideButtonTrans
);
11022 XtOverrideTranslations(g
->grid
.hideButton
,
11023 g
->grid
.hideButtonTrans
);
11028 HideAction(Widget w
,
11031 Cardinal
*num_params
)
11033 XmLGridHideRightColumn(w
);
11037 UnhideAction(Widget w
,
11040 Cardinal
*num_params
)
11042 XmLGridUnhideRightColumn(w
);
11046 setHideUnhideSensitivity(Widget w
)
11048 XmLGridWidget g
= (XmLGridWidget
)w
;
11049 int total_columns
= XmLArrayGetCount(g
->grid
.colArray
);
11050 Boolean can_unhide
, can_hide
;
11052 if (!g
->grid
.hideUnhideButtons
) return;
11054 /* If visibleCols is zero, that means all the columns are visible. */
11055 if (g
->grid
.visibleCols
== 0) {
11057 can_hide
= (total_columns
> 1);
11059 can_unhide
= (g
->grid
.visibleCols
< total_columns
);
11060 can_hide
= (g
->grid
.visibleCols
> 1);
11062 XtSetSensitive(g
->grid
.unhideButton
, can_unhide
);
11063 XtSetSensitive(g
->grid
.hideButton
, can_hide
);
11067 XmLGridHideRightColumn(Widget w
)
11069 XmLGridWidget g
= (XmLGridWidget
)w
;
11070 int total_columns
= XmLArrayGetCount(g
->grid
.colArray
);
11071 if (total_columns
<= 1)
11074 /* If visibleCols is zero, that means all the columns are visible. */
11075 if (g
->grid
.visibleCols
== 0 || g
->grid
.visibleCols
> total_columns
)
11076 XmLGridSetVisibleColumnCount(w
, total_columns
- 1);
11078 XmLGridSetVisibleColumnCount(w
, g
->grid
.visibleCols
- 1);
11082 XmLGridUnhideRightColumn(Widget w
)
11084 XmLGridWidget g
= (XmLGridWidget
)w
;
11085 int total_columns
= XmLArrayGetCount(g
->grid
.colArray
);
11087 /* If visibleCols is zero, that means all the columns are visible. */
11088 if ( g
->grid
.visibleCols
!= 0 && g
->grid
.visibleCols
< total_columns
)
11089 XmLGridSetVisibleColumnCount(w
, g
->grid
.visibleCols
+ 1);
11096 Cardinal
*num_params
)
11098 XmLGridWidget g
= (XmLGridWidget
)w
;
11100 SelectTypeArea(g
, SelectRow
, (XEvent
*)0, g
->grid
.lastSelectRow
, 0, False
, False
);
11102 g
->grid
.inMode
= InSelect
;
11106 MenuDisarm(Widget w
,
11109 Cardinal
*num_params
)
11111 XmLGridWidget g
= (XmLGridWidget
)w
;
11113 g
->grid
.inMode
= InNormal
;
11117 ResizeColumnToFit(XmLGridWidget g
, int new_x
)
11119 XmLGridColumn colp
;
11122 if (!RowColToXY(g
, 0, g
->grid
.resizeCol
, False
, &rect
))
11124 if (new_x
> rect
.x
)
11125 width
= (new_x
- rect
.x
) -
11126 (rect
.width
- GetColWidth(g
, g
->grid
.resizeCol
));
11127 if (width
< g
->grid
.minColWidth
)
11128 width
= g
->grid
.minColWidth
;
11130 /*printf("col(%d) resize_xy(%3d) colx(%3d) colw(%3d) column_width(%3d) new_width(%3d)\n", g->grid.resizeCol, g->grid.resizeLineXY, rect.x, rect.width, GetColWidth(g, g->grid.resizeCol), width);*/
11132 /* Resize all columns to the right */
11133 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
,
11134 g
->grid
.resizeCol
);
11135 colp
->grid
.width
= width
;
11136 SizeColumnsToFit(g
, g
->grid
.resizeCol
+ 1);
11138 DrawArea(g
, DrawAll
, 0, 0);
11139 g
->grid
.resizeLineXY
= rect
.x
+ width
;
11145 SizeColumnsToFit(XmLGridWidget g
, int starting_at
)
11147 int resizable_width
= 0;
11149 float hidden_col_adjust
;
11150 int ii
, num_columns
;
11151 XmLGridColumn colp
;
11153 /* Total the width of the columns and
11154 also total how much of that can be resized */
11155 delta
= g
->core
.width
;
11156 delta
-= g
->manager
.shadow_thickness
* 2;
11158 if (g
->grid
.hideUnhideButtons
)
11160 delta
-= g
->grid
.unhideButton
->core
.width
;
11161 delta
-= g
->grid
.hideButton
->core
.width
;
11163 else if (XtIsManaged(g
->grid
.vsb
))
11165 delta
-= g
->grid
.vsb
->core
.width
;
11168 num_columns
= g
->grid
.colCount
+ g
->grid
.headingColCount
11169 + g
->grid
.footerColCount
;
11170 for (ii
= 0; ii
< num_columns
; ii
++)
11172 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, ii
);
11174 if (colp
->grid
.sizePolicy
!= XmCONSTANT
)
11176 if (g
->grid
.debugLevel
)
11177 XmLWarning((Widget
)g
, "SizeColumnsToFit() - only valid for XmNcolumnSizePolicy == XmCONSTANT");
11178 colp
->grid
.sizePolicy
= XmCONSTANT
;
11180 if (!g
->grid
.visibleCols
|| ii
< g
->grid
.visibleCols
)
11182 delta
-= colp
->grid
.width
;
11184 if (ii
>= starting_at
&& colp
->grid
.resizable
)
11185 resizable_width
+= colp
->grid
.width
;
11188 if (delta
== 0 || resizable_width
<= 0)
11191 if (g
->grid
.debugLevel
)
11193 fprintf(stderr
,"Applying delta(%d) from %d to %d (%d resizable)\n",
11194 delta
, starting_at
, num_columns
- 1, resizable_width
);
11197 hidden_col_adjust
= (float)delta
/ resizable_width
;
11199 /* Adjust each column to fit based on its percentage of the total width */
11200 for (ii
= starting_at
; ii
< num_columns
; ii
++)
11206 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, ii
);
11207 col_width
= colp
->grid
.width
;
11209 if (!colp
->grid
.resizable
|| col_width
== 0)
11212 if (colp
->grid
.hidden
)
11213 col_delta
= (int)(hidden_col_adjust
* col_width
);
11215 if (col_width
< resizable_width
&& resizable_width
> 0)
11216 col_delta
= delta
* ((float)col_width
/ resizable_width
);
11220 new_col_width
= col_width
+ col_delta
;
11222 if (new_col_width
< g
->grid
.minColWidth
)
11224 new_col_width
= g
->grid
.minColWidth
;
11225 col_delta
= col_width
- new_col_width
;
11228 if (!colp
->grid
.hidden
)
11230 delta
-= col_delta
;
11231 resizable_width
-= col_width
;
11234 colp
->grid
.width
= new_col_width
;
11236 if (g
->grid
.debugLevel
)
11237 fprintf (stderr
, "Column %d, width %d -> %d, new delta %d, new resizable width %d\n",
11238 ii
, col_width
, new_col_width
,
11239 delta
, resizable_width
);
11247 XmLGridGetSort(Widget w
, int *column
, unsigned char *sortType
)
11249 XmLGridWidget g
= (XmLGridWidget
)w
;
11250 XmLGridColumn colp
;
11251 int num_columns
= XmLArrayGetCount(g
->grid
.colArray
);
11255 *sortType
= XmSORT_NONE
;
11257 for (ii
= 0; ii
< num_columns
; ii
++)
11259 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, ii
);
11261 if (colp
&& colp
->grid
.sort
!= XmSORT_NONE
)
11264 *sortType
= colp
->grid
.sort
;
11271 XmLGridSetSort(Widget w
, int column
, unsigned char sortType
)
11273 XmLGridWidget g
= (XmLGridWidget
)w
;
11275 XmLGridColumn colp
;
11277 int old_sort_column
;
11278 unsigned char old_sort_type
;
11280 /*printf("XmLGridSetSort: (%d,%s)\n", column,
11281 sortType == XmSORT_NONE ? "none" :
11282 sortType == XmSORT_ASCENDING ? "ascending" : "descending");
11285 /* Clear old sort resource */
11286 XmLGridGetSort(w
, &old_sort_column
, &old_sort_type
);
11287 if (old_sort_type
!= XmSORT_NONE
)
11289 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, old_sort_column
);
11291 colp
->grid
.sort
= XmSORT_NONE
;
11294 colp
= (XmLGridColumn
)XmLArrayGet(g
->grid
.colArray
, column
);
11295 colp
->grid
.sort
= sortType
;
11297 /* Clear any existing cell sort masks. */
11298 rowp
= (XmLGridRow
)XmLArrayGet(g
->grid
.rowArray
, 0);
11303 count
= XmLArrayGetCount(rowp
->grid
.cellArray
);
11304 for (ii
= 0; ii
< count
; ii
++)
11306 cellp
= (XmLGridCell
)XmLArrayGet(rowp
->grid
.cellArray
, ii
);
11308 if (XmLGridCellDrawSort(cellp
))
11310 DrawArea(g
, DrawCell
, 0, ii
);
11311 XmLGridCellSetDrawSort(cellp
, False
);
11316 /* Set the cell mask of the heading cell. */
11317 cellp
= GetCell(g
, 0, column
);
11321 XmLGridCellSetDrawSort(cellp
, True
);
11322 if (sortType
== XmSORT_NONE
)
11323 XmLGridCellSetDrawSort(cellp
, False
);
11324 else if (sortType
== XmSORT_ASCENDING
)
11325 XmLGridCellSetSortAscending(cellp
, True
);
11326 else if (sortType
== XmSORT_DESCENDING
)
11327 XmLGridCellSetSortAscending(cellp
, False
);
11329 DrawArea(g
, DrawCell
, 0, column
);
11334 /*----------------------------------------------------------------------*/
11336 GridInvokeCallbacks(Widget w
,
11337 XtCallbackList list
,
11341 XmLGridWidget g
= (XmLGridWidget
)w
;
11343 /* Make sure widget is alive and callback list is not NULL */
11344 if (!g
->core
.being_destroyed
&& list
)
11346 XmAnyCallbackStruct cbs
;
11349 cbs
.reason
= reason
;
11351 /* Invoke the Callback List */
11352 XtCallCallbackList(w
,list
,&cbs
);
11355 /*----------------------------------------------------------------------*/
11357 GridInvokeCellCrossingCallbacks(Widget w
,
11358 XtCallbackList list
,
11364 XmLGridWidget g
= (XmLGridWidget
)w
;
11366 /* Make sure widget is alive and callback list is not NULL */
11367 if (!g
->core
.being_destroyed
&& list
)
11369 if (row
!= -1 && col
!= -1)
11372 XmLGridCallbackStruct cbs
;
11374 cell
= GetCell(g
, row
, col
);
11378 cbs
.reason
= XmCR_CELL_FOCUS_OUT
;
11379 cbs
.columnType
= ColPosToType(g
, col
);
11380 cbs
.column
= ColPosToTypePos(g
, cbs
.columnType
, col
);
11381 cbs
.rowType
= RowPosToType(g
, row
);
11382 cbs
.row
= RowPosToTypePos(g
, cbs
.rowType
, row
);
11384 /* XmLGridCellAction(cell, (Widget)g, &cbs); */
11386 /* Invoke the Callback List */
11387 XtCallCallbackList(w
,list
,&cbs
);
11392 /*----------------------------------------------------------------------*/
11394 GridCrossingEH(Widget w
,
11399 XmLGridWidget g
= (XmLGridWidget
)w
;
11403 if (event
->type
== EnterNotify
)
11405 /* Invoke XmNenterGridCallback */
11406 GridInvokeCallbacks(w
,
11407 g
->grid
.enterGridCallback
,
11411 /* printf("Enter(%s)\n",XtName(w)); */
11413 else if (event
->type
== LeaveNotify
)
11415 g
->grid
.lastCursorMotionRow
= -1;
11416 g
->grid
.lastCursorMotionCol
= -1;
11418 /* Invoke XmNleaveGridCallback */
11419 GridInvokeCallbacks(w
,
11420 g
->grid
.leaveGridCallback
,
11424 /* printf("Leave(%s)\n",XtName(w)); */
11430 /*----------------------------------------------------------------------*/