123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- class IUP_NORMALIZER
- -- Creates a void container that does not affect the dialog layout. It acts by
- -- normalizing all the controls in a list so their natural size becomes the
- -- biggest natural size amongst them. All natural widths will be set to the
- -- biggest width, and all natural heights will be set to the biggest height.
- -- The controls of the list must be inside a valid container in the
- -- dialog.
- --
- -- It is NOT necessary to add the normalizer to a dialog hierarchy. Every time
- -- "set_normalize" is set, a normalization occurs. If the normalizer is
- -- added to a dialog hierarchy, then whenever the Natural size is calculated a
- -- normalization occurs, so you should add it to the hierarchy before the
- -- elements you want to normalize or its normalization will be not used.
- --
- -- The elements do NOT need to be children of the same parent, do NOT need to
- -- be mapped, and do NOT need to be in a complete hierarchy of a dialog.
- --
- -- The elements are NOT children of the normalizer. To add or remove elements
- -- use the add_control and delete_control attributes.
- --
- -- Notice that the set_normalizar_group (at controls) attribute can simplify a
- -- lot of the process of creating a normalizer, so you do not need to list
- -- several elements from different parts of the dialog.
- --
- -- Has the same effect as the set_normalize_size attribute of the IUP_VBOX and
- -- IUP_HBOX controls, but it can be used for elements with different parents,
- -- it changes the User size of the elements.
- inherit
- IUP_WIDGET
- create {ANY}
- normalizer_empty,
- normalizer
- feature {ANY}
- normalizer_empty
- local
- a_normalizer, p: POINTER
- do
- a_normalizer := int_normalizer (p)
- set_widget(a_normalizer)
- end
- normalizer (list: ARRAY[IUP_WIDGET])
- local
- i: INTEGER;
- arg: ARRAY[POINTER]; s: IUP_WIDGET; a_normalizer: POINTER
- do
- i := list.count
- create arg.make_filled(default_pointer, 1, i + 1)
- i := 0
- across
- list as ic
- loop
- i := i + 1
- s := ic.item
- arg.put(s.widget, i)
- end
-
- a_normalizer := int_normalizerv (get_pointer(arg.to_c))
- set_widget(a_normalizer)
- end
- -- Attributes
- set_normalize (value: STRING)
- -- (non inheritable): normalization direction. Can be HORIZONTAL,
- -- VERTICAL or BOTH. Default: HORIZONTAL
- require
- is_valid_normalize(value)
- do
- iup_open.set_attribute(Current, "NORMALIZE", value)
- end
- set_normalize_horizontal
- do
- set_normalize("HORIZONTAL")
- end
- set_normalize_vertical
- do
- set_normalize("VERTICAL")
- end
- set_normalize_both
- do
- set_normalize("BOTH")
- end
- -- Operations
- add_control (name: STRING)
- -- (non inheritable, write-only): Adds a control to the normalizer. The
- -- value passed must be the name of an element. Use set_widget_name
- -- to associate an element to a name.
- do
- iup_open.set_attribute(Current, "ADDCONTROL", name)
- end
- add_control_widget (wgt: IUP_WIDGET)
- -- (non inheritable, write-only): Adds a control to the normalizer.
- do
- iup_open.set_attribute_widget(Current, "ADDCONTROL_HANDLE", wgt)
- end
- delete_control (name: STRING)
- -- (non inheritable, write-only): Removes a control from the normalizer.
- -- The value passed must be the name of an element. Use
- -- set_widget_name to associate an element to a name.
- do
- iup_open.set_attribute(Current, "DELCONTROL", name)
- end
- delete_control_widget (wgt: IUP_WIDGET)
- -- (non inheritable, write-only): Removes a control from the normalizer.
- do
- iup_open.set_attribute_widget(Current, "DELCONTROL_HANDLE", wgt)
- end
- -- Validations
- is_valid_normalize (value: STRING): BOOLEAN
- do
- if value.is_equal("HORIZONTAL") or
- value.is_equal("VERTICAL") or
- value.is_equal("BOTH") then
- Result := True
- else
- Result := False
- end
- end
- feature {NONE}
- -- Internal
- int_normalizer (arguments: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupNormalizer ($arguments);"
- end
- int_normalizerv (arguments: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupNormalizerv ($arguments);"
- end
- end
- -- The MIT License (MIT)
- -- Copyright (c) 2016, 2019, 2020 by German A. Arias
- -- Permission is hereby granted, free of charge, to any person obtaining a copy
- -- of this software and associated documentation files (the "Software"), to deal
- -- in the Software without restriction, including without limitation the rights
- -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- -- copies of the Software, and to permit persons to whom the Software is
- -- furnished to do so, subject to the following conditions:
- --
- -- The above copyright notice and this permission notice shall be included in
- -- all copies or substantial portions of the Software.
- --
- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- -- SOFTWARE.
|