From ff8dc639741345cf366d7f8bb60c6d30847981b2 Mon Sep 17 00:00:00 2001 From: Jakob Leben Date: Thu, 23 Jun 2011 02:19:51 +0200 Subject: [PATCH] docs: update Qt layout documentation Update documentation to mirror changes in layout creation syntax. --- HelpSource/Classes/LineItem.schelp | 46 -------------------------- HelpSource/Classes/QLineLayout.schelp | 23 +++++++------ HelpSource/Classes/SpacerItem.schelp | 16 --------- HelpSource/Classes/StretchItem.schelp | 15 --------- HelpSource/Guides/GUI-Layout-Management.schelp | 8 ++--- 5 files changed, 16 insertions(+), 92 deletions(-) delete mode 100644 HelpSource/Classes/LineItem.schelp delete mode 100644 HelpSource/Classes/SpacerItem.schelp delete mode 100644 HelpSource/Classes/StretchItem.schelp diff --git a/HelpSource/Classes/LineItem.schelp b/HelpSource/Classes/LineItem.schelp deleted file mode 100644 index e19aea6cc..000000000 --- a/HelpSource/Classes/LineItem.schelp +++ /dev/null @@ -1,46 +0,0 @@ -CLASS:: LineItem -summary:: An item of a QLineLayout -categories:: GUI>Layout -related:: Classes/QLineLayout - -DESCRIPTION:: -This class allows you to assign a stretch factor and alignment to an item of a QLineLayout, as well as to represent an empty space with an arbitrary stretch factor or an empty space of fixed size. link::Classes/StretchItem:: and link::Classes/SpacerItem:: are convenience subclasses for the latter two cases. - -You can make an instance of this class giving it a QView or a QLayout and desired stretch factor and alignment as arguments, and then pass it to a QHLayout or QVLayout link::Classes/QLineLayout#*new#constructor::, or their link::Classes/QLineLayout#-add#'add':: method. You pass a StretchItem or a SpacerItem directly to a layout. - -note:: There is an alternative method to using LineItem to assign stretch factor and alignment to an item at layout construction. See QLineLayout's link::Classes/QLineLayout#*new#constructor:: for explanation. -:: - - -CLASSMETHODS:: - -PRIVATE:: wrap - -METHOD:: new - -argument:: object -A QView or a QLayout represented by this item, or an integer representing empty space. If an integer of value 0 is given, this item will represent a stretching empty space. If an integer of value greater than zero is given, it will define the fixed size in pixels of empty space represented by this item. - -argument:: stretch -Integer stretch factor assigned to this item. If this item represents a fixed-size empty space (see previous argument) this argument will have no effect. - -argument:: align -Alignment of this item if it represents a QView, in other case this argument has no effect. Any of the following symbols are accepted: \left, \center, \right, \topLeft, \topCenter, \topRight, \bottomLeft, \bottomCenter, \bottomRight. - - - -INSTANCEMETHODS:: - -PRIVATE:: object -PRIVATE:: stretch -PRIVATE:: align -PRIVATE:: initLineItem -PRIVATE:: serialized - - - -EXAMPLES:: - -code:: -(some example code) -:: \ No newline at end of file diff --git a/HelpSource/Classes/QLineLayout.schelp b/HelpSource/Classes/QLineLayout.schelp index ba7335110..a2d3c893a 100644 --- a/HelpSource/Classes/QLineLayout.schelp +++ b/HelpSource/Classes/QLineLayout.schelp @@ -1,7 +1,7 @@ CLASS:: QLineLayout summary:: Superclass of layouts that distribute views in a line categories:: GUI>Layout -related:: Classes/StretchItem, Classes/SpacerItem, Guides/GUI-Layout-Management +related:: Guides/GUI-Layout-Management DESCRIPTION:: The two subclasses - QHLayout and QVLayout - distribute views in a horizontal or vertical line, respectively. @@ -10,11 +10,11 @@ subsection:: Fine tuning Each item can be assigned a stretch factor and an alignment flag to fine tune how its size and position are managed. This can be done at layout link::#*new#construction::, when an item is added with link::#-add:: method or for an already contained item with link::#-setStretch:: and link::#-setAlignment:: methods. -Stretch factors only affects distribution in the direction of the layout (vertical or horizontal). All items have a stretch factor of 0 by default, so only their own preferences will determine space distribution. As soon as an item is assigned a stretch factor higher than 0, the space will be redistributed according to proportions of stretch factors. +Stretch factor only affects distribution in the direction of the layout (vertical or horizontal). All items have a stretch factor of 0 by default, so only their own preferences will determine space distribution. As soon as an item is assigned a stretch factor higher than 0, the space will be redistributed according to proportions of stretch factors. subsection:: Leaving empty space -An empty space with an arbitrary stretch factor or an empty space of fixed size may be placed instead of an item by using link::Classes/StretchItem:: and link::Classes/SpacerItem:: classes. See link::#*new#constructor:: and link::#-add:: as well as documentation of those classes for details. +An empty space with an arbitrary stretch factor may be inserted using nil in place of an item in combination with the stretch factor. Similarily, an empty space of fixed size may be inserted using an integer in place of an item. See link::#*new#constructor:: and link::#-add:: for details. CLASSMETHODS:: @@ -27,14 +27,15 @@ METHOD:: new Create a QLineLayout and immediately fill it with items given as arguments. argument:: items -A sequence of items that the layout will distribute in the given order. An item can be a QView, a QLayout, a StretchItem or a SpacerItem. You can assign stretch factor and/or alignment to a QView or a QLayout by wrapping it into an array, followed by pairs of (\stretch, factor) and/or (\align, flag), for example: +A sequence of items that the layout will distribute in the given order. An item can be a QView, a QLayout, nil (for stretchable empty space) or an Integer (for fixed-size empty space). You can assign stretch factor and/or alignment to an item by wrapping it into an array, followed by pairs of ('stretch', factor) and/or ('align', flag). 'stretch' and 'align' may be abbreviated with 's' and 'a'. Simplified syntax for placing key-value pairs into an array comes handy. If the item is nil only the stretch parameter will have effect; if the item is an integer none of the parameters will have any effect. For example: code:: w = Window.new; w.layout = QVLayout( - [Button(), \stretch, 1, \align, \bottomLeft], - SpacerItem(20), - [TextView(), \stretch, 3] + [Button().states_([["Foo"]]), stretch:1, align:\bottomLeft], + 20, + [TextView().string_("Bar\nBar\nBar\n"), s:3], + [nil, s:1] ); w.front; :: @@ -46,7 +47,7 @@ METHOD:: add Add an item to the right or the bottom end of the line, for QHLayout and QVLayout respectively. argument:: item -The item can be a QView, a QLayout, a StretchItem or a SpacerItem. If it is one of the last two, the following arguments have no effect. +The item can be a QView, a QLayout, an Integer (specifying amount in pixels of empty space) or nil (for stretchable empty space). If the item is nil the align argument will have no effect; if the item is an Integer none of the other arguments will have any effect. argument:: stretch An integer stretch factor. @@ -104,9 +105,9 @@ w.layout = QVLayout( QTextView(), QHLayout( QButton().states_([["Foo"]]), - LineItem( QTextField().string_("Bar"), stretch: 1 ), - LineItem( QTextField().string_("BarBarBar"), stretch: 4 ) + [QTextField().string_("Bar"), stretch:1], + [QTextField().string_("BarBarBar"), stretch:4] ) ); w.front; -:: \ No newline at end of file +:: diff --git a/HelpSource/Classes/SpacerItem.schelp b/HelpSource/Classes/SpacerItem.schelp deleted file mode 100644 index c8943c4d1..000000000 --- a/HelpSource/Classes/SpacerItem.schelp +++ /dev/null @@ -1,16 +0,0 @@ -CLASS:: SpacerItem -summary:: An empty space of fixed size within a QLineLayout -categories:: GUI>Layout -related:: Classes/StretchItem, Classes/QLineLayout - -DESCRIPTION:: -You can pass an instance of this class to a QVLayout's or QHLayout's link::Classes/QLineLayout#*new#constructor:: or their link::Classes/QLineLayout#-add#'add':: method to insert an empty space of fixed size. - - - -CLASSMETHODS:: - -METHOD:: new - -argument:: size -Integer fixed size (in pixels) of the empty space that this item represents. diff --git a/HelpSource/Classes/StretchItem.schelp b/HelpSource/Classes/StretchItem.schelp deleted file mode 100644 index e55d6dbe0..000000000 --- a/HelpSource/Classes/StretchItem.schelp +++ /dev/null @@ -1,15 +0,0 @@ -CLASS:: StretchItem -summary:: A stretching empty space within a QLineLayout -categories:: GUI>Layout -related:: Classes/SpacerItem, Classes/QLineLayout - -DESCRIPTION:: -You can pass an instance of this class to a QVLayout's or QHLayout's link::Classes/QLineLayout#*new#constructor:: or their link::Classes/QLineLayout#-add#'add':: method to insert an empty space with an arbitrary stretch factor. - - -CLASSMETHODS:: - -METHOD:: new - -argument:: factor -Integer stretch factor of the empty space that this item represents. diff --git a/HelpSource/Guides/GUI-Layout-Management.schelp b/HelpSource/Guides/GUI-Layout-Management.schelp index 29251b633..6309a4bc5 100644 --- a/HelpSource/Guides/GUI-Layout-Management.schelp +++ b/HelpSource/Guides/GUI-Layout-Management.schelp @@ -58,9 +58,9 @@ subsection:: Stretch factors Layouts typically allow the user to override their default distribution policy by assigning stretch factors to items or aspects of the layout's distribution pattern. code:: -w = Window.new(bounds:Rect(100,100,300,80)).layout_( +w = Window.new(bounds:Rect(100,100,400,80)).layout_( QHLayout( - [Button().states_([["Super"]]), \stretch, 1], + [Button().states_([["Super"]]), stretch:1], TextField().string_("Collider") ) ).front; @@ -86,9 +86,9 @@ The combination of size constraints and preferences of all items in a layout hie code:: w = Window.new.layout_( QHLayout( - [Button.new.states_([["Super"]]), \align, \bottom], + [Button.new.states_([["Super"]]), align:\bottom], TextView(), - [Button.new.states_([["Collider"]]), \align, \top] + [Button.new.states_([["Collider"]]), align:\top] ) ).front; :: -- 2.11.4.GIT