Torque3D Documentation / _generateds / guiStackCtrl.cpp

guiStackCtrl.cpp

Engine/source/gui/containers/guiStackCtrl.cpp

More...

Public Functions

ConsoleDocClass(GuiStackControl , "@brief A container that stacks its children horizontally or <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vertically.\n\n</a>" "This container maintains <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> horizontal or vertical stack of GUI controls. If " "one is added, deleted , or resized, then the stack is resized <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> fit. The " "order of the stack is determined by the internal order of the children(ie. " "the order of addition).< br >" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "<a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classguistackcontrol/">GuiStackControl</a>()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " stackingType=\"Dynamic\";\n" "   horizStacking = \"Left <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> Right\";\n" "   vertStacking = \"Top <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> Bottom\";\n" "   padding = \"4\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   dynamicSize = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   dynamicNonStackExtent = \"0\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   dynamicPos = \"0\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   changeChildSizeToFit = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   changeChildPosition = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   //Properties not specific <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> this <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> have been omitted from this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">example.\n</a>" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@ingroup GuiContainers" )
DefineEngineMethod(GuiStackControl , freeze , void , (bool freeze) , "Prevents <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> from restacking - useful when adding or removing child <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">controls\n</a>" "@param freeze True <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> freeze the control, false <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> unfreeze <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">it\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "%stackCtrl.freeze(true);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//add controls <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">stack\n</a>" "%stackCtrl.freeze(false);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n</a>" )
DefineEngineMethod(GuiStackControl , isFrozen , bool , () , "Return whether or not this <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> is frozen" )
DefineEngineMethod(GuiStackControl , updateStack , void , () , "Restack the child <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">controls.\n</a>" )
ImplementEnumType(GuiHorizontalStackingType , "Determines how child controls are stacked <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">horizontally.\n\n</a>" "@ingroup GuiContainers" )
ImplementEnumType(GuiStackingType , "Stacking method used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> position child <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">controls.\n\n</a>" "@ingroup GuiContainers" )
ImplementEnumType(GuiVerticalStackingType , "Determines how child controls are stacked <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vertically.\n\n</a>" "@ingroup GuiContainers" )

Detailed Description

Public Functions

ConsoleDocClass(GuiStackControl , "@brief A container that stacks its children horizontally or <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vertically.\n\n</a>" "This container maintains <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> horizontal or vertical stack of GUI controls. If " "one is added, deleted , or resized, then the stack is resized <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> fit. The " "order of the stack is determined by the internal order of the children(ie. " "the order of addition).< br >" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "<a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classguistackcontrol/">GuiStackControl</a>()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " stackingType=\"Dynamic\";\n" "   horizStacking = \"Left <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> Right\";\n" "   vertStacking = \"Top <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> Bottom\";\n" "   padding = \"4\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   dynamicSize = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   dynamicNonStackExtent = \"0\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   dynamicPos = \"0\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   changeChildSizeToFit = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   changeChildPosition = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   //Properties not specific <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> this <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> have been omitted from this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">example.\n</a>" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@ingroup GuiContainers" )

DefineEngineMethod(GuiStackControl , freeze , void , (bool freeze) , "Prevents <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> from restacking - useful when adding or removing child <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">controls\n</a>" "@param freeze True <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> freeze the control, false <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> unfreeze <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">it\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "%stackCtrl.freeze(true);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//add controls <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">stack\n</a>" "%stackCtrl.freeze(false);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n</a>" )

DefineEngineMethod(GuiStackControl , isFrozen , bool , () , "Return whether or not this <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> is frozen" )

DefineEngineMethod(GuiStackControl , updateStack , void , () , "Restack the child <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">controls.\n</a>" )

IMPLEMENT_CONOBJECT(GuiStackControl )

ImplementEnumType(GuiHorizontalStackingType , "Determines how child controls are stacked <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">horizontally.\n\n</a>" "@ingroup GuiContainers" )

ImplementEnumType(GuiStackingType , "Stacking method used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> position child <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">controls.\n\n</a>" "@ingroup GuiContainers" )

ImplementEnumType(GuiVerticalStackingType , "Determines how child controls are stacked <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">vertically.\n\n</a>" "@ingroup GuiContainers" )

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#include "console/engineAPI.h"
 25#include "gui/containers/guiStackCtrl.h"
 26
 27IMPLEMENT_CONOBJECT(GuiStackControl);
 28
 29ConsoleDocClass( GuiStackControl,
 30   "@brief A container that stacks its children horizontally or vertically.\n\n"
 31
 32   "This container maintains a horizontal or vertical stack of GUI controls. If "
 33   "one is added, deleted, or resized, then the stack is resized to fit. The "
 34   "order of the stack is determined by the internal order of the children (ie. "
 35   "the order of addition).<br>"
 36
 37   "@tsexample\n"
 38   "new GuiStackControl()\n"
 39   "{\n"
 40   "   stackingType = \"Dynamic\";\n"
 41   "   horizStacking = \"Left to Right\";\n"
 42   "   vertStacking = \"Top to Bottom\";\n"
 43   "   padding = \"4\";\n"
 44   "   dynamicSize = \"1\";\n"
 45   "   dynamicNonStackExtent = \"0\";\n"
 46   "   dynamicPos = \"0\";\n"
 47   "   changeChildSizeToFit = \"1\";\n"
 48   "   changeChildPosition = \"1\";\n"
 49   "   //Properties not specific to this control have been omitted from this example.\n"
 50   "};\n"
 51   "@endtsexample\n\n"
 52
 53   "@ingroup GuiContainers"
 54);
 55
 56ImplementEnumType( GuiStackingType,
 57   "Stacking method used to position child controls.\n\n"
 58   "@ingroup GuiContainers" )
 59   { GuiStackControl::stackingTypeVert, "Vertical", "Stack children vertically by setting their Y position" },
 60   { GuiStackControl::stackingTypeHoriz,"Horizontal", "Stack children horizontall by setting their X position" },
 61   { GuiStackControl::stackingTypeDyn,"Dynamic", "Automatically switch between "
 62      "Vertical and Horizontal stacking. Vertical stacking is chosen when the "
 63      "stack control is taller than it is wide, horizontal stacking is chosen "
 64      "when the stack control is wider than it is tall." }
 65EndImplementEnumType;
 66
 67ImplementEnumType( GuiHorizontalStackingType,
 68   "Determines how child controls are stacked horizontally.\n\n"
 69   "@ingroup GuiContainers" )
 70   { GuiStackControl::horizStackLeft, "Left to Right", "Child controls are positioned in order from left to right (left-most control is first)" },
 71   { GuiStackControl::horizStackRight,"Right to Left", "Child controls are positioned in order from right to left (right-most control is first)" }
 72EndImplementEnumType;
 73
 74ImplementEnumType( GuiVerticalStackingType,
 75   "Determines how child controls are stacked vertically.\n\n"
 76   "@ingroup GuiContainers" )
 77   { GuiStackControl::vertStackTop, "Top to Bottom", "Child controls are positioned in order from top to bottom (top-most control is first)" },
 78   { GuiStackControl::vertStackBottom,"Bottom to Top", "Child controls are positioned in order from bottom to top (bottom-most control is first)" }
 79EndImplementEnumType;
 80
 81
 82GuiStackControl::GuiStackControl()
 83{
 84   setMinExtent(Point2I(16,16));
 85   mResizing = false;
 86   mStackingType = stackingTypeVert;
 87   mStackVertSizing = vertStackTop;
 88   mStackHorizSizing = horizStackLeft;
 89   mPadding = 0;
 90   mIsContainer = true;
 91   mDynamicSize = true;
 92   mDynamicNonStackExtent = false;
 93   mDynamicPos = false;
 94   mChangeChildSizeToFit = true;
 95   mChangeChildPosition = true;
 96}
 97
 98void GuiStackControl::initPersistFields()
 99{
100
101   addGroup( "Stacking" );
102   addField( "stackingType", TYPEID< StackingType >(), Offset(mStackingType, GuiStackControl),
103      "Determines the method used to position the child controls.\n\n" );
104
105   addField( "horizStacking", TYPEID< HorizontalType >(), Offset(mStackHorizSizing, GuiStackControl),
106      "Controls the type of horizontal stacking to use (<i>Left to Right</i> or "
107      "<i>Right to Left</i>)" );
108
109   addField( "vertStacking", TYPEID< VerticalType >(), Offset(mStackVertSizing, GuiStackControl),
110      "Controls the type of vertical stacking to use (<i>Top to Bottom</i> or "
111      "<i>Bottom to Top</i>)" );
112
113   addField( "padding", TypeS32, Offset(mPadding, GuiStackControl),
114      "Distance (in pixels) between stacked child controls." );
115
116   addField( "dynamicSize", TypeBool, Offset(mDynamicSize, GuiStackControl),
117      "Determines whether to resize the stack control along the stack axis (change "
118      "width for horizontal stacking, change height for vertical stacking).\n\n"
119      "If true, the stack width/height will be resized to the sum of the child control widths/heights. "
120      "If false, the stack will not be resized." );
121
122   addField( "dynamicNonStackExtent", TypeBool, Offset(mDynamicNonStackExtent, GuiStackControl),
123      "Determines whether to resize the stack control along the non-stack axis (change "
124      "height for horizontal stacking, change width for vertical stacking). No effect "
125      "if dynamicSize is false.\n\n"
126      "If true, the stack will be resized to the maximum of the child control widths/heights. "
127      "If false, the stack will not be resized." );
128
129   addField( "dynamicPos", TypeBool, Offset(mDynamicPos, GuiStackControl),
130      "Determines whether to reposition the stack along the stack axis when it is "
131      "auto-resized. No effect if dynamicSize is false.\n\n"
132      "If true, the stack will grow left for horizontal stacking, and grow up for vertical stacking.\n"
133      "If false, the stack will grow right for horizontal stacking, and grow down for vertical stacking.\n" );
134
135   addField( "changeChildSizeToFit", TypeBool, Offset(mChangeChildSizeToFit, GuiStackControl),
136      "Determines whether to resize child controls.\n\n"
137      "If true, horizontally stacked children keep their width, but have their "
138      "height set to the stack control height. Vertically stacked children keep "
139      "their height, but have their width set to the stack control width. If "
140      "false, child controls are not resized." );
141
142   addField( "changeChildPosition", TypeBool, Offset(mChangeChildPosition, GuiStackControl),
143      "Determines whether to reposition child controls.\n\n"
144      "If true, horizontally stacked children are aligned along the top edge of "
145      "the stack control. Vertically stacked children are aligned along the left "
146      "edge of the stack control. If false, horizontally stacked children retain "
147      "their Y position, and vertically stacked children retain their X position." );
148   endGroup( "Stacking" );
149
150   Parent::initPersistFields();
151}
152
153DefineEngineMethod( GuiStackControl, isFrozen, bool, (),,
154   "Return whether or not this control is frozen" )
155{
156   return object->isFrozen();
157}
158
159DefineEngineMethod( GuiStackControl, freeze, void, ( bool freeze ),,
160   "Prevents control from restacking - useful when adding or removing child controls\n"
161   "@param freeze True to freeze the control, false to unfreeze it\n\n"
162   "@tsexample\n"
163   "%stackCtrl.freeze(true);\n"
164   "// add controls to stack\n"
165   "%stackCtrl.freeze(false);\n"
166   "@endtsexample\n" )
167{
168   object->freeze( freeze );
169}
170
171DefineEngineMethod( GuiStackControl, updateStack, void, (),,
172   "Restack the child controls.\n" )
173{
174   object->updatePanes();
175}
176
177bool GuiStackControl::onWake()
178{
179   if ( !Parent::onWake() )
180      return false;
181
182   updatePanes();
183
184   return true;
185}
186
187void GuiStackControl::onSleep()
188{
189   Parent::onSleep();
190}
191
192void GuiStackControl::updatePanes()
193{
194   // Prevent recursion
195   if(mResizing) 
196      return;
197
198   // Set Resizing.
199   mResizing = true;
200
201   Point2I extent = getExtent();
202
203   // Do we need to stack horizontally?
204   if( ( extent.x > extent.y && mStackingType == stackingTypeDyn ) || mStackingType == stackingTypeHoriz )
205   {
206      stackHorizontal( mStackHorizSizing == horizStackLeft );
207   }
208   // Or, vertically?
209   else if( ( extent.y > extent.x && mStackingType == stackingTypeDyn ) || mStackingType == stackingTypeVert)
210   {
211      stackVertical( mStackVertSizing == vertStackTop );
212   }
213
214   // Clear Sizing Flag.
215   mResizing = false;
216}
217
218void GuiStackControl::freeze(bool _shouldfreeze)
219{
220   mResizing = _shouldfreeze;
221}
222
223void GuiStackControl::stackVertical(bool fromTop)
224{
225   if( empty() )
226      return;
227
228   S32 begin, end, step;
229   if ( fromTop )
230   {
231      // Stack from Child0 at top to ChildN at bottom
232      begin = 0;
233      end = size();
234      step = 1;
235   }
236   else
237   {
238      // Stack from ChildN at top to Child0 at bottom
239      begin = size()-1;
240      end = -1;
241      step = -1;
242   }
243
244   // Place each visible child control
245   S32 maxWidth = 0;
246   Point2I curPos(0, 0);
247   for ( S32 i = begin; i != end; i += step )
248   {
249      GuiControl * gc = dynamic_cast<GuiControl*>( at(i) );
250      if ( gc && gc->isVisible() )
251      {
252         // Add padding between controls
253         if ( curPos.y > 0 )
254            curPos.y += mPadding;
255
256         Point2I childPos = curPos;
257         if ( !mChangeChildPosition )
258            childPos.x = gc->getLeft();
259
260         Point2I childSize( gc->getExtent() );
261         if ( mChangeChildSizeToFit )
262            childSize.x = getWidth();
263
264         gc->resize( childPos, childSize );
265
266         curPos.y += gc->getHeight();
267         maxWidth = getMax( maxWidth, childPos.x + childSize.x );
268      }
269   }
270
271   if ( mDynamicSize )
272   {
273      // Conform our size to the sum of the child sizes.
274      Point2I newPos( getPosition() );
275      Point2I newSize( mDynamicNonStackExtent ? maxWidth : getWidth(), curPos.y );
276
277      newSize.setMax( getMinExtent() );
278
279      // Grow the stack up instead of down?
280      if ( mDynamicPos )
281         newPos.y -= ( newSize.y - getHeight() );
282
283      resize( newPos, newSize );
284   }
285}
286
287void GuiStackControl::stackHorizontal(bool fromLeft)
288{
289   if( empty() )
290      return;
291
292   S32 begin, end, step;
293   if ( fromLeft )
294   {
295      // Stack from Child0 at left to ChildN at right
296      begin = 0;
297      end = size();
298      step = 1;
299   }
300   else
301   {
302      // Stack from ChildN at left to Child0 at right
303      begin = size()-1;
304      end = -1;
305      step = -1;
306   }
307
308   // Place each visible child control
309   S32 maxHeight = 0;
310   Point2I curPos(0, 0);
311   for ( S32 i = begin; i != end; i += step )
312   {
313      GuiControl * gc = dynamic_cast<GuiControl*>( at(i) );
314      if ( gc && gc->isVisible() )
315      {
316         // Add padding between controls
317         if ( curPos.x > 0 )
318            curPos.x += mPadding;
319
320         Point2I childPos = curPos;
321         if ( !mChangeChildPosition )
322            childPos.y = gc->getTop();
323
324         Point2I childSize( gc->getExtent() );
325         if ( mChangeChildSizeToFit )
326            childSize.y = getHeight();
327
328         gc->resize( childPos, childSize );
329
330         curPos.x += gc->getWidth();
331         maxHeight = getMax( maxHeight, childPos.y + childSize.y );
332      }
333   }
334
335   if ( mDynamicSize )
336   {
337      // Conform our size to the sum of the child sizes.
338      Point2I newPos( getPosition() );
339      Point2I newSize( curPos.x, mDynamicNonStackExtent ? maxHeight : getHeight() );
340
341      newSize.setMax( getMinExtent() );
342
343      // Grow the stack left instead of right?
344      if ( mDynamicPos )
345         newPos.x -= ( newSize.x - getWidth() );
346
347      resize( newPos, newSize );
348   }
349}
350
351bool GuiStackControl::resize(const Point2I &newPosition, const Point2I &newExtent)
352{
353   if( !Parent::resize( newPosition, newExtent ) )
354      return false;
355
356   updatePanes();
357
358   // CodeReview This logic should be updated to correctly return true/false
359   //  based on whether it sized it's children. [7/1/2007 justind]
360   return true;
361}
362
363void GuiStackControl::addObject(SimObject *obj)
364{
365   Parent::addObject(obj);
366
367   updatePanes();
368}
369
370void GuiStackControl::removeObject(SimObject *obj)
371{
372   Parent::removeObject(obj);
373
374   updatePanes();
375}
376
377bool GuiStackControl::reOrder(SimObject* obj, SimObject* target)
378{
379   bool ret = Parent::reOrder(obj, target);
380   if (ret)
381      updatePanes();
382
383   return ret;
384}
385
386void GuiStackControl::childResized(GuiControl *child)
387{
388   updatePanes();
389}
390