Class: Wx::SizerFlags

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

Overview

Note:

This class is untracked and should not be derived from nor instances extended!

Container for sizer items flags providing readable names for them.

Normally, when you add an item to a sizer via Wx::Sizer#add, you have to specify a lot of flags and parameters which can be unwieldy. This is where SizerFlags comes in: it allows you to specify all parameters using the named methods instead. For example, instead of

sizer.add(ctrl, 0, Wx::EXPAND | Wx::ALL, 10)

you can now write

sizer.add(ctrl, Wx::SizerFlags.new.expand.border(Wx::ALL, 10))

This is more readable and also allows you to create SizerFlags objects which can be reused for several sizer items.

flagsExpand = Wx::SizerFlags.new(1)
  flagsExpand.expand.border(Wx::ALL, 10)
  
  sizer.add(ctrl1, flagsExpand)
  sizer.add(ctrl2, flagsExpand)

Note that by specification, all methods of SizerFlags return the SizerFlags object itself to allowing chaining multiple methods calls like in the examples above.

Category: Window Layout

See Also:

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proportion = 0) ⇒ Wx::SizerFlags

Creates the Wx::Sizer with the proportion specified by proportion.

Parameters:

  • proportion (Integer) (defaults to: 0)


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

def initialize(proportion=0) end

Class Method Details

.disable_consistency_checksvoid

This method returns an undefined value.

Globally disable checks for sizer flag consistency in debug builds.

By default, sizer classes such as BoxSizer and FlexGridSizer assert when passed invalid flags, even though doing this usually doesn’t result in any catastrophic consequences and the invalid flags are simply ignored later. Due to this, and the fact that these checks were only added in wxWidgets 3.1, existing code may run into multiple asserts warning about incorrect sizer flags use. Using this function provides a temporary solution for avoiding such asserts when upgrading to wxWidgets 3.1 from a previous version and will prevent such checks from being done. Please do note that correcting the code by removing the invalid flags remains a much better solution as these asserts may be very helpful to understand why some code using sizer flags doesn’t work as expected, so using this function, especially permanently, rather than a temporary workaround, is not recommended. Notice that the same effect as calling this function can be achieved by setting the environment variable WXSUPPRESS_SIZER_FLAGS_CHECK to any value.



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

def self.disable_consistency_checks; end

.get_default_borderInteger

Returns the border used by default in #border method.

This value is scaled appropriately for the current DPI on the systems where physical pixel values are used for the control positions and sizes, i.e. not with WXGTK or WXOSX.

Returns:

  • (Integer)

See Also:



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

def self.get_default_border; end

.get_default_border_fractionalFloat

Returns the border used by default, with fractional precision.

For example when the border is scaled to a non-integer DPI.

Returns:

  • (Float)

See Also:



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

def self.get_default_border_fractional; end

Instance Method Details

#align(alignment) ⇒ Wx::SizerFlags

Sets the alignment of this Wx::SizerFlags to align.

This method replaces the previously set alignment with the specified one.

Parameters:

  • alignment (Integer)

    Combination of ALIGN_XXX bit masks.

Returns:

See Also:



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

def align(alignment) end

#border(direction, borderinpixels) ⇒ Wx::SizerFlags #border(direction = Wx::Direction::ALL) ⇒ Wx::SizerFlags

Overloads:

  • #border(direction, borderinpixels) ⇒ Wx::SizerFlags

    Sets the Wx::SizerFlags to have a border of a number of pixels specified by borderinpixels with the directions specified by direction.

    Prefer to use the overload below or #double_border or #triple_border versions instead of hard-coding the border value in pixels to avoid too small borders on devices with high DPI displays.

    Parameters:

    • direction (Integer)
    • borderinpixels (Integer)

    Returns:

  • #border(direction = Wx::Direction::ALL) ⇒ Wx::SizerFlags

    Sets the Wx::SizerFlags to have a border with size as returned by get_default_border.

    Parameters:

    • direction (Integer) (defaults to: Wx::Direction::ALL)

      Direction(s) to apply the border in.

    Returns:



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

def border(*args) end

#bottomWx::SizerFlags

Aligns the object to the bottom, similar for Align(wxALIGN_BOTTOM).

Unlike #align, this method doesn’t change the horizontal alignment of the item.

Returns:



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

def bottom; end

#centerWx::SizerFlags

Sets the object of the Wx::SizerFlags to center itself in the area it is given.

Returns:



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

def center; end

#center_horizontalWx::SizerFlags

Returns:



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

def center_horizontal; end

#center_verticalWx::SizerFlags

Same as #centre_vertical.

Returns:



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

def center_vertical; end

#centreWx::SizerFlags

#center for people with the other dialect of English.

Returns:



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

def centre; end

#centre_horizontalWx::SizerFlags

Center an item only in horizontal direction.

This is mostly useful for 2D sizers as for the 1D ones it is shorter to just use #centre as the alignment is only used in one direction with them anyhow. For 2D sizers, centering an item in one direction is quite different from centering it in both directions however. Note that, unlike #align, this method doesn’t change the vertical alignment.

Returns:

See Also:



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

def centre_horizontal; end

#centre_verticalWx::SizerFlags

Center an item only in vertical direction.

The remarks in #centre_horizontal documentation also apply to this function. Note that, unlike #align, this method doesn’t change the horizontal alignment.

Returns:



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

def centre_vertical; end

#double_border(direction = Wx::Direction::ALL) ⇒ Wx::SizerFlags

Sets the border in the given direction having twice the default border size.

Parameters:

  • direction (Integer) (defaults to: Wx::Direction::ALL)

Returns:



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

def double_border(direction=Wx::Direction::ALL) end

#double_horz_borderWx::SizerFlags

Sets the border in left and right directions having twice the default border size.

Returns:



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

def double_horz_border; end

#expandWx::SizerFlags

Sets the object of the Wx::SizerFlags to expand to fill as much area as it can.

Returns:



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

def expand; end

#fixed_min_sizeWx::SizerFlags

Set the Wx::SizerFlagBits::FIXED_MINSIZE flag which indicates that the initial size of the window should be also set as its minimal size.

Returns:



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

def fixed_min_size; end

#horz_borderWx::SizerFlags

Sets the border in left and right directions having the default border size.

Returns:



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

def horz_border; end

#leftWx::SizerFlags

Aligns the object to the left, similar for Align(wxALIGN_LEFT).

Unlike #align, this method doesn’t change the vertical alignment of the item.

Returns:



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

def left; end

#proportion(proportion) ⇒ Wx::SizerFlags

Sets the proportion of this Wx::SizerFlags to proportion.

Parameters:

  • proportion (Integer)

Returns:



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

def proportion(proportion) end

#reserve_space_even_if_hiddenWx::SizerFlags

Set the Wx::SizerFlagBits::RESERVE_SPACE_EVEN_IF_HIDDEN flag.

Normally Wx::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.

Returns:



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

def reserve_space_even_if_hidden; end

#rightWx::SizerFlags

Aligns the object to the right, similar for Align(wxALIGN_RIGHT).

Unlike #align, this method doesn’t change the vertical alignment of the item.

Returns:



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

def right; end

#shapedWx::SizerFlags

Set the Wx::SHAPED flag which indicates that the elements should always keep the fixed width to height ratio equal to its original value.

Returns:



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

def shaped; end

#topWx::SizerFlags

Aligns the object to the top, similar for Align(wxALIGN_TOP).

Unlike #align, this method doesn’t change the horizontal alignment of the item.

Returns:



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

def top; end

#triple_border(direction = Wx::Direction::ALL) ⇒ Wx::SizerFlags

Sets the border in the given direction having thrice the default border size.

Parameters:

  • direction (Integer) (defaults to: Wx::Direction::ALL)

Returns:



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

def triple_border(direction=Wx::Direction::ALL) end