Class: Wx::Sizer

Inherits:
Object show all
Defined in:
lib/wx/doc/gen/sizer.rb,
lib/wx/doc/sizer.rb

Overview

Sizer is the abstract base class used for laying out subwindows in a window.

You cannot use Sizer directly; instead, you will have to use one of the sizer classes derived from it. Currently there are BoxSizer, StaticBoxSizer, GridSizer, FlexGridSizer, WrapSizer and GridBagSizer. The layout algorithm used by sizers in wxWidgets is closely related to layout in other GUI toolkits, such as Java’s AWT, the GTK toolkit or the Qt toolkit. It is based upon the idea of the individual subwindows reporting their minimal required size and their ability to get stretched if the size of the parent window has changed. This will most often mean that the programmer does not set the original size of a dialog in the beginning, rather the dialog will be assigned a sizer and this sizer will be queried about the recommended size. The sizer in turn will query its children, which can be normal windows, empty space or other sizers, so that a hierarchy of sizers can be constructed. Note that Sizer does not derive from Window and thus does not interfere with tab ordering and requires very little resources compared to a real window on screen. What makes sizers so well fitted for use in wxWidgets is the fact that every control reports its own minimal size and the algorithm can handle differences in font sizes or different window (dialog item) sizes on different platforms without problems. If e.g. the standard font as well as the overall design of Motif widgets requires more space than on Windows, the initial dialog size will automatically be bigger on Motif than on Windows. Sizers may also be used to control the layout of custom drawn items on the window. The #add, #insert, and #prepend functions return a pointer to the newly added SizerItem. Just add empty space of the desired size and attributes, and then use the Wx::SizerItem#get_rect method to determine where the drawing operations should take place. Please notice that sizers, like child windows, are owned by the library and will be deleted by it which implies that they must be allocated on the heap. However if you create a sizer and do not add it to another sizer or window, the library wouldn’t be able to delete such an orphan sizer and in this, and only this, case it should be deleted explicitly.

wxSizer flags

The “flag” argument accepted by SizerItem constructors and other functions, e.g. #add, is an OR-combination of the following flags. Two main behaviours are defined using these flags. One is the border around a window: the border parameter determines the border width whereas the flags given here determine which side(s) of the item that the border will be added. The other flags determine how the sizer item behaves when the space allotted to the sizer changes, and is somewhat dependent on the specific kind of sizer used.

Direction::TOP

Direction::BOTTOM

Direction::LEFT

Direction::RIGHT

Direction::ALL These flags are used to specify which side(s) of the sizer item the border width will apply to.

Wx::Stretch::EXPAND The item will be expanded to fill the space assigned to the item. When used for the items of BoxSizer, the expansion only happens in the transversal direction of the sizer as only the item proportion governs its behaviour in the principal sizer direction. But when it is used for the items of GridSizer, this flag can be combined with the alignment flags which override it in the corresponding direction if specified, e.g. Wx::Stretch::EXPAND | Alignment::ALIGN_CENTRE_VERTICAL would expand the item only horizontally but center it vertically. Notice that this doesn’t work for the default left/top alignment and Wx::Stretch::EXPAND still applies in both directions if it is combined with Alignment::ALIGN_LEFT or Alignment::ALIGN_TOP.

Wx::Stretch::SHAPED The item will be expanded as much as possible while also maintaining its aspect ratio.

Wx::SizerFlagBits::FIXED_MINSIZE Normally sizers use the “best”, i.e. most appropriate, size of the window to determine what the minimal size of window items should be. This allows layouts to adjust correctly when the item contents, and hence its best size, changes. If this behaviour is unwanted, Wx::SizerFlagBits::FIXED_MINSIZE can be used to fix minimal size of the window to its initial value and not change it any more in the future. Note that the same thing can be accomplished by calling Window#set_min_size explicitly as well.

Wx::SizerFlagBits::RESERVE_SPACE_EVEN_IF_HIDDEN Normally Sizers don’t allocate space for hidden windows or other items. This flag overrides this behaviour so that sufficient space is allocated for the window even if it isn’t visible. This makes it possible to dynamically show and hide controls without resizing parent dialog, for example. (Available since 2.8.8.)

Alignment::ALIGN_CENTER

Alignment::ALIGN_CENTRE

Alignment::ALIGN_LEFT

Alignment::ALIGN_RIGHT

Alignment::ALIGN_TOP

Alignment::ALIGN_BOTTOM

Alignment::ALIGN_CENTER_VERTICAL

Alignment::ALIGN_CENTRE_VERTICAL

Alignment::ALIGN_CENTER_HORIZONTAL

Alignment::ALIGN_CENTRE_HORIZONTAL The wxALIGN_* flags allow you to specify the alignment of the item within the space allotted to it by the sizer, adjusted for the border if any.

Category: Window Layout

See Also:

  • Overview

Direct Known Subclasses

BoxSizer, GridSizer

Instance Method Summary collapse

Methods inherited from Object

#clone, #dup, #is_same_as, #un_share

Constructor Details

#initializeWx::Sizer

The constructor.

Note that Wx::Sizer is an abstract base class and may not be instantiated.



174
# File 'lib/wx/doc/gen/sizer.rb', line 174

def initialize; end

Instance Method Details

#add(window, flags) ⇒ Wx::SizerItem #add(window, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem #add(sizer, flags) ⇒ Wx::SizerItem #add(sizer, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem #add(width, height, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem #add(width, height, flags) ⇒ Wx::SizerItem

Overloads:

  • #add(window, flags) ⇒ Wx::SizerItem

    Appends a child to the sizer.

    Wx::Sizer itself is an abstract class, but the parameters are equivalent in the derived classes that you will instantiate to use it so they are described here:

    Parameters:

    • window (Wx::Window)

      The window to be added to the sizer. Its initial size (either set explicitly by the user or calculated internally when using DEFAULT_SIZE) is interpreted as the minimal and in many cases also the initial size.

    • flags (Wx::SizerFlags)

      A Wx::SizerFlags object that enables you to specify most of the above parameters more conveniently.

    Returns:

  • #add(window, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem

    Appends a child to the sizer.

    Wx::Sizer itself is an abstract class, but the parameters are equivalent in the derived classes that you will instantiate to use it so they are described here:

    Parameters:

    • window (Wx::Window)

      The window to be added to the sizer. Its initial size (either set explicitly by the user or calculated internally when using DEFAULT_SIZE) is interpreted as the minimal and in many cases also the initial size.

    • proportion (Integer) (defaults to: 0)

      Although the meaning of this parameter is undefined in Wx::Sizer, it is used in BoxSizer to indicate if a child of a sizer can change its size in the main orientation of the BoxSizer - where 0 stands for not changeable and a value of more than zero is interpreted relative to the value of other children of the same BoxSizer. For example, you might have a horizontal BoxSizer with three children, two of which are supposed to change their size with the sizer. Then the two stretchable windows would get a value of 1 each to make them grow and shrink equally with the sizer’s horizontal dimension.

    • flag (Integer) (defaults to: 0)

      OR-combination of flags affecting sizer’s behaviour. See wxSizer flags list for details.

    • border (Integer) (defaults to: 0)

      Determines the border width, if the flag parameter is set to include any border flag.

    • userData (Object) (defaults to: nil)

      Allows an extra object to be attached to the sizer item, for use in derived classes when sizing information is more complex than the proportion and flag will allow for.

    Returns:

  • #add(sizer, flags) ⇒ Wx::SizerItem

    Appends a child to the sizer.

    Wx::Sizer itself is an abstract class, but the parameters are equivalent in the derived classes that you will instantiate to use it so they are described here:

    Parameters:

    • sizer (Wx::Sizer)

      The (child-)sizer to be added to the sizer. This allows placing a child sizer in a sizer and thus to create hierarchies of sizers (typically a vertical box as the top sizer and several horizontal boxes on the level beneath).

    • flags (Wx::SizerFlags)

      A Wx::SizerFlags object that enables you to specify most of the above parameters more conveniently.

    Returns:

  • #add(sizer, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem

    Appends a child to the sizer.

    Wx::Sizer itself is an abstract class, but the parameters are equivalent in the derived classes that you will instantiate to use it so they are described here:

    Parameters:

    • sizer (Wx::Sizer)

      The (child-)sizer to be added to the sizer. This allows placing a child sizer in a sizer and thus to create hierarchies of sizers (typically a vertical box as the top sizer and several horizontal boxes on the level beneath).

    • proportion (Integer) (defaults to: 0)

      Although the meaning of this parameter is undefined in Wx::Sizer, it is used in BoxSizer to indicate if a child of a sizer can change its size in the main orientation of the BoxSizer - where 0 stands for not changeable and a value of more than zero is interpreted relative to the value of other children of the same BoxSizer. For example, you might have a horizontal BoxSizer with three children, two of which are supposed to change their size with the sizer. Then the two stretchable windows would get a value of 1 each to make them grow and shrink equally with the sizer’s horizontal dimension.

    • flag (Integer) (defaults to: 0)

      OR-combination of flags affecting sizer’s behaviour. See wxSizer flags list for details.

    • border (Integer) (defaults to: 0)

      Determines the border width, if the flag parameter is set to include any border flag.

    • userData (Object) (defaults to: nil)

      Allows an extra object to be attached to the sizer item, for use in derived classes when sizing information is more complex than the proportion and flag will allow for.

    Returns:

  • #add(width, height, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem

    Appends a spacer child to the sizer.

    Wx::Sizer itself is an abstract class, but the parameters are equivalent in the derived classes that you will instantiate to use it so they are described here. width and height specify the dimension of a spacer to be added to the sizer. Adding spacers to sizers gives more flexibility in the design of dialogs; imagine for example a horizontal box with two buttons at the bottom of a dialog: you might want to insert a space between the two buttons and make that space stretchable using the proportion flag and the result will be that the left button will be aligned with the left side of the dialog and the right button with the right side - the space in between will shrink and grow with the dialog.

    Parameters:

    • width (Integer)

      Width of the spacer.

    • height (Integer)

      Height of the spacer.

    • proportion (Integer) (defaults to: 0)

      Although the meaning of this parameter is undefined in Wx::Sizer, it is used in BoxSizer to indicate if a child of a sizer can change its size in the main orientation of the BoxSizer - where 0 stands for not changeable and a value of more than zero is interpreted relative to the value of other children of the same BoxSizer. For example, you might have a horizontal BoxSizer with three children, two of which are supposed to change their size with the sizer. Then the two stretchable windows would get a value of 1 each to make them grow and shrink equally with the sizer’s horizontal dimension.

    • flag (Integer) (defaults to: 0)

      OR-combination of flags affecting sizer’s behaviour. See wxSizer flags list for details.

    • border (Integer) (defaults to: 0)

      Determines the border width, if the flag parameter is set to include any border flag.

    • userData (Object) (defaults to: nil)

      Allows an extra object to be attached to the sizer item, for use in derived classes when sizing information is more complex than the proportion and flag will allow for.

    Returns:

  • #add(width, height, flags) ⇒ Wx::SizerItem

    Appends a spacer child to the sizer.

    Parameters:

    • width (Integer)

      Width of the spacer.

    • height (Integer)

      Height of the spacer.

    • flags (Wx::SizerFlags)

      A Wx::SizerFlags object that enables you to specify most of the other parameters more conveniently.

    Returns:



228
# File 'lib/wx/doc/gen/sizer.rb', line 228

def add(*args) end

#add_spacer(size) ⇒ Wx::SizerItem

This base function adds non-stretchable space to both the horizontal and vertical orientation of the sizer.

More readable way of calling:

Wx::Sizer::add(size, size, 0)

Parameters:

  • size (Integer)

Returns:

See Also:



239
# File 'lib/wx/doc/gen/sizer.rb', line 239

def add_spacer(size) end

#add_stretch_spacer(prop = 1) ⇒ Wx::SizerItem

Adds stretchable space to the sizer.

More readable way of calling:

Wx::Sizer::add(0, 0, prop)

Parameters:

  • prop (Integer) (defaults to: 1)

Returns:



249
# File 'lib/wx/doc/gen/sizer.rb', line 249

def add_stretch_spacer(prop=1) end

#calc_minWx::Size

This method is abstract and has to be overwritten by any derived class.

Here, the sizer will do the actual calculation of its children’s minimal sizes.

Returns:



255
# File 'lib/wx/doc/gen/sizer.rb', line 255

def calc_min; end

#clear(delete_windows = false) ⇒ void

This method returns an undefined value.

Detaches all children from the sizer.

If delete_windows is true then child windows will also be deleted. Notice that child sizers are always deleted, as a general consequence of the principle that sizers own their sizer children, but don’t own their window children (because they are already owned by their parent windows).

Parameters:

  • delete_windows (Boolean) (defaults to: false)


263
# File 'lib/wx/doc/gen/sizer.rb', line 263

def clear(delete_windows=false) end

#compute_fitting_client_size(window) ⇒ Wx::Size

Computes client area size for window so that it matches the sizer’s minimal size.

Unlike #get_min_size, this method accounts for other constraints imposed on window, namely display’s size (returned size will never be too large for the display) and maximum window size if previously set by Window#set_max_size. The returned value is suitable for passing to Window#set_client_size or Window#set_min_client_size.

Parameters:

Returns:

See Also:



273
# File 'lib/wx/doc/gen/sizer.rb', line 273

def compute_fitting_client_size(window) end

#compute_fitting_window_size(window) ⇒ Wx::Size

Like #compute_fitting_client_size, but converts the result into window size.

The returned value is suitable for passing to Window#set_size or Window#set_min_size.

Parameters:

Returns:

See Also:



282
# File 'lib/wx/doc/gen/sizer.rb', line 282

def compute_fitting_window_size(window) end

#detach(window) ⇒ Boolean #detach(sizer) ⇒ Boolean #detach(index) ⇒ Boolean

Overloads:

  • #detach(window) ⇒ Boolean

    Detach the child window from the sizer without destroying it.

    This method does not cause any layout or resizing to take place, call #layout to update the layout “on screen” after detaching a child from the sizer. Returns true if the child item was found and detached, false otherwise.

    Parameters:

    Returns:

    • (Boolean)

    See Also:

  • #detach(sizer) ⇒ Boolean

    Detach the child sizer from the sizer without destroying it.

    This method does not cause any layout or resizing to take place, call #layout to update the layout “on screen” after detaching a child from the sizer. Returns true if the child item was found and detached, false otherwise.

    Parameters:

    Returns:

    • (Boolean)

    See Also:

  • #detach(index) ⇒ Boolean

    Detach an item at position index from the sizer without destroying it.

    This method does not cause any layout or resizing to take place, call #layout to update the layout “on screen” after detaching a child from the sizer. Returns true if the child item was found and detached, false otherwise.

    Parameters:

    • index (Integer)

    Returns:

    • (Boolean)

    See Also:



307
# File 'lib/wx/doc/gen/sizer.rb', line 307

def detach(*args) end

#each_child {|child| ... } ⇒ Object, Enumerator

Yield each child item to the given block. Returns an Enumerator if no block given.

Yield Parameters:

Returns:

  • (Object, Enumerator)

    last result of block or Enumerator if no block given.



16
# File 'lib/wx/doc/sizer.rb', line 16

def each_child; end

#fit(window) ⇒ Wx::Size

Tell the sizer to resize the window so that its client area matches the sizer’s minimal size (#compute_fitting_client_size is called to determine it).

This is commonly done in the constructor of the window itself, see sample in the description of BoxSizer. The new window size.



317
# File 'lib/wx/doc/gen/sizer.rb', line 317

def fit(window) end

#fit_inside(window) ⇒ void

This method returns an undefined value.

Tell the sizer to resize the virtual size of the window to match the sizer’s minimal size.

This will not alter the on screen size of the window, but may cause the addition/removal/alteration of scrollbars required to view the virtual area in windows which manage it.

Parameters:

See Also:

  • Wx::Scrolled#set_scrollbars
  • set_virtual_size_hints


326
# File 'lib/wx/doc/gen/sizer.rb', line 326

def fit_inside(window) end

#get_childrenWx::SizerItemList Also known as: children

Returns the list of the items in this sizer.

The elements of type-safe List Wx::SizerItemList are pointers to objects of type Wx::SizerItem.

Returns:

  • (Wx::SizerItemList)


96
# File 'lib/wx/doc/gen/sizer.rb', line 96

def get_children; end

#get_containing_windowWx::Window Also known as: containing_window

Returns the window this sizer is used in or NULL if none.

Returns:



339
# File 'lib/wx/doc/gen/sizer.rb', line 339

def get_containing_window; end

#get_item(window, recursive = false) ⇒ Wx::SizerItem #get_item(sizer, recursive = false) ⇒ Wx::SizerItem #get_item(index) ⇒ Wx::SizerItem Also known as: item

Overloads:

  • #get_item(window, recursive = false) ⇒ Wx::SizerItem

    Finds the Wx::SizerItem which holds the given window.

    Use parameter recursive to search in subsizers too. Pointer to the item or NULL if there is no item with the window.

    Parameters:

    • window (Wx::Window)
    • recursive (Boolean) (defaults to: false)

    Returns:

  • #get_item(sizer, recursive = false) ⇒ Wx::SizerItem

    Finds the Wx::SizerItem which holds the given sizer.

    Use parameter recursive to search in subsizers too. Pointer to the item or NULL if the given sizer is not in the sizer.

    Parameters:

    • sizer (Wx::Sizer)
    • recursive (Boolean) (defaults to: false)

    Returns:

  • #get_item(index) ⇒ Wx::SizerItem

    Finds the Wx::SizerItem which is located in the sizer at position index.

    Pointer to the item or NULL if there is no item at that index.

    Parameters:

    • index (Integer)

    Returns:



377
# File 'lib/wx/doc/gen/sizer.rb', line 377

def get_item(*args) end

#get_item_by_id(id, recursive = false) ⇒ Wx::SizerItem Also known as: item_by_id

Finds the item in the sizer which has the given id.

This id is not the window id but the id of the Wx::SizerItem itself. This is mainly useful for retrieving the sizers created from XRC resources. Use parameter recursive to search in subsizers too. Pointer to item or NULL if no item has that id.

Parameters:

  • id (Integer)
  • recursive (Boolean) (defaults to: false)

Returns:



387
# File 'lib/wx/doc/gen/sizer.rb', line 387

def get_item_by_id(id, recursive=false) end

#get_item_countInteger Also known as: item_count

Returns the number of items in the sizer.

If you just need to test whether the sizer is empty or not you can also use the #is_empty function.

Returns:

  • (Integer)


352
# File 'lib/wx/doc/gen/sizer.rb', line 352

def get_item_count; end

#get_min_sizeWx::Size Also known as: min_size

Returns the minimal size of the sizer.

This is either the combined minimal size of all the children and their borders or the minimal size set by #set_min_size, depending on which is bigger. Note that the returned value is client size, not window size. In particular, if you use the value to set toplevel window’s minimal or actual size, use Window#set_min_client_size or Window#set_client_size, not Window#set_min_size or Window#set_size.

Returns:



394
# File 'lib/wx/doc/gen/sizer.rb', line 394

def get_min_size; end

#get_positionWx::Point Also known as: position

Returns the current position of the sizer.

Returns:



399
# File 'lib/wx/doc/gen/sizer.rb', line 399

def get_position; end

#get_sizeWx::Size Also known as: size

Returns the current size of the sizer.

Returns:



404
# File 'lib/wx/doc/gen/sizer.rb', line 404

def get_size; end

#hide(window, recursive = false) ⇒ Boolean #hide(sizer, recursive = false) ⇒ Boolean #hide(index) ⇒ Boolean

Overloads:

  • #hide(window, recursive = false) ⇒ Boolean

    Hides the child window.

    To make a sizer item disappear, use #hide followed by #layout. Use parameter recursive to hide elements found in subsizers. Returns true if the child item was found, false otherwise.

    Parameters:

    • window (Wx::Window)
    • recursive (Boolean) (defaults to: false)

    Returns:

    • (Boolean)

    See Also:

  • #hide(sizer, recursive = false) ⇒ Boolean

    Hides the child sizer.

    To make a sizer item disappear, use #hide followed by #layout. Use parameter recursive to hide elements found in subsizers. Returns true if the child item was found, false otherwise.

    Parameters:

    • sizer (Wx::Sizer)
    • recursive (Boolean) (defaults to: false)

    Returns:

    • (Boolean)

    See Also:

  • #hide(index) ⇒ Boolean

    Hides the item at position index.

    To make a sizer item disappear, use #hide followed by #layout. Use parameter recursive to hide elements found in subsizers. Returns true if the child item was found, false otherwise.

    Parameters:

    • index (Integer)

    Returns:

    • (Boolean)

    See Also:



436
# File 'lib/wx/doc/gen/sizer.rb', line 436

def hide(*args) end

#inform_first_direction(direction, size, availableOtherDir) ⇒ Boolean

Inform sizer about the first direction that has been decided (by parent item).

Returns true if it made use of the information (and recalculated min size).

Parameters:

  • direction (Integer)
  • size (Integer)
  • availableOtherDir (Integer)

Returns:

  • (Boolean)


335
# File 'lib/wx/doc/gen/sizer.rb', line 335

def inform_first_direction(direction, size, availableOtherDir) end

#insert(index, window, flags) ⇒ Wx::SizerItem #insert(index, window, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem #insert(index, sizer, flags) ⇒ Wx::SizerItem #insert(index, sizer, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem #insert(index, width, height, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem #insert(index, width, height, flags) ⇒ Wx::SizerItem

Overloads:

  • #insert(index, window, flags) ⇒ Wx::SizerItem

    Insert a child into the sizer before any existing item at index.

    See #add for the meaning of the other parameters.

    Parameters:

    Returns:

  • #insert(index, window, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem

    Insert a child into the sizer before any existing item at index.

    See #add for the meaning of the other parameters.

    Parameters:

    • index (Integer)
    • window (Wx::Window)
    • proportion (Integer) (defaults to: 0)
    • flag (Integer) (defaults to: 0)
    • border (Integer) (defaults to: 0)
    • userData (Object) (defaults to: nil)

    Returns:

  • #insert(index, sizer, flags) ⇒ Wx::SizerItem

    Insert a child into the sizer before any existing item at index.

    See #add for the meaning of the other parameters.

    Parameters:

    Returns:

  • #insert(index, sizer, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem

    Insert a child into the sizer before any existing item at index.

    See #add for the meaning of the other parameters.

    Parameters:

    • index (Integer)
    • sizer (Wx::Sizer)
    • proportion (Integer) (defaults to: 0)
    • flag (Integer) (defaults to: 0)
    • border (Integer) (defaults to: 0)
    • userData (Object) (defaults to: nil)

    Returns:

  • #insert(index, width, height, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem

    Insert a child into the sizer before any existing item at index.

    See #add for the meaning of the other parameters.

    Parameters:

    • index (Integer)
    • width (Integer)
    • height (Integer)
    • proportion (Integer) (defaults to: 0)
    • flag (Integer) (defaults to: 0)
    • border (Integer) (defaults to: 0)
    • userData (Object) (defaults to: nil)

    Returns:

  • #insert(index, width, height, flags) ⇒ Wx::SizerItem

    Insert a child into the sizer before any existing item at index.

    See #add for the meaning of the other parameters.

    Parameters:

    • index (Integer)
    • width (Integer)
    • height (Integer)
    • flags (Wx::SizerFlags)

    Returns:



497
# File 'lib/wx/doc/gen/sizer.rb', line 497

def insert(*args) end

#insert_spacer(index, size) ⇒ Wx::SizerItem

Inserts non-stretchable space to the sizer.

More readable way of calling #insert(index,size,size).

Parameters:

  • index (Integer)
  • size (Integer)

Returns:



505
# File 'lib/wx/doc/gen/sizer.rb', line 505

def insert_spacer(index, size) end

#insert_stretch_spacer(index, prop = 1) ⇒ Wx::SizerItem

Inserts stretchable space to the sizer.

More readable way of calling #insert(0,0,prop).

Parameters:

  • index (Integer)
  • prop (Integer) (defaults to: 1)

Returns:



513
# File 'lib/wx/doc/gen/sizer.rb', line 513

def insert_stretch_spacer(index, prop=1) end

#is_emptyBoolean Also known as: empty?

Return true if the sizer has no elements.

Returns:

  • (Boolean)

See Also:



520
# File 'lib/wx/doc/gen/sizer.rb', line 520

def is_empty; end

#layoutvoid

This method returns an undefined value.

Call this to force layout of the children anew, e.g. after having added a child to or removed a child (window, other sizer or space) from the sizer while keeping the current dimension.



525
# File 'lib/wx/doc/gen/sizer.rb', line 525

def layout; end

#prepend(window, flags) ⇒ Wx::SizerItem #prepend(window, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem #prepend(sizer, flags) ⇒ Wx::SizerItem #prepend(sizer, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem #prepend(width, height, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem #prepend(width, height, flags) ⇒ Wx::SizerItem

Overloads:

  • #prepend(window, flags) ⇒ Wx::SizerItem

    Same as #add, but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer.

    Parameters:

    Returns:

  • #prepend(window, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem

    Same as #add, but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer.

    Parameters:

    • window (Wx::Window)
    • proportion (Integer) (defaults to: 0)
    • flag (Integer) (defaults to: 0)
    • border (Integer) (defaults to: 0)
    • userData (Object) (defaults to: nil)

    Returns:

  • #prepend(sizer, flags) ⇒ Wx::SizerItem

    Same as #add, but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer.

    Parameters:

    Returns:

  • #prepend(sizer, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem

    Same as #add, but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer.

    Parameters:

    • sizer (Wx::Sizer)
    • proportion (Integer) (defaults to: 0)
    • flag (Integer) (defaults to: 0)
    • border (Integer) (defaults to: 0)
    • userData (Object) (defaults to: nil)

    Returns:

  • #prepend(width, height, proportion = 0, flag = 0, border = 0, userData = nil) ⇒ Wx::SizerItem

    Same as #add, but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer.

    Parameters:

    • width (Integer)
    • height (Integer)
    • proportion (Integer) (defaults to: 0)
    • flag (Integer) (defaults to: 0)
    • border (Integer) (defaults to: 0)
    • userData (Object) (defaults to: nil)

    Returns:

  • #prepend(width, height, flags) ⇒ Wx::SizerItem

    Same as #add, but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer.

    Parameters:

    Returns:



568
# File 'lib/wx/doc/gen/sizer.rb', line 568

def prepend(*args) end

#prepend_spacer(size) ⇒ Wx::SizerItem

Prepends non-stretchable space to the sizer.

More readable way of calling #prepend(size,size,0).

Parameters:

  • size (Integer)

Returns:



575
# File 'lib/wx/doc/gen/sizer.rb', line 575

def prepend_spacer(size) end

#prepend_stretch_spacer(prop = 1) ⇒ Wx::SizerItem

Prepends stretchable space to the sizer.

More readable way of calling #prepend(0,0,prop).

Parameters:

  • prop (Integer) (defaults to: 1)

Returns:



582
# File 'lib/wx/doc/gen/sizer.rb', line 582

def prepend_stretch_spacer(prop=1) end

#remove(sizer) ⇒ Boolean #remove(index) ⇒ Boolean

Overloads:

  • #remove(sizer) ⇒ Boolean

    Removes a sizer child from the sizer and destroys it.

    Note:

    This method does not cause any layout or resizing to take place, call #layout to update the layout "on screen" after removing a child from the sizer.

    true if the child item was found and removed, false otherwise.

    Parameters:

    Returns:

    • (Boolean)
  • #remove(index) ⇒ Boolean

    Removes a child from the sizer and destroys it if it is a sizer or a spacer, but not if it is a window (because windows are owned by their parent window, not the sizer).

    Note:

    This method does not cause any layout or resizing to take place, call #layout to update the layout "on screen" after removing a child from the sizer.

    true if the child item was found and removed, false otherwise.

    Parameters:

    • index (Integer)

      The position of the child in the sizer, e.g. 0 for the first item.

    Returns:

    • (Boolean)


616
# File 'lib/wx/doc/gen/sizer.rb', line 616

def remove(*args) end

#replace(oldwin, newwin, recursive = false) ⇒ Boolean #replace(oldsz, newsz, recursive = false) ⇒ Boolean #replace(index, newitem) ⇒ Boolean

Overloads:

  • #replace(oldwin, newwin, recursive = false) ⇒ Boolean

    Detaches the given oldwin from the sizer and replaces it with the given newwin.

    The detached child window is not deleted (because windows are owned by their parent window, not the sizer). Use parameter recursive to search the given element recursively in subsizers. This method does not cause any layout or resizing to take place, call #layout to update the layout “on screen” after replacing a child from the sizer. Returns true if the child item was found and removed, false otherwise.

    Parameters:

    Returns:

    • (Boolean)
  • #replace(oldsz, newsz, recursive = false) ⇒ Boolean

    Detaches the given oldsz from the sizer and replaces it with the given newsz.

    The detached child sizer is deleted. Use parameter recursive to search the given element recursively in subsizers. This method does not cause any layout or resizing to take place, call #layout to update the layout “on screen” after replacing a child from the sizer. Returns true if the child item was found and removed, false otherwise.

    Parameters:

    Returns:

    • (Boolean)
  • #replace(index, newitem) ⇒ Boolean

    Detaches the given item at position index from the sizer and replaces it with the given Wx::SizerItem newitem.

    The detached child is deleted only if it is a sizer or a spacer (but not if it is a Window because windows are owned by their parent window, not the sizer). This method does not cause any layout or resizing to take place, call #layout to update the layout “on screen” after replacing a child from the sizer. Returns true if the child item was found and removed, false otherwise.

    Parameters:

    Returns:

    • (Boolean)


649
# File 'lib/wx/doc/gen/sizer.rb', line 649

def replace(*args) end

#reposition_children(minSize) ⇒ void

This method returns an undefined value.

Method which must be overridden in the derived sizer classes.

The implementation should reposition the children using the current total size available to the sizer (m_size) and the size computed by the last call to #calc_min. Note that you should never call this method directly, call #layout instead if you need to manually update the sizer elements positions. This method is only called by wxWidgets itself.

Parameters:

  • minSize (Array(Integer, Integer), Wx::Size)


590
# File 'lib/wx/doc/gen/sizer.rb', line 590

def reposition_children(minSize) end

#set_containing_window(window) ⇒ void Also known as: containing_window=

This method returns an undefined value.

Set the window this sizer is used in.

Parameters:



345
# File 'lib/wx/doc/gen/sizer.rb', line 345

def set_containing_window(window) end

#set_dimension(x, y, width, height) ⇒ void #set_dimension(pos, size) ⇒ void

Overloads:

  • #set_dimension(x, y, width, height) ⇒ void

    This method returns an undefined value.

    Call this to force the sizer to take the given dimension and thus force the items owned by the sizer to resize themselves according to the rules defined by the parameter in the #add and #prepend methods.

    Parameters:

    • x (Integer)
    • y (Integer)
    • width (Integer)
    • height (Integer)
  • #set_dimension(pos, size) ⇒ void

    This method returns an undefined value.

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

    Parameters:



663
# File 'lib/wx/doc/gen/sizer.rb', line 663

def set_dimension(*args) end

#set_item_min_size(window, width, height) ⇒ Boolean #set_item_min_size(window, size) ⇒ Boolean #set_item_min_size(sizer, width, height) ⇒ Boolean #set_item_min_size(sizer, size) ⇒ Boolean #set_item_min_size(index, width, height) ⇒ Boolean #set_item_min_size(index, size) ⇒ Boolean

Overloads:

  • #set_item_min_size(window, width, height) ⇒ Boolean

    Set an item’s minimum size by window, sizer, or position.

    This function enables an application to set the size of an item after initial creation. The window or sizer will be found recursively in the sizer’s descendants.

    true if the minimal size was successfully set or false if the item was not found.

    Parameters:

    • window (Wx::Window)
    • width (Integer)
    • height (Integer)

    Returns:

    • (Boolean)

    See Also:

  • #set_item_min_size(window, size) ⇒ Boolean

    Set an item’s minimum size by window, sizer, or position.

    This function enables an application to set the size of an item after initial creation. The window or sizer will be found recursively in the sizer’s descendants.

    true if the minimal size was successfully set or false if the item was not found.

    Parameters:

    Returns:

    • (Boolean)

    See Also:

  • #set_item_min_size(sizer, width, height) ⇒ Boolean

    Set an item’s minimum size by window, sizer, or position.

    This function enables an application to set the size of an item after initial creation. The window or sizer will be found recursively in the sizer’s descendants.

    true if the minimal size was successfully set or false if the item was not found.

    Parameters:

    • sizer (Wx::Sizer)
    • width (Integer)
    • height (Integer)

    Returns:

    • (Boolean)

    See Also:

  • #set_item_min_size(sizer, size) ⇒ Boolean

    Set an item’s minimum size by window, sizer, or position.

    This function enables an application to set the size of an item after initial creation. The window or sizer will be found recursively in the sizer’s descendants.

    true if the minimal size was successfully set or false if the item was not found.

    Parameters:

    Returns:

    • (Boolean)

    See Also:

  • #set_item_min_size(index, width, height) ⇒ Boolean

    Set an item’s minimum size by window, sizer, or position.

    This function enables an application to set the size of an item after initial creation. The window or sizer will be found recursively in the sizer’s descendants.

    true if the minimal size was successfully set or false if the item was not found.

    Parameters:

    • index (Integer)
    • width (Integer)
    • height (Integer)

    Returns:

    • (Boolean)

    See Also:

  • #set_item_min_size(index, size) ⇒ Boolean

    Set an item’s minimum size by window, sizer, or position.

    This function enables an application to set the size of an item after initial creation. The window or sizer will be found recursively in the sizer’s descendants.

    true if the minimal size was successfully set or false if the item was not found.

    Parameters:

    • index (Integer)
    • size (Array(Integer, Integer), Wx::Size)

    Returns:

    • (Boolean)

    See Also:



168
# File 'lib/wx/doc/gen/sizer.rb', line 168

def set_item_min_size(*args) end

#set_min_size(size) ⇒ void #set_min_size(width, height) ⇒ void Also known as: min_size=

Overloads:

  • #set_min_size(size) ⇒ void

    This method returns an undefined value.

    Call this to give the sizer a minimal size.

    Normally, the sizer will calculate its minimal size based purely on how much space its children need. After calling this method #get_min_size will return either the minimal size as requested by its children or the minimal size set here, depending on which is bigger.

    Parameters:

    • size (Array(Integer, Integer), Wx::Size)
  • #set_min_size(width, height) ⇒ void

    This method returns an undefined value.

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

    Parameters:

    • width (Integer)
    • height (Integer)


676
# File 'lib/wx/doc/gen/sizer.rb', line 676

def set_min_size(*args) end

#set_size_hints(window) ⇒ void Also known as: size_hints=

This method returns an undefined value.

This method first calls #fit and then TopLevelWindow#set_size_hints on the window passed to it.

This function is only when window is actually a TopLevelWindow such as a Frame or a Dialog, since SetSizeHints only has any effect in these classes. It does nothing in normal windows or controls. Note that window does not need to be the window using this sizer and it is, in fact, common to call this function on the sizer associated with the panel covering the client area of a frame passing it the frame pointer, as this has the desired effect of adjusting the frame size to the size fitting the panel, e.g.:

class MyFrame < Wx::Frame 
    def initialize(...)
      super
      panel = Wx::Panel.new(self)
      sizer = Wx::BoxSizer.new(Wx::VERTICAL)
      sizer.add(...)
      sizer.add(...)
      panel.set_sizer(sizer)
  
      # Use the panel sizer to set the initial and minimal size of the
      # frame to fit its contents.
      sizer.set_size_hints(this)
    end

This function is also used by Window#set_sizer_and_fit which is commonly invoked in the constructor of Dialog-derived classes, which don’t need to use an intermediate panel, see the example in wxBoxSizer overview.

Parameters:



702
# File 'lib/wx/doc/gen/sizer.rb', line 702

def set_size_hints(window) end

#show(window, show = true, recursive = false) ⇒ Boolean #show(sizer, show = true, recursive = false) ⇒ Boolean #show(index, show = true) ⇒ Boolean

Overloads:

  • #show(window, show = true, recursive = false) ⇒ Boolean

    Shows or hides the window.

    To make a sizer item disappear or reappear, use #show followed by #layout. Use parameter recursive to show or hide elements found in subsizers. Returns true if the child item was found, false otherwise.

    Parameters:

    • window (Wx::Window)
    • show (Boolean) (defaults to: true)
    • recursive (Boolean) (defaults to: false)

    Returns:

    • (Boolean)

    See Also:

  • #show(sizer, show = true, recursive = false) ⇒ Boolean

    Shows or hides sizer.

    To make a sizer item disappear or reappear, use #show followed by #layout. Use parameter recursive to show or hide elements found in subsizers. Returns true if the child item was found, false otherwise.

    Parameters:

    • sizer (Wx::Sizer)
    • show (Boolean) (defaults to: true)
    • recursive (Boolean) (defaults to: false)

    Returns:

    • (Boolean)

    See Also:

  • #show(index, show = true) ⇒ Boolean

    Shows the item at index.

    To make a sizer item disappear or reappear, use #show followed by #layout. Returns true if the child item was found, false otherwise.

    Parameters:

    • index (Integer)
    • show (Boolean) (defaults to: true)

    Returns:

    • (Boolean)

    See Also:



739
# File 'lib/wx/doc/gen/sizer.rb', line 739

def show(*args) end

#show_items(show) ⇒ void

This method returns an undefined value.

Show or hide all items managed by the sizer.

Parameters:

  • show (Boolean)


744
# File 'lib/wx/doc/gen/sizer.rb', line 744

def show_items(show) end