From 6f36a9a51930b927c5fc61cc80cc5b0ff89f5130 Mon Sep 17 00:00:00 2001 From: treectrl Date: Mon, 4 Dec 2006 20:54:54 +0000 Subject: New style layout option -visible. Elements with zero requested size are not included in the layout, including any padding. Union elements are not included in the layout if all the elements they surround are hidden or have zero size. --- doc/What's New in TkTreeCtrl.html | 1003 ++++++++++++++++++++++++++++++++++++- doc/treectrl.html | 15 +- doc/treectrl.man | 10 +- doc/treectrl.n | 12 +- generic/tkTreeStyle.c | 190 ++++++- 5 files changed, 1192 insertions(+), 38 deletions(-) diff --git a/doc/What's New in TkTreeCtrl.html b/doc/What's New in TkTreeCtrl.html index cf4a2c0..6a254b6 100644 --- a/doc/What's New in TkTreeCtrl.html +++ b/doc/What's New in TkTreeCtrl.html @@ -1,21 +1,26 @@ - + + + + + + What's New in TkTreeCtrl @@ -25,131 +30,191 @@ +

What's New in TkTreeCtrl 2.2.x

+

Column Configuration Options

+ + + + + + + + + + + +
NewComment
-itemjustifyThis option allows item styles to to justified separately from the image/text in the column header. If the value of this option is unspecified (the default), then item styles are justified according to the -justify option of the column.
+

Item Configuration Options

+ + + + + + + + + + + +
Usage ChangedHow it changed
-buttonThe value of this option can now be the word auto (or any abbreviation) in which case a button is drawn only when the item has at least one child item with its item option -visible set to true.
+

Style Layout Changes

+ +

Item Descriptions

+ -
-
.t item id "root child end-1" ; # get the second-to-last child of the root item
+
+
.t item id "root child end-1" ; # get the second-to-last child of the root item
+

Bug Fixes

+ + + +

What's New in TkTreeCtrl 2.2

+

TreeCtrl Configuration Options

+ + + + + + + + + + + + @@ -157,44 +222,54 @@ instead +

TreeCtrl Command

+
DeprecatedWhat to use instead
-defaultstyleThe -itemstyle option of a column.
+ + + + + + + + + + + + + + + + + + + + + + + @@ -313,79 +418,98 @@ will return the bounds of the left-locked and right-locked columns. +

Column Configuration Options

+
Arguments/Result ChangedWhat changed
contentboxThe return value is an empty string if the content area is totally obscurred by column headers, borders, and/or locked columns. Typically this will only happen if the window is too @@ -202,110 +277,140 @@ small.
selection getAccepts 2 optional arguments to allow in-place lindex and lrange queries of the selection. For example:
+ +
.t selection get 0       ; # the first selected item
.t selection get end     ; # the last selected item
.t selection get 1 end-1 ; # every selected item except the first and last
+
NewComment
bboxReturns the bounding box of different areas of the window. For example:
+ +
.t bbox
+ will return the bounds of the window, and:
+ +
.t bbox header
+ will return the bounds of the column headers, and:
+ +
.t bbox content
+ will return the same result as the [contentbox] command, and:
+ +
.t bbox left
.t bbox right
+ will return the bounds of the left-locked and right-locked columns.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -484,99 +631,123 @@ will give column 0 twice the extra space as column 1. +

Column Command

+
Renamed
+
New name
-tag-tags
NewComment
-lockThis option allows columns to stick to the left or right edge of the window. Locked columns can scroll vertically but not @@ -393,90 +517,113 @@ horizontally. Valid values for this option are +
-itemstyleSpecifies the name of a style to set in this column for newly-created items. This option replaces the treectrl option -defaultstyle.
-uniformThese two options operate the same as the grid geometry manager options of the same name. For example:
+ +
.t column configure 0 -uniform a
.t column configure 1 -uniform a
+ will give columns 0 and 1 the same requested width, whichever is the larger of the two columns. And:
+ +
.t column configure 0 -uniform a -weight 2
.t column configure 1 -uniform a
+ will give column 0 twice the maximum of the requested widths of columns 0 and 1. And:
+ +
.t column configure 0 -expand yes -weight 2
.t column configure 1 -expand yes
+ will give column 0 twice the extra space as column 1.
-weight
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -631,42 +814,52 @@ word "tail" in column descriptions. +

Item Configuration Options

+
Arguments/Result ChangedWhat changed
column countTakes an optional column-description argument; the result is the number of columns that match the column description. For example:
+ +
.t column count visible
+ will return the number of columns whose -visible option is true, and:
+ +
.t column count {tag a^b}
+ will return the number of columns with either tag "a" or "b", but not both.
NewComment
column tag addColumns can have a list of tag names. Previously only a single tag was allowed. The tail column no longer has the word "tail" as a tag, but it is still referred to by the @@ -584,46 +755,58 @@ word "tail" in column descriptions.
column tag expr
column tag names
column tag remove
+ + + + + + + + + + + @@ -686,170 +882,212 @@ found in the man page. +

Item Command

+
NewComment
-tagsTags are textual labels applied to items to group them. Tags do not affect the appearance or behaviour of items. Tags can be used in @@ -675,10 +868,13 @@ found in the man page.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -997,19 +1273,23 @@ will remove tags "b" and "c" from any items that have them. +

Text Element

+ The new option -underline draws an underline under a single character of the displayed text.
+

Window Element

+ Window elements can now be properly clipped so they don't draw over the column header, borders, or outside the bounds of the item columns they occupy. This is accomplished by making the window you want @@ -1019,18 +1299,22 @@ a window element, you would change this code:
+
set canvas [canvas .t.canvas ...]
.t item element configure $item $column myElement -window $canvas
+ to this:
+
set frame [frame .t.clip -borderwidth 0]
set canvas [canvas $frame.canvas ...]
.t item element configure $item $column myElement -window $frame -clip yes
+ The -clip option tells the window element to manage the geometry of both the -window widget (i.e, @@ -1042,174 +1326,215 @@ demos. + New keywords were added to allow multiple items to be specified by an item description:
+ + New modifiers were added to match multiple items: + New qualifiers were added to refine which items are matched:
+ +
.t item id "all depth 2" ; # find all items that are children of the root's children
.t item id "depth 2" ; # ditto
+
+ +
+ The keyword all may now be followed by a list of qualifiers. For example:
+
.t item id "all !visible state myState" ; # find every item that is not displayed with user-defined state "myState"
+ A list of qualifiers may be used as the first part of an item description. This gives the same result as  "all" followed by the @@ -1217,19 +1542,23 @@ qualifiers. For example:
+
.t item id "!visible state myState" ; # same as the previous example
+
+

Column Descriptions

+ New keywords list and range can be used to @@ -1237,17 +1566,20 @@ match multiple columns.
+ New qualifiers state, tag, !tail and !visible can be used to restrict which columns are specified.
+ The keyword all may be followed by a list of qualifiers.
+ A list of qualifiers may used as the first part of a column description. This gives the same result as  "all" followed by the @@ -1256,6 +1588,7 @@ qualifiers. + Many commands can now operate on multiple items and/or columns by using the improved item descriptions and column descriptions mentioned above. For example: @@ -1264,52 +1597,63 @@ For example: + +

Demo Changes

+ +

Misc Changes

+ +

Bug Fixes

+ +

What's New in TkTreeCtrl 2.1.1

+

Column Command

+
Arguments/Result ChangedWhat changed
item countTakes an optional item-description argument; the result is the number of items that match the item description. For example:
+ +
.t item count visible
+ will return the number of items that are displayed (i.e., those whose ancestors are all expanded, -visible options are true, etc), and:
+ +
.t item count {tag a^b}
+ will return the number of items with either tag "a" or "b", but not both.
item createNew option -tags specifies an initial list of tags for created items.
item idReturns a list of item ids if the item description matches multiple items. For example:
+ +
.t item id all
+ will return a list of ids for all items, and:
+ +
.t item id "$item children"
+ will return the ids of every child of an item.
NewComment
item descendantsReturns the ids of the children, grandchildren, etc of an item.
item enabledGets and sets the enabled state for items. All items are enabled when first created. Disabled items cannot be selected, and are ignored by the default key-navigation @@ -857,139 +1095,177 @@ and mouse bindings.
item tag addAdd tags to items. For example:
+ +
.t item tag add all {a b c}
+ will add tags "a", "b" and "c" to every item.
+
item tag exprEvaluate a tag expression against items. For example:
+ +
.t item tag expr $item a
+ returns 1 if an item has tag "a". Also:
+ +
.t item tag expr $item a||b
+ returns 1 if  an item has tag "a" or "b".
item tag namesReturn a list of tag names assigned to items. For example:
+ +
.t item tag names $item
+ returns the tag list for an item, and:
+ +
.t item tag names all
+ returns every tag assigned to any item.
item tag removeRemove tags from items. For example:
+ +
.t item tag remove all {b c}
+ will remove tags "b" and "c" from any items that have them.
+ + + + + + + + + + + @@ -1451,14 +1823,17 @@ columns to be deleted. +

Bug Fixes

+ +

Other Changes

+ +

Demo Changes

+ +

What's New in TkTreeCtrl 2.1

+ This version should be backwards compatible with 2.0, except for a few obscure changes.
+

TreeCtrl Configuration Options

+
Arguments/Result ChangedWhat changed
column delete
+
Added an optional second argument allowing a range of columns to be deleted.
+ + + + + + + + + + + + + + + + + + + @@ -1640,68 +2055,85 @@ obscure changes.
+

Column Configuration Options

+
NewComment
-itemwidth
+
-itemwidthequalDeprecates the column -widthhack option.
-itemwidthmultipleDeprecates the column -stepwidth option.
+ + + + + + + + + + + + + + + @@ -1709,50 +2141,63 @@ instead +

Element Command

+
DeprecatedWhat to use instead
-stepwidthtreectrl's -itemwidthmultiple option
-widthhacktreectrl's -itemwidthequal option
+ + + + + + + + + + + @@ -1760,50 +2205,63 @@ instead +

Item Configuration Options

+
NewComment
element perstateLike [item element perstate].
+ + + + + + + + + + + @@ -1811,128 +2269,158 @@ instead +

Item Command

+
NewComment
-heightOverrides the treectrl's -itemheight option
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2165,56 +2705,70 @@ columns.
+

Notify Command

+
DeprecatedWhat to use instead
item element actualitem element perstate
item complexitem element configure
Behaviour ChangedWhat changed
item bboxNo longer returns an error if no style had been assigned to the column.
item state forcolumnNo longer returns an error if no style had been assigned to the column.
item style setDoes nothing when replacing a style with the same style. Previously the old style was freed before assigning the new style, @@ -1940,41 +2428,50 @@ losing the element config info if the old and new styles were the same.
+ Potential incompatibility
Arguments/Result ChangedWhat changed
item createAdded options: -count -height, -nextsibling, -open, -parent, -prevsibling, and -returnid. Multiple items may be created with one @@ -1982,18 +2479,22 @@ call using the -count option.
item element configureMultiple elements in multiple columns may be configured with a single call. Use '+' to separate elements, and ',' to separate @@ -2001,18 +2502,22 @@ columns. See the docs.
item style setWhen no column is specified, returns a list of one style name per column. Previously, the list would have less values than the number @@ -2021,72 +2526,89 @@ column(s).
+ Potential incompatibility
item textWhen no column is specified, returns a list of one string per column.
NewComment
item imagePartner to the [item text] command.
item element perstateNot really new, just renamed from [item element actual] to better describe what it does. Accepts a new optional argument which @@ -2095,69 +2617,87 @@ option.
+
+ The following options no longer return a default value if the per-state option itself does not have a value specified:
+ +
    +
  • bitmap -foreground, -background
  • +
  • border -relief
  • +
  • text -fill, -font
  • + +
+ Potential incompatibility
item spanA style may now be displayed over multiple adjacent columns.
+
+ + + + + + + + + + + @@ -2222,77 +2776,94 @@ call. +

Style Layout Changes

+ +
    +
  1. If a -detach element had a fixed width larger than the other elements.
  2. +
  3. If an element had -iexpand x specified as well as -maxwidth, leaving some space available.
  4. +
+

Element Changes

+ +

Event Changes

+ +

Other Changes

+ +

Demo Changes

+ +

What's New in TkTreeCtrl 2.0

+

TreeCtrl Configuration Options

+
NewComment
notify unbind
+
Let's you unbind all scripts from an object with one call.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2634,116 +3282,145 @@ buttons/lines. +

TreeCtrl Commands

+
ReplacedWhat to use instead
-openbuttonimage-buttonimage
-closedbuttonimage-buttonimage
-openbuttonbitmap-buttonbitmap
-closedbuttonbitmap-buttonbitmap
Usage ChangedHow it changed
-backgroundmodeThe values "index" and "visindex" are deprecated. The value "order" should be used instead of "index", and @@ -2491,18 +3104,22 @@ index" command.
-treecolumnThis used to be any integer value which may or may not have corresponded to an actual column. Now the value must be a valid column @@ -2511,122 +3128,153 @@ buttons/lines.
New
-backgroundimage
-columnprefix
-columnresizemode
-itemprefix
-minitemheight
-usetheme
+ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2751,281 +3428,350 @@ instead +

Column Configuration Options

+
DeprecatedWhat to use instead
compareitem compare
indexitem id
numcolumnscolumn count
numitemsitem count
rangeitem range
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3033,104 +3779,128 @@ for valid state names. +

Column Command

+
RemovedWhat to use instead
-relief
+
-state
-sunken-state
Renamed
+
New name
-arrowpad-arrowpadx
Usage ChangedHow it changed
-backgroundThis is now a per-state option. See COLUMNS in the help file for valid state names.
New
+
-arrowbitmap
+
-arrowimage
-arrowpady
-maxwidth
-resize
-state
-textlines
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3293,148 +4102,185 @@ index in the list of columns. +

Item Command

+
DeprecatedWhat to use instead
column indexcolumn id
Arguments/Result ChangedWhat changed
column configure
+
A column description of "all" is allowed if at least one option-value pair is given.
+
column createThe result is a unique identifier. Previously the result was an @@ -3138,154 +3908,193 @@ index in the list of columns.
column deleteA column description of "all" is allowed.
NewComment
column compare
column countreplaces "numcolumns"
column dragconfigure
column dragcget
column idreplaces "column index"
column list
column order
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3442,185 +4288,235 @@ instead +

Notify Command

+
RemovedWhat to use instead
item indexitem order
NewComment
item comparereplaces "compare"
item countreplaces "numitems"
item idreplaces "index"
item orderreplaces "item index"
item rangereplaces "range"
+ + + + + + + + + + + + + + + + + + + + + + + @@ -3628,44 +4524,54 @@ above +

Style Layout Options

+
Arguments/Result ChangedWhat changed
notify generate
+
Added optional percentsCommand argument
notify installOld syntax (supported but deprecated):
+ +
notify install event eventName
+ +
notify install detail eventName detail
+ New syntax:
+ +
notify install <eventName>
+ +
notify install <eventName-detail>
+
notify linkageOld syntax (supported but deprecated):
+ +
+
notify linkage eventName
+ +
notify linkage eventName detail
+
+ New syntax:
+ +
+
notify linkage <eventName>
+ +
notify linkage <eventName-detail>
+
+
notify uninstallsee notify install above
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3853,14 +4805,17 @@ surrounds. +

Element Changes

+ +

Event Changes

+ +

Library Script Changes

+

filelist-bindings.tcl:

+ +

treectrl.tcl:

+ +

Other Changes

+ +

Demo Changes

+ + diff --git a/doc/treectrl.html b/doc/treectrl.html index 87680cf..363c52a 100644 --- a/doc/treectrl.html +++ b/doc/treectrl.html @@ -1,10 +1,10 @@ -treectrl - Tk Commands - @@ -2801,7 +2801,14 @@ size and position of the elements in elementList. The -ipadx and -ipady options in this case refer to the distance of the edges of the display area of this element from those elements it surrounds. This option is typically used to display a selection rectangle -around a piece of text. +around a piece of text. If none of the elements in elementList are +visible, then the element is not displayed. + +

+
-visible boolean
+This is a per-state option that controls visibility +of an element. If the value of the option evaluates to false for a given +item state, then the element is not displayed and consumes no space in the layout. @@ -3042,7 +3049,7 @@ See also the -backgroundmode widget option for more on this.
-itemjustify justification
This option determines how the item styles in this column line up with each other. Must be one of left, center, or right. The default -value is the empty string (for compatibility with older versions), in which +value is an empty string (for compatibility with older versions), in which case the column option -justify is used to align item styles in this column. diff --git a/doc/treectrl.man b/doc/treectrl.man index c3135ff..4e696f7 100644 --- a/doc/treectrl.man +++ b/doc/treectrl.man @@ -3,7 +3,7 @@ See the file "license.terms" for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. - $Id: treectrl.man,v 1.46 2006/12/03 00:24:00 treectrl Exp $} + $Id: treectrl.man,v 1.47 2006/12/04 20:55:19 treectrl Exp $} ][manpage_begin treectrl n 2.2] [moddesc {Tk Commands}] [titledesc {Create and manipulate hierarchical multicolumn widgets}] @@ -2133,7 +2133,13 @@ size and position of the elements in [arg elementList]. The [option -ipadx] and [option -ipady] options in this case refer to the distance of the edges of the display area of this element from those elements it surrounds. This option is typically used to display a selection rectangle -around a piece of text. +around a piece of text. If none of the elements in [arg elementList] are +visible, then the element is not displayed. + +[opt_def [option -visible] [arg boolean]] +This is a [sectref {PER-STATE OPTIONS} per-state] option that controls visibility +of an element. If the value of the option evaluates to false for a given +item state, then the element is not displayed and consumes no space in the layout. [list_end] diff --git a/doc/treectrl.n b/doc/treectrl.n index 8942f3f..4426f89 100644 --- a/doc/treectrl.n +++ b/doc/treectrl.n @@ -6,7 +6,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" $Id: treectrl.n,v 1.62 2006/12/03 00:24:00 treectrl Exp $ +'\" $Id: treectrl.n,v 1.63 2006/12/04 20:55:19 treectrl Exp $ .so man.macros .TH "treectrl" n 2.2 treectrl "Tk Commands" .BS @@ -2688,7 +2688,13 @@ size and position of the elements in \fIelementList\fR. The \fB-ipadx\fR and \fB-ipady\fR options in this case refer to the distance of the edges of the display area of this element from those elements it surrounds. This option is typically used to display a selection rectangle -around a piece of text. +around a piece of text. If none of the elements in \fIelementList\fR are +visible, then the element is not displayed. +.TP +\fB\fB-visible\fR\fR \fIboolean\fR +This is a \fBper-state\fR option that controls visibility +of an element. If the value of the option evaluates to false for a given +item state, then the element is not displayed and consumes no space in the layout. .RE .TP \fIpathName\fR \fBstyle names\fR @@ -2886,7 +2892,7 @@ See also the \fB-backgroundmode\fR widget option for more on this. \fB\fB-itemjustify\fR\fR \fIjustification\fR This option determines how the item styles in this column line up with each other. Must be one of \fBleft\fR, \fBcenter\fR, or \fBright\fR. The default -value is the empty string (for compatibility with older versions), in which +value is an empty string (for compatibility with older versions), in which case the column option \fB-justify\fR is used to align item styles in this column. .TP diff --git a/generic/tkTreeStyle.c b/generic/tkTreeStyle.c index e3ba035..0f1efd6 100644 --- a/generic/tkTreeStyle.c +++ b/generic/tkTreeStyle.c @@ -5,7 +5,7 @@ * * Copyright (c) 2002-2006 Tim Baker * - * RCS: @(#) $Id: tkTreeStyle.c,v 1.66 2006/12/02 21:38:57 treectrl Exp $ + * RCS: @(#) $Id: tkTreeStyle.c,v 1.67 2006/12/04 20:54:54 treectrl Exp $ */ #include "tkTreeCtrl.h" @@ -113,6 +113,7 @@ struct MElementLink int *onion, onionCount; /* -union option info */ int minWidth, fixedWidth, maxWidth; int minHeight, fixedHeight, maxHeight; + PerStateInfo visible; /* -visible */ }; /* @@ -169,15 +170,10 @@ struct Layout int uPadX[2]; /* padding due to -union */ int uPadY[2]; /* padding due to -union */ int temp; + int visible; /* TRUE if the element should be displayed. */ }; -#ifdef CACHE_ELEM_SIZE -#define IS_HIDDEN(L) (!DETACH_OR_UNION((L)->master) && \ - ((L)->eLink->neededWidth * (L)->eLink->neededHeight <= 0)) -#else -#define IS_HIDDEN(L) (!DETACH_OR_UNION((L)->master) && \ - ((L)->neededWidth * (L)->neededHeight <= 0)) -#endif +#define IS_HIDDEN(L) ((L)->visible == 0) /* *---------------------------------------------------------------------- @@ -606,6 +602,22 @@ Style_DoLayoutH( #endif } + /* Remember whether this element is visible or not. First check the + * -visible style layout option. If it is not false, then check for + * zero size. */ + layout->visible = PerStateBoolean_ForState(drawArgs->tree, + &eLink1->visible, drawArgs->state, NULL) != 0; + if (layout->visible) { +#ifdef CACHE_ELEM_SIZE + if (!DETACH_OR_UNION(eLink1) && (eLink2->neededWidth * + eLink2->neededHeight <= 0)) +#else + if (!DETACH_OR_UNION(eLink1) && (layout->neededWidth * + layout->neededHeight <= 0)) +#endif + layout->visible = 0; + } + if (IS_HIDDEN(layout)) continue; @@ -632,11 +644,38 @@ Style_DoLayoutH( /* Calculate the padding around elements surrounded by -union elements */ for (i = 0; i < eLinkCount; i++) { + struct Layout *layout = &layouts[i]; + int first = -1, last = -1; + + if (IS_HIDDEN(layout)) + continue; + eLink1 = &eLinks1[i]; if (eLink1->onion == NULL) continue; + for (j = 0; j < eLink1->onionCount; j++) + { + struct Layout *layout = &layouts[eLink1->onion[j]]; + + if (IS_HIDDEN(layout)) + continue; + + /* Remember the first and last visible elements surrounded by + * this -union element. */ + if (first == -1) + first = j; + last = j; + } + + /* If there are no visible elements surrounded by this -union + * element, then hide it. */ + if (first == -1) { + layout->visible = 0; + continue; + } + ePadX = eLink1->ePadX; ePadY = eLink1->ePadY; iPadX = eLink1->iPadX; @@ -656,16 +695,16 @@ Style_DoLayoutH( { uPadX[PAD_TOP_LEFT] = MAX(uPadX[PAD_TOP_LEFT], iPadX[PAD_TOP_LEFT] + ePadX[PAD_TOP_LEFT]); uPadX[PAD_BOTTOM_RIGHT] = MAX(uPadX[PAD_BOTTOM_RIGHT], iPadX[PAD_BOTTOM_RIGHT] + ePadX[PAD_BOTTOM_RIGHT]); - if (j == 0) /* topmost */ + if (j == first) /* topmost */ uPadY[PAD_TOP_LEFT] = MAX(uPadY[PAD_TOP_LEFT], iPadY[PAD_TOP_LEFT] + ePadY[PAD_TOP_LEFT]); - if (j == eLink1->onionCount - 1) /* bottommost */ + if (j == last) /* bottommost */ uPadY[PAD_BOTTOM_RIGHT] = MAX(uPadY[PAD_BOTTOM_RIGHT], iPadY[PAD_BOTTOM_RIGHT] + ePadY[PAD_BOTTOM_RIGHT]); } else { - if (j == 0) /* leftmost */ + if (j == first) /* leftmost */ uPadX[PAD_TOP_LEFT] = MAX(uPadX[PAD_TOP_LEFT], iPadX[PAD_TOP_LEFT] + ePadX[PAD_TOP_LEFT]); - if (j == eLink1->onionCount - 1) /* rightmost */ + if (j == last) /* rightmost */ uPadX[PAD_BOTTOM_RIGHT] = MAX(uPadX[PAD_BOTTOM_RIGHT], iPadX[PAD_BOTTOM_RIGHT] + ePadX[PAD_BOTTOM_RIGHT]); uPadY[PAD_TOP_LEFT] = MAX(uPadY[PAD_TOP_LEFT], iPadY[PAD_TOP_LEFT] + ePadY[PAD_TOP_LEFT]); uPadY[PAD_BOTTOM_RIGHT] = MAX(uPadY[PAD_BOTTOM_RIGHT], iPadY[PAD_BOTTOM_RIGHT] + ePadY[PAD_BOTTOM_RIGHT]); @@ -1938,6 +1977,19 @@ Style_NeededSize( #endif } + layout->visible = PerStateBoolean_ForState(tree, &eLink1->visible, + state, NULL) != 0; + if (layout->visible) { +#ifdef CACHE_ELEM_SIZE + if (!DETACH_OR_UNION(eLink1) && (eLink2->neededWidth * + eLink2->neededHeight <= 0)) +#else + if (!DETACH_OR_UNION(eLink1) && (layout->neededWidth * + layout->neededHeight <= 0)) +#endif + layout->visible = 0; + } + if (IS_HIDDEN(layout)) continue; @@ -1951,7 +2003,10 @@ Style_NeededSize( /* Figure out the padding around elements surrounded by -union elements */ for (i = 0; i < masterStyle->numElements; i++) { - if (IS_HIDDEN(&layouts[i])) + struct Layout *layout = &layouts[i]; + int first = -1, last = -1; + + if (IS_HIDDEN(layout)) continue; eLink1 = &eLinks1[i]; @@ -1959,6 +2014,27 @@ Style_NeededSize( if (eLink1->onion == NULL) continue; + for (j = 0; j < eLink1->onionCount; j++) + { + struct Layout *layout = &layouts[eLink1->onion[j]]; + + if (IS_HIDDEN(layout)) + continue; + + /* Remember the first and last visible elements surrounded by + * this -union element. */ + if (first == -1) + first = j; + last = j; + } + + /* If there are no visible elements surrounded by this -union + * element, then hide it. */ + if (first == -1) { + layout->visible = 0; + continue; + } + ePadX = eLink1->ePadX; ePadY = eLink1->ePadY; iPadX = eLink1->iPadX; @@ -1978,16 +2054,16 @@ Style_NeededSize( { uPadX[PAD_TOP_LEFT] = MAX(uPadX[PAD_TOP_LEFT], iPadX[PAD_TOP_LEFT] + ePadX[PAD_TOP_LEFT]); uPadX[PAD_BOTTOM_RIGHT] = MAX(uPadX[PAD_BOTTOM_RIGHT], iPadX[PAD_BOTTOM_RIGHT] + ePadX[PAD_BOTTOM_RIGHT]); - if (j == 0) /* topmost */ + if (j == first) /* topmost */ uPadY[PAD_TOP_LEFT] = MAX(uPadY[PAD_TOP_LEFT], iPadY[PAD_TOP_LEFT] + ePadY[PAD_TOP_LEFT]); - if (j == eLink1->onionCount - 1) /* bottommost */ + if (j == last) /* bottommost */ uPadY[PAD_BOTTOM_RIGHT] = MAX(uPadY[PAD_BOTTOM_RIGHT], iPadY[PAD_BOTTOM_RIGHT] + ePadY[PAD_BOTTOM_RIGHT]); } else { - if (j == 0) /* leftmost */ + if (j == first) /* leftmost */ uPadX[PAD_TOP_LEFT] = MAX(uPadX[PAD_TOP_LEFT], iPadX[PAD_TOP_LEFT] + ePadX[PAD_TOP_LEFT]); - if (j == eLink1->onionCount - 1) /* rightmost */ + if (j == last) /* rightmost */ uPadX[PAD_BOTTOM_RIGHT] = MAX(uPadX[PAD_BOTTOM_RIGHT], iPadX[PAD_BOTTOM_RIGHT] + ePadX[PAD_BOTTOM_RIGHT]); uPadY[PAD_TOP_LEFT] = MAX(uPadY[PAD_TOP_LEFT], iPadY[PAD_TOP_LEFT] + ePadY[PAD_TOP_LEFT]); uPadY[PAD_BOTTOM_RIGHT] = MAX(uPadY[PAD_BOTTOM_RIGHT], iPadY[PAD_BOTTOM_RIGHT] + ePadY[PAD_BOTTOM_RIGHT]); @@ -2803,6 +2879,9 @@ MElementLink_FreeResources( { if (eLink->onion != NULL) WCFREE(eLink->onion, int, eLink->onionCount); + PerStateInfo_Free(tree, &pstBoolean, &eLink->visible); + if (eLink->visible.obj != NULL) + Tcl_DecrRefCount(eLink->visible.obj); } /* @@ -5330,7 +5409,7 @@ enum { OPTION_INDENT, OPTION_iPADX, OPTION_iPADY, OPTION_MAXHEIGHT, OPTION_MAXWIDTH, OPTION_MINHEIGHT, OPTION_MINWIDTH, OPTION_PADX, OPTION_PADY, OPTION_SQUEEZE, OPTION_STICKY, OPTION_UNION, - OPTION_WIDTH + OPTION_WIDTH, OPTION_VISIBLE }; /* @@ -5475,6 +5554,10 @@ LayoutOptionToObj( return Tcl_NewStringObj(flags, n); break; } + case OPTION_VISIBLE: + { + return eLink->visible.obj; + } } return NULL; } @@ -5515,7 +5598,7 @@ StyleLayoutCmd( "-detach", "-expand", "-height", "-iexpand", "-indent", "-ipadx", "-ipady", "-maxheight", "-maxwidth", "-minheight", "-minwidth", "-padx", "-pady", "-squeeze", "-sticky", "-union", - "-width", + "-width", "-visible", (char *) NULL }; if (objc < 5) @@ -5935,16 +6018,47 @@ StyleLayoutCmd( } break; } + case OPTION_VISIBLE: + { + /* Already configured this once. */ + if (eLink->visible.obj != NULL && + eLink->visible.obj != saved.visible.obj) { + PerStateInfo_Free(tree, &pstBoolean, &eLink->visible); + Tcl_DecrRefCount(eLink->visible.obj); + + /* First configure. Don't free the saved data. */ + } else { + eLink->visible.data = NULL; + eLink->visible.count = 0; + } + eLink->visible.obj = objv[i + 1]; + Tcl_IncrRefCount(eLink->visible.obj); + if (PerStateInfo_FromObj(tree, TreeStateFromObj, &pstBoolean, + &eLink->visible) != TCL_OK) { + goto badConfig; + } + break; + } } } if (saved.onion && (eLink->onion != saved.onion)) WCFREE(saved.onion, int, saved.onionCount); + if (saved.visible.obj != NULL && + saved.visible.obj != eLink->visible.obj) { + PerStateInfo_Free(tree, &pstBoolean, &saved.visible); + Tcl_DecrRefCount(saved.visible.obj); + } Style_Changed(tree, style); return TCL_OK; badConfig: if (eLink->onion && (eLink->onion != saved.onion)) WCFREE(eLink->onion, int, eLink->onionCount); + if (eLink->visible.obj != NULL && + eLink->visible.obj != saved.visible.obj) { + PerStateInfo_Free(tree, &pstBoolean, &eLink->visible); + Tcl_DecrRefCount(eLink->visible.obj); + } *eLink = saved; return TCL_ERROR; } @@ -6857,9 +6971,12 @@ TreeStyle_ChangeState( ) { IStyle *style = (IStyle *) style_; - IElementLink *eLink; + MStyle *masterStyle = style->master; + MElementLink *eLink1; + IElementLink *eLink2; ElementArgs args; int i, eMask, mask = 0; + int visible1, visible2; if (state1 == state2) return 0; @@ -6868,16 +6985,27 @@ TreeStyle_ChangeState( args.states.state1 = state1; args.states.state2 = state2; - for (i = 0; i < style->master->numElements; i++) + for (i = 0; i < masterStyle->numElements; i++) { - eLink = &style->elements[i]; - args.elem = eLink->elem; - eMask = (*eLink->elem->typePtr->stateProc)(&args); + eLink2 = &style->elements[i]; + args.elem = eLink2->elem; + eMask = (*eLink2->elem->typePtr->stateProc)(&args); + + eLink1 = &masterStyle->elements[i]; + if (eLink1->visible.count > 0) { + visible1 = PerStateBoolean_ForState(tree, + &eLink1->visible, state1, NULL); + visible2 = PerStateBoolean_ForState(tree, + &eLink1->visible, state2, NULL); + if ((visible1 == 0) != (visible2 == 0)) + eMask |= CS_DISPLAY | CS_LAYOUT; + } + if (eMask) { #ifdef CACHE_ELEM_SIZE if (eMask & CS_LAYOUT) - eLink->neededWidth = eLink->neededHeight = -1; + eLink2->neededWidth = eLink2->neededHeight = -1; #endif mask |= eMask; } @@ -6927,6 +7055,18 @@ Tree_UndefineState( int i, columnIndex; ElementArgs args; + hPtr = Tcl_FirstHashEntry(&tree->styleHash, &search); + while (hPtr != NULL) + { + MStyle *masterStyle = (MStyle *) Tcl_GetHashValue(hPtr); + for (i = 0; i < masterStyle->numElements; i++) + { + MElementLink *eLink1 = &masterStyle->elements[i]; + PerStateInfo_Undefine(tree, &pstBoolean, &eLink1->visible, state); + } + hPtr = Tcl_NextHashEntry(&search); + } + args.tree = tree; args.state = state; -- cgit v0.12
Usage ChangedHow it changed
-iexpandTwo new flags "x' and "y" are allowed. Previously, only the -ipadx and -ipady padding could be expanded by this option. The new xy @@ -3674,178 +4580,224 @@ update your code, you will probably want to change this:
+ +
+
$T style layout $S $E -iexpand we
+
+ to this:
+ +
+
$T style layout $S $E -iexpand x
+
+ Keep in mind that -union elements are not affected by -iexpand xy, since the size of a -union element is determined by the elements it surrounds.
New
+
-height
-maxheight
-maxwidth
-minheight
-minwidth
-sticky
-width