00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 #include <X11/IntrinsicP.h>
00064 #include <X11/cursorfont.h>
00065 #include <X11/StringDefs.h>
00066
00067 #include <X11/Xmu/Misc.h>
00068 #include <X11/Xmu/Converters.h>
00069
00070 #include <X11/Xaw3d/XawInit.h>
00071 #include <X11/Xaw3d/Grip.h>
00072 #include <X11/Xaw3d/PanedP.h>
00073
00074
00075 #include <X11/Xaw3d/XawImP.h>
00076
00077 #include <ctype.h>
00078
00079 typedef enum {UpLeftPane = 'U', LowRightPane = 'L',
00080 ThisBorderOnly = 'T', AnyPane = 'A' } Direction;
00081
00082 #define NO_INDEX -100
00083 #define IS_GRIP NULL
00084
00085 #define PaneInfo(w) ((Pane)(w)->core.constraints)
00086 #define HasGrip(w) (PaneInfo(w)->grip != NULL)
00087 #define IsPane(w) ((w)->core.widget_class != gripWidgetClass)
00088 #define PaneIndex(w) (PaneInfo(w)->position)
00089 #define IsVert(w) ( (w)->paned.orientation == XtorientVertical )
00090
00091 #define ForAllPanes(pw, childP) \
00092 for ( (childP) = (pw)->composite.children ; \
00093 (childP) < (pw)->composite.children + (pw)->paned.num_panes ; \
00094 (childP)++ )
00095
00096 #define ForAllChildren(pw, childP) \
00097 for ( (childP) = (pw)->composite.children ; \
00098 (childP) < (pw)->composite.children + (pw)->composite.num_children ; \
00099 (childP)++ )
00100
00101
00102
00103
00104
00105
00106
00107 static char defGripTranslations[] =
00108 "<Btn1Down>: GripAction(Start, UpLeftPane) \n\
00109 <Btn2Down>: GripAction(Start, ThisBorderOnly) \n\
00110 <Btn3Down>: GripAction(Start, LowRightPane) \n\
00111 <Btn1Motion>: GripAction(Move, UpLeft) \n\
00112 <Btn2Motion>: GripAction(Move, ThisBorder) \n\
00113 <Btn3Motion>: GripAction(Move, LowRight) \n\
00114 Any<BtnUp>: GripAction(Commit)";
00115
00116 #define offset(field) XtOffsetOf(PanedRec, paned.field)
00117
00118 static XtResource resources[] = {
00119 {XtNinternalBorderColor, XtCBorderColor, XtRPixel, sizeof(Pixel),
00120 offset(internal_bp), XtRString,
00121 (XtPointer) XtDefaultForeground},
00122 {XtNinternalBorderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension),
00123 offset(internal_bw), XtRImmediate, (XtPointer) 1},
00124 {XtNgripIndent, XtCGripIndent, XtRPosition, sizeof(Position),
00125 offset(grip_indent), XtRImmediate, (XtPointer) 10},
00126 {XtNrefigureMode, XtCBoolean, XtRBoolean, sizeof(Boolean),
00127 offset(refiguremode), XtRImmediate, (XtPointer) TRUE},
00128 {XtNgripTranslations, XtCTranslations, XtRTranslationTable,
00129 sizeof(XtTranslations),
00130 offset(grip_translations), XtRString, (XtPointer)defGripTranslations},
00131 {XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation),
00132 offset(orientation), XtRImmediate, (XtPointer) XtorientVertical},
00133
00134
00135
00136 {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
00137 offset(cursor), XtRImmediate, None},
00138 {XtNgripCursor, XtCCursor, XtRCursor, sizeof(Cursor),
00139 offset(grip_cursor), XtRImmediate, None},
00140 {XtNverticalGripCursor, XtCCursor, XtRCursor, sizeof(Cursor),
00141 offset(v_grip_cursor), XtRString, "sb_v_double_arrow"},
00142 {XtNhorizontalGripCursor, XtCCursor, XtRCursor, sizeof(Cursor),
00143 offset(h_grip_cursor), XtRString, "sb_h_double_arrow"},
00144
00145 {XtNbetweenCursor, XtCCursor, XtRCursor, sizeof(Cursor),
00146 offset(adjust_this_cursor), XtRString, None},
00147 {XtNverticalBetweenCursor, XtCCursor, XtRCursor, sizeof(Cursor),
00148 offset(v_adjust_this_cursor), XtRString, "sb_left_arrow"},
00149 {XtNhorizontalBetweenCursor, XtCCursor, XtRCursor, sizeof(Cursor),
00150 offset(h_adjust_this_cursor), XtRString, "sb_up_arrow"},
00151
00152 {XtNupperCursor, XtCCursor, XtRCursor, sizeof(Cursor),
00153 offset(adjust_upper_cursor), XtRString, "sb_up_arrow"},
00154 {XtNlowerCursor, XtCCursor, XtRCursor, sizeof(Cursor),
00155 offset(adjust_lower_cursor), XtRString, "sb_down_arrow"},
00156 {XtNleftCursor, XtCCursor, XtRCursor, sizeof(Cursor),
00157 offset(adjust_left_cursor), XtRString, "sb_left_arrow"},
00158 {XtNrightCursor, XtCCursor, XtRCursor, sizeof(Cursor),
00159 offset(adjust_right_cursor), XtRString, "sb_right_arrow"},
00160 };
00161
00162 #undef offset
00163
00164 #define offset(field) XtOffsetOf(PanedConstraintsRec, paned.field)
00165
00166 static XtResource subresources[] = {
00167 {XtNallowResize, XtCBoolean, XtRBoolean, sizeof(Boolean),
00168 offset(allow_resize), XtRImmediate, (XtPointer) FALSE},
00169 {XtNposition, XtCPosition, XtRInt, sizeof(int),
00170 offset(position), XtRImmediate, (XtPointer) 0},
00171 {XtNmin, XtCMin, XtRDimension, sizeof(Dimension),
00172 offset(min), XtRImmediate, (XtPointer) PANED_GRIP_SIZE},
00173 {XtNmax, XtCMax, XtRDimension, sizeof(Dimension),
00174 offset(max), XtRImmediate, (XtPointer) ~0},
00175 {XtNpreferredPaneSize, XtCPreferredPaneSize, XtRDimension,
00176 sizeof(Dimension), offset(preferred_size),
00177 XtRImmediate, (XtPointer) PANED_ASK_CHILD},
00178 {XtNresizeToPreferred, XtCBoolean, XtRBoolean, sizeof(Boolean),
00179 offset(resize_to_pref), XtRImmediate, (XtPointer) FALSE},
00180 {XtNskipAdjust, XtCBoolean, XtRBoolean, sizeof(Boolean),
00181 offset(skip_adjust), XtRImmediate, (XtPointer) FALSE},
00182 {XtNshowGrip, XtCShowGrip, XtRBoolean, sizeof(Boolean),
00183 offset(show_grip), XtRImmediate, (XtPointer) TRUE},
00184 };
00185
00186 #undef offset
00187
00188 static void ClassInitialize(), Initialize();
00189 static void Realize(), Resize();
00190 static void Redisplay();
00191 static void GetGCs(), ReleaseGCs();
00192 static void RefigureLocationsAndCommit();
00193 static Boolean SetValues();
00194 static XtGeometryResult GeometryManager();
00195 static void ChangeManaged();
00196 static void InsertChild();
00197 static void DeleteChild();
00198 static Boolean PaneSetValues();
00199 static Dimension PaneSize(), GetRequestInfo();
00200 static Boolean SatisfiesRule1(), SatisfiesRule2(), SatisfiesRule3();
00201
00202 static void PushPaneStack();
00203 static void GetPaneStack();
00204 static Boolean PopPaneStack();
00205 static void ClearPaneStack();
00206
00207 #define SuperClass ((ConstraintWidgetClass)&constraintClassRec)
00208
00209 PanedClassRec panedClassRec = {
00210 {
00211
00212 (WidgetClass) SuperClass,
00213 "Paned",
00214 sizeof(PanedRec),
00215 ClassInitialize,
00216 NULL,
00217 FALSE,
00218 Initialize,
00219 NULL,
00220 Realize,
00221 NULL,
00222 0,
00223 resources,
00224 XtNumber(resources),
00225 NULLQUARK,
00226 TRUE,
00227 TRUE,
00228 TRUE,
00229 FALSE,
00230 ReleaseGCs,
00231 Resize,
00232 Redisplay,
00233 SetValues,
00234 NULL,
00235 XtInheritSetValuesAlmost,
00236 NULL,
00237 NULL,
00238 XtVersion,
00239 NULL,
00240 NULL,
00241 XtInheritQueryGeometry,
00242 XtInheritDisplayAccelerator,
00243 NULL
00244 }, {
00245
00246 GeometryManager,
00247 ChangeManaged,
00248 InsertChild,
00249 DeleteChild,
00250 NULL
00251 }, {
00252
00253 subresources,
00254 XtNumber(subresources),
00255 sizeof(PanedConstraintsRec),
00256 NULL,
00257 NULL,
00258 PaneSetValues,
00259 NULL
00260 }
00261 };
00262
00263 WidgetClass panedWidgetClass = (WidgetClass) &panedClassRec;
00264
00265
00266 WidgetClass vPanedWidgetClass = (WidgetClass) &panedClassRec;
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284 static void
00285 AdjustPanedSize(pw, off_size, result_ret, on_size_ret, off_size_ret)
00286 PanedWidget pw;
00287 Dimension off_size;
00288 XtGeometryResult * result_ret;
00289 Dimension * on_size_ret, * off_size_ret;
00290 {
00291 Dimension old_size = PaneSize( (Widget) pw, IsVert(pw));
00292 Dimension newsize = 0;
00293 Widget * childP;
00294 XtWidgetGeometry request, reply;
00295 request.request_mode = CWWidth | CWHeight;
00296
00297 ForAllPanes(pw, childP) {
00298 int size = Max(PaneInfo(*childP)->size, (int)PaneInfo(*childP)->min);
00299 AssignMin(size, (int) PaneInfo(*childP)->max);
00300 newsize += size + pw->paned.internal_bw;
00301 }
00302 newsize -= pw->paned.internal_bw;
00303
00304 if (newsize < 1) newsize = 1;
00305
00306 if ( IsVert(pw) ) {
00307 request.width = off_size;
00308 request.height = newsize;
00309 }
00310 else {
00311 request.width = newsize;
00312 request.height = off_size;
00313 }
00314
00315 if (result_ret != NULL) {
00316 request.request_mode |= XtCWQueryOnly;
00317
00318 *result_ret = XtMakeGeometryRequest( (Widget) pw, &request, &reply );
00319 _XawImCallVendorShellExtResize( (Widget) pw );
00320
00321 if ( (newsize == old_size) || (*result_ret == XtGeometryNo) ) {
00322 *on_size_ret = old_size;
00323 *off_size_ret = off_size;
00324 return;
00325 }
00326 if (*result_ret != XtGeometryAlmost) {
00327 *on_size_ret = GetRequestInfo( &request, IsVert(pw) );
00328 *off_size_ret = GetRequestInfo( &request, !IsVert(pw) );
00329 return;
00330 }
00331 *on_size_ret = GetRequestInfo( &reply, IsVert(pw) );
00332 *off_size_ret = GetRequestInfo( &reply, !IsVert(pw) );
00333 return;
00334 }
00335
00336 if (newsize == old_size) return;
00337
00338 if (XtMakeGeometryRequest( (Widget) pw,
00339 &request, &reply) == XtGeometryAlmost)
00340 XtMakeGeometryRequest( (Widget) pw, &reply, &request);
00341 }
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354 static Dimension
00355 PaneSize(w, vertical)
00356 Widget w;
00357 Boolean vertical;
00358 {
00359 if (vertical) return (w->core.height);
00360 return (w->core.width);
00361 }
00362
00363
00364
00365
00366
00367
00368
00369
00370 static Dimension
00371 GetRequestInfo(geo_struct, vert)
00372 XtWidgetGeometry * geo_struct;
00373 Boolean vert;
00374 {
00375 if ( vert ) return ( (Dimension) geo_struct->height);
00376 return ( (Dimension) geo_struct->width);
00377 }
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403 static Pane
00404 ChoosePaneToResize(pw, paneindex, dir, shrink)
00405 PanedWidget pw;
00406 int paneindex;
00407 Direction dir;
00408 Boolean shrink;
00409 {
00410 Widget *childP;
00411 int rules = 3;
00412 Direction _dir = dir;
00413 int _index = paneindex;
00414
00415 if ( (paneindex == NO_INDEX) || (dir == AnyPane) ) {
00416 _dir = LowRightPane;
00417 _index = pw->paned.num_panes - 1;
00418
00419 }
00420 childP = pw->composite.children + _index;
00421
00422
00423 while(TRUE) {
00424 Pane pane = PaneInfo(*childP);
00425
00426 if ( (rules < 3 || SatisfiesRule3(pane, shrink)) &&
00427 (rules < 2 || SatisfiesRule2(pane)) &&
00428 (SatisfiesRule1(pane, shrink)) &&
00429 ((paneindex != PaneIndex(*childP)) || (dir == AnyPane)) )
00430 return(pane);
00431
00432
00433
00434
00435
00436
00437
00438 if (_dir == LowRightPane) --childP; else ++childP;
00439
00440
00441
00442
00443
00444
00445 if ( (childP - pw->composite.children < 0) ||
00446 (childP - pw->composite.children >= pw->paned.num_panes) ) {
00447 if (--rules < 1)
00448 return(NULL);
00449 childP = pw->composite.children + _index;
00450 }
00451 }
00452 }
00453
00454
00455
00456
00457
00458
00459
00460
00461 static Boolean
00462 SatisfiesRule1(pane, shrink)
00463 Pane pane;
00464 Boolean shrink;
00465 {
00466 return( (shrink && (pane->size != pane->min)) ||
00467 (!shrink && (pane->size != pane->max)) );
00468 }
00469
00470
00471
00472
00473
00474
00475
00476 static Boolean
00477 SatisfiesRule2(pane)
00478 Pane pane;
00479 {
00480 return(!pane->skip_adjust || pane->paned_adjusted_me);
00481 }
00482
00483
00484
00485
00486
00487
00488
00489
00490 static Boolean
00491 SatisfiesRule3(pane, shrink)
00492 Pane pane;
00493 Boolean shrink;
00494 {
00495 return ( pane->paned_adjusted_me &&
00496 ( (shrink && ((int)pane->wp_size <= pane->size)) ||
00497 (!shrink && ((int)pane->wp_size >= pane->size))) );
00498 }
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512 static void
00513 LoopAndRefigureChildren(pw, paneindex, dir, sizeused)
00514 PanedWidget pw;
00515 int paneindex, *sizeused;
00516 Direction dir;
00517 {
00518 int pane_size = (int) PaneSize( (Widget) pw, IsVert(pw));
00519 Boolean shrink = (*sizeused > pane_size);
00520
00521 if (dir == LowRightPane) paneindex++;
00522
00523 while (*sizeused != pane_size) {
00524
00525
00526
00527
00528
00529 Pane pane;
00530 int start_size;
00531 Dimension old;
00532 Boolean rule3_ok = FALSE, from_stack = TRUE;
00533
00534 GetPaneStack(pw, shrink, &pane, &start_size);
00535 if (pane == NULL) {
00536 pane = ChoosePaneToResize(pw, paneindex, dir, shrink);
00537 if (pane == NULL)
00538 return;
00539
00540 rule3_ok = SatisfiesRule3(pane, shrink);
00541 from_stack = FALSE;
00542 PushPaneStack(pw, pane);
00543 }
00544
00545
00546
00547
00548
00549
00550 old = pane->size;
00551 pane->size += pane_size - *sizeused;
00552
00553 if (from_stack) {
00554 if (shrink) {
00555 AssignMax(pane->size, start_size);
00556 }
00557 else
00558 AssignMin(pane->size, start_size);
00559
00560 if (pane->size == start_size) (void) PopPaneStack(pw);
00561 }
00562 else if (rule3_ok) {
00563 if (shrink) {
00564 AssignMax(pane->size, (int) pane->wp_size);
00565 }
00566 else
00567 AssignMin(pane->size, (int) pane->wp_size);
00568 }
00569
00570 pane->paned_adjusted_me = (pane->size != pane->wp_size);
00571 AssignMax(pane->size, (int) pane->min);
00572 AssignMin(pane->size, (int) pane->max);
00573 *sizeused += (pane->size - old);
00574 }
00575 }
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593 static void
00594 RefigureLocations(pw, paneindex, dir)
00595 PanedWidget pw;
00596 int paneindex;
00597 Direction dir;
00598 {
00599 Widget *childP;
00600 int pane_size = (int) PaneSize( (Widget) pw, IsVert(pw) );
00601 int sizeused = 0;
00602 Position loc = 0;
00603
00604 if (pw->paned.num_panes == 0 || !pw->paned.refiguremode) return;
00605
00606
00607
00608
00609
00610 ForAllPanes(pw, childP) {
00611 Pane pane = PaneInfo(*childP);
00612 AssignMax(pane->size, (int) pane->min);
00613 AssignMin(pane->size, (int) pane->max);
00614 sizeused += (int) pane->size + (int) pw->paned.internal_bw;
00615 }
00616 sizeused -= (int) pw->paned.internal_bw;
00617
00618 if ( (dir != ThisBorderOnly) && (sizeused != pane_size) )
00619 LoopAndRefigureChildren(pw, paneindex, dir, &sizeused);
00620
00621
00622
00623
00624
00625
00626
00627 if ( (paneindex != NO_INDEX) && (dir != AnyPane) ) {
00628 Pane pane = PaneInfo(*(pw->composite.children + paneindex));
00629 Dimension old = pane->size;
00630
00631 pane->size += pane_size - sizeused;
00632 AssignMax(pane->size, (int) pane->min);
00633 AssignMin(pane->size, (int) pane->max);
00634 sizeused += pane->size - old;
00635 }
00636
00637
00638
00639
00640
00641
00642
00643
00644 ForAllPanes(pw, childP) {
00645 PaneInfo(*childP)->delta = loc;
00646 loc += PaneInfo(*childP)->size + pw->paned.internal_bw;
00647 }
00648 }
00649
00650
00651
00652
00653
00654
00655
00656 static void
00657 CommitNewLocations(pw)
00658 PanedWidget pw;
00659 {
00660 Widget *childP;
00661 XWindowChanges changes;
00662
00663 changes.stack_mode = Above;
00664
00665 ForAllPanes(pw, childP) {
00666 Pane pane = PaneInfo(*childP);
00667 Widget grip = pane->grip;
00668
00669 if (IsVert(pw)) {
00670 XtMoveWidget(*childP, (Position) 0, pane->delta);
00671 XtResizeWidget(*childP, pw->core.width, (Dimension) pane->size,
00672 (Dimension) 0);
00673
00674 if (HasGrip(*childP)) {
00675 changes.x = pw->core.width - pw->paned.grip_indent -
00676 grip->core.width - grip->core.border_width*2;
00677 changes.y = (*childP)->core.y + (*childP)->core.height -
00678 grip->core.height/2 - grip->core.border_width +
00679 pw->paned.internal_bw/2;
00680 }
00681 }
00682 else {
00683 XtMoveWidget(*childP, pane->delta, (Position) 0);
00684 XtResizeWidget(*childP, (Dimension) pane->size, pw->core.height,
00685 (Dimension) 0);
00686
00687
00688 if (HasGrip(*childP)) {
00689 changes.x = (*childP)->core.x + (*childP)->core.width -
00690 grip->core.width/2 - grip->core.border_width +
00691 pw->paned.internal_bw/2;
00692 changes.y = pw->core.height - pw->paned.grip_indent -
00693 grip->core.height - grip->core.border_width*2;
00694 }
00695 }
00696
00697
00698
00699
00700
00701
00702 if (HasGrip(*childP)) {
00703 grip->core.x = changes.x;
00704 grip->core.y = changes.y;
00705
00706 if (XtIsRealized(pane->grip))
00707 XConfigureWindow( XtDisplay(pane->grip), XtWindow(pane->grip),
00708 CWX | CWY | CWStackMode, &changes );
00709 }
00710 }
00711 ClearPaneStack(pw);
00712 }
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728 static void
00729 RefigureLocationsAndCommit(w)
00730 Widget w;
00731 {
00732 PanedWidget pw = (PanedWidget) w;
00733 if (pw->paned.refiguremode && XtIsRealized( (Widget) pw) &&
00734 pw->paned.num_panes > 0 ) {
00735 RefigureLocations(pw, NO_INDEX, AnyPane);
00736 CommitNewLocations(pw);
00737 }
00738 }
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749 static void
00750 _DrawRect(pw, gc, on_loc, off_loc, on_size, off_size)
00751 PanedWidget pw;
00752 GC gc;
00753 int on_loc, off_loc;
00754 unsigned int on_size, off_size;
00755 {
00756 if (IsVert(pw))
00757 XFillRectangle(XtDisplay(pw), XtWindow(pw), gc,
00758 off_loc, on_loc, off_size, on_size);
00759 else
00760 XFillRectangle(XtDisplay(pw), XtWindow(pw), gc,
00761 on_loc, off_loc, on_size, off_size);
00762 }
00763
00764
00765
00766
00767
00768
00769
00770
00771 static void
00772 _DrawInternalBorders(pw, gc)
00773 PanedWidget pw;
00774 GC gc;
00775 {
00776 Widget *childP;
00777 int on_loc, off_loc;
00778 unsigned int on_size, off_size;
00779
00780
00781
00782
00783
00784
00785 if (pw->core.background_pixel == pw->paned.internal_bp)
00786 return;
00787
00788 off_loc = 0;
00789 off_size = (unsigned int) PaneSize( (Widget) pw, !IsVert(pw) );
00790 on_size = (unsigned int) pw->paned.internal_bw;
00791
00792 ForAllPanes(pw, childP) {
00793 on_loc = IsVert(pw) ? (*childP)->core.y : (*childP)->core.x;
00794 on_loc -= (int) on_size;
00795
00796 _DrawRect( pw, gc, on_loc, off_loc, on_size, off_size);
00797 }
00798 }
00799
00800
00801
00802
00803
00804 #define DrawInternalBorders(pw) _DrawInternalBorders((pw), (pw)->paned.normgc);
00805 #define EraseInternalBorders(pw) _DrawInternalBorders((pw), (pw)->paned.invgc);
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816 static void
00817 _DrawTrackLines(pw, erase)
00818 PanedWidget pw;
00819 Boolean erase;
00820 {
00821 Widget *childP;
00822 Pane pane;
00823 int on_loc, off_loc;
00824 unsigned int on_size, off_size;
00825
00826 off_loc = 0;
00827 off_size = PaneSize( (Widget) pw, !IsVert(pw));
00828
00829 ForAllPanes(pw, childP) {
00830 pane = PaneInfo(*childP);
00831 if ( erase || (pane->olddelta != pane->delta) ) {
00832 on_size = pw->paned.internal_bw;
00833 if (!erase) {
00834 on_loc = PaneInfo(*childP)->olddelta - (int) on_size;
00835
00836 _DrawRect( pw, pw->paned.flipgc,
00837 on_loc, off_loc, on_size, off_size);
00838 }
00839
00840 on_loc = PaneInfo(*childP)->delta - (int) on_size;
00841
00842 _DrawRect(pw, pw->paned.flipgc,
00843 on_loc, off_loc, on_size, off_size);
00844
00845 pane->olddelta = pane->delta;
00846 }
00847 }
00848 }
00849
00850
00851
00852
00853
00854 #define DrawTrackLines(pw) _DrawTrackLines((pw), FALSE);
00855 #define EraseTrackLines(pw) _DrawTrackLines((pw), TRUE);
00856
00857
00858
00859
00860
00861
00862
00863
00864 static int
00865 GetEventLocation(pw, event)
00866 PanedWidget pw;
00867 XEvent *event;
00868 {
00869 int x, y;
00870
00871 switch (event->xany.type) {
00872 case ButtonPress:
00873 case ButtonRelease:
00874 x = event->xbutton.x_root;
00875 y = event->xbutton.y_root;
00876 break;
00877 case KeyPress:
00878 case KeyRelease:
00879 x = event->xkey.x_root;
00880 y = event->xkey.y_root;
00881 break;
00882 case MotionNotify:
00883 x = event->xmotion.x_root;
00884 y = event->xmotion.y_root;
00885 break;
00886 default:
00887 x = pw->paned.start_loc;
00888 y = pw->paned.start_loc;
00889 }
00890 if (IsVert(pw))
00891 return(y);
00892 return(x);
00893 }
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903 static void
00904 StartGripAdjustment(pw, grip, dir)
00905 PanedWidget pw;
00906 Widget grip;
00907 Direction dir;
00908 {
00909 Widget *childP;
00910 Cursor cursor;
00911
00912 pw->paned.whichadd = pw->paned.whichsub = (Widget) NULL;
00913
00914 if (dir == ThisBorderOnly || dir == UpLeftPane)
00915 pw->paned.whichadd = pw->composite.children[PaneIndex(grip)];
00916 if (dir == ThisBorderOnly || dir == LowRightPane)
00917 pw->paned.whichsub = pw->composite.children[PaneIndex(grip) + 1];
00918
00919
00920
00921
00922
00923 if (XtIsRealized(grip)) {
00924 if ( IsVert(pw) ) {
00925 if (dir == UpLeftPane)
00926 cursor = pw->paned.adjust_upper_cursor;
00927 else if (dir == LowRightPane)
00928 cursor = pw->paned.adjust_lower_cursor;
00929 else {
00930 if ( pw->paned.adjust_this_cursor == None)
00931 cursor = pw->paned.v_adjust_this_cursor;
00932 else
00933 cursor = pw->paned.adjust_this_cursor;
00934 }
00935 }
00936 else {
00937 if (dir == UpLeftPane)
00938 cursor = pw->paned.adjust_left_cursor;
00939 else if (dir == LowRightPane)
00940 cursor = pw->paned.adjust_right_cursor;
00941 else {
00942 if (pw->paned.adjust_this_cursor == None)
00943 cursor = pw->paned.h_adjust_this_cursor;
00944 else
00945 cursor = pw->paned.adjust_this_cursor;
00946 }
00947 }
00948
00949 XDefineCursor(XtDisplay(grip), XtWindow(grip), cursor);
00950 }
00951
00952 EraseInternalBorders(pw);
00953 ForAllPanes(pw, childP)
00954 PaneInfo(*childP)->olddelta = -99;
00955 }
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967 static void
00968 MoveGripAdjustment(pw, grip, dir, loc)
00969 PanedWidget pw;
00970 Widget grip;
00971 Direction dir;
00972 int loc;
00973 {
00974 int diff, add_size = 0, sub_size = 0;
00975
00976 diff = loc - pw->paned.start_loc;
00977
00978 if (pw->paned.whichadd)
00979 add_size = PaneSize(pw->paned.whichadd, IsVert(pw) ) + diff;
00980
00981 if (pw->paned.whichsub)
00982 sub_size = PaneSize(pw->paned.whichsub, IsVert(pw) ) - diff;
00983
00984
00985
00986
00987
00988
00989 if ( (dir == ThisBorderOnly) ) {
00990 int old_add_size = add_size, old_sub_size;
00991
00992 AssignMax(add_size, (int) PaneInfo(pw->paned.whichadd)->min);
00993 AssignMin(add_size, (int) PaneInfo(pw->paned.whichadd)->max);
00994 if (add_size != old_add_size)
00995 sub_size += old_add_size - add_size;
00996
00997 old_sub_size = sub_size;
00998 AssignMax(sub_size, (int) PaneInfo(pw->paned.whichsub)->min);
00999 AssignMin(sub_size, (int) PaneInfo(pw->paned.whichsub)->max);
01000 if (sub_size != old_sub_size) return;
01001 }
01002
01003 if (add_size != 0)
01004 PaneInfo(pw->paned.whichadd)->size = add_size;
01005 if (sub_size != 0)
01006 PaneInfo(pw->paned.whichsub)->size = sub_size;
01007 RefigureLocations(pw, PaneIndex(grip), dir);
01008 DrawTrackLines(pw);
01009 }
01010
01011
01012
01013
01014
01015
01016
01017 static void
01018 CommitGripAdjustment(pw)
01019 PanedWidget pw;
01020 {
01021 EraseTrackLines(pw);
01022 CommitNewLocations(pw);
01023 DrawInternalBorders(pw);
01024
01025
01026
01027
01028
01029 if (pw->paned.whichadd) {
01030 Pane pane = PaneInfo(pw->paned.whichadd);
01031 pane->wp_size = pane->size;
01032 }
01033 if (pw->paned.whichsub) {
01034 Pane pane = PaneInfo(pw->paned.whichsub);
01035 pane->wp_size = pane->size;
01036 }
01037 }
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048 static void
01049 HandleGrip(grip, junk, callData)
01050 Widget grip;
01051 XtPointer junk, callData;
01052 {
01053 XawGripCallData call_data = (XawGripCallData)callData;
01054 PanedWidget pw = (PanedWidget) XtParent(grip);
01055 int loc;
01056 char action_type;
01057 Cursor cursor;
01058 Direction direction = 0;
01059 Arg arglist[1];
01060
01061 action_type = *call_data->params[0];
01062
01063 if (call_data->num_params == 0 ||
01064 (action_type == 'C' && call_data->num_params != 1) ||
01065 (action_type != 'C' && call_data->num_params != 2))
01066 XtError( "Paned GripAction has been passed incorrect parameters." );
01067
01068 if (islower(action_type)) action_type = toupper(action_type);
01069
01070 loc = GetEventLocation(pw, (XEvent *) (call_data->event));
01071
01072 if (action_type != 'C') {
01073 if ( isupper(*call_data->params[1]) )
01074 direction = (Direction) *call_data->params[1];
01075 else
01076 direction = (Direction) toupper(*call_data->params[1]);
01077 }
01078
01079 switch (action_type) {
01080 case 'S':
01081 pw->paned.resize_children_to_pref = FALSE;
01082 StartGripAdjustment(pw, grip, direction);
01083 pw->paned.start_loc = loc;
01084 break;
01085
01086 case 'M':
01087 MoveGripAdjustment(pw, grip, direction, loc);
01088 break;
01089
01090 case 'C':
01091 XtSetArg(arglist[0], XtNcursor, &cursor);
01092 XtGetValues(grip, arglist, (Cardinal) 1);
01093 XDefineCursor(XtDisplay(grip), XtWindow(grip), cursor);
01094 CommitGripAdjustment(pw);
01095 break;
01096
01097 default:
01098 XtError( "Paned GripAction(); 1st parameter invalid" );
01099 }
01100 }
01101
01102
01103
01104
01105
01106
01107
01108
01109 static void
01110 ResortChildren(pw)
01111 PanedWidget pw;
01112 {
01113 Widget * unmanagedP, * childP;
01114
01115 unmanagedP = NULL;
01116 ForAllChildren(pw, childP) {
01117 if (!IsPane(*childP) || !XtIsManaged(*childP)) {
01118
01119
01120
01121 if (unmanagedP == NULL)
01122 unmanagedP = childP;
01123 }
01124 else {
01125
01126
01127
01128 if (unmanagedP != NULL) {
01129 Widget child = *unmanagedP;
01130 *unmanagedP = *childP;
01131 *childP = child;
01132 childP = unmanagedP;
01133 unmanagedP = NULL;
01134 }
01135 }
01136 }
01137 }
01138
01139
01140
01141
01142
01143
01144
01145
01146 static void
01147 ManageAndUnmanageGrips(pw)
01148 PanedWidget pw;
01149 {
01150 WidgetList managed_grips, unmanaged_grips;
01151 Widget *managedP, *unmanagedP, *childP;
01152 Cardinal alloc_size;
01153
01154 alloc_size = (Cardinal) sizeof(Widget) * pw->composite.num_children / 2;
01155 managedP = managed_grips = (WidgetList) XtMalloc(alloc_size);
01156 unmanagedP = unmanaged_grips = (WidgetList) XtMalloc(alloc_size);
01157
01158 ForAllChildren(pw, childP)
01159 if (IsPane(*childP) && HasGrip(*childP))
01160 if ( XtIsManaged(*childP) )
01161 *managedP++ = PaneInfo(*childP)->grip;
01162 else
01163 *unmanagedP++ = PaneInfo(*childP)->grip;
01164
01165 if (managedP != managed_grips) {
01166 *unmanagedP++ = *--managedP;
01167 XtManageChildren( managed_grips, (Cardinal)(managedP - managed_grips) );
01168 }
01169
01170 if (unmanagedP != unmanaged_grips)
01171 XtUnmanageChildren( unmanaged_grips,
01172 (Cardinal)(unmanagedP - unmanaged_grips) );
01173
01174 XtFree((char *)managed_grips);
01175 XtFree((char *)unmanaged_grips);
01176 }
01177
01178
01179
01180
01181
01182
01183
01184 static void
01185 CreateGrip(child)
01186 Widget child;
01187 {
01188 PanedWidget pw = (PanedWidget) XtParent(child);
01189 Arg arglist[2];
01190 Cardinal num_args = 0;
01191 Cursor cursor;
01192
01193 XtSetArg(arglist[num_args], XtNtranslations, pw->paned.grip_translations);
01194 num_args++;
01195 if ( (cursor = pw->paned.grip_cursor) == None )
01196 if (IsVert(pw))
01197 cursor = pw->paned.v_grip_cursor;
01198 else
01199 cursor = pw->paned.h_grip_cursor;
01200
01201 XtSetArg(arglist[num_args], XtNcursor, cursor);
01202 num_args++;
01203 PaneInfo(child)->grip = XtCreateWidget("grip", gripWidgetClass, (Widget)pw,
01204 arglist, num_args);
01205
01206 XtAddCallback(PaneInfo(child)->grip, XtNcallback,
01207 HandleGrip, (XtPointer) child);
01208 }
01209
01210
01211
01212
01213
01214
01215
01216 static void
01217 GetGCs(w)
01218 Widget w;
01219 {
01220 PanedWidget pw = (PanedWidget) w;
01221 XtGCMask valuemask;
01222 XGCValues values;
01223
01224
01225
01226
01227
01228 values.foreground = pw->paned.internal_bp;
01229 valuemask = GCForeground;
01230 pw->paned.normgc = XtGetGC(w, valuemask, &values);
01231
01232
01233
01234
01235
01236 values.foreground = pw->core.background_pixel;
01237 valuemask = GCForeground;
01238 pw->paned.invgc = XtGetGC(w, valuemask, &values);
01239
01240
01241
01242
01243
01244 values.function = GXinvert;
01245 values.plane_mask = pw->paned.internal_bp ^ pw->core.background_pixel;
01246 values.subwindow_mode = IncludeInferiors;
01247 valuemask = GCPlaneMask | GCFunction | GCSubwindowMode;
01248 pw->paned.flipgc = XtGetGC(w, valuemask, &values);
01249 }
01250
01251
01252
01253
01254
01255
01256
01257 static void
01258 SetChildrenPrefSizes(pw, off_size)
01259 PanedWidget pw;
01260 Dimension off_size;
01261 {
01262 Widget * childP;
01263 Boolean vert = IsVert(pw);
01264 XtWidgetGeometry request, reply;
01265
01266 ForAllPanes(pw, childP)
01267 if ( pw->paned.resize_children_to_pref ||
01268 (PaneInfo(*childP)->size == 0) ||
01269 (PaneInfo(*childP)->resize_to_pref) ) {
01270
01271 if (PaneInfo(*childP)->preferred_size != PANED_ASK_CHILD)
01272 PaneInfo(*childP)->wp_size=PaneInfo(*childP)->preferred_size;
01273 else {
01274 if( vert ) {
01275 request.request_mode = CWWidth;
01276 request.width = off_size;
01277 }
01278 else {
01279 request.request_mode = CWHeight;
01280 request.height = off_size;
01281 }
01282
01283 if ((XtQueryGeometry( *childP, &request, &reply )
01284 == XtGeometryAlmost) &&
01285 (reply.request_mode = (vert ? CWHeight : CWWidth)))
01286 PaneInfo(*childP)->wp_size = GetRequestInfo(&reply, vert);
01287 else
01288 PaneInfo(*childP)->wp_size = PaneSize(*childP, vert);
01289 }
01290
01291 PaneInfo(*childP)->size = PaneInfo(*childP)->wp_size;
01292 }
01293 }
01294
01295
01296
01297
01298
01299
01300
01301 static void
01302 ChangeAllGripCursors(pw)
01303 PanedWidget pw;
01304 {
01305 Widget * childP;
01306
01307 ForAllPanes(pw, childP) {
01308 Arg arglist[1];
01309 Cursor cursor;
01310
01311 if ( (cursor = pw->paned.grip_cursor) == None )
01312 if ( IsVert(pw) )
01313 cursor = pw->paned.v_grip_cursor;
01314 else
01315 cursor = pw->paned.h_grip_cursor;
01316
01317 if (HasGrip (*childP)) {
01318 XtSetArg(arglist[0], XtNcursor, cursor);
01319 XtSetValues(PaneInfo(*childP)->grip, arglist, (Cardinal) 1);
01320 }
01321 }
01322 }
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337 static void
01338 PushPaneStack(pw, pane)
01339 PanedWidget pw;
01340 Pane pane;
01341 {
01342 PaneStack * stack = (PaneStack *) XtMalloc(sizeof(PaneStack));
01343
01344 stack->next = pw->paned.stack;
01345 stack->pane = pane;
01346 stack->start_size = pane->size;
01347
01348 pw->paned.stack = stack;
01349 }
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361 static void
01362 GetPaneStack(pw, shrink, pane, start_size)
01363 PanedWidget pw;
01364 Boolean shrink;
01365 Pane * pane;
01366 int * start_size;
01367 {
01368 if (pw->paned.stack == NULL) {
01369 *pane = NULL;
01370 return;
01371 }
01372
01373 *pane = pw->paned.stack->pane;
01374 *start_size = pw->paned.stack->start_size;
01375
01376 if (shrink != ((*pane)->size > *start_size)) *pane = NULL;
01377 }
01378
01379
01380
01381
01382
01383
01384
01385 static Boolean
01386 PopPaneStack(pw)
01387 PanedWidget pw;
01388 {
01389 PaneStack * stack = pw->paned.stack;
01390
01391 if (stack == NULL) return(FALSE);
01392
01393 pw->paned.stack = stack->next;
01394 XtFree((char*)stack);
01395
01396 if (pw->paned.stack == NULL) return(FALSE);
01397 return(TRUE);
01398 }
01399
01400
01401
01402
01403
01404
01405
01406 static void
01407 ClearPaneStack(pw)
01408 PanedWidget pw;
01409 {
01410 while(PopPaneStack(pw));
01411 }
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425 static void
01426 ClassInitialize()
01427 {
01428 XawInitializeWidgetSet();
01429 XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation,
01430 (XtConvertArgList)NULL, (Cardinal)0 );
01431 }
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447 static XtGeometryResult GeometryManager(w, request, reply)
01448 Widget w;
01449 XtWidgetGeometry *request, *reply;
01450 {
01451 PanedWidget pw = (PanedWidget) XtParent(w);
01452 XtGeometryMask mask = request->request_mode;
01453 Dimension old_size, old_wpsize, old_paned_size;
01454 Pane pane = PaneInfo(w);
01455 Boolean vert = IsVert(pw);
01456 Dimension on_size, off_size;
01457 XtGeometryResult result;
01458 Boolean almost = FALSE;
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469 if ( (XtIsRealized((Widget)pw) && !pane->allow_resize) ||
01470 !(mask & ((vert) ? CWHeight : CWWidth)) ||
01471 (mask & ~(CWWidth | CWHeight)) ||
01472 (GetRequestInfo(request, vert) == PaneSize(w, vert)) ) {
01473 return XtGeometryNo;
01474 }
01475
01476 old_paned_size = PaneSize( (Widget) pw, vert);
01477 old_wpsize = pane->wp_size;
01478 old_size = pane->size;
01479
01480 pane->wp_size = pane->size = GetRequestInfo(request, vert);
01481
01482 AdjustPanedSize(pw, PaneSize((Widget) pw, !vert), &result, &on_size,
01483 &off_size);
01484
01485
01486
01487
01488
01489
01490 if (result != XtGeometryNo)
01491 if (vert)
01492 pw->core.height = on_size;
01493 else
01494 pw->core.width = on_size;
01495
01496 RefigureLocations(pw, PaneIndex(w), AnyPane);
01497
01498
01499
01500
01501
01502 if (vert) {
01503 pw->core.height = old_paned_size;
01504 reply->height = pane->size;
01505 reply->width = off_size;
01506 }
01507 else {
01508 pw->core.width = old_paned_size;
01509 reply->height = off_size;
01510 reply->width = pane->size;
01511 }
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525 if ( !((vert ? CWWidth : CWHeight) & mask))
01526 if (vert)
01527 request->width = w->core.width;
01528 else
01529 request->height = w->core.height;
01530
01531 almost = GetRequestInfo(request, !vert) != GetRequestInfo(reply, !vert);
01532 almost |= (GetRequestInfo(request, vert) != GetRequestInfo(reply, vert));
01533
01534 if ( (mask & XtCWQueryOnly) || almost ) {
01535 pane->wp_size = old_wpsize;
01536 pane->size = old_size;
01537 RefigureLocations(pw, PaneIndex(w), AnyPane);
01538 reply->request_mode = CWWidth | CWHeight;
01539 if (almost) return XtGeometryAlmost;
01540 }
01541 else {
01542 AdjustPanedSize(pw, PaneSize((Widget) pw, !vert),
01543 (XtGeometryResult *)NULL,
01544 (Dimension *)NULL, (Dimension *)NULL);
01545 CommitNewLocations( pw );
01546 }
01547 return XtGeometryDone;
01548 }
01549
01550
01551 static void Initialize(request, new, args, num_args)
01552 Widget request, new;
01553 ArgList args;
01554 Cardinal *num_args;
01555 {
01556 PanedWidget pw = (PanedWidget)new;
01557
01558 GetGCs( (Widget) pw);
01559
01560 pw->paned.recursively_called = False;
01561 pw->paned.stack = NULL;
01562 pw->paned.resize_children_to_pref = TRUE;
01563 pw->paned.num_panes = 0;
01564 }
01565
01566 static void
01567 Realize(w, valueMask, attributes)
01568 Widget w;
01569 Mask *valueMask;
01570 XSetWindowAttributes *attributes;
01571 {
01572 PanedWidget pw = (PanedWidget) w;
01573 Widget * childP;
01574
01575 if ((attributes->cursor = (pw)->paned.cursor) != None)
01576 *valueMask |= CWCursor;
01577
01578 (*SuperClass->core_class.realize) (w, valueMask, attributes);
01579
01580
01581
01582
01583
01584
01585 ForAllPanes(pw, childP) {
01586 XtRealizeWidget( *childP );
01587 if (HasGrip (*childP))
01588 XtRealizeWidget( PaneInfo(*childP)->grip );
01589 }
01590
01591 RefigureLocationsAndCommit(w);
01592 pw->paned.resize_children_to_pref = FALSE;
01593 }
01594
01595 static void
01596 ReleaseGCs(w)
01597 Widget w;
01598 {
01599 PanedWidget pw = (PanedWidget)w;
01600
01601 XtReleaseGC( w, pw->paned.normgc );
01602 XtReleaseGC( w, pw->paned.invgc );
01603 XtReleaseGC( w, pw->paned.flipgc );
01604 }
01605
01606 static void InsertChild(w)
01607 Widget w;
01608 {
01609 Pane pane = PaneInfo(w);
01610
01611
01612
01613 (*SuperClass->composite_class.insert_child)(w);
01614
01615 if (!IsPane(w)) return;
01616
01617
01618
01619 if ( pane->show_grip == TRUE ) {
01620 CreateGrip(w);
01621 if (pane->min == PANED_GRIP_SIZE)
01622 pane->min = PaneSize(pane->grip, IsVert((PanedWidget) XtParent(w)));
01623 }
01624 else {
01625 if (pane->min == PANED_GRIP_SIZE)
01626 pane->min = 1;
01627 pane->grip = NULL;
01628 }
01629
01630 pane->size = 0;
01631 pane->paned_adjusted_me = FALSE;
01632
01633 }
01634
01635 static void DeleteChild(w)
01636 Widget w;
01637 {
01638
01639
01640 if ( IsPane(w) && HasGrip(w) ) XtDestroyWidget(PaneInfo(w)->grip);
01641
01642
01643
01644 (*SuperClass->composite_class.delete_child) (w);
01645
01646 }
01647
01648 static void ChangeManaged(w)
01649 Widget w;
01650 {
01651 PanedWidget pw = (PanedWidget)w;
01652 Boolean vert = IsVert(pw);
01653 Dimension size;
01654 Widget *childP;
01655
01656 if (pw->paned.recursively_called++) return;
01657
01658
01659
01660
01661
01662 if ( (size = PaneSize( (Widget) pw, !vert )) == 0) {
01663 size = 1;
01664 ForAllChildren(pw, childP)
01665 if ( XtIsManaged(*childP) && (PaneSize( *childP, !vert ) > size) )
01666 size = PaneSize( *childP, !vert );
01667 }
01668
01669 ManageAndUnmanageGrips(pw);
01670 pw->paned.recursively_called = False;
01671 ResortChildren(pw);
01672
01673 pw->paned.num_panes = 0;
01674 ForAllChildren(pw, childP)
01675 if ( IsPane(*childP) )
01676 if ( XtIsManaged(*childP) ) {
01677 Pane pane = PaneInfo(*childP);
01678 if (HasGrip(*childP))
01679 PaneInfo(pane->grip)->position = pw->paned.num_panes;
01680 pane->position = pw->paned.num_panes;
01681 pw->paned.num_panes++;
01682 }
01683 else
01684 break;
01685
01686 SetChildrenPrefSizes( (PanedWidget) w, size);
01687
01688
01689
01690
01691
01692 if ( PaneSize((Widget) pw, vert) == 0 )
01693 AdjustPanedSize(pw, size, (XtGeometryResult *)NULL,
01694 (Dimension *)NULL, (Dimension *)NULL);
01695
01696 if (XtIsRealized( (Widget) pw))
01697 RefigureLocationsAndCommit( (Widget) pw);
01698
01699 }
01700
01701
01702
01703
01704
01705
01706
01707 static void
01708 Resize(w)
01709 Widget w;
01710 {
01711 SetChildrenPrefSizes( (PanedWidget) w,
01712 PaneSize(w, !IsVert((PanedWidget) w)) );
01713 RefigureLocationsAndCommit(w);
01714 }
01715
01716
01717 static void
01718 Redisplay(w, event, region)
01719 Widget w;
01720 XEvent * event;
01721 Region region;
01722 {
01723 DrawInternalBorders( (PanedWidget) w);
01724 }
01725
01726
01727 static Boolean
01728 SetValues(old, request, new, args, num_args)
01729 Widget old, request, new;
01730 ArgList args;
01731 Cardinal *num_args;
01732 {
01733 PanedWidget old_pw = (PanedWidget) old;
01734 PanedWidget new_pw = (PanedWidget) new;
01735 Boolean redisplay = FALSE;
01736
01737 if ( (old_pw->paned.cursor != new_pw->paned.cursor) && XtIsRealized(new))
01738 XDefineCursor(XtDisplay(new), XtWindow(new), new_pw->paned.cursor);
01739
01740 if ( (old_pw->paned.internal_bp != new_pw->paned.internal_bp) ||
01741 (old_pw->core.background_pixel != new_pw->core.background_pixel) ) {
01742 ReleaseGCs(old);
01743 GetGCs(new);
01744 redisplay = TRUE;
01745 }
01746
01747 if ( (old_pw->paned.grip_cursor != new_pw->paned.grip_cursor) ||
01748 (old_pw->paned.v_grip_cursor != new_pw->paned.v_grip_cursor) ||
01749 (old_pw->paned.h_grip_cursor != new_pw->paned.h_grip_cursor) ) {
01750 ChangeAllGripCursors(new_pw);
01751 }
01752
01753 if ( IsVert(old_pw) != IsVert(new_pw)) {
01754
01755
01756
01757
01758 if (IsVert(new_pw))
01759 new_pw->core.width = 0;
01760 else
01761 new_pw->core.height = 0;
01762
01763 new_pw->paned.resize_children_to_pref = TRUE;
01764 ChangeManaged(new);
01765 new_pw->paned.resize_children_to_pref = FALSE;
01766 if (new_pw->paned.grip_cursor == None)
01767 ChangeAllGripCursors(new_pw);
01768 return(TRUE);
01769 }
01770
01771 if (old_pw->paned.internal_bw != new_pw->paned.internal_bw) {
01772 AdjustPanedSize( new_pw, PaneSize(new, !IsVert(old_pw)),
01773 (XtGeometryResult *)NULL,
01774 (Dimension *)NULL, (Dimension *)NULL);
01775 RefigureLocationsAndCommit(new);
01776 return(TRUE);
01777 }
01778
01779 if ( (old_pw->paned.grip_indent != new_pw->paned.grip_indent) &&
01780 (XtIsRealized(new)) ) {
01781 CommitNewLocations(new_pw);
01782 redisplay = TRUE;
01783 }
01784
01785 return (redisplay);
01786 }
01787
01788
01789
01790 static Boolean
01791 PaneSetValues(old, request, new, args, num_args)
01792 Widget old, request, new;
01793 ArgList args;
01794 Cardinal *num_args;
01795 {
01796 Pane old_pane = PaneInfo(old);
01797 Pane new_pane = PaneInfo(new);
01798 Boolean redisplay = FALSE;
01799
01800
01801
01802 if (old_pane->min != new_pane->min || old_pane->max != new_pane->max)
01803 XawPanedSetMinMax(new, (int)new_pane->min, (int)new_pane->max);
01804
01805
01806
01807 if (old_pane->show_grip != new_pane->show_grip)
01808 if (new_pane->show_grip == TRUE) {
01809 CreateGrip(new);
01810 if (XtIsRealized(XtParent(new))) {
01811 if (XtIsManaged(new))
01812
01813 XtManageChild(PaneInfo(new)->grip);
01814 XtRealizeWidget(PaneInfo(new)->grip);
01815 CommitNewLocations( (PanedWidget) XtParent(new) );
01816 }
01817 }
01818 else if ( HasGrip(old) ) {
01819 XtDestroyWidget( old_pane->grip );
01820 new_pane->grip = NULL;
01821 redisplay = TRUE;
01822 }
01823
01824
01825
01826 return(redisplay);
01827 }
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842 void
01843 #if NeedFunctionPrototypes
01844 XawPanedSetMinMax(Widget widget, int min, int max)
01845 #else
01846 XawPanedSetMinMax(widget, min, max)
01847 Widget widget;
01848 int min, max;
01849 #endif
01850 {
01851 Pane pane = PaneInfo(widget);
01852
01853 pane->min = min;
01854 pane->max = max;
01855 RefigureLocationsAndCommit( widget->core.parent );
01856 }
01857
01858
01859
01860
01861
01862
01863
01864
01865 void
01866 #if NeedFunctionPrototypes
01867 XawPanedGetMinMax(Widget widget, int *min, int *max)
01868 #else
01869 XawPanedGetMinMax(widget, min, max)
01870 Widget widget;
01871 int *min, *max;
01872 #endif
01873 {
01874 Pane pane = PaneInfo(widget);
01875
01876 *min = pane->min;
01877 *max = pane->max;
01878 }
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888 void
01889 #if NeedFunctionPrototypes
01890 XawPanedSetRefigureMode(Widget w,
01891 #if NeedWidePrototypes
01892 int mode)
01893 #else
01894 Boolean mode)
01895 #endif
01896 #else
01897 XawPanedSetRefigureMode(w, mode)
01898 Widget w;
01899 Boolean mode;
01900 #endif
01901 {
01902 ((PanedWidget) w)->paned.refiguremode = mode;
01903 RefigureLocationsAndCommit( w );
01904 }
01905
01906
01907
01908
01909
01910
01911
01912 int
01913 #if NeedFunctionPrototypes
01914 XawPanedGetNumSub(Widget w)
01915 #else
01916 XawPanedGetNumSub(w)
01917 Widget w;
01918 #endif
01919 {
01920 return ((PanedWidget)w)->paned.num_panes;
01921 }
01922
01923
01924
01925
01926
01927
01928
01929
01930 void
01931 #if NeedFunctionPrototypes
01932 XawPanedAllowResize(Widget widget,
01933 #if NeedWidePrototypes
01934 int allow_resize)
01935 #else
01936 Boolean allow_resize)
01937 #endif
01938 #else
01939 XawPanedAllowResize(widget, allow_resize)
01940 Widget widget;
01941 Boolean allow_resize;
01942 #endif
01943 {
01944 PaneInfo(widget)->allow_resize = allow_resize;
01945 }