comparison lwlib/xlwtabs.c @ 428:3ecd8885ac67 r21-2-22

Import from CVS: tag r21-2-22
author cvs
date Mon, 13 Aug 2007 11:28:15 +0200
parents
children a5df635868b2
comparison
equal deleted inserted replaced
427:0a0253eac470 428:3ecd8885ac67
1 /* Tabs Widget for XEmacs.
2 Copyright (C) 1999 Edward A. Falk
3
4 This file is part of XEmacs.
5
6 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
10
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with XEmacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21 /* Synched up with: Tabs.c 1.23 */
22
23 /*
24 * Tabs.c - Index Tabs composite widget
25 *
26 * Author: Edward A. Falk
27 * falk@falconer.vip.best.com
28 *
29 * Date: July 29, 1997
30 *
31 *
32 * Overall layout of this widget is as follows:
33 *
34 * ________ ,---------. _________
35 * | label || Label || Label | \ tabs
36 * |________|| ||_________| /
37 * |+----------------------------+| \
38 * || || |
39 * || child widget window || > frame
40 * |+----------------------------+| |
41 * +------------------------------+ /
42 *
43 * The height of the tabs includes the shadow width, top and bottom
44 * margins, and the height of the text.
45 *
46 * The height of the frame includes the top and bottom shadow width and the
47 * size of the child widget window.
48 *
49 * The tabs overlap the frame and each other vertically by the shadow
50 * width, so that when the topmost tab is drawn, it obliterates part of
51 * the frame.
52 */
53
54 /* TODO: min child height = tab height
55 *
56 */
57
58 #include <config.h>
59 #include <stdio.h>
60
61 #include <X11/Xlib.h>
62 #include <X11/IntrinsicP.h>
63 #include <X11/StringDefs.h>
64 #include "../src/xmu.h"
65 #include "xlwtabsP.h"
66 #include "xlwgcs.h"
67
68 #define MIN_WID 10
69 #define MIN_HGT 10
70 #define INDENT 3 /* tabs indented from edge by this much */
71 #define SPACING 0 /* distance between tabs */
72 #define SHADWID 1 /* default shadow width */
73 #define TABDELTA 2 /* top tab grows this many pixels */
74 #define TABLDELTA 2 /* top tab label offset this many pixels */
75
76
77 /****************************************************************
78 *
79 * IndexTabs Resources
80 *
81 ****************************************************************/
82
83 static char defaultTranslations[] = "\
84 <BtnUp>: select() \n\
85 <FocusIn>: highlight() \n\
86 <FocusOut>: unhighlight() \n\
87 <Key>Page_Up: page(up) \n\
88 <Key>KP_Page_Up: page(up) \n\
89 <Key>Prior: page(up) \n\
90 <Key>KP_Prior: page(up) \n\
91 <Key>Page_Down: page(down) \n\
92 <Key>KP_Page_Down: page(down) \n\
93 <Key>Next: page(down) \n\
94 <Key>KP_Next: page(down) \n\
95 <Key>Home: page(home) \n\
96 <Key>KP_Home: page(home) \n\
97 <Key>End: page(end) \n\
98 <Key>KP_End: page(end) \n\
99 <Key>Up: highlight(up) \n\
100 <Key>KP_Up: highlight(up) \n\
101 <Key>Down: highlight(down) \n\
102 <Key>KP_Down: highlight(down) \n\
103 <Key> : page(select) \n\
104 " ;
105
106 static char accelTable[] = " #augment\n\
107 <Key>Page_Up: page(up) \n\
108 <Key>KP_Page_Up: page(up) \n\
109 <Key>Prior: page(up) \n\
110 <Key>KP_Prior: page(up) \n\
111 <Key>Page_Down: page(down) \n\
112 <Key>KP_Page_Down: page(down) \n\
113 <Key>Next: page(down) \n\
114 <Key>KP_Next: page(down) \n\
115 <Key>Home: page(home) \n\
116 <Key>KP_Home: page(home) \n\
117 <Key>End: page(end) \n\
118 <Key>KP_End: page(end) \n\
119 <Key>Up: highlight(up) \n\
120 <Key>KP_Up: highlight(up) \n\
121 <Key>Down: highlight(down) \n\
122 <Key>KP_Down: highlight(down) \n\
123 <Key> : page(select) \n\
124 " ;
125 static XtAccelerators defaultAccelerators ;
126
127 #define offset(field) XtOffsetOf(TabsRec, tabs.field)
128 static XtResource resources[] = {
129
130 {XtNselectInsensitive, XtCSelectInsensitive, XtRBoolean, sizeof(Boolean),
131 offset(selectInsensitive), XtRImmediate, (XtPointer) True},
132 {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
133 offset(font), XtRString, (XtPointer) XtDefaultFont},
134 {XtNinternalWidth, XtCWidth, XtRDimension, sizeof(Dimension),
135 offset(internalWidth), XtRImmediate, (XtPointer)4 },
136 {XtNinternalHeight, XtCHeight, XtRDimension, sizeof(Dimension),
137 offset(internalHeight), XtRImmediate, (XtPointer)4 },
138 {XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension),
139 XtOffsetOf(RectObjRec,rectangle.border_width), XtRImmediate, (XtPointer)0},
140 {XtNtopWidget, XtCTopWidget, XtRWidget, sizeof(Widget),
141 offset(topWidget), XtRImmediate, NULL},
142 {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
143 offset(callbacks), XtRCallback, NULL},
144 {XtNpopdownCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
145 offset(popdownCallbacks), XtRCallback, NULL},
146 {XtNbeNiceToColormap, XtCBeNiceToColormap, XtRBoolean, sizeof(Boolean),
147 offset(be_nice_to_cmap), XtRImmediate, (XtPointer) True},
148 {XtNtopShadowContrast, XtCTopShadowContrast, XtRInt, sizeof(int),
149 offset(top_shadow_contrast), XtRImmediate, (XtPointer) 20},
150 {XtNbottomShadowContrast, XtCBottomShadowContrast, XtRInt, sizeof(int),
151 offset(bot_shadow_contrast), XtRImmediate, (XtPointer) 40},
152 {XtNinsensitiveContrast, XtCInsensitiveContrast, XtRInt, sizeof(int),
153 offset(insensitive_contrast), XtRImmediate, (XtPointer) 33},
154 {XtNaccelerators, XtCAccelerators, XtRAcceleratorTable,sizeof(XtTranslations),
155 XtOffsetOf(TabsRec,core.accelerators), XtRString, accelTable},
156 };
157 #undef offset
158
159
160
161 /* constraint resources */
162
163 #define offset(field) XtOffsetOf(TabsConstraintsRec, tabs.field)
164 static XtResource tabsConstraintResources[] = {
165 {XtNtabLabel, XtCLabel, XtRString, sizeof(String),
166 offset(label), XtRString, NULL},
167 {XtNtabLeftBitmap, XtCLeftBitmap, XtRBitmap, sizeof(Pixmap),
168 offset(left_bitmap), XtRImmediate, None},
169 {XtNtabForeground, XtCForeground, XtRPixel, sizeof(Pixel),
170 offset(foreground), XtRString, (XtPointer) XtDefaultForeground},
171 {XtNresizable, XtCResizable, XtRBoolean, sizeof(Boolean),
172 offset(resizable), XtRImmediate, (XtPointer) True},
173 } ;
174 #undef offset
175
176
177
178
179 #if !NeedFunctionPrototypes
180
181 /* FORWARD REFERENCES: */
182
183 /* member functions */
184
185 static void TabsClassInit();
186 static void TabsInit();
187 static void TabsResize();
188 static void TabsExpose();
189 static void TabsDestroy();
190 static void TabsRealize();
191 static Boolean TabsSetValues();
192 static XtGeometryResult TabsQueryGeometry();
193 static XtGeometryResult TabsGeometryManager();
194 static void TabsChangeManaged();
195 static void TabsConstraintInitialize() ;
196 static Boolean TabsConstraintSetValues() ;
197
198 /* action procs */
199
200 static void TabsSelect() ;
201 static void TabsPage() ;
202 static void TabsHighlight() ;
203 static void TabsUnhighlight() ;
204
205 /* internal privates */
206
207 static void TabsAllocGCs() ; /* get rendering GCs */
208 static void TabsFreeGCs() ; /* return rendering GCs */
209 static void DrawTabs() ; /* draw all tabs */
210 static void DrawTab() ; /* draw one index tab */
211 static void DrawFrame() ; /* draw frame around contents */
212 static void DrawTrim() ; /* draw trim around a tab */
213 static void DrawBorder() ; /* draw border */
214 static void DrawHighlight() ; /* draw highlight */
215 static void UndrawTab() ; /* undraw interior of a tab */
216 static void TabWidth() ; /* recompute tab size */
217 static void GetPreferredSizes() ; /* query all children for their sizes */
218 static void MaxChild() ; /* find max preferred child size */
219 static int PreferredSize() ; /* compute preferred size */
220 static int PreferredSize2() ; /* compute preferred size */
221 static int PreferredSize3() ; /* compute preferred size */
222 static void MakeSizeRequest() ; /* try to change size */
223 static void getBitmapInfo() ;
224 static int TabLayout() ; /* lay out tabs */
225 static void TabsShuffleRows() ; /* bring current tab to bottom row */
226
227 static void TabsAllocFgGC() ;
228 static void TabsAllocGreyGC() ;
229
230 #else
231
232 static void TabsClassInit(void) ;
233 static void TabsInit( Widget req, Widget new, ArgList, Cardinal *nargs) ;
234 static void TabsConstraintInitialize(Widget, Widget, ArgList, Cardinal *) ;
235 static void TabsRealize(Widget, Mask *, XSetWindowAttributes *) ;
236 static void TabsDestroy( Widget w) ;
237 static void TabsResize( Widget w) ;
238 static void TabsExpose( Widget w, XEvent *event, Region region) ;
239 static Boolean TabsSetValues(Widget, Widget, Widget, ArgList, Cardinal *) ;
240 static Boolean TabsConstraintSetValues(Widget, Widget, Widget,
241 ArgList, Cardinal *) ;
242 static XtGeometryResult TabsQueryGeometry(Widget,
243 XtWidgetGeometry *, XtWidgetGeometry *) ;
244 static XtGeometryResult TabsGeometryManager(Widget,
245 XtWidgetGeometry *, XtWidgetGeometry *) ;
246 static void TabsChangeManaged( Widget w) ;
247
248 static void TabsSelect(Widget, XEvent *, String *, Cardinal *) ;
249 static void TabsPage(Widget, XEvent *, String *, Cardinal *) ;
250 static void TabsHighlight(Widget, XEvent *, String *, Cardinal *) ;
251 static void TabsUnhighlight(Widget, XEvent *, String *, Cardinal *) ;
252
253 static void DrawTabs( TabsWidget tw, Bool labels) ;
254 static void DrawTab( TabsWidget tw, Widget child, Bool labels) ;
255 static void DrawFrame( TabsWidget tw) ;
256 static void DrawTrim( TabsWidget, int x, int y,
257 int wid, int hgt, Bool bottom, Bool undraw) ;
258 static void DrawBorder( TabsWidget tw, Widget child, Bool undraw) ;
259 static void DrawHighlight( TabsWidget tw, Widget child, Bool undraw) ;
260 static void UndrawTab( TabsWidget tw, Widget child) ;
261
262 static void TabWidth( Widget w) ;
263 static int TabLayout( TabsWidget, int wid, int hgt, Dimension *r_hgt,
264 Bool query_only) ;
265 static void GetPreferredSizes(TabsWidget) ;
266 static void MaxChild(TabsWidget) ;
267 static void TabsShuffleRows( TabsWidget tw) ;
268 static int PreferredSize( TabsWidget,
269 Dimension *reply_width, Dimension *reply_height,
270 Dimension *reply_cw, Dimension *reply_ch) ;
271 static int PreferredSize2( TabsWidget, int cw, int ch,
272 Dimension *rw, Dimension *rh) ;
273 static int PreferredSize3( TabsWidget, int wid, int hgt,
274 Dimension *rw, Dimension *rh) ;
275 static void MakeSizeRequest(TabsWidget) ;
276
277 static void TabsAllocGCs(TabsWidget) ;
278 static void TabsFreeGCs(TabsWidget) ;
279 static void getBitmapInfo( TabsWidget tw, TabsConstraints tab) ;
280 static void TabsAllocFgGC( TabsWidget tw) ;
281 static void TabsAllocGreyGC( TabsWidget tw) ;
282
283 #endif
284
285 #define AddRect(i,xx,yy,w,h) \
286 do{rects[(i)].x=(xx); rects[i].y=(yy); \
287 rects[i].width=(w); rects[i].height=(h);}while(0)
288
289 static XtActionsRec actionsList[] =
290 {
291 {"select", TabsSelect},
292 {"page", TabsPage},
293 {"highlight", TabsHighlight},
294 {"unhighlight", TabsUnhighlight},
295 } ;
296
297
298 /****************************************************************
299 *
300 * Full class record constant
301 *
302 ****************************************************************/
303
304 #ifndef NEED_MOTIF
305 #define SuperClass (&constraintClassRec)
306 #else
307 #define SuperClass (&xmManagerClassRec)
308 #endif
309
310 TabsClassRec tabsClassRec = {
311 {
312 /* core_class fields */
313 /* superclass */ (WidgetClass) SuperClass,
314 /* class_name */ "Tabs",
315 /* widget_size */ sizeof(TabsRec),
316 /* class_initialize */ TabsClassInit,
317 /* class_part_init */ NULL, /* TODO? */
318 /* class_inited */ FALSE,
319 /* initialize */ TabsInit,
320 /* initialize_hook */ NULL,
321 /* realize */ TabsRealize,
322 /* actions */ actionsList,
323 /* num_actions */ XtNumber(actionsList),
324 /* resources */ resources,
325 /* num_resources */ XtNumber(resources),
326 /* xrm_class */ NULLQUARK,
327 /* compress_motion */ TRUE,
328 /* compress_exposure */ TRUE,
329 /* compress_enterleave*/ TRUE,
330 /* visible_interest */ FALSE,
331 /* destroy */ TabsDestroy,
332 /* resize */ TabsResize,
333 /* expose */ TabsExpose,
334 /* set_values */ TabsSetValues,
335 /* set_values_hook */ NULL,
336 /* set_values_almost */ XtInheritSetValuesAlmost,
337 /* get_values_hook */ NULL,
338 /* accept_focus */ NULL,
339 /* version */ XtVersion,
340 /* callback_private */ NULL,
341 /* tm_table */ defaultTranslations,
342 /* query_geometry */ TabsQueryGeometry,
343 /* display_accelerator*/ XtInheritDisplayAccelerator,
344 /* extension */ NULL
345 },
346 {
347 /* composite_class fields */
348 /* geometry_manager */ TabsGeometryManager,
349 /* change_managed */ TabsChangeManaged,
350 /* insert_child */ XtInheritInsertChild, /* TODO? */
351 /* delete_child */ XtInheritDeleteChild, /* TODO? */
352 /* extension */ NULL
353 },
354 {
355 /* constraint_class fields */
356 /* subresources */ tabsConstraintResources,
357 /* subresource_count */ XtNumber(tabsConstraintResources),
358 /* constraint_size */ sizeof(TabsConstraintsRec),
359 /* initialize */ TabsConstraintInitialize,
360 /* destroy */ NULL,
361 /* set_values */ TabsConstraintSetValues,
362 /* extension */ NULL,
363 },
364 #ifdef NEED_MOTIF
365 /* Manager Class fields */
366 {
367 /* translations */ NULL,
368 /* syn_resources */ NULL,
369 /* num_syn_resources */ 0,
370 /* syn_constraint_resources */ NULL,
371 /* num_syn_constraint_resources */ 0,
372 /* parent_process */ XmInheritParentProcess,
373 /* extension */ NULL
374 },
375 #endif
376 {
377 /* Tabs class fields */
378 /* extension */ NULL,
379 }
380 };
381
382 WidgetClass tabsWidgetClass = (WidgetClass)&tabsClassRec;
383
384
385
386 #ifdef DEBUG
387 #ifdef __STDC__
388 #define assert(e) \
389 if(!(e)) fprintf(stderr,"yak! %s at %s:%d\n",#e,__FILE__,__LINE__)
390 #else
391 #define assert(e) \
392 if(!(e)) fprintf(stderr,"yak! e at %s:%d\n",__FILE__,__LINE__)
393 #endif
394 #else
395 #define assert(e)
396 #endif
397
398
399
400
401 /****************************************************************
402 *
403 * Member Procedures
404 *
405 ****************************************************************/
406
407 static void
408 TabsClassInit(void)
409 {
410 defaultAccelerators = XtParseAcceleratorTable(accelTable) ;
411 /* TODO: register converter for labels? */
412 }
413
414
415
416 /* Init a newly created tabs widget. Compute height of tabs
417 * and optionally compute size of widget. */
418
419 /* ARGSUSED */
420
421 static void
422 TabsInit(Widget request, Widget new, ArgList args, Cardinal *num_args)
423 {
424 TabsWidget newTw = (TabsWidget)new;
425
426 newTw->tabs.numRows = 0 ;
427 newTw->tabs.displayChildren = 0;
428
429 GetPreferredSizes(newTw) ;
430
431 /* height is easy, it's the same for all tabs:
432 * TODO: font height + height of tallest bitmap.
433 */
434 newTw->tabs.tab_height = 2 * newTw->tabs.internalHeight + SHADWID ;
435
436 if( newTw->tabs.font != NULL )
437 newTw->tabs.tab_height += newTw->tabs.font->max_bounds.ascent +
438 newTw->tabs.font->max_bounds.descent ;
439
440 /* GC allocation is deferred until XtRealize() */
441
442 /* if size not explicitly set, set it to our preferred size now. */
443
444 if( request->core.width == 0 || request->core.height == 0 )
445 {
446 Dimension w,h ;
447 PreferredSize(newTw, &w, &h, NULL,NULL) ;
448 if( request->core.width == 0 ) new->core.width = w ;
449 if( request->core.height == 0 ) new->core.height = h ;
450 XtClass(new)->core_class.resize(new) ;
451 }
452
453 /* defer GC allocation, etc., until Realize() time. */
454 newTw->tabs.foregroundGC =
455 newTw->tabs.backgroundGC =
456 newTw->tabs.greyGC =
457 newTw->tabs.topGC =
458 newTw->tabs.botGC = None ;
459
460 newTw->tabs.grey50 = None ;
461
462 newTw->tabs.needs_layout = False ;
463
464 newTw->tabs.hilight = NULL ;
465
466 #ifdef NEED_MOTIF
467 newTw->manager.navigation_type = XmTAB_GROUP ;
468 newTw->manager.traversal_on = True ;
469 #endif
470 }
471
472
473 /* Init the constraint part of a new tab child. Compute the
474 * size of the tab.
475 */
476 /* ARGSUSED */
477 static void
478 TabsConstraintInitialize(Widget request, Widget new,
479 ArgList args, Cardinal *num_args)
480 {
481 TabsConstraints tab = (TabsConstraints) new->core.constraints ;
482 tab->tabs.greyAlloc = False ; /* defer allocation of pixel */
483 tab->tabs.queried = False ; /* defer size query */
484
485 getBitmapInfo((TabsWidget)XtParent(new), tab) ;
486 TabWidth(new) ;
487 }
488
489
490
491 /* Called when tabs widget first realized. Create the window
492 * and allocate the GCs
493 */
494
495 static void
496 TabsRealize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
497 {
498 TabsWidget tw = (TabsWidget) w;
499
500 attributes->bit_gravity = NorthWestGravity;
501 *valueMask |= CWBitGravity;
502
503 SuperClass->core_class.realize(w, valueMask, attributes);
504
505 TabsAllocGCs(tw) ;
506 }
507
508
509
510 static void
511 TabsDestroy(Widget w)
512 {
513 TabsFreeGCs((TabsWidget)w) ;
514 }
515
516
517 /* Parent has resized us. This will require that the tabs be
518 * laid out again.
519 */
520
521 static void
522 TabsResize(Widget w)
523 {
524 TabsWidget tw = (TabsWidget) w;
525 int i ;
526 int num_children = tw->composite.num_children ;
527 Widget *childP ;
528 TabsConstraints tab ;
529 Dimension cw,ch,bw ;
530
531 /* Our size has now been dictated by the parent. Lay out the
532 * tabs, lay out the frame, lay out the children. Remember
533 * that the tabs overlap each other and the frame by shadowWidth.
534 * Also, the top tab is larger than the others, so if there's only
535 * one row, the widget must be made taller to accommodate this.
536 *
537 * Once the tabs are laid out, if there is more than one
538 * row, we may need to shuffle the rows to bring the top tab
539 * to the bottom row.
540 */
541
542 if( num_children > 0 && tw->composite.children != NULL )
543 {
544 /* Loop through the tabs and assign rows & x positions */
545 (void) TabLayout(tw, tw->core.width, tw->core.height, NULL, False) ;
546 num_children = tw->tabs.displayChildren;
547
548 /* assign a top widget, bring it to bottom row. */
549 TabsShuffleRows(tw) ;
550
551 /* now assign child positions & sizes. Positions are all the
552 * same: just inside the frame. Sizes are also all the same.
553 */
554
555 tw->tabs.child_width = cw = tw->core.width - 2 * SHADWID ;
556 tw->tabs.child_height = ch =
557 tw->core.height - tw->tabs.tab_total - 2 * SHADWID ;
558
559
560 for(i=0, childP=tw->composite.children;
561 i < num_children;
562 ++i, ++childP)
563 if( XtIsManaged(*childP) )
564 {
565 tab = (TabsConstraints) (*childP)->core.constraints ;
566 bw = tab->tabs.bwid ;
567 XtConfigureWidget(*childP, SHADWID,tw->tabs.tab_total+SHADWID,
568 cw-bw*2,ch-bw*2, bw) ;
569 }
570 if( XtIsRealized(w) )
571 XClearWindow(XtDisplay((Widget)tw), XtWindow((Widget)tw)) ;
572 }
573
574 tw->tabs.needs_layout = False ;
575 } /* Resize */
576
577
578
579 /* Redraw entire Tabs widget */
580
581 /* ARGSUSED */
582 static void
583 TabsExpose(Widget w, XEvent *event, Region region)
584 {
585 TabsWidget tw = (TabsWidget) w;
586
587 if( tw->tabs.needs_layout )
588 XtClass(w)->core_class.resize(w) ;
589
590 DrawTabs(tw, True) ;
591 }
592
593
594 /* Called when any Tabs widget resources are changed. */
595
596 /* ARGSUSED */
597 static Boolean
598 TabsSetValues(Widget current, Widget request, Widget new,
599 ArgList args, Cardinal *num_args)
600 {
601 TabsWidget curtw = (TabsWidget) current ;
602 TabsWidget tw = (TabsWidget) new ;
603 Boolean needRedraw = False ;
604 Widget *childP ;
605 int i ;
606
607
608 if( tw->tabs.font != curtw->tabs.font ||
609 tw->tabs.internalWidth != curtw->tabs.internalWidth ||
610 tw->tabs.internalHeight != curtw->tabs.internalHeight )
611 {
612 tw->tabs.tab_height = 2 * tw->tabs.internalHeight + SHADWID ;
613
614 if( tw->tabs.font != NULL )
615 tw->tabs.tab_height += tw->tabs.font->max_bounds.ascent +
616 tw->tabs.font->max_bounds.descent ;
617
618 /* Tab size has changed. Resize all tabs and request a new size */
619 for(i=0, childP=tw->composite.children;
620 i < tw->composite.num_children;
621 ++i, ++childP)
622 if( XtIsManaged(*childP) )
623 TabWidth(*childP) ;
624 PreferredSize(tw, &tw->core.width, &tw->core.height, NULL,NULL) ;
625 needRedraw = True ;
626 tw->tabs.needs_layout = True ;
627 }
628
629 /* TODO: if any color changes, need to recompute GCs and redraw */
630
631 if( tw->core.background_pixel != curtw->core.background_pixel ||
632 tw->core.background_pixmap != curtw->core.background_pixmap )
633 if( XtIsRealized(new) )
634 {
635 TabsFreeGCs(tw) ;
636 TabsAllocGCs(tw) ;
637 needRedraw = True ;
638 }
639
640 if( tw->core.sensitive != curtw->core.sensitive )
641 needRedraw = True ;
642
643 /* If top widget changes, need to change stacking order, redraw tabs.
644 * Window system will handle the redraws.
645 */
646
647 if( tw->tabs.topWidget != curtw->tabs.topWidget )
648 {
649 if( XtIsRealized(tw->tabs.topWidget) )
650 {
651 Widget w = tw->tabs.topWidget ;
652 TabsConstraints tab = (TabsConstraints) w->core.constraints ;
653
654 XRaiseWindow(XtDisplay(w), XtWindow(w)) ;
655 #ifdef NEED_MOTIF
656 XtVaSetValues(curtw->tabs.topWidget, XmNtraversalOn, False, 0) ;
657 XtVaSetValues(w, XmNtraversalOn, True, 0) ;
658 #endif
659
660 if( tab->tabs.row != tw->tabs.numRows-1 )
661 TabsShuffleRows(tw) ;
662
663 needRedraw = True ;
664 }
665 else
666 tw->tabs.needs_layout = True ;
667 }
668
669 return needRedraw ;
670 }
671
672
673 /* Called when any child constraint resources change. */
674
675 /* ARGSUSED */
676 static Boolean
677 TabsConstraintSetValues(Widget current, Widget request, Widget new,
678 ArgList args, Cardinal *num_args)
679 {
680 TabsWidget tw = (TabsWidget) XtParent(new) ;
681 TabsConstraints ctab = (TabsConstraints) current->core.constraints ;
682 TabsConstraints tab = (TabsConstraints) new->core.constraints ;
683
684
685 /* if label changes, need to re-layout the entire widget */
686 /* if foreground changes, need to redraw tab label */
687
688 /* TODO: only need resize of new bitmap has different dimensions
689 * from old bitmap.
690 */
691
692 if( tab->tabs.label != ctab->tabs.label || /* Tab size has changed. */
693 tab->tabs.left_bitmap != ctab->tabs.left_bitmap )
694 {
695 TabWidth(new) ;
696 tw->tabs.needs_layout = True ;
697
698 if( tab->tabs.left_bitmap != ctab->tabs.left_bitmap )
699 getBitmapInfo(tw, tab) ;
700
701 /* If there are no subclass ConstraintSetValues procedures remaining
702 * to be invoked, and if the preferred size has changed, ask
703 * for a resize.
704 */
705 if( XtClass((Widget)tw) == tabsWidgetClass )
706 MakeSizeRequest(tw) ;
707 }
708
709
710 /* The child widget itself never needs a redisplay, but the parent
711 * Tabs widget might.
712 */
713
714 if( XtIsRealized(new) )
715 {
716 if( tw->tabs.needs_layout ) {
717 XClearWindow(XtDisplay((Widget)tw), XtWindow((Widget)tw)) ;
718 XtClass(tw)->core_class.expose((Widget)tw,NULL,None) ;
719 }
720
721 else if( tab->tabs.foreground != ctab->tabs.foreground )
722 DrawTab(tw, new, True) ;
723 }
724
725 return False ;
726 }
727
728
729
730 /*
731 * Return preferred size. Happily accept anything >= our preferred size.
732 * (TODO: is that the right thing to do? Should we always return "almost"
733 * if offerred more than we need?)
734 */
735
736 static XtGeometryResult
737 TabsQueryGeometry(Widget w,
738 XtWidgetGeometry *intended, XtWidgetGeometry *preferred)
739 {
740 register TabsWidget tw = (TabsWidget)w ;
741 XtGeometryMask mode = intended->request_mode ;
742
743 preferred->request_mode = CWWidth | CWHeight ;
744 PreferredSize(tw, &preferred->width, &preferred->height, NULL,NULL) ;
745
746 if( (!(mode & CWWidth) || intended->width == w->core.width) &&
747 (!(mode & CWHeight) || intended->height == w->core.height) )
748 return XtGeometryNo ;
749
750 #ifdef COMMENT
751 if( (!(mode & CWWidth) || intended->width >= preferred->width) &&
752 (!(mode & CWHeight) || intended->height >= preferred->height) )
753 return XtGeometryYes;
754 #endif /* COMMENT */
755
756 return XtGeometryAlmost;
757 }
758
759
760
761 /*
762 * Geometry Manager; called when a child wants to be resized.
763 */
764
765 static XtGeometryResult
766 TabsGeometryManager(Widget w, XtWidgetGeometry *req, XtWidgetGeometry *reply)
767 {
768 TabsWidget tw = (TabsWidget) XtParent(w);
769 Dimension s = SHADWID ;
770 TabsConstraints tab = (TabsConstraints)w->core.constraints;
771 XtGeometryResult result ;
772
773 /* Position request always denied */
774
775 if( ((req->request_mode & CWX) && req->x != w->core.x) ||
776 ((req->request_mode & CWY) && req->y != w->core.y) ||
777 !tab->tabs.resizable )
778 return XtGeometryNo ;
779
780 /* Make all three fields in the request valid */
781 if( !(req->request_mode & CWWidth) )
782 req->width = w->core.width;
783 if( !(req->request_mode & CWHeight) )
784 req->height = w->core.height;
785 if( !(req->request_mode & CWBorderWidth) )
786 req->border_width = w->core.border_width;
787
788 if( req->width == w->core.width &&
789 req->height == w->core.height &&
790 req->border_width == w->core.border_width )
791 return XtGeometryNo ;
792
793 /* updated cached preferred size of the child */
794 tab->tabs.bwid = req->border_width ;
795 tab->tabs.wid = req->width + req->border_width * 2 ;
796 tab->tabs.hgt = req->height + req->border_width * 2 ;
797 MaxChild(tw) ;
798
799
800 /* Size changes must see if the new size can be accommodated.
801 * The Tabs widget keeps all of its children the same
802 * size. A request to shrink will be accepted only if the
803 * new size is still big enough for all other children. A
804 * request to shrink that is not big enough for all children
805 * returns an "almost" response with the new proposed size.
806 * A request to grow will be accepted only if the Tabs parent can
807 * grow to accommodate.
808 *
809 * TODO:
810 * We could get fancy here and re-arrange the tabs if it is
811 * necessary to compromise with the parent, but we'll save that
812 * for another day.
813 */
814
815 if (req->request_mode & (CWWidth | CWHeight | CWBorderWidth))
816 {
817 Dimension rw,rh ; /* child's requested width, height */
818 Dimension cw,ch ; /* children's preferred size */
819 Dimension aw,ah ; /* available size we can give child */
820 Dimension th ; /* space used by tabs */
821 Dimension wid,hgt ; /* Tabs widget size */
822
823 rw = tab->tabs.wid ;
824 rh = tab->tabs.hgt ;
825
826 /* find out what the resulting preferred size would be */
827
828 #ifdef COMMENT
829 MaxChild(tw, &cw, &ch) ;
830 #endif /* COMMENT */
831 PreferredSize2(tw, tw->tabs.max_cw,tw->tabs.max_ch, &wid, &hgt) ;
832
833 /* Ask to be resized to accommodate. */
834
835 if( wid != tw->core.width || hgt != tw->core.height )
836 {
837 Dimension oldWid = tw->core.width, oldHgt = tw->core.height ;
838 XtWidgetGeometry myrequest, myreply ;
839
840 myrequest.width = wid ;
841 myrequest.height = hgt ;
842 myrequest.request_mode = CWWidth | CWHeight ;
843
844 /* If child is only querying, or if we're going to have to
845 * offer the child a compromise, then make this a query only.
846 */
847
848 if( (req->request_mode & XtCWQueryOnly) || rw < cw || rh < ch )
849 myrequest.request_mode |= XtCWQueryOnly ;
850
851 result = XtMakeGeometryRequest((Widget)tw, &myrequest, &myreply) ;
852
853 /* !$@# Box widget changes the core size even if QueryOnly
854 * is set. I'm convinced this is a bug. At any rate, to work
855 * around the bug, we need to restore the core size after every
856 * query geometry request. This is only partly effective,
857 * as there may be other boxes further up the tree.
858 */
859 if( myrequest.request_mode & XtCWQueryOnly ) {
860 tw->core.width = oldWid ;
861 tw->core.height = oldHgt ;
862 }
863
864 /* based on the parent's response, determine what the
865 * resulting Tabs widget size would be.
866 */
867
868 switch( result ) {
869 case XtGeometryYes:
870 case XtGeometryDone:
871 break ;
872
873 case XtGeometryNo:
874 wid = tw->core.width ;
875 hgt = tw->core.height ;
876 break ;
877
878 case XtGeometryAlmost:
879 wid = myreply.width ;
880 hgt = myreply.height ;
881 }
882 }
883
884 /* Within the constraints imposed by the parent, what is
885 * the max size we can give the child?
886 */
887 (void) TabLayout(tw, wid, hgt, &th, True) ;
888 aw = wid - 2*s ;
889 ah = hgt - th - 2*s ;
890
891 /* OK, make our decision. If requested size is >= max sibling
892 * preferred size, AND requested size <= available size, then
893 * we accept. Otherwise, we offer a compromise.
894 */
895
896 if( rw == aw && rh == ah )
897 {
898 /* Acceptable. If this wasn't a query, change *all* children
899 * to this size.
900 */
901 if( req->request_mode & XtCWQueryOnly )
902 return XtGeometryYes ;
903 else
904 {
905 Widget *childP = tw->composite.children ;
906 int i,bw ;
907 w->core.border_width = req->border_width ;
908 for(i=tw->tabs.displayChildren; --i >= 0; ++childP)
909 if( XtIsManaged(*childP) )
910 {
911 bw = (*childP)->core.border_width ;
912 XtConfigureWidget(*childP, s,tw->tabs.tab_total+s,
913 rw-2*bw, rh-2*bw, bw) ;
914 }
915 #ifdef COMMENT
916 /* TODO: under what conditions will we need to redraw? */
917 XClearWindow(XtDisplay((Widget)tw), XtWindow((Widget)tw)) ;
918 XtClass(tw)->core_class.expose((Widget)tw,NULL,NULL) ;
919 #endif /* COMMENT */
920 return XtGeometryDone ;
921 }
922 }
923
924 /* Cannot grant child's request. Describe what we *can* do
925 * and return counter-offer.
926 */
927 reply->width = aw - 2 * req->border_width ;
928 reply->height = ah - 2 * req->border_width ;
929 reply->border_width = req->border_width ;
930 reply->request_mode = CWWidth | CWHeight | CWBorderWidth ;
931 return XtGeometryAlmost ;
932 }
933
934 return XtGeometryYes ;
935 }
936
937
938
939
940 /* The number of children we manage has changed; recompute
941 * size from scratch.
942 */
943
944 static void
945 TabsChangeManaged(Widget w)
946 {
947 TabsWidget tw = (TabsWidget)w ;
948 Widget *childP = tw->composite.children ;
949 int i ;
950
951 if( tw->tabs.topWidget != NULL &&
952 ( !XtIsManaged(tw->tabs.topWidget) ||
953 tw->tabs.topWidget->core.being_destroyed ) )
954 tw->tabs.topWidget = NULL ;
955
956 GetPreferredSizes(tw) ;
957 MakeSizeRequest(tw) ;
958
959 XtClass(w)->core_class.resize(w) ;
960 if( XtIsRealized(w) )
961 {
962 Display *dpy = XtDisplay(w) ;
963 XClearWindow(dpy, XtWindow(w)) ;
964 XtClass(w)->core_class.expose(w,NULL,NULL) ;
965
966 /* make sure the top widget stays on top. This requires
967 * making sure that all new children are realized first.
968 */
969 if( tw->tabs.topWidget != NULL && XtIsRealized(tw->tabs.topWidget) )
970 {
971 for(i=tw->tabs.displayChildren; --i >= 0; ++childP)
972 if( !XtIsRealized(*childP) )
973 XtRealizeWidget(*childP) ;
974
975 XRaiseWindow(dpy, XtWindow(tw->tabs.topWidget)) ;
976 }
977 }
978
979 #ifdef NEED_MOTIF
980 /* Only top widget may receive input */
981
982 for(childP = tw->composite.children, i=tw->composite.num_children;
983 --i >= 0;
984 ++childP)
985 {
986 XtVaSetValues(*childP, XmNtraversalOn, False, 0) ;
987 }
988
989 if( tw->tabs.topWidget != NULL )
990 XtVaSetValues(tw->tabs.topWidget, XmNtraversalOn, True, 0) ;
991 #endif
992
993
994
995 }
996
997
998
999
1000 /****************************************************************
1001 *
1002 * Action Procedures
1003 *
1004 ****************************************************************/
1005
1006
1007 /* User clicks on a tab, figure out which one it was. */
1008
1009 /* ARGSUSED */
1010 static void
1011 TabsSelect(Widget w, XEvent *event, String *params, Cardinal *num_params)
1012 {
1013 TabsWidget tw = (TabsWidget) w ;
1014 Widget *childP ;
1015 Position x,y ;
1016 Dimension h = tw->tabs.tab_height ;
1017 int i ;
1018
1019 #ifdef NEED_MOTIF
1020 XmProcessTraversal (w, XmTRAVERSE_CURRENT) ;
1021 #endif
1022
1023 /* TODO: is there an Xmu function or something to do this instead? */
1024 switch( event->type ) {
1025 case ButtonPress:
1026 case ButtonRelease:
1027 x = event->xbutton.x ; y = event->xbutton.y ; break ;
1028 case KeyPress:
1029 case KeyRelease:
1030 x = event->xkey.x ; y = event->xkey.y ; break ;
1031 default:
1032 return ;
1033 }
1034
1035 /* TODO: determine which tab was clicked, if any. Set that
1036 * widget to be top of stacking order with XawTabsSetTop().
1037 */
1038 for(i=0, childP=tw->composite.children;
1039 i < tw->tabs.displayChildren;
1040 ++i, ++childP)
1041 if( XtIsManaged(*childP) )
1042 {
1043 TabsConstraints tab = (TabsConstraints)(*childP)->core.constraints;
1044 if( x > tab->tabs.x && x < tab->tabs.x + tab->tabs.width &&
1045 y > tab->tabs.y && y < tab->tabs.y + h )
1046 {
1047 if( *childP != tw->tabs.topWidget &&
1048 (XtIsSensitive(*childP) || tw->tabs.selectInsensitive) )
1049 XawTabsSetTop(*childP, True) ;
1050 break ;
1051 }
1052 }
1053 }
1054
1055
1056 /* User hits a key */
1057
1058 static void
1059 TabsPage(Widget w, XEvent *event, String *params, Cardinal *num_params)
1060 {
1061 TabsWidget tw = (TabsWidget) w ;
1062 Widget newtop ;
1063 Widget *childP ;
1064 int idx ;
1065 int nc = tw->composite.num_children ;
1066
1067 if( nc <= 0 )
1068 return ;
1069
1070 if( *num_params < 1 ) {
1071 XtAppWarning(XtWidgetToApplicationContext(w),
1072 "Tabs: page() action called with no arguments") ;
1073 return ;
1074 }
1075
1076 if( tw->tabs.topWidget == NULL )
1077 tw->tabs.topWidget = tw->composite.children[0] ;
1078
1079 for(idx=0, childP=tw->composite.children; idx < nc; ++idx, ++childP )
1080 if( tw->tabs.topWidget == *childP )
1081 break ;
1082
1083 switch( params[0][0] ) {
1084 case 'u': /* up */
1085 case 'U':
1086 if( idx == 0 )
1087 idx = nc ;
1088 newtop = tw->composite.children[idx-1] ;
1089 break ;
1090
1091 case 'd': /* down */
1092 case 'D':
1093 if( ++idx >= nc )
1094 idx = 0 ;
1095 newtop = tw->composite.children[idx] ;
1096 break ;
1097
1098 case 'h':
1099 case 'H':
1100 newtop = tw->composite.children[0] ;
1101 break ;
1102
1103 case 'e':
1104 case 'E':
1105 newtop = tw->composite.children[nc-1] ;
1106 break ;
1107
1108 case 's': /* selected */
1109 case 'S':
1110 if( (newtop = tw->tabs.hilight) == NULL )
1111 return ;
1112 break ;
1113 }
1114
1115 XawTabsSetTop(newtop, True) ;
1116 }
1117
1118
1119 /* User hits up/down key */
1120
1121 static void
1122 TabsHighlight(Widget w, XEvent *event, String *params, Cardinal *num_params)
1123 {
1124 TabsWidget tw = (TabsWidget) w ;
1125 Widget newhl ;
1126 Widget *childP ;
1127 int idx ;
1128 int nc = tw->composite.num_children ;
1129
1130 if( nc <= 0 )
1131 return ;
1132
1133 if( *num_params < 1 )
1134 {
1135 if( tw->tabs.hilight != NULL )
1136 DrawHighlight(tw, tw->tabs.hilight, False) ;
1137 return ;
1138 }
1139
1140 if( tw->tabs.hilight == NULL )
1141 newhl = tw->composite.children[0] ;
1142
1143 else
1144 {
1145 for(idx=0, childP=tw->composite.children; idx < nc; ++idx, ++childP )
1146 if( tw->tabs.hilight == *childP )
1147 break ;
1148
1149 switch( params[0][0] ) {
1150 case 'u': /* up */
1151 case 'U':
1152 if( idx == 0 )
1153 idx = nc ;
1154 newhl = tw->composite.children[idx-1] ;
1155 break ;
1156
1157 case 'd': /* down */
1158 case 'D':
1159 if( ++idx >= nc )
1160 idx = 0 ;
1161 newhl = tw->composite.children[idx] ;
1162 break ;
1163
1164 case 'h':
1165 case 'H':
1166 newhl = tw->composite.children[0] ;
1167 break ;
1168
1169 case 'e':
1170 case 'E':
1171 newhl = tw->composite.children[nc-1] ;
1172 break ;
1173 }
1174 }
1175
1176 XawTabsSetHighlight(w, newhl) ;
1177 }
1178
1179
1180
1181 static void
1182 TabsUnhighlight(Widget w, XEvent *event, String *params, Cardinal *num_params)
1183 {
1184 TabsWidget tw = (TabsWidget) w ;
1185 int nc = tw->composite.num_children ;
1186
1187 if( nc <= 0 )
1188 return ;
1189
1190 if( tw->tabs.hilight != NULL )
1191 DrawHighlight(tw, tw->tabs.hilight, True) ;
1192 }
1193
1194
1195
1196
1197
1198 /****************************************************************
1199 *
1200 * Public Procedures
1201 *
1202 ****************************************************************/
1203
1204
1205 /* Set the top tab, optionally call all callbacks. */
1206 void
1207 XawTabsSetTop(Widget w, Bool callCallbacks)
1208 {
1209 TabsWidget tw = (TabsWidget)w->core.parent ;
1210 TabsConstraints tab ;
1211 Widget oldtop = tw->tabs.topWidget ;
1212
1213 if( !XtIsSubclass(w->core.parent, tabsWidgetClass) )
1214 {
1215 char line[1024] ;
1216 sprintf(line, "XawTabsSetTop: widget \"%s\" is not the child of a tabs widget.", XtName(w)) ;
1217 XtAppWarning(XtWidgetToApplicationContext(w), line) ;
1218 return ;
1219 }
1220
1221 if( callCallbacks )
1222 XtCallCallbackList(w, tw->tabs.popdownCallbacks,
1223 (XtPointer)tw->tabs.topWidget) ;
1224
1225 if( !XtIsRealized(w) ) {
1226 tw->tabs.topWidget = w ;
1227 tw->tabs.needs_layout = True ;
1228 return ;
1229 }
1230
1231 XRaiseWindow(XtDisplay(w), XtWindow(w)) ;
1232 #ifdef NEED_MOTIF
1233 XtVaSetValues(oldtop, XmNtraversalOn, False, 0) ;
1234 XtVaSetValues(w, XmNtraversalOn, True, 0) ;
1235 #endif
1236
1237 tab = (TabsConstraints) w->core.constraints ;
1238 if( tab->tabs.row == 0 )
1239 {
1240 /* Easy case; undraw current top, undraw new top, assign new
1241 * top, redraw all borders.
1242 * We *could* just erase and execute a full redraw, but I like to
1243 * reduce screen flicker.
1244 */
1245 UndrawTab(tw, oldtop) ; /* undraw old */
1246 DrawBorder(tw, oldtop, True) ;
1247 UndrawTab(tw, w) ; /* undraw new */
1248 DrawBorder(tw, w, True) ;
1249 tw->tabs.topWidget = w ;
1250 DrawTab(tw, oldtop, True) ; /* redraw old */
1251 DrawTab(tw, w, True) ; /* redraw new */
1252 DrawTabs(tw, False) ;
1253 }
1254 else
1255 {
1256 tw->tabs.topWidget = w ;
1257 TabsShuffleRows(tw) ;
1258 XClearWindow(XtDisplay((Widget)tw), XtWindow((Widget)tw)) ;
1259 XtClass(tw)->core_class.expose((Widget)tw,NULL,None) ;
1260 }
1261
1262 XawTabsSetHighlight((Widget)tw, w) ;
1263
1264 if( callCallbacks )
1265 XtCallCallbackList(w, tw->tabs.callbacks, (XtPointer)w) ;
1266 }
1267
1268
1269 /* Set the top tab, optionally call all callbacks. */
1270 void
1271 XawTabsSetHighlight(Widget t, Widget w)
1272 {
1273 TabsWidget tw = (TabsWidget)t ;
1274
1275 if( !XtIsSubclass(t, tabsWidgetClass) )
1276 return ;
1277
1278 if( XtIsRealized(t) && w != tw->tabs.hilight )
1279 {
1280 if( tw->tabs.hilight != NULL )
1281 DrawHighlight(tw, tw->tabs.hilight, True) ;
1282 if( w != NULL )
1283 DrawHighlight(tw, w, False) ;
1284 }
1285
1286 tw->tabs.hilight = w ;
1287 }
1288
1289
1290
1291
1292 /****************************************************************
1293 *
1294 * Private Procedures
1295 *
1296 ****************************************************************/
1297
1298
1299 static void
1300 TabsAllocGCs(TabsWidget tw)
1301 {
1302 TabsAllocFgGC(tw) ;
1303 TabsAllocGreyGC(tw) ;
1304 tw->tabs.backgroundGC = AllocBackgroundGC((Widget)tw, None) ;
1305 tw->tabs.topGC = AllocTopShadowGC((Widget)tw,
1306 tw->tabs.top_shadow_contrast, tw->tabs.be_nice_to_cmap) ;
1307 tw->tabs.botGC = AllocBotShadowGC((Widget)tw,
1308 tw->tabs.bot_shadow_contrast, tw->tabs.be_nice_to_cmap) ;
1309 }
1310
1311
1312 static void
1313 TabsFreeGCs(TabsWidget tw)
1314 {
1315 Widget w = (Widget) tw;
1316
1317 XtReleaseGC(w, tw->tabs.foregroundGC) ;
1318 XtReleaseGC(w, tw->tabs.greyGC) ;
1319 XtReleaseGC(w, tw->tabs.backgroundGC) ;
1320 XtReleaseGC(w, tw->tabs.topGC) ;
1321 XtReleaseGC(w, tw->tabs.botGC) ;
1322 #ifdef HAVE_XMU
1323 XmuReleaseStippledPixmap(XtScreen(w), tw->tabs.grey50) ;
1324 #endif
1325 }
1326
1327
1328
1329
1330
1331 /* Redraw entire Tabs widget */
1332
1333 static void
1334 DrawTabs(TabsWidget tw, Bool labels)
1335 {
1336 Widget *childP ;
1337 int i,j ;
1338 Dimension s = SHADWID ;
1339 Dimension th = tw->tabs.tab_height ;
1340 Position y ;
1341 TabsConstraints tab ;
1342
1343 if( !XtIsRealized((Widget)tw))
1344 return ;
1345
1346 /* draw tabs and frames by row except for the top tab, which
1347 * is drawn last. (This is inefficiently written, but should not
1348 * be too slow as long as there are not a lot of rows.)
1349 */
1350
1351 y = tw->tabs.numRows == 1 ? TABDELTA : 0 ;
1352 for(i=0; i<tw->tabs.numRows; ++i, y += th)
1353 {
1354 for( j=tw->tabs.displayChildren, childP=tw->composite.children;
1355 --j >= 0; ++childP )
1356 if( XtIsManaged(*childP) )
1357 {
1358 tab = (TabsConstraints)(*childP)->core.constraints;
1359 if( tab->tabs.row == i && *childP != tw->tabs.topWidget )
1360 DrawTab(tw, *childP, labels) ;
1361 }
1362 if( i != tw->tabs.numRows -1 )
1363 DrawTrim(tw, 0,y+th, tw->core.width, th+s, False,False) ;
1364 }
1365
1366 DrawFrame(tw) ;
1367
1368 /* and now the top tab */
1369 if( tw->tabs.topWidget != NULL )
1370 DrawTab(tw, tw->tabs.topWidget, labels) ;
1371 }
1372
1373
1374
1375 /* Draw one tab. Corners are rounded very slightly. */
1376
1377 static void
1378 DrawTab(TabsWidget tw, Widget child, Bool labels)
1379 {
1380 GC gc ;
1381 int x,y ;
1382
1383 if( !XtIsRealized((Widget)tw))
1384 return ;
1385
1386 DrawBorder(tw, child, False) ;
1387
1388 if( labels )
1389 {
1390 TabsConstraints tab = (TabsConstraints)child->core.constraints;
1391 Display *dpy = XtDisplay((Widget)tw) ;
1392 Window win = XtWindow((Widget)tw) ;
1393 String lbl = tab->tabs.label != NULL ?
1394 tab->tabs.label : XtName(child) ;
1395
1396 if( XtIsSensitive(child) )
1397 {
1398 gc = tw->tabs.foregroundGC ;
1399 XSetForeground(dpy, gc, tab->tabs.foreground) ;
1400 }
1401 else
1402 {
1403 /* grey pixel allocation deferred until now */
1404 if( !tab->tabs.greyAlloc )
1405 {
1406 if( tw->tabs.be_nice_to_cmap || tw->core.depth == 1 )
1407 tab->tabs.grey = tab->tabs.foreground ;
1408 else
1409 tab->tabs.grey = AllocGreyPixel((Widget)tw,
1410 tab->tabs.foreground,
1411 tw->core.background_pixel,
1412 tw->tabs.insensitive_contrast ) ;
1413 tab->tabs.greyAlloc = True ;
1414 }
1415 gc = tw->tabs.greyGC ;
1416 XSetForeground(dpy, gc, tab->tabs.grey) ;
1417 }
1418
1419 x = tab->tabs.x ;
1420 y = tab->tabs.y ;
1421 if( child == tw->tabs.topWidget )
1422 y -= TABLDELTA ;
1423
1424 if( tab->tabs.left_bitmap != None && tab->tabs.lbm_width > 0 )
1425 {
1426 if( tab->tabs.lbm_depth == 1 )
1427 XCopyPlane(dpy, tab->tabs.left_bitmap, win,gc,
1428 0,0, tab->tabs.lbm_width, tab->tabs.lbm_height,
1429 x+tab->tabs.lbm_x, y+tab->tabs.lbm_y, 1L) ;
1430 else
1431 XCopyArea(dpy, tab->tabs.left_bitmap, win,gc,
1432 0,0, tab->tabs.lbm_width, tab->tabs.lbm_height,
1433 x+tab->tabs.lbm_x, y+tab->tabs.lbm_y) ;
1434 }
1435
1436 if( lbl != NULL && tw->tabs.font != NULL )
1437 XDrawString(dpy,win,gc,
1438 x+tab->tabs.l_x, y+tab->tabs.l_y,
1439 lbl, (int)strlen(lbl)) ;
1440 }
1441
1442 if( child == tw->tabs.hilight )
1443 DrawHighlight(tw, child, False) ;
1444 }
1445
1446
1447 /* draw frame all the way around the child windows. */
1448
1449 static void
1450 DrawFrame(TabsWidget tw)
1451 {
1452 GC topgc = tw->tabs.topGC ;
1453 GC botgc = tw->tabs.botGC ;
1454 Dimension s = SHADWID ;
1455 Dimension ch = tw->tabs.child_height ;
1456 Draw3dBox((Widget)tw, 0,tw->tabs.tab_total,
1457 tw->core.width, ch+2*s, s, topgc, botgc) ;
1458 }
1459
1460
1461 /* draw trim around a tab or underneath a row of tabs */
1462
1463 static void
1464 DrawTrim(TabsWidget tw, /* widget */
1465 int x, /* upper-left corner */
1466 int y,
1467 int wid, /* total size */
1468 int hgt,
1469 Bool bottom, /* draw bottom? */
1470 Bool undraw) /* undraw all */
1471 {
1472 Display *dpy = XtDisplay((Widget)tw) ;
1473 Window win = XtWindow((Widget)tw) ;
1474 GC bggc = tw->tabs.backgroundGC ;
1475 GC topgc = undraw ? bggc : tw->tabs.topGC ;
1476 GC botgc = undraw ? bggc : tw->tabs.botGC ;
1477 if( bottom )
1478 XDrawLine(dpy,win,bggc, x,y+hgt-1, x+wid-1,y+hgt-1) ; /* bottom */
1479 XDrawLine(dpy,win,topgc, x,y+2, x,y+hgt-2) ; /* left */
1480 XDrawPoint(dpy,win,topgc, x+1,y+1) ; /* corner */
1481 XDrawLine(dpy,win,topgc, x+2,y, x+wid-3,y) ; /* top */
1482 XDrawLine(dpy,win,botgc, x+wid-2,y+1, x+wid-2,y+hgt-2) ; /* right */
1483 XDrawLine(dpy,win,botgc, x+wid-1,y+2, x+wid-1,y+hgt-2) ; /* right */
1484 }
1485
1486
1487 /* Draw one tab border. */
1488
1489 static void
1490 DrawBorder(TabsWidget tw, Widget child, Bool undraw)
1491 {
1492 TabsConstraints tab = (TabsConstraints)child->core.constraints;
1493 Position x = tab->tabs.x ;
1494 Position y = tab->tabs.y ;
1495 Dimension twid = tab->tabs.width ;
1496 Dimension thgt = tw->tabs.tab_height ;
1497
1498 /* top tab requires a little special attention; it overlaps
1499 * neighboring tabs slightly, so the background must be cleared
1500 * in the region of the overlap to partially erase those neighbors.
1501 * TODO: is this worth doing with regions instead?
1502 */
1503 if( child == tw->tabs.topWidget )
1504 {
1505 Display *dpy = XtDisplay((Widget)tw) ;
1506 Window win = XtWindow((Widget)tw) ;
1507 GC bggc = tw->tabs.backgroundGC ;
1508 XRectangle rects[3] ;
1509 x -= TABDELTA ;
1510 y -= TABDELTA ;
1511 twid += TABDELTA*2 ;
1512 thgt += TABDELTA ;
1513 AddRect(0, x,y+1,twid,TABDELTA) ;
1514 AddRect(1, x+1,y,TABDELTA,thgt) ;
1515 AddRect(2, x+twid-TABDELTA-1,y,TABDELTA,thgt) ;
1516 XFillRectangles(dpy,win,bggc, rects, 3) ;
1517 }
1518
1519 DrawTrim(tw, x,y,twid,thgt+1, child == tw->tabs.topWidget, undraw) ;
1520 }
1521
1522
1523 /* Draw highlight around tab that has focus */
1524
1525 static void
1526 DrawHighlight(TabsWidget tw, Widget child, Bool undraw)
1527 {
1528 TabsConstraints tab = (TabsConstraints)child->core.constraints;
1529 Display *dpy = XtDisplay((Widget)tw) ;
1530 Window win = XtWindow((Widget)tw) ;
1531 GC gc ;
1532 Position x = tab->tabs.x ;
1533 Position y = tab->tabs.y ;
1534 Dimension wid = tab->tabs.width ;
1535 Dimension hgt = tw->tabs.tab_height ;
1536 XPoint points[6] ;
1537
1538 /* top tab does not have a highlight */
1539
1540 if( child == tw->tabs.topWidget )
1541 return ;
1542
1543 if( undraw )
1544 gc = tw->tabs.backgroundGC ;
1545
1546 else if( XtIsSensitive(child) )
1547 {
1548 gc = tw->tabs.foregroundGC ;
1549 XSetForeground(dpy, gc, tab->tabs.foreground) ;
1550 }
1551 else
1552 {
1553 gc = tw->tabs.greyGC ;
1554 XSetForeground(dpy, gc, tab->tabs.grey) ;
1555 }
1556
1557 points[0].x = x+1 ; points[0].y = y+hgt-1 ;
1558 points[1].x = x+1 ; points[1].y = y+2 ;
1559 points[2].x = x+2 ; points[2].y = y+1 ;
1560 points[3].x = x+wid-4 ; points[3].y = y+1 ;
1561 points[4].x = x+wid-3 ; points[4].y = y+2 ;
1562 points[5].x = x+wid-3 ; points[5].y = y+hgt-1 ;
1563
1564 XDrawLines(dpy,win,gc, points,6, CoordModeOrigin) ;
1565 }
1566
1567
1568 /* Undraw one tab interior */
1569
1570 static void
1571 UndrawTab(TabsWidget tw, Widget child)
1572 {
1573 TabsConstraints tab = (TabsConstraints)child->core.constraints;
1574 Position x = tab->tabs.x ;
1575 Position y = tab->tabs.y ;
1576 Dimension twid = tab->tabs.width ;
1577 Dimension thgt = tw->tabs.tab_height ;
1578 Display *dpy = XtDisplay((Widget)tw) ;
1579 Window win = XtWindow((Widget)tw) ;
1580 GC bggc = tw->tabs.backgroundGC ;
1581
1582 XFillRectangle(dpy,win,bggc, x,y, twid,thgt) ;
1583 }
1584
1585
1586
1587
1588
1589 /* GEOMETRY UTILITIES */
1590
1591
1592 /* Compute the size of one child's tab. Positions will be computed
1593 * elsewhere.
1594 *
1595 * height: font height + vertical_space*2 + shadowWid*2
1596 * width: string width + horizontal_space*2 + shadowWid*2
1597 *
1598 * All tabs are the same height, so that is computed elsewhere.
1599 */
1600
1601 static void
1602 TabWidth(Widget w)
1603 {
1604 TabsConstraints tab = (TabsConstraints) w->core.constraints ;
1605 TabsWidget tw = (TabsWidget)XtParent(w) ;
1606 String lbl = tab->tabs.label != NULL ?
1607 tab->tabs.label : XtName(w) ;
1608 XFontStruct *font = tw->tabs.font ;
1609 int iw = tw->tabs.internalWidth ;
1610
1611 tab->tabs.width = iw + SHADWID*2 ;
1612 tab->tabs.l_x = tab->tabs.lbm_x = SHADWID + iw ;
1613
1614 if( tab->tabs.left_bitmap != None )
1615 {
1616 tab->tabs.width += tab->tabs.lbm_width + iw ;
1617 tab->tabs.l_x += tab->tabs.lbm_width + iw ;
1618 tab->tabs.lbm_y = (tw->tabs.tab_height - tab->tabs.lbm_height)/2 ;
1619 }
1620
1621 if( lbl != NULL && font != NULL )
1622 {
1623 tab->tabs.width += XTextWidth( font, lbl, (int)strlen(lbl) ) + iw ;
1624 tab->tabs.l_y = (tw->tabs.tab_height +
1625 tw->tabs.font->max_bounds.ascent -
1626 tw->tabs.font->max_bounds.descent)/2 ;
1627 }
1628 }
1629
1630
1631
1632 /* Lay out tabs to fit in given width. Compute x,y position and
1633 * row number for each tab. Return number of rows and total height
1634 * required by all tabs. If there is only one row, add TABDELTA
1635 * height to the total. Rows are assigned bottom to top.
1636 *
1637 * Tabs are indented from the edges by INDENT.
1638 *
1639 * TODO: if they require more than two rows and the total height:width
1640 * ratio is more than 2:1, then try something else.
1641 */
1642
1643 static int
1644 TabLayout(TabsWidget tw, int wid, int hgt, Dimension *reply_height, Bool query_only)
1645 {
1646 int i, row ;
1647 int num_children = tw->composite.num_children ;
1648 Widget *childP ;
1649 Dimension w ;
1650 Position x,y ;
1651 TabsConstraints tab ;
1652
1653 if (!query_only)
1654 tw->tabs.displayChildren = 0;
1655
1656 /* Algorithm: loop through children, assign X positions. If a tab
1657 * would extend beyond the right edge, start a new row. After all
1658 * rows are assigned, make a second pass and assign Y positions.
1659 */
1660
1661 if( num_children > 0 )
1662 {
1663 /* Loop through the tabs and see how much space they need. */
1664
1665 row = 0 ;
1666 x = INDENT ;
1667 y = 0 ;
1668 wid -= INDENT ;
1669 for(i=num_children, childP=tw->composite.children; --i >= 0; ++childP)
1670 if( XtIsManaged(*childP) )
1671 {
1672 tab = (TabsConstraints) (*childP)->core.constraints ;
1673 w = tab->tabs.width ;
1674 if( x + w > wid ) { /* new row */
1675 if (y + tw->tabs.tab_height > hgt)
1676 break;
1677 ++row ;
1678 x = INDENT ;
1679 y += tw->tabs.tab_height ;
1680 }
1681 if( !query_only ) {
1682 tab->tabs.x = x ;
1683 tab->tabs.y = y ;
1684 tab->tabs.row = row ;
1685 }
1686 x += w + SPACING ;
1687 if (!query_only)
1688 tw->tabs.displayChildren++;
1689 }
1690 /* If there was only one row, increse the height by TABDELTA */
1691 if( ++row == 1 )
1692 {
1693 y = TABDELTA ;
1694 if( !query_only )
1695 for(i=num_children, childP=tw->composite.children;
1696 --i >= 0 ; ++childP)
1697 if( XtIsManaged(*childP) )
1698 {
1699 tab = (TabsConstraints) (*childP)->core.constraints ;
1700 tab->tabs.y = y ;
1701 }
1702 }
1703 y += tw->tabs.tab_height ;
1704 }
1705 else
1706 row = y = 0 ;
1707
1708 if( !query_only ) {
1709 tw->tabs.tab_total = y ;
1710 tw->tabs.numRows = row ;
1711 }
1712
1713 if( reply_height != NULL )
1714 *reply_height = y ;
1715
1716 return row ;
1717 }
1718
1719
1720
1721 /* Find max preferred child size. Returned sizes include child
1722 * border widths. We only ever ask a child its preferred
1723 * size once. After that, the preferred size is updated only
1724 * if the child makes a geometry request.
1725 */
1726
1727 static void
1728 GetPreferredSizes(TabsWidget tw)
1729 {
1730 int i ;
1731 Widget *childP = tw->composite.children ;
1732 XtWidgetGeometry preferred ;
1733 TabsConstraints tab ;
1734 Dimension cw = 0, ch = 0 ;
1735
1736 for(i=tw->tabs.displayChildren; --i >= 0; ++childP)
1737 if( XtIsManaged(*childP) )
1738 {
1739 tab = (TabsConstraints) (*childP)->core.constraints ;
1740 if( !tab->tabs.queried ) {
1741 (void) XtQueryGeometry(*childP, NULL, &preferred) ;
1742 tab->tabs.bwid = preferred.border_width ;
1743 tab->tabs.wid = preferred.width + preferred.border_width * 2 ;
1744 tab->tabs.hgt = preferred.height + preferred.border_width * 2 ;
1745 tab->tabs.queried = True ;
1746 }
1747 cw = Max(cw, tab->tabs.wid ) ;
1748 ch = Max(ch, tab->tabs.hgt ) ;
1749 }
1750 tw->tabs.max_cw = cw ;
1751 tw->tabs.max_ch = ch ;
1752 }
1753
1754
1755
1756 /* Find max preferred child size. Returned sizes include child
1757 * border widths. */
1758
1759 static void
1760 MaxChild(TabsWidget tw)
1761 {
1762 Dimension cw,ch ; /* child width, height */
1763 int i ;
1764 Widget *childP = tw->composite.children ;
1765 TabsConstraints tab ;
1766
1767 cw = ch = 0 ;
1768
1769 for(i=tw->composite.num_children; --i >=0; ++childP)
1770 if( XtIsManaged(*childP) )
1771 {
1772 tab = (TabsConstraints) (*childP)->core.constraints ;
1773 cw = Max(cw, tab->tabs.wid ) ;
1774 ch = Max(ch, tab->tabs.hgt ) ;
1775 }
1776
1777 tw->tabs.max_cw = cw ;
1778 tw->tabs.max_ch = ch ;
1779 }
1780
1781
1782
1783 /* rotate row numbers to bring current widget to bottom row,
1784 * compute y positions for all tabs
1785 */
1786
1787 static void
1788 TabsShuffleRows(TabsWidget tw)
1789 {
1790 TabsConstraints tab ;
1791 int move ;
1792 int nrows ;
1793 Widget *childP ;
1794 Dimension th = tw->tabs.tab_height ;
1795 Position bottom ;
1796 int i ;
1797
1798 /* There must be a top widget. If not, assign one. */
1799 if( tw->tabs.topWidget == NULL && tw->composite.children != NULL )
1800 for(i=tw->composite.num_children, childP=tw->composite.children;
1801 --i >= 0;
1802 ++childP)
1803 if( XtIsManaged(*childP) ) {
1804 tw->tabs.topWidget = *childP ;
1805 break ;
1806 }
1807
1808 if( tw->tabs.topWidget != NULL )
1809 {
1810 nrows = tw->tabs.numRows ;
1811 assert( nrows > 0 ) ;
1812
1813 if( nrows > 1 )
1814 {
1815 tab = (TabsConstraints) tw->tabs.topWidget->core.constraints ;
1816 assert( tab != NULL ) ;
1817
1818 /* how far to move top row */
1819 move = nrows - tab->tabs.row ;
1820 bottom = tw->tabs.tab_total - th ;
1821
1822 for(i=tw->tabs.displayChildren, childP=tw->composite.children;
1823 --i >= 0;
1824 ++childP)
1825 if( XtIsManaged(*childP) )
1826 {
1827 tab = (TabsConstraints) (*childP)->core.constraints ;
1828 tab->tabs.row = (tab->tabs.row + move) % nrows ;
1829 tab->tabs.y = bottom - tab->tabs.row * th ;
1830 }
1831 }
1832 }
1833 }
1834
1835
1836 /* find preferred size. Ask children, find size of largest,
1837 * add room for tabs & return. This can get a little involved,
1838 * as we don't want to have too many rows of tabs; we may widen
1839 * the widget to reduce # of rows.
1840 */
1841
1842 static int
1843 PreferredSize(
1844 TabsWidget tw,
1845 Dimension *reply_width, /* total widget size */
1846 Dimension *reply_height,
1847 Dimension *reply_cw, /* child widget size */
1848 Dimension *reply_ch)
1849 {
1850 Dimension cw,ch ; /* child width, height */
1851 Dimension wid,hgt ;
1852 Dimension rwid,rhgt ;
1853 int nrow ;
1854
1855
1856 /* find max desired child height */
1857 #ifdef COMMENT
1858 MaxChild(tw, &cw, &ch) ;
1859 #endif /* COMMENT */
1860
1861 wid = cw = tw->tabs.max_cw ;
1862 hgt = ch = tw->tabs.max_ch ;
1863
1864 nrow = PreferredSize2(tw, wid,hgt, &rwid, &rhgt) ;
1865
1866 /* Check for absurd results (more than 2 rows, high aspect
1867 * ratio). Try wider size if needed.
1868 * TODO: make sure this terminates.
1869 */
1870
1871 if( nrow > 2 && rhgt > rwid )
1872 {
1873 Dimension w0, w1 ;
1874
1875 /* step 1: start doubling size until it's too big */
1876 do {
1877 w0 = wid ;
1878 wid = Max(wid*2, wid+20) ;
1879 nrow = PreferredSize2(tw, wid,hgt, &rwid,&rhgt) ;
1880 } while( nrow > 2 && rhgt > rwid ) ;
1881 w1 = wid ;
1882
1883 /* step 2: use Newton's method to find ideal size. Stop within
1884 * 8 pixels.
1885 */
1886 while( w1 > w0 + 8 )
1887 {
1888 wid = (w0+w1)/2 ;
1889 nrow = PreferredSize2(tw, wid,hgt, &rwid,&rhgt) ;
1890 if( nrow > 2 && rhgt > rwid )
1891 w0 = wid ;
1892 else
1893 w1 = wid ;
1894 }
1895 wid = w1 ;
1896 }
1897
1898 *reply_width = rwid ;
1899 *reply_height = rhgt ;
1900 if( reply_cw != NULL ) *reply_cw = cw ;
1901 if( reply_ch != NULL ) *reply_ch = ch ;
1902 return nrow ;
1903 }
1904
1905
1906 /* Find preferred size, given size of children. */
1907
1908 static int
1909 PreferredSize2(
1910 TabsWidget tw,
1911 int cw, /* child width, height */
1912 int ch,
1913 Dimension *reply_width, /* total widget size */
1914 Dimension *reply_height)
1915 {
1916 Dimension s = SHADWID ;
1917
1918 /* make room for shadow frame */
1919 cw += s*2 ;
1920 ch += s*2 ;
1921
1922 return PreferredSize3(tw, cw, ch, reply_width, reply_height) ;
1923 }
1924
1925
1926 /* Find preferred size, given size of children+shadow. */
1927
1928 static int
1929 PreferredSize3(
1930 TabsWidget tw,
1931 int wid, /* child width, height */
1932 int hgt,
1933 Dimension *reply_width, /* total widget size */
1934 Dimension *reply_height)
1935 {
1936 Dimension th ; /* space used by tabs */
1937 int nrows ;
1938
1939 if( tw->composite.num_children > 0 )
1940 nrows = TabLayout(tw, wid, hgt, &th, True) ;
1941 else {
1942 th = 0 ;
1943 nrows = 0 ;
1944 }
1945
1946 *reply_width = Max(wid, MIN_WID) ;
1947 *reply_height = Max(th+hgt, MIN_HGT) ;
1948
1949 return nrows ;
1950 }
1951
1952
1953 static void
1954 MakeSizeRequest(TabsWidget tw)
1955 {
1956 Widget w = (Widget)tw ;
1957 XtWidgetGeometry request, reply ;
1958 XtGeometryResult result ;
1959 Dimension cw,ch ;
1960
1961 request.request_mode = CWWidth | CWHeight ;
1962 PreferredSize(tw, &request.width, &request.height, &cw, &ch) ;
1963
1964 if( request.width == tw->core.width &&
1965 request.height == tw->core.height )
1966 return ;
1967
1968 result = XtMakeGeometryRequest(w, &request, &reply) ;
1969
1970 if( result == XtGeometryAlmost )
1971 {
1972 /* Bugger. Didn't get what we want, but were offered a
1973 * compromise. If the width was too small, recompute
1974 * based on the too-small width and try again.
1975 * If the height was too small, make a wild-ass guess
1976 * at a wider width and try again.
1977 */
1978
1979 if( reply.width < request.width && reply.height >= request.height )
1980 {
1981 Dimension s = SHADWID ;
1982 ch += s*2 ;
1983 PreferredSize3(tw, reply.width,ch, &request.width, &request.height);
1984 result = XtMakeGeometryRequest(w, &request, &reply) ;
1985 if( result == XtGeometryAlmost )
1986 (void) XtMakeGeometryRequest(w, &reply, NULL) ;
1987 }
1988
1989 else
1990 (void) XtMakeGeometryRequest(w, &reply, NULL) ;
1991 }
1992 }
1993
1994
1995 static void
1996 getBitmapInfo(TabsWidget tw, TabsConstraints tab)
1997 {
1998 Window root ;
1999 int x,y ;
2000 unsigned int bw ;
2001
2002 if( tab->tabs.left_bitmap == None ||
2003 !XGetGeometry(XtDisplay(tw), tab->tabs.left_bitmap, &root, &x, &y,
2004 &tab->tabs.lbm_width, &tab->tabs.lbm_height,
2005 &bw, &tab->tabs.lbm_depth) )
2006 tab->tabs.lbm_width = tab->tabs.lbm_height = 0 ;
2007 }
2008
2009
2010
2011
2012 /* Code copied & modified from Gcs.c. This version has dynamic
2013 * foreground.
2014 */
2015
2016 static void
2017 TabsAllocFgGC(TabsWidget tw)
2018 {
2019 Widget w = (Widget) tw;
2020 XGCValues values ;
2021
2022 values.background = tw->core.background_pixel ;
2023 values.font = tw->tabs.font->fid ;
2024 values.line_style = LineOnOffDash ;
2025 values.line_style = LineSolid ;
2026
2027 tw->tabs.foregroundGC =
2028 XtAllocateGC(w, w->core.depth,
2029 GCBackground|GCFont|GCLineStyle, &values,
2030 GCForeground,
2031 GCSubwindowMode|GCGraphicsExposures|GCDashOffset|
2032 GCDashList|GCArcMode) ;
2033 }
2034
2035 static void
2036 TabsAllocGreyGC(TabsWidget tw)
2037 {
2038 Widget w = (Widget) tw;
2039 XGCValues values ;
2040
2041 values.background = tw->core.background_pixel ;
2042 values.font = tw->tabs.font->fid ;
2043 #ifdef HAVE_XMU
2044 if( tw->tabs.be_nice_to_cmap || w->core.depth == 1)
2045 {
2046 values.fill_style = FillStippled ;
2047 tw->tabs.grey50 =
2048 values.stipple = XmuCreateStippledPixmap(XtScreen(w), 1L, 0L, 1) ;
2049
2050 tw->tabs.greyGC =
2051 XtAllocateGC(w, w->core.depth,
2052 GCBackground|GCFont|GCStipple|GCFillStyle, &values,
2053 GCForeground,
2054 GCSubwindowMode|GCGraphicsExposures|GCDashOffset|
2055 GCDashList|GCArcMode) ;
2056 }
2057 else
2058 #endif
2059 {
2060 tw->tabs.greyGC =
2061 XtAllocateGC(w, w->core.depth,
2062 GCFont, &values,
2063 GCForeground,
2064 GCBackground|GCSubwindowMode|GCGraphicsExposures|GCDashOffset|
2065 GCDashList|GCArcMode) ;
2066 }
2067 }