123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- class IUP_ZBOX
- -- Creates a void container for composing elements in hidden layers with only
- -- one layer visible. It is a box that piles up the children it contains,
- -- only the one child is visible.
- --
- -- It does not have a native representation.
- --
- -- Zbox works by changing the VISIBLE attribute of its children, so if any of
- -- the grand children has its VISIBLE attribute directly defined then Zbox
- -- will NOT change its state.
- --
- -- IMPORTANT: Each element must have a name defined by "set_widget_name".
- inherit
- IUP_CONTAINER
- IUP_WIDGET_CUSTOM_ATTRIBUTES
- IUP_WIDGET_EXPAND
- IUP_WIDGET_SIZE
- IUP_WIDGET_RASTERSIZE
- IUP_WIDGET_USERSIZE
- IUP_WIDGET_WID
- IUP_WIDGET_FONT
- IUP_WIDGET_CLIENTSIZE
- IUP_WIDGET_CLIENTOFFSET
- IUP_WIDGET_POSITION
- IUP_WIDGET_MAXMIN_SIZE
- IUP_WIDGET_CHILD
- IUP_WIDGET_NAME
- IUP_WIDGET_CHILDSIZEALL
-
- create {ANY}
- zbox_empty,
- zbox
-
- feature {ANY}
- zbox_empty
- -- Create an empty zbox
- local
- p, a_zbox: POINTER
- do
- a_zbox := int_zbox_empty (p)
- set_widget(a_zbox)
- end
-
- zbox (col: ARRAY[IUP_WIDGET])
- -- Create a new zbox containing the list of widgets
- local
- i: INTEGER; arg: ARRAY[POINTER]; s: IUP_WIDGET; a_zbox: POINTER
- do
- i := col.count
- create arg.make_filled(default_pointer, 1, i + 1)
- i := 0
-
- across
- col as ic
- loop
- i := i + 1
- s := ic.item
- arg.put(s.widget, i)
- end
- a_zbox := int_zbox (get_pointer(arg.to_c))
- set_widget(a_zbox)
- end
- -- Attributes
- set_alignment (value: STRING)
- -- (non inheritable): Defines the alignment of the visible child. Possible
- -- values: "NORTH", "SOUTH", "WEST", "EAST", "NE", "SE", "NW", "SW",
- -- "ACENTER". Default: "NW".
- require
- is_valid: is_valid_alignment(value)
- do
- iup_open.set_attribute(Current, "ALIGNMENT", value)
- end
-
- get_alignment: STRING
- -- Return the value of the alignment.
- do
- Result := iup_open.get_attribute(Current, "ALIGNMENT")
- end
- set_value (name: STRING)
- -- (non inheritable): The visible child accessed by its name. The value
- -- passed must be the name of one of the children contained in the zbox.
- -- Use set_widget_name to associate a child to a name. When the
- -- value is changed the selected child is made visible and all other
- -- children are made invisible, regardless their previous visible state.
- do
- iup_open.set_attribute(Current, "VALUE", name)
- end
-
- get_value: STRING
- -- Return the name of the visible child.
- do
- Result := iup_open.get_attribute(Current, "VALUE")
- end
- set_value_widget (wgt: IUP_WIDGET)
- -- (non inheritable): The visible child accessed by its handle. The
- -- value passed must be the handle of a child contained in the zbox.
- -- When the zbox is created, the first element inserted is set as the
- -- visible child.
- do
- iup_open.set_attribute_widget(Current, "VALUE_HANDLE", wgt)
- end
- get_value_widget: IUP_WIDGET
- -- Return the IUP_WIDGET that is visible.
- do
- Result := iup_open.get_attribute_widget(Current, "VALUE_HANDLE")
- end
-
- set_value_position (pos: INTEGER)
- -- (non inheritable): The visible child accessed by its position. The
- -- value passed must be the index of a child contained in the zbox,
- -- starting at 0. When the zbox is created, the first element inserted
- -- is set as the visible child.
- require
- pos >= 0
- do
- iup_open.set_attribute(Current, "VALUEPOS", pos.out)
- end
-
- get_value_position: INTEGER
- -- Return the position of the visible child.
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "VALUEPOS")
- Result := str.to_integer
- end
- -- Validations
- is_valid_alignment (value: STRING): BOOLEAN
- do
- if value.is_equal("NORTH") or
- value.is_equal("SOUTH") or
- value.is_equal("WEST") or
- value.is_equal("EAST") or
- value.is_equal("NE") or
- value.is_equal("SE") or
- value.is_equal("NW") or
- value.is_equal("SW") or
- value.is_equal("ACENTER") then
- Result := True
- else
- Result := False
- end
- end
- feature {NONE}
- -- Internals
-
- int_zbox_empty (arguments: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupZbox ($arguments);"
- end
-
- int_zbox (arguments: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupZboxv ($arguments);"
- end
- end -- class IUP_ZBOX
- -- The MIT License (MIT)
- -- Copyright (c) 2016, 2017, 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.
|