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 ***** */
49 /*----------------------------------------------------------------------*/
51 /* Name: <XmL/GridUtil.c> */
53 /* Description: XmLGrid misc utilities. They are here in order not to */
54 /* continue bloating Grid.c beyond hope. */
56 /* Author: Ramiro Estrugo <ramiro@netscape.com> */
58 /* Created: Thu May 28 21:55:45 PDT 1998 */
60 /*----------------------------------------------------------------------*/
66 /*----------------------------------------------------------------------*/
68 XmLGridGetRowCount(Widget w
)
70 XmLGridWidget g
= (XmLGridWidget
) w
;
78 XtVaGetValues(w
,XmNrows
,&rows
,NULL
);
80 assert( rows
== g
->grid
.rowCount
);
84 return g
->grid
.rowCount
;
86 /*----------------------------------------------------------------------*/
88 XmLGridGetColumnCount(Widget w
)
90 XmLGridWidget g
= (XmLGridWidget
) w
;
98 XtVaGetValues(w
,XmNcolumns
,&columns
,NULL
);
100 assert( columns
== g
->grid
.colCount
);
104 return g
->grid
.colCount
;
106 /*----------------------------------------------------------------------*/
108 XmLGridXYToCellTracking(Widget widget
,
109 int x
, /* input only args. */
110 int y
, /* input only args. */
111 Boolean
* m_inGrid
, /* input/output args. */
112 int * m_lastRow
, /* input/output args. */
113 int * m_lastCol
, /* input/output args. */
114 unsigned char * m_lastRowtype
, /* input/output args. */
115 unsigned char * m_lastColtype
,/* input/output args. */
116 int * outRow
, /* output only args. */
117 int * outCol
, /* output only args. */
118 Boolean
* enter
, /* output only args. */
119 Boolean
* leave
) /* output only args. */
121 int m_totalLines
= 0;
122 int m_numcolumns
= 0;
125 unsigned char rowtype
= XmCONTENT
;
126 unsigned char coltype
= XmCONTENT
;
128 if (0 > XmLGridXYToRowColumn(widget
,
136 /* In grid; but, not in any cells
138 /* treat it as a leave
145 m_totalLines
= XmLGridGetRowCount(widget
);
146 m_numcolumns
= XmLGridGetColumnCount(widget
);
148 if ((row
< m_totalLines
) &&
149 (column
< m_numcolumns
) &&
150 ((*m_lastRow
!= row
)||
151 (*m_lastCol
!= column
) ||
152 (*m_lastRowtype
!= rowtype
)||
153 (*m_lastColtype
!= coltype
)))
155 *outRow
= (rowtype
== XmHEADING
)?-1:row
;
158 if (*m_inGrid
== False
)
170 /* Cruising among cells
177 *m_lastRowtype
= rowtype
;
178 *m_lastColtype
= coltype
;
179 }/* row /col in grid */
181 /*----------------------------------------------------------------------*/