| 1 |
/* $TOG: Container.c /main/7 1997/05/02 10:09:20 dbl $ */ |
| 2 |
/* |
| 3 |
* Motif |
| 4 |
* |
| 5 |
* Copyright (c) 1987-2012, The Open Group. All rights reserved. |
| 6 |
* |
| 7 |
* These libraries and programs are free software; you can |
| 8 |
* redistribute them and/or modify them under the terms of the GNU |
| 9 |
* Lesser General Public License as published by the Free Software |
| 10 |
* Foundation; either version 2 of the License, or (at your option) |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* These libraries and programs are distributed in the hope that |
| 14 |
* they will be useful, but WITHOUT ANY WARRANTY; without even the |
| 15 |
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 16 |
* PURPOSE. See the GNU Lesser General Public License for more |
| 17 |
* details. |
| 18 |
* |
| 19 |
* You should have received a copy of the GNU Lesser General Public |
| 20 |
* License along with these librararies and programs; if not, write |
| 21 |
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth |
| 22 |
* Floor, Boston, MA 02110-1301 USA |
| 23 |
* |
| 24 |
*/ |
| 25 |
/* |
| 26 |
* HISTORY |
| 27 |
*/ |
| 28 |
|
| 29 |
/********************************* WARNING ********************************** |
| 30 |
* |
| 31 |
* This widget is for educational purposes only. |
| 32 |
* Commercial applications should NOT instantiate this widget. |
| 33 |
* OSF makes no guarantees on the stability of this widget. |
| 34 |
* |
| 35 |
********************************* WARNING *********************************/ |
| 36 |
|
| 37 |
|
| 38 |
/****************************************************************************** |
| 39 |
* |
| 40 |
* Container.c - ExmContainer widget. |
| 41 |
* |
| 42 |
******************************************************************************/ |
| 43 |
|
| 44 |
/* Include appropriate files. */ |
| 45 |
#include <Xm/GadgetP.h> /* header file for gadget management functions */ |
| 46 |
#include <Xm/TraitP.h> /* header file for trait functions */ |
| 47 |
#include <Xm/ContainerT.h> /* container trait */ |
| 48 |
#include <Xm/ContItemT.h> /* container item trait */ |
| 49 |
#include <Xm/DrawingA.h> |
| 50 |
#include <Xm/IconH.h> |
| 51 |
#include <Xm/ScrollFrameT.h> |
| 52 |
#include <Xm/XmI.h> |
| 53 |
#include <Xm/XmTabListI.h> |
| 54 |
#include <Exm/ContainerP.h> |
| 55 |
|
| 56 |
/* This one should be somewhere common */ |
| 57 |
/* The Max macro returns the higher of two input arguments. */ |
| 58 |
#define Max(x, y) (((x) > (y)) ? (x) : (y)) |
| 59 |
|
| 60 |
extern Dimension XmTabListGetPosition(Screen *,XmTabList, Cardinal); |
| 61 |
|
| 62 |
|
| 63 |
/* Declare static functions. */ |
| 64 |
static void ButtonHandler(Widget wid, |
| 65 |
XtPointer data, |
| 66 |
XEvent * event, |
| 67 |
Boolean *cont); |
| 68 |
static void GetFirstColumnWidth( |
| 69 |
Widget wid, |
| 70 |
int offset, |
| 71 |
XtArgVal *value); |
| 72 |
static void GetDetailTabList( |
| 73 |
Widget wid, |
| 74 |
int offset, |
| 75 |
XtArgVal *value); |
| 76 |
static void SelectColorDefault( |
| 77 |
Widget widget, |
| 78 |
int offset, |
| 79 |
XrmValue *value ); |
| 80 |
static void ClassPartInitialize( |
| 81 |
WidgetClass widgetClass); |
| 82 |
static void Initialize( |
| 83 |
Widget rw, |
| 84 |
Widget nw, |
| 85 |
ArgList args, |
| 86 |
Cardinal *num_args); |
| 87 |
static void Destroy( |
| 88 |
Widget wid); |
| 89 |
static void Layout ( |
| 90 |
Widget wid, |
| 91 |
Widget instigator); |
| 92 |
static void CalcSize ( |
| 93 |
Widget wid, |
| 94 |
Widget instigator, |
| 95 |
Dimension *gridWidth, |
| 96 |
Dimension *gridHeight); |
| 97 |
static Boolean NeedRelayout ( |
| 98 |
Widget old_w, |
| 99 |
Widget new_w); |
| 100 |
|
| 101 |
static XmTabList GetDefaultTabList( |
| 102 |
ExmContainerWidget cw, |
| 103 |
Cardinal detail_order_count); |
| 104 |
static XmTabList GetDumbTabList( |
| 105 |
Dimension tab_size, |
| 106 |
Cardinal asked_num_tab); |
| 107 |
|
| 108 |
static void ContainerGetValues(Widget w, |
| 109 |
XmContainerData containerData); |
| 110 |
|
| 111 |
static Dimension GetDefaultFirstColumnWidth( |
| 112 |
ExmContainerWidget cw, |
| 113 |
Dimension fcw_init); |
| 114 |
static Cardinal GetDefaultDetailCount( |
| 115 |
ExmContainerWidget cw, |
| 116 |
Cardinal detail_count); |
| 117 |
|
| 118 |
|
| 119 |
/* No translations and no actions. */ |
| 120 |
|
| 121 |
|
| 122 |
static XtResource resources[] = |
| 123 |
{ |
| 124 |
{ |
| 125 |
ExmNfirstColumnWidth, |
| 126 |
ExmCFirstColumnWidth, |
| 127 |
XmRDimension, |
| 128 |
sizeof (Dimension), |
| 129 |
XtOffsetOf(ExmContainerRec, container.first_column_width), |
| 130 |
XmRImmediate, |
| 131 |
(XtPointer) 0 |
| 132 |
}, |
| 133 |
{ |
| 134 |
ExmNdetailOrder, |
| 135 |
ExmCDetailOrder, |
| 136 |
XmRCardinalList, |
| 137 |
sizeof (Cardinal *), |
| 138 |
XtOffsetOf(ExmContainerRec, container.detail_order), |
| 139 |
XmRImmediate, |
| 140 |
(XtPointer) NULL |
| 141 |
}, |
| 142 |
{ |
| 143 |
ExmNdetailOrderCount, |
| 144 |
ExmCDetailOrderCount, |
| 145 |
XmRCardinal, |
| 146 |
sizeof (Cardinal), |
| 147 |
XtOffsetOf(ExmContainerRec, container.detail_order_count), |
| 148 |
XmRImmediate, |
| 149 |
(XtPointer) 0 |
| 150 |
}, |
| 151 |
{ |
| 152 |
ExmNdetailTabList, |
| 153 |
ExmCDetailTabList, |
| 154 |
XmRTabList, |
| 155 |
sizeof (XmTabList), |
| 156 |
XtOffsetOf(ExmContainerRec, container.detail_tablist), |
| 157 |
XmRImmediate, |
| 158 |
(XtPointer) NULL |
| 159 |
}, |
| 160 |
{ |
| 161 |
ExmNdetailHeader, |
| 162 |
ExmCDetailHeader, |
| 163 |
XmRXmStringTable, |
| 164 |
sizeof (XmStringTable), |
| 165 |
XtOffsetOf(ExmContainerRec, container.detail_header), |
| 166 |
XmRImmediate, |
| 167 |
(XtPointer) NULL |
| 168 |
}, |
| 169 |
{ |
| 170 |
ExmNdetailHeaderCount, |
| 171 |
ExmCDetailHeaderCount, |
| 172 |
XmRCardinal, |
| 173 |
sizeof (Cardinal), |
| 174 |
XtOffsetOf(ExmContainerRec, container.detail_header_count), |
| 175 |
XmRImmediate, |
| 176 |
(XtPointer) 0 |
| 177 |
}, |
| 178 |
{ |
| 179 |
ExmNselectColor, |
| 180 |
ExmCSelectColor, |
| 181 |
XmRPixel, |
| 182 |
sizeof (Pixel), |
| 183 |
XtOffsetOf(ExmContainerRec, container.select_color), |
| 184 |
XmRImmediate, (XtPointer) SelectColorDefault |
| 185 |
}, |
| 186 |
{ |
| 187 |
ExmNlayoutType, |
| 188 |
ExmCLayoutType, |
| 189 |
XmRLayoutType, |
| 190 |
sizeof (unsigned char), |
| 191 |
XtOffsetOf(ExmContainerRec, container.layout_type), |
| 192 |
XmRImmediate, (XtPointer) XmDETAIL |
| 193 |
}, |
| 194 |
}; |
| 195 |
|
| 196 |
|
| 197 |
static XmSyntheticResource syn_resources[] = |
| 198 |
{ |
| 199 |
{ |
| 200 |
ExmNfirstColumnWidth, |
| 201 |
sizeof (Dimension), |
| 202 |
XtOffsetOf( ExmContainerRec, container.first_column_width), |
| 203 |
GetFirstColumnWidth, NULL |
| 204 |
}, |
| 205 |
{ |
| 206 |
ExmNdetailTabList, |
| 207 |
sizeof (XmTabList), |
| 208 |
XtOffsetOf( ExmContainerRec, container.detail_tablist), |
| 209 |
GetDetailTabList, NULL |
| 210 |
}, |
| 211 |
}; |
| 212 |
|
| 213 |
/* Define the widget class record. See Chapter 4 of the |
| 214 |
"OSF/Motif Widget Writer's Guide" for details. */ |
| 215 |
externaldef(exmcontainerclassrec) ExmContainerClassRec exmContainerClassRec = |
| 216 |
{ |
| 217 |
{ /* core_class */ |
| 218 |
/* superclass */ (WidgetClass) &exmGridClassRec, |
| 219 |
/* class_name */ "ExmContainer", |
| 220 |
/* widget_size */ sizeof(ExmContainerRec), |
| 221 |
/* class_initialize */ NULL, |
| 222 |
/* class_part_initialize */ ClassPartInitialize, |
| 223 |
/* class_inited */ FALSE, |
| 224 |
/* initialize */ Initialize, |
| 225 |
/* initialize_hook */ NULL, |
| 226 |
/* realize */ XtInheritRealize, |
| 227 |
/* actions */ NULL, |
| 228 |
/* num_actions */ 0, |
| 229 |
/* resources */ resources, |
| 230 |
/* num_resources */ XtNumber(resources), |
| 231 |
/* xrm_class */ NULLQUARK, |
| 232 |
/* compress_motion */ TRUE, |
| 233 |
/* compress_exposure */ XtExposeCompressMaximal, |
| 234 |
/* compress_enterleave */ TRUE, |
| 235 |
/* visible_interest */ FALSE, |
| 236 |
/* destroy */ Destroy, |
| 237 |
/* resize */ XtInheritResize, |
| 238 |
/* expose */ XtInheritExpose, |
| 239 |
/* set_values */ NULL, |
| 240 |
/* set_values_hook */ NULL, |
| 241 |
/* set_values_almost */ XtInheritSetValuesAlmost, |
| 242 |
/* get_values_hook */ NULL, |
| 243 |
/* accept_focus */ NULL, |
| 244 |
/* version */ XtVersion, |
| 245 |
/* callback_private */ NULL, |
| 246 |
/* tm_table */ XtInheritTranslations, |
| 247 |
/* query_geometry */ XtInheritQueryGeometry, |
| 248 |
/* display_accelerator */ NULL, |
| 249 |
/* extension */ NULL, |
| 250 |
}, |
| 251 |
{ /* composite_class */ |
| 252 |
/* geometry_manager */ XtInheritGeometryManager, |
| 253 |
/* change_managed */ XtInheritChangeManaged, |
| 254 |
/* insert_child */ XtInheritInsertChild, |
| 255 |
/* delete_child */ XtInheritDeleteChild, |
| 256 |
/* extension */ NULL, |
| 257 |
}, |
| 258 |
{ /* constraint_class */ |
| 259 |
/* constraint_resources */ NULL, |
| 260 |
/* constraint_num_resources */ 0, |
| 261 |
/* constraint_size */ sizeof(ExmGridConstraintRec), |
| 262 |
/* constraint_initialize */ NULL, |
| 263 |
/* constraint_destroy */ NULL, |
| 264 |
/* constraint_set_values */ NULL, |
| 265 |
/* extension */ NULL, |
| 266 |
}, |
| 267 |
{ /* manager class */ |
| 268 |
/* translations */ XtInheritTranslations, |
| 269 |
/* syn_resources */ syn_resources, |
| 270 |
/* num_syn_resources */ XtNumber(syn_resources), |
| 271 |
/* syn_constraint_resources */ NULL, |
| 272 |
/* num_syn_constraint_resources */ 0, |
| 273 |
/* parent_process */ XmInheritParentProcess, |
| 274 |
/* extension */ NULL, |
| 275 |
}, |
| 276 |
{ /* grid class */ |
| 277 |
/* layout */ Layout, |
| 278 |
/* calc_size */ CalcSize, |
| 279 |
/* need_relayout */ NeedRelayout, |
| 280 |
/* extension */ NULL, |
| 281 |
}, |
| 282 |
{ /* container class */ |
| 283 |
/* extension */ NULL, |
| 284 |
} |
| 285 |
}; |
| 286 |
|
| 287 |
/* Establish the widget class name as an externally accessible symbol. |
| 288 |
Use the "externaldef" macro rather than the "extern" keyword. */ |
| 289 |
externaldef(exmcontainerwidgetclass) WidgetClass exmContainerWidgetClass = |
| 290 |
(WidgetClass) &exmContainerClassRec; |
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
/* Container Trait record for Grid */ |
| 295 |
static XmContainerTraitRec containerCT = { |
| 296 |
0, /* version */ |
| 297 |
ContainerGetValues, |
| 298 |
}; |
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
/************************************************************************ |
| 303 |
* GetFirstColumnWidth |
| 304 |
************************************************************************/ |
| 305 |
/*ARGSUSED*/ |
| 306 |
static void |
| 307 |
GetFirstColumnWidth( |
| 308 |
Widget wid, |
| 309 |
int offset, /* unused */ |
| 310 |
XtArgVal *value) |
| 311 |
{ |
| 312 |
ExmContainerWidget cw = (ExmContainerWidget) wid ; |
| 313 |
Dimension fcw = cw->container.first_column_width ; |
| 314 |
|
| 315 |
if (!fcw) { |
| 316 |
/* get the max of icon_width + their indentation */ |
| 317 |
fcw = GetDefaultFirstColumnWidth(cw, 0); |
| 318 |
} |
| 319 |
|
| 320 |
*value = (XtArgVal)fcw; |
| 321 |
} |
| 322 |
|
| 323 |
|
| 324 |
/************************************************************************ |
| 325 |
* GetDetailTabList |
| 326 |
************************************************************************/ |
| 327 |
/*ARGSUSED*/ |
| 328 |
static void |
| 329 |
GetDetailTabList( |
| 330 |
Widget wid, |
| 331 |
int offset, /* unused */ |
| 332 |
XtArgVal *value) |
| 333 |
{ |
| 334 |
ExmContainerWidget cw = (ExmContainerWidget) wid ; |
| 335 |
XmTabList tab_list = cw->container.detail_tablist ; |
| 336 |
|
| 337 |
if (!tab_list) { |
| 338 |
/* get the default one */ |
| 339 |
Cardinal detail_order_count ; |
| 340 |
|
| 341 |
if (cw->container.detail_order_count != 0) { |
| 342 |
detail_order_count = cw->container.detail_order_count ; |
| 343 |
} else { |
| 344 |
detail_order_count = |
| 345 |
GetDefaultDetailCount(cw, 0) ; |
| 346 |
} |
| 347 |
tab_list = GetDefaultTabList(cw, detail_order_count); |
| 348 |
/* callers should not free this memory */ |
| 349 |
} |
| 350 |
|
| 351 |
*value = (XtArgVal)tab_list; |
| 352 |
} |
| 353 |
|
| 354 |
|
| 355 |
/**************************************************************************** |
| 356 |
* |
| 357 |
* SelectColorDefault. |
| 358 |
* |
| 359 |
****************************************************************************/ |
| 360 |
static void |
| 361 |
SelectColorDefault( |
| 362 |
Widget widget, |
| 363 |
int offset, |
| 364 |
XrmValue *value ) |
| 365 |
{ |
| 366 |
XmeGetDefaultPixel (widget, XmSELECT, offset, value); |
| 367 |
} |
| 368 |
|
| 369 |
/**************************************************************************** |
| 370 |
* |
| 371 |
* ClassPartInitialize: |
| 372 |
* Called when this widget or a subclass of this widget is instantiated. |
| 373 |
* |
| 374 |
****************************************************************************/ |
| 375 |
static void |
| 376 |
ClassPartInitialize ( |
| 377 |
WidgetClass widgetClass |
| 378 |
) |
| 379 |
{ |
| 380 |
/* Install the XmQTcontainer trait on ExmContainer |
| 381 |
and all its subclasses. */ |
| 382 |
XmeTraitSet(widgetClass, XmQTcontainer, (XtPointer) &containerCT); |
| 383 |
} |
| 384 |
|
| 385 |
|
| 386 |
/************************************************************************ |
| 387 |
* Initialize |
| 388 |
************************************************************************/ |
| 389 |
/*ARGSUSED*/ |
| 390 |
static void |
| 391 |
Initialize( |
| 392 |
Widget rw, |
| 393 |
Widget nw, |
| 394 |
ArgList args, /* unused */ |
| 395 |
Cardinal *num_args) /* unused */ |
| 396 |
{ |
| 397 |
ExmContainerWidget cw = (ExmContainerWidget)nw; |
| 398 |
ExmContainerWidget rcw = (ExmContainerWidget)rw; |
| 399 |
Arg sargs[10] ; |
| 400 |
Cardinal n = 0, i ; |
| 401 |
Widget header_parent = nw ; |
| 402 |
unsigned char scrollp = XmAPPLICATION_DEFINED ; |
| 403 |
XmScrollFrameTrait scrollFrameTrait; |
| 404 |
|
| 405 |
cw->container.icon_header = NULL ; |
| 406 |
|
| 407 |
if (cw->container.detail_header && |
| 408 |
cw->container.detail_header_count) { |
| 409 |
|
| 410 |
/**** first make a copy of the detail header table */ |
| 411 |
cw->container.detail_header = (XmStringTable) |
| 412 |
XtMalloc(cw->container.detail_header_count * sizeof(XmString)); |
| 413 |
|
| 414 |
for (i=0; i<cw->container.detail_header_count; i++) |
| 415 |
cw->container.detail_header[i] = |
| 416 |
XmStringCopy(rcw->container.detail_header[i]); |
| 417 |
|
| 418 |
/**** deal with the IconHeader creation */ |
| 419 |
scrollFrameTrait = (XmScrollFrameTrait) |
| 420 |
XmeTraitGet((XtPointer) XtClass(XtParent(nw)), XmQTscrollFrame); |
| 421 |
|
| 422 |
/* check that the parent is a scrollframe already initialize, |
| 423 |
which also means an automatic scrolledwindow in Motif */ |
| 424 |
if (scrollFrameTrait && |
| 425 |
scrollFrameTrait -> getInfo (XtParent(nw), NULL, NULL, NULL)) { |
| 426 |
|
| 427 |
scrollp = XmAUTOMATIC ; |
| 428 |
/* use an intermediate DA so that we can have margins */ |
| 429 |
n = 0 ; |
| 430 |
XtSetArg(sargs[n], XmNmarginHeight, |
| 431 |
cw->grid.margin_height); n++ ; |
| 432 |
XtSetArg(sargs[n], XmNmarginWidth, |
| 433 |
cw->grid.margin_width); n++ ; |
| 434 |
XtSetArg(sargs[n], XmNscrolledWindowChildType, |
| 435 |
XmSCROLL_HOR); n++; |
| 436 |
XtSetArg(sargs[n], XmNbackground, |
| 437 |
nw->core.background_pixel); n++; |
| 438 |
XtSetArg(sargs[n], XmNbackgroundPixmap, |
| 439 |
nw->core.background_pixmap); n++; |
| 440 |
XtSetArg(sargs[n], XmNborderWidth, |
| 441 |
nw->core.border_width); n++; |
| 442 |
XtSetArg(sargs[n], XmNforeground, |
| 443 |
cw->manager.foreground); n++; |
| 444 |
header_parent = XmCreateDrawingArea(XtParent(nw), |
| 445 |
"HeaderDA", sargs, n); |
| 446 |
XtManageChild(header_parent); |
| 447 |
} |
| 448 |
|
| 449 |
n = 0 ; |
| 450 |
/* this is required */ |
| 451 |
XtSetArg(sargs[n], XmNcontainerID, nw); n++ ; |
| 452 |
|
| 453 |
/* this is optional */ |
| 454 |
XtSetArg(sargs[n], XmNshadowThickness, 0); n++ ; |
| 455 |
XtSetArg(sargs[n], XmNtraversalOn, False); n++ ; |
| 456 |
|
| 457 |
XtSetArg(sargs[n], XmNlabelString, |
| 458 |
cw->container.detail_header[0]); n++ ; |
| 459 |
if (cw->container.detail_header_count > 1) { |
| 460 |
XtSetArg(sargs[n], XmNdetail, |
| 461 |
&(cw->container.detail_header[1])); n++ ; |
| 462 |
} |
| 463 |
XtSetArg(sargs[n], XmNdetailCount, |
| 464 |
cw->container.detail_header_count - 1); n++ ; |
| 465 |
|
| 466 |
cw->container.icon_header = XmCreateIconHeader(header_parent, |
| 467 |
"Header", sargs, n); |
| 468 |
XtManageChild(cw->container.icon_header); |
| 469 |
|
| 470 |
/**** Now we have to position the Container properly in the |
| 471 |
scrolling window if there is one */ |
| 472 |
|
| 473 |
if (scrollp == XmAUTOMATIC) { |
| 474 |
cw->core.y = cw->container.icon_header->core.height ; |
| 475 |
/* also resize the DA to remove the bottom margin */ |
| 476 |
XmeConfigureObject(header_parent, |
| 477 |
header_parent->core.x, |
| 478 |
header_parent->core.y, |
| 479 |
cw->container.icon_header->core.width + |
| 480 |
2*cw->grid.margin_height, |
| 481 |
cw->container.icon_header->core.height + |
| 482 |
cw->grid.margin_height, |
| 483 |
header_parent->core.border_width); |
| 484 |
} else { |
| 485 |
/* if not scrolling, no need to keep it, it will |
| 486 |
be dealt with as a regular kid */ |
| 487 |
cw->container.icon_header = NULL ; |
| 488 |
} |
| 489 |
} |
| 490 |
|
| 491 |
/**** copy the tablist */ |
| 492 |
if (cw->container.detail_tablist) { |
| 493 |
cw->container.detail_tablist = |
| 494 |
XmTabListCopy(cw->container.detail_tablist, 0, 0); |
| 495 |
} |
| 496 |
|
| 497 |
|
| 498 |
/* add an event handler to play with selection */ |
| 499 |
XtAddEventHandler(nw, ButtonPressMask, False, ButtonHandler, NULL); |
| 500 |
|
| 501 |
} |
| 502 |
|
| 503 |
static void |
| 504 |
ButtonHandler(Widget wid, |
| 505 |
XtPointer data, |
| 506 |
XEvent * event, |
| 507 |
Boolean *cont) |
| 508 |
{ |
| 509 |
Widget item ; |
| 510 |
XmContainerItemDataRec cItemData; |
| 511 |
XmContainerItemTrait cItemTrait; |
| 512 |
|
| 513 |
item = XmObjectAtPoint(wid, event->xbutton.x, event->xbutton.y); |
| 514 |
|
| 515 |
if (item) { |
| 516 |
if ((cItemTrait = (XmContainerItemTrait) |
| 517 |
XmeTraitGet((XtPointer)XtClass(item), |
| 518 |
XmQTcontainerItem))) { |
| 519 |
cItemData.valueMask = ContItemVisualEmphasis; |
| 520 |
cItemTrait->getValues(item, &cItemData); |
| 521 |
if (cItemData.visual_emphasis == XmSELECTED) |
| 522 |
cItemData.visual_emphasis = XmNOT_SELECTED ; |
| 523 |
else |
| 524 |
cItemData.visual_emphasis = XmSELECTED ; |
| 525 |
|
| 526 |
cItemTrait->setValues(item, &cItemData); |
| 527 |
} |
| 528 |
} |
| 529 |
} |
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
/************************************************************************ |
| 535 |
* Destroy |
| 536 |
************************************************************************/ |
| 537 |
static void |
| 538 |
Destroy( |
| 539 |
Widget wid) |
| 540 |
{ |
| 541 |
ExmContainerWidget cw = (ExmContainerWidget)wid; |
| 542 |
Cardinal i ; |
| 543 |
|
| 544 |
if (cw->container.icon_header) { |
| 545 |
/* that will destroy the icon header child as well */ |
| 546 |
XtDestroyWidget(XtParent(cw->container.icon_header)); |
| 547 |
} |
| 548 |
|
| 549 |
if (cw->container.detail_header && |
| 550 |
cw->container.detail_header_count) { |
| 551 |
|
| 552 |
for (i=0; i<cw->container.detail_header_count; i++) |
| 553 |
XmStringFree(cw->container.detail_header[i]); |
| 554 |
|
| 555 |
XtFree((char*)cw->container.detail_header); |
| 556 |
} |
| 557 |
|
| 558 |
if (cw->container.detail_tablist) { |
| 559 |
XmTabListFree(cw->container.detail_tablist); |
| 560 |
} |
| 561 |
} |
| 562 |
|
| 563 |
|
| 564 |
/***************************************************************************** |
| 565 |
* |
| 566 |
* NeedRelayout: |
| 567 |
* need to tell if any of the resource values change should cause |
| 568 |
* a relayout. Must envelop the superclass method because it is |
| 569 |
* only called once by the superclass defining the method. |
| 570 |
* |
| 571 |
****************************************************************************/ |
| 572 |
static Boolean |
| 573 |
NeedRelayout ( |
| 574 |
Widget old_w, |
| 575 |
Widget new_w |
| 576 |
) |
| 577 |
{ |
| 578 |
ExmContainerWidget cw = (ExmContainerWidget)old_w; |
| 579 |
ExmContainerWidget nw = (ExmContainerWidget)new_w; |
| 580 |
Boolean need_relayout ; |
| 581 |
|
| 582 |
/* envelop the superclass method */ |
| 583 |
need_relayout = |
| 584 |
((* ((ExmGridClassRec *) exmContainerClassRec.core_class.superclass) |
| 585 |
->grid_class.need_relayout) (old_w, new_w) || |
| 586 |
(nw->container.first_column_width != |
| 587 |
cw->container.first_column_width || |
| 588 |
nw->container.detail_order != cw->container.detail_order || |
| 589 |
nw->container.detail_order_count != |
| 590 |
cw->container.detail_order_count || |
| 591 |
nw->container.detail_tablist != |
| 592 |
cw->container.detail_tablist)); |
| 593 |
|
| 594 |
|
| 595 |
return (need_relayout); |
| 596 |
} |
| 597 |
|
| 598 |
|
| 599 |
/*************************************************************************** |
| 600 |
* |
| 601 |
* Layout: |
| 602 |
* Does all the placement of children. |
| 603 |
* Instigator tells whether or not to resize all children. |
| 604 |
* |
| 605 |
*************************************************************************/ |
| 606 |
static void |
| 607 |
Layout ( |
| 608 |
Widget wid, |
| 609 |
Widget instigator |
| 610 |
) |
| 611 |
{ |
| 612 |
ExmContainerWidget cw = (ExmContainerWidget) wid ; |
| 613 |
Cardinal i, num_managed = 0; |
| 614 |
int line_count ; |
| 615 |
Dimension width, height, baseline_first = 0, interspace_max = 0, |
| 616 |
pref_height, interspace; |
| 617 |
int height_under_prec = 0 ; |
| 618 |
Dimension * baselines ; |
| 619 |
Position x, y ; |
| 620 |
|
| 621 |
/**** a first pass to compute the interspace */ |
| 622 |
for (i = 0; i < cw->composite.num_children; i++) { |
| 623 |
Widget ic = cw->composite.children[i]; |
| 624 |
XtWidgetGeometry reply; |
| 625 |
|
| 626 |
if (!XtIsManaged(ic)) continue ; |
| 627 |
num_managed ++ ; |
| 628 |
|
| 629 |
/* ask for preferred height and baseline to the kid */ |
| 630 |
|
| 631 |
XmWidgetGetBaselines(ic, &baselines, &line_count); |
| 632 |
if (!line_count) continue ; |
| 633 |
|
| 634 |
/* store the first baseline and height under */ |
| 635 |
if (!baseline_first) { |
| 636 |
baseline_first = baselines[0]; |
| 637 |
/* negative so that it gives 0 below, so that it |
| 638 |
doesn't count in the max */ |
| 639 |
height_under_prec = -baseline_first ; |
| 640 |
} |
| 641 |
|
| 642 |
interspace = height_under_prec + baselines[0] ; |
| 643 |
interspace_max = Max(interspace_max, interspace); |
| 644 |
|
| 645 |
/* Get child's preferred height. */ |
| 646 |
XtQueryGeometry (ic, NULL, &reply); |
| 647 |
pref_height = (reply.request_mode & CWHeight) ? |
| 648 |
reply.height : ic->core.height; |
| 649 |
|
| 650 |
height_under_prec = pref_height - baselines[0] ; |
| 651 |
|
| 652 |
XtFree((char*) baselines); |
| 653 |
|
| 654 |
} |
| 655 |
|
| 656 |
/* now layout */ |
| 657 |
|
| 658 |
/**** a second pass to actually do the layout */ |
| 659 |
|
| 660 |
/* first deal with the icon header outside the container */ |
| 661 |
if (cw->container.icon_header && |
| 662 |
XtIsManaged(cw->container.icon_header)) { |
| 663 |
Widget header_parent ; |
| 664 |
|
| 665 |
XmeConfigureObject (cw->container.icon_header, |
| 666 |
cw->grid.margin_width, |
| 667 |
cw->grid.margin_height, |
| 668 |
cw->core.width - 2*cw->grid.margin_width, |
| 669 |
cw->container.icon_header->core.height, |
| 670 |
cw->container.icon_header->core.border_width); |
| 671 |
|
| 672 |
/* also reconfigure the parent DA */ |
| 673 |
header_parent = XtParent(cw->container.icon_header) ; |
| 674 |
XmeConfigureObject(header_parent, |
| 675 |
header_parent->core.x, |
| 676 |
header_parent->core.y, |
| 677 |
cw->core.width, |
| 678 |
cw->container.icon_header->core.height + |
| 679 |
cw->grid.margin_height, |
| 680 |
header_parent->core.border_width); |
| 681 |
} |
| 682 |
|
| 683 |
y = cw->grid.margin_height ; |
| 684 |
for (i = 0; i < cw->composite.num_children; i++) { |
| 685 |
Widget ic = cw->composite.children[i]; |
| 686 |
ExmGridConstraint glc = ExmGridCPart (ic); |
| 687 |
|
| 688 |
if (LayoutIsRtoLM(cw)) |
| 689 |
x = cw->grid.margin_width ; |
| 690 |
else |
| 691 |
x = cw->grid.margin_width + glc->grid_margin_width_within_cell ; |
| 692 |
width = cw->core.width - 2*cw->grid.margin_width - |
| 693 |
glc->grid_margin_width_within_cell; |
| 694 |
height = ic->core.height ; |
| 695 |
if (ic != instigator) { |
| 696 |
XtConfigureWidget (ic, x, y, width, height, ic->core.border_width); |
| 697 |
} |
| 698 |
else { |
| 699 |
ic->core.x = x; |
| 700 |
ic->core.y = y; |
| 701 |
ic->core.width = width; |
| 702 |
ic->core.height = height; |
| 703 |
} |
| 704 |
XmWidgetGetBaselines(ic, &baselines, &line_count); |
| 705 |
if (line_count) y += baselines[0] + interspace_max ; |
| 706 |
|
| 707 |
if (i != cw->composite.num_children - 1) { |
| 708 |
XmWidgetGetBaselines(cw->composite.children[i+1], |
| 709 |
&baselines, &line_count); |
| 710 |
if (line_count) y -= baselines[0] ; |
| 711 |
} |
| 712 |
} |
| 713 |
} |
| 714 |
|
| 715 |
/**************************************************************************** |
| 716 |
* |
| 717 |
* CalcSize: |
| 718 |
* Calculate the ideal size of the ExmGrid widget. |
| 719 |
* Only affect the returned size if it is 0 |
| 720 |
* |
| 721 |
***************************************************************************/ |
| 722 |
static void |
| 723 |
CalcSize ( |
| 724 |
Widget wid, |
| 725 |
Widget instigator, |
| 726 |
Dimension *width_ret, |
| 727 |
Dimension *height_ret) |
| 728 |
{ |
| 729 |
/* The Width of the Container is the sum of the first_column_width |
| 730 |
and the detail width. |
| 731 |
If the first_column_width is not set, we must compute it as the |
| 732 |
max of all the icon_width at their position (we set the fcw |
| 733 |
temporarily so that it is not recomputed when the detailwidth are |
| 734 |
calculated. |
| 735 |
The detail width is the position of the last tab if there is one |
| 736 |
for the last detail_order, otherwise it's the max width of all |
| 737 |
icon detail width. |
| 738 |
The Height of the container is n-1 time the max of height_under |
| 739 |
baseline of i-1 + baseline of i , + baseline 0 + h_under n-1 */ |
| 740 |
|
| 741 |
ExmContainerWidget cw = (ExmContainerWidget) wid ; |
| 742 |
Boolean fcw_set = False ; |
| 743 |
Cardinal i, num_managed = 0 ; |
| 744 |
int line_count ; |
| 745 |
Dimension height, baseline_first = 0, interspace_max = 0, |
| 746 |
pref_height, pref_width, interspace, detail_width; |
| 747 |
int height_under_prec = 0 ; |
| 748 |
Dimension * baselines ; |
| 749 |
Cardinal tab_count = 0 ; |
| 750 |
|
| 751 |
/**** first get the first column width */ |
| 752 |
if (!cw->container.first_column_width) { |
| 753 |
|
| 754 |
cw->container.first_column_width = GetDefaultFirstColumnWidth(cw, 0); |
| 755 |
|
| 756 |
/* we don't want to keep this calculated first_column_width in cw, |
| 757 |
so set a flag to reset it to 0 at the end */ |
| 758 |
fcw_set = True ; |
| 759 |
} |
| 760 |
|
| 761 |
|
| 762 |
/**** now get the details part */ |
| 763 |
if (cw->container.layout_type != XmDETAIL) |
| 764 |
detail_width = 0 ; |
| 765 |
else { |
| 766 |
if (cw->container.detail_tablist) |
| 767 |
tab_count = XmTabListTabCount(cw->container.detail_tablist) ; |
| 768 |
if (cw->container.detail_order_count && |
| 769 |
tab_count >= cw->container.detail_order_count) { |
| 770 |
detail_width = XmTabListGetPosition(XtScreen((Widget)cw), |
| 771 |
cw->container.detail_tablist, tab_count-1); |
| 772 |
} else { |
| 773 |
XtWidgetGeometry reply; |
| 774 |
|
| 775 |
/* get the max width of all details */ |
| 776 |
if (cw->container.icon_header && |
| 777 |
XtIsManaged(cw->container.icon_header)) { |
| 778 |
Dimension header_width ; |
| 779 |
|
| 780 |
/* start with header's preferred width. */ |
| 781 |
XtQueryGeometry (cw->container.icon_header, NULL, &reply); |
| 782 |
header_width = (reply.request_mode & CWWidth) ? |
| 783 |
reply.width : cw->container.icon_header->core.width; |
| 784 |
detail_width = header_width - |
| 785 |
/* remove the horiz indent */ |
| 786 |
(cw->container.first_column_width |
| 787 |
- cw->container.icon_header->core.x); |
| 788 |
} else |
| 789 |
detail_width = 0 ; |
| 790 |
|
| 791 |
for (i = 0; i < cw->composite.num_children; i++) { |
| 792 |
Widget ic = cw->composite.children[i]; |
| 793 |
|
| 794 |
/* Get child's preferred width. */ |
| 795 |
if (ic != instigator) { |
| 796 |
XtQueryGeometry (ic, NULL, &reply); |
| 797 |
pref_width = (reply.request_mode & CWWidth) ? |
| 798 |
reply.width : ic->core.width; |
| 799 |
} else { |
| 800 |
pref_width = ic->core.width ; |
| 801 |
} |
| 802 |
|
| 803 |
detail_width = Max(detail_width, |
| 804 |
pref_width - |
| 805 |
/* remove the horiz indent */ |
| 806 |
(cw->container.first_column_width |
| 807 |
- ic->core.x)); |
| 808 |
} |
| 809 |
} |
| 810 |
} |
| 811 |
|
| 812 |
/**** compute the ideal height */ |
| 813 |
for (i = 0; i < cw->composite.num_children; i++) { |
| 814 |
Widget ic = cw->composite.children[i]; |
| 815 |
XtWidgetGeometry reply; |
| 816 |
|
| 817 |
if (!XtIsManaged(ic)) continue ; |
| 818 |
num_managed ++ ; |
| 819 |
|
| 820 |
/* ask for preferred height and baseline to the kid */ |
| 821 |
|
| 822 |
XmWidgetGetBaselines(ic, &baselines, &line_count); |
| 823 |
if (!line_count) continue ; |
| 824 |
|
| 825 |
/* store the first baseline and height under */ |
| 826 |
if (!baseline_first) { |
| 827 |
baseline_first = baselines[0]; |
| 828 |
/* negative so that it gives 0 below, so that it |
| 829 |
doesn't count in the max */ |
| 830 |
height_under_prec = -baseline_first ; |
| 831 |
} |
| 832 |
|
| 833 |
interspace = height_under_prec + baselines[0] ; |
| 834 |
interspace_max = Max(interspace_max, interspace); |
| 835 |
|
| 836 |
/* Get child's preferred height. */ |
| 837 |
XtQueryGeometry (ic, NULL, &reply); |
| 838 |
pref_height = (reply.request_mode & CWHeight) ? |
| 839 |
reply.height : ic->core.height; |
| 840 |
|
| 841 |
height_under_prec = pref_height - baselines[0] ; |
| 842 |
|
| 843 |
XtFree((char*) baselines); |
| 844 |
|
| 845 |
} |
| 846 |
|
| 847 |
/* now sum up everything */ |
| 848 |
height = baseline_first + interspace_max * (num_managed-1) + |
| 849 |
height_under_prec ; |
| 850 |
|
| 851 |
/*** do not set non null dimensions */ |
| 852 |
if (*width_ret == 0) *width_ret = |
| 853 |
cw->container.first_column_width + detail_width + |
| 854 |
cw->grid.margin_width ; |
| 855 |
if (*height_ret == 0) *height_ret = height + |
| 856 |
2*cw->grid.margin_height; |
| 857 |
|
| 858 |
|
| 859 |
/*** set it back to 0, a getvalueshook will provide the real |
| 860 |
information */ |
| 861 |
if (fcw_set) cw->container.first_column_width = 0 ; |
| 862 |
} |
| 863 |
|
| 864 |
|
| 865 |
/************************************************************************ |
| 866 |
* GetDefaultFirstColumnWidth |
| 867 |
************************************************************************/ |
| 868 |
/*ARGSUSED*/ |
| 869 |
static Dimension |
| 870 |
GetDefaultFirstColumnWidth( |
| 871 |
ExmContainerWidget cw, |
| 872 |
Dimension first_column_width) |
| 873 |
{ |
| 874 |
Dimension width ; |
| 875 |
Cardinal i ; |
| 876 |
XmContainerItemDataRec cont_item_data ; |
| 877 |
XmContainerItemTrait cont_item_trait ; |
| 878 |
|
| 879 |
/* Get the max icon width + indent of all managed kids */ |
| 880 |
|
| 881 |
/* deal with icon_header outside container first */ |
| 882 |
if (cw->container.icon_header && |
| 883 |
XtIsManaged(cw->container.icon_header)) { |
| 884 |
|
| 885 |
/* start with header's icon width. */ |
| 886 |
cont_item_trait = (XmContainerItemTrait) |
| 887 |
XmeTraitGet((XtPointer) XtClass(cw->container.icon_header), |
| 888 |
XmQTcontainerItem) ; |
| 889 |
|
| 890 |
cont_item_data.valueMask = ContItemIconWidth ; |
| 891 |
cont_item_trait->getValues(cw->container.icon_header, |
| 892 |
&cont_item_data); |
| 893 |
first_column_width = Max(first_column_width, |
| 894 |
cw->grid.margin_width + |
| 895 |
cont_item_data.icon_width) ; |
| 896 |
} |
| 897 |
|
| 898 |
for (i = 0; i < cw->composite.num_children; i++) { |
| 899 |
Widget ic = cw->composite.children[i]; |
| 900 |
ExmGridConstraint glc = ExmGridCPart (ic); |
| 901 |
|
| 902 |
if (!XtIsManaged(ic)) continue ; |
| 903 |
|
| 904 |
/* if the child has the ContItem trait, use its icon_width, |
| 905 |
othersize, use it's width */ |
| 906 |
|
| 907 |
cont_item_trait = (XmContainerItemTrait) |
| 908 |
XmeTraitGet((XtPointer) XtClass(ic), XmQTcontainerItem) ; |
| 909 |
|
| 910 |
if (cont_item_trait) { |
| 911 |
cont_item_data.valueMask = ContItemIconWidth ; |
| 912 |
cont_item_trait->getValues(ic, &cont_item_data); |
| 913 |
width = cont_item_data.icon_width ; |
| 914 |
} else { |
| 915 |
width = ic->core.width ; |
| 916 |
} |
| 917 |
|
| 918 |
/* the inner cell margin width plays the outline |
| 919 |
indentation role in this example widget */ |
| 920 |
first_column_width = |
| 921 |
Max (first_column_width, |
| 922 |
cw->grid.margin_width + width |
| 923 |
+ glc->grid_margin_width_within_cell); |
| 924 |
} |
| 925 |
|
| 926 |
return first_column_width ; |
| 927 |
} |
| 928 |
|
| 929 |
|
| 930 |
/************************************************************************ |
| 931 |
* GetDefaultDetailCount |
| 932 |
************************************************************************/ |
| 933 |
/*ARGSUSED*/ |
| 934 |
static Cardinal |
| 935 |
GetDefaultDetailCount( |
| 936 |
ExmContainerWidget cw, |
| 937 |
Cardinal detail_count) |
| 938 |
{ |
| 939 |
Cardinal i ; |
| 940 |
XmContainerItemDataRec cont_item_data ; |
| 941 |
XmContainerItemTrait cont_item_trait ; |
| 942 |
|
| 943 |
/* Get the max detail_count of all managed kids */ |
| 944 |
|
| 945 |
/* deal with icon_header outside container first */ |
| 946 |
if (cw->container.icon_header && |
| 947 |
XtIsManaged(cw->container.icon_header)) { |
| 948 |
|
| 949 |
/* start with header's detail_count */ |
| 950 |
cont_item_trait = (XmContainerItemTrait) |
| 951 |
XmeTraitGet((XtPointer) XtClass(cw->container.icon_header), |
| 952 |
XmQTcontainerItem) ; |
| 953 |
|
| 954 |
/* icon headert always has the trait */ |
| 955 |
cont_item_data.valueMask = ContItemDetailCount ; |
| 956 |
cont_item_trait->getValues(cw->container.icon_header, |
| 957 |
&cont_item_data); |
| 958 |
detail_count = Max(detail_count, cont_item_data.detail_count) ; |
| 959 |
} |
| 960 |
|
| 961 |
for (i = 0; i < cw->composite.num_children; i++) { |
| 962 |
Widget ic = cw->composite.children[i]; |
| 963 |
|
| 964 |
if (!XtIsManaged(ic)) continue ; |
| 965 |
|
| 966 |
/* if the child has the ContItem trait, use its detail_count */ |
| 967 |
|
| 968 |
cont_item_trait = (XmContainerItemTrait) |
| 969 |
XmeTraitGet((XtPointer) XtClass(ic), XmQTcontainerItem) ; |
| 970 |
|
| 971 |
if (cont_item_trait) { |
| 972 |
cont_item_data.valueMask = ContItemDetailCount ; |
| 973 |
cont_item_trait->getValues(ic, &cont_item_data); |
| 974 |
|
| 975 |
detail_count = |
| 976 |
Max (detail_count, cont_item_data.detail_count); |
| 977 |
} |
| 978 |
} |
| 979 |
|
| 980 |
return detail_count ; |
| 981 |
} |
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
/**************************************************************************** |
| 986 |
* |
| 987 |
* GetDefaultTabList |
| 988 |
* (XmNwidth-2*XmNmarginWidth-XmNfirstColumnWidth)/XmNdetailOrderCount |
| 989 |
* |
| 990 |
***************************************************************************/ |
| 991 |
static XmTabList |
| 992 |
GetDefaultTabList( |
| 993 |
ExmContainerWidget cw, |
| 994 |
Cardinal detail_order_count) |
| 995 |
{ |
| 996 |
XmTabList default_tablist = NULL ; |
| 997 |
|
| 998 |
/* if the Container has a valid size, a default tablist of |
| 999 |
size detail_order_count shall be returned in detail_tablist. |
| 1000 |
The tabs in this tablist shall be equal to: |
| 1001 |
|
| 1002 |
(XmNwidth-2*XmNmarginWidth-XmNfirstColumnWidth) |
| 1003 |
/XmNdetailOrderCount |
| 1004 |
|
| 1005 |
If XmNwidth is not yet valid, a NULL detail_tablist |
| 1006 |
is returned, so that the icon can concat all its details |
| 1007 |
and get a reasonable size. */ |
| 1008 |
|
| 1009 |
if (cw->core.width) { |
| 1010 |
Dimension tab_size = 0 ; |
| 1011 |
|
| 1012 |
if ((cw->core.width > (2*cw->grid.margin_width + |
| 1013 |
cw->container.first_column_width)) && |
| 1014 |
detail_order_count) { |
| 1015 |
tab_size = (cw->core.width - 2*cw->grid.margin_width - |
| 1016 |
cw->container.first_column_width) |
| 1017 |
/ detail_order_count ; |
| 1018 |
default_tablist = GetDumbTabList(tab_size, |
| 1019 |
detail_order_count); |
| 1020 |
} /* else return NULL as well */ |
| 1021 |
} |
| 1022 |
|
| 1023 |
return default_tablist ; |
| 1024 |
} |
| 1025 |
|
| 1026 |
|
| 1027 |
/**************************************************************************** |
| 1028 |
* |
| 1029 |
* GetDumbTabList |
| 1030 |
* fixed space - lazy allocation .do not deallocate the returned value |
| 1031 |
* |
| 1032 |
***************************************************************************/ |
| 1033 |
static XmTabList |
| 1034 |
GetDumbTabList( |
| 1035 |
Dimension tab_size, |
| 1036 |
Cardinal asked_num_tab) |
| 1037 |
{ |
| 1038 |
static int Num_tab = 0 ; |
| 1039 |
static XmTab * Tab_pool = NULL ; |
| 1040 |
static XmTabList Tab_list = NULL ; |
| 1041 |
Cardinal i, prev_num_tab = Num_tab ; |
| 1042 |
|
| 1043 |
if (Num_tab < asked_num_tab) { |
| 1044 |
Num_tab = asked_num_tab ; |
| 1045 |
Tab_pool = (XmTab*) XtRealloc((char*)Tab_pool, |
| 1046 |
Num_tab*sizeof(XmTab)); |
| 1047 |
} |
| 1048 |
|
| 1049 |
/* create more tabs */ |
| 1050 |
for (i=prev_num_tab; i<Num_tab; i++) |
| 1051 |
Tab_pool[i] = XmTabCreate(0.0, XmPIXELS, XmABSOLUTE, |
| 1052 |
XmALIGNMENT_BEGINNING, XmS); |
| 1053 |
|
| 1054 |
/* update the values */ |
| 1055 |
for (i=0; i<asked_num_tab; i++) |
| 1056 |
XmTabSetValue(Tab_pool[i], (float)tab_size*(i+1)); |
| 1057 |
|
| 1058 |
/* free the previous tablist and return a new one. |
| 1059 |
Not clear what is going to happen to the Tab_pool array, |
| 1060 |
is it going to be copied or ref counted, but I won't free them... */ |
| 1061 |
if (Tab_list) XmTabListFree(Tab_list); |
| 1062 |
Tab_list = XmTabListInsertTabs(NULL, Tab_pool, asked_num_tab, 0); |
| 1063 |
|
| 1064 |
return Tab_list ; |
| 1065 |
} |
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
/*-- Trait methods --*/ |
| 1070 |
|
| 1071 |
/************************************************************************ |
| 1072 |
* ContainerGetValues |
| 1073 |
* |
| 1074 |
************************************************************************/ |
| 1075 |
static void |
| 1076 |
ContainerGetValues(Widget w, |
| 1077 |
XmContainerData containerData) |
| 1078 |
{ |
| 1079 |
|
| 1080 |
ExmContainerWidget cw = (ExmContainerWidget) w ; |
| 1081 |
Boolean fcw_set = False ; |
| 1082 |
|
| 1083 |
/**** fill in detail_order */ |
| 1084 |
if (cw->container.layout_type == XmDETAIL) { |
| 1085 |
if (cw->container.detail_order_count != 0) { |
| 1086 |
containerData->detail_order_count = |
| 1087 |
cw->container.detail_order_count ; |
| 1088 |
containerData->detail_order = cw->container.detail_order ; |
| 1089 |
} else { |
| 1090 |
/* take the max detail count and return NULL for the |
| 1091 |
detail_order, so that the icon takes a default order */ |
| 1092 |
if (containerData->valueMask & ContDetailOrder) { |
| 1093 |
containerData->detail_order_count = |
| 1094 |
GetDefaultDetailCount(cw, 0); |
| 1095 |
containerData->detail_order = NULL ; |
| 1096 |
} |
| 1097 |
} |
| 1098 |
} else { |
| 1099 |
containerData->detail_order_count = 0 ; |
| 1100 |
containerData->detail_order = NULL ; |
| 1101 |
} |
| 1102 |
|
| 1103 |
/**** if the resource firstColumnWidth is set, use it, otherwise, |
| 1104 |
default it */ |
| 1105 |
|
| 1106 |
if (cw->container.layout_type == XmDETAIL) { |
| 1107 |
if (cw->container.first_column_width) |
| 1108 |
containerData->first_column_width = |
| 1109 |
cw->container.first_column_width ; |
| 1110 |
else |
| 1111 |
/* don't bother computing it if not asked */ |
| 1112 |
if (containerData->valueMask & ContFirstColumnWidth) { |
| 1113 |
/* set the container resource temporarily */ |
| 1114 |
cw->container.first_column_width = |
| 1115 |
containerData->first_column_width = |
| 1116 |
GetDefaultFirstColumnWidth(cw, |
| 1117 |
containerData->first_column_width) ; |
| 1118 |
fcw_set = True ; |
| 1119 |
} |
| 1120 |
} else if (cw->container.layout_type == XmSPATIAL) |
| 1121 |
containerData->first_column_width = 0; |
| 1122 |
|
| 1123 |
/**** if detail_tablist has been set, use it, else compute a default */ |
| 1124 |
if (cw->container.detail_tablist) |
| 1125 |
containerData->detail_tablist = cw->container.detail_tablist ; |
| 1126 |
else |
| 1127 |
/* go find a default only if needed */ |
| 1128 |
if (containerData->valueMask & ContDetailTabList) { |
| 1129 |
containerData->detail_tablist = GetDefaultTabList(cw, |
| 1130 |
containerData->detail_order_count); |
| 1131 |
} |
| 1132 |
|
| 1133 |
/**** get a value for this one - kinda random, just to test */ |
| 1134 |
if (cw->manager.navigation_type == XmTAB_GROUP) |
| 1135 |
containerData->selection_mode = XmNORMAL_MODE ; |
| 1136 |
else |
| 1137 |
containerData->selection_mode = XmADD_MODE ; |
| 1138 |
|
| 1139 |
|
| 1140 |
/**** just to try out the trait protocol */ |
| 1141 |
if (cw->container.select_color == WhitePixelOfScreen(XtScreen(w))) |
| 1142 |
containerData->valueMask &= ~ContSelectColor ; |
| 1143 |
else |
| 1144 |
containerData->select_color = cw->container.select_color ; |
| 1145 |
|
| 1146 |
|
| 1147 |
/*** set first_column_width back to 0, a getvalueshook |
| 1148 |
will provided the real |
| 1149 |
information */ |
| 1150 |
if (fcw_set) cw->container.first_column_width = 0 ; |
| 1151 |
|
| 1152 |
} |
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
/***************************************************************************** |
| 1158 |
* |
| 1159 |
* ExmCreateContainer: |
| 1160 |
* Called by an application. |
| 1161 |
* |
| 1162 |
****************************************************************************/ |
| 1163 |
Widget |
| 1164 |
ExmCreateContainer ( |
| 1165 |
Widget parent, |
| 1166 |
char *name, |
| 1167 |
ArgList arglist, |
| 1168 |
Cardinal argcount |
| 1169 |
) |
| 1170 |
{ |
| 1171 |
/* This is a convenience function to instantiate an ExmContainer widget. */ |
| 1172 |
return (XtCreateWidget (name, exmContainerWidgetClass, parent, |
| 1173 |
arglist, argcount)); |
| 1174 |
} |
| 1175 |
|