123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- class IUP_FLAT_FRAME
- -- Creates a native container, which draws a frame with a title around its
- -- child. The decorations are manually drawn. The control inherits from
- -- IUP_BACKGROUND_BOX. Inherits all attributes and callbacks of the IUP_CANVAS,
- -- but redefines a few attributes.
- inherit
- IUP_BACKGROUND_BOX
- rename
- background_box_empty as flat_frame_empty,
- background_box as flat_frame
- redefine
- flat_frame_empty,
- flat_frame,
- set_rgb_background_color,
- set_decoration
- end
- IUP_WIDGET_TITLE
- IUP_WIDGET_FLAT_TEXT
- create {ANY}
- flat_frame_empty,
- flat_frame
- feature {ANY}
- flat_frame_empty
- -- Create an empty flat frame.
- local
- a_flat_frame, p: POINTER
- do
- a_flat_frame := int_flat_frame (p)
- set_widget(a_flat_frame)
- end
- flat_frame (child: IUP_WIDGET)
- -- Create a flat frame with the child.
- --
- -- child: Identifier of an interface element which will receive the frame
- -- around.
- local
- a_flat_frame: POINTER
- do
- a_flat_frame := int_flat_frame (child.widget)
- set_widget(a_flat_frame)
- end
- -- Attributes
- set_decoration (state: BOOLEAN)
- -- Does nothing since the frame always have a decoration.
- do
- end
- set_rgb_background_color (red: INTEGER; green: INTEGER; blue: INTEGER)
- -- Background color of the child area. If not defined it will use the
- -- background color of the native parent.
- do
- Precursor (red, green, blue)
- end
- disable_frame
- -- (non inheritable): Disables the frame line.
- do
- iup_open.set_attribute(Current, "FRAME", "NO")
- end
- set_frame_line
- -- (non inheritable): Enables the frame line.
- do
- iup_open.set_attribute(Current, "FRAME", "YES")
- end
- set_frame_cross_title
- -- (non inheritable): Enables the frame cross title.
- do
- iup_open.set_attribute(Current, "FRAME", "CROSSTITLE")
- end
- get_frame_value: STRING
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "FRAME")
- Result := str
- end
- set_rgb_frame_color (red: INTEGER; green: INTEGER; blue: INTEGER)
- -- (non inheritable): frame line color. Default: "160 160 160"
- do
- iup_open.set_attribute(Current, "FRAMECOLOR", rgb_to_string(red, green, blue))
- end
- get_rgb_frame_color: TUPLE[INTEGER, INTEGER, INTEGER]
- do
- Result := iup_open.get_rgb(Current, "FRAMECOLOR")
- end
- set_frame_width (value: INTEGER)
- -- (non inheritable): frame line width. Default: 1.
- require
- value > 0
- do
- iup_open.set_attribute(Current, "FRAMEWIDTH", value.out)
- end
- get_frame_width: INTEGER
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "FRAMEWIDTH")
- Result := str.to_integer
- end
- set_frame_space (value: INTEGER)
- -- (non inheritable): spacing between frame line and child area. Used
- -- only when FRAME=True. Default: 2.
- require
- value >= 0
- do
- iup_open.set_attribute(Current, "FRAMESPACE", value.out)
- end
- get_frame_space: INTEGER
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "FRAMESPACE")
- Result := str.to_integer
- end
- set_rgb_title_color (red: INTEGER; green: INTEGER; blue: INTEGER)
- -- (non inheritable): title text color. Default: the global attribute
- -- DLGFGCOLOR.
- do
- iup_open.set_attribute(Current, "TITLECOLOR", rgb_to_string(red, green, blue))
- end
- get_rgb_title_color: TUPLE[INTEGER, INTEGER, INTEGER]
- do
- Result := iup_open.get_rgb(Current, "TITLECOLOR")
- end
- set_rgb_title_background_color (red: INTEGER; green: INTEGER; blue: INTEGER)
- -- (non inheritable): background color of the title area. Default: the
- -- global attribute DLGBGCOLOR.
- do
- iup_open.set_attribute(Current, "TITLEBGCOLOR", rgb_to_string(red, green, blue))
- end
- get_rgb_title_background_color: TUPLE[INTEGER, INTEGER, INTEGER]
- do
- Result := iup_open.get_rgb(Current, "TITLEBGCOLOR")
- end
- set_title_line (state: BOOLEAN)
- -- (non inheritable): enables the title line. Horizontal line that
- -- separates the title area from the child area. Default: True.
- do
- iup_open.set_attribute(Current, "TITLELINE", boolean_to_yesno(state))
- end
- has_title_line: BOOLEAN
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "TITLELINE")
- Result := yesno_to_boolean(str)
- end
- set_rgb_title_line_color (red: INTEGER; green: INTEGER; blue: INTEGER)
- -- (non inheritable): title line color. Default: the global attribute
- -- DLGFGCOLOR.
- do
- iup_open.set_attribute(Current, "TITLELINECOLOR", rgb_to_string(red, green, blue))
- end
- get_rgb_title_line_color: TUPLE[INTEGER, INTEGER, INTEGER]
- do
- Result := iup_open.get_rgb(Current, "TITLELINECOLOR")
- end
- set_title_line_width (value: INTEGER)
- -- (non inheritable): title line width. Default: 1.
- require
- value > 0
- do
- iup_open.set_attribute(Current, "TITLELINEWIDTH", value.out)
- end
- get_title_line_width: INTEGER
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "TITLELINEWIDTH")
- Result := str.to_integer
- end
- set_title_image (imagename: STRING)
- -- (non inheritable): image name to be used in title. Use
- -- set_widget_name to associate an image to a name.
- -- See also IUP_IMAGE.
- do
- iup_open.set_attribute(Current, "TITLEIMAGE", imagename)
- end
- get_title_image: STRING
- do
- Result := iup_open.get_attribute(Current, "TITLEIMAGE")
- end
- set_title_image_inactive (imagename: STRING)
- -- (non inheritable): image used in title when inactive. If it is not
- -- defined then the TITLEIMAGE is used and its colors will be replaced by
- -- a modified version creating the disabled effect.
- do
- iup_open.set_attribute(Current, "TITLEIMAGEINACTIVE", imagename)
- end
- get_title_image_inactive: STRING
- do
- Result := iup_open.get_attribute(Current, "TITLEIMAGEINACTIVE")
- end
- set_title_image_position (position: STRING)
- -- (non inheritable): position of the image relative to the text when
- -- both are displayed. Can be: LEFT, RIGHT, TOP, BOTTOM. Default: LEFT.
- require
- is_valid_position(position)
- do
- iup_open.set_attribute(Current, "TITLEIMAGEPOSITION", position)
- end
- get_title_image_position: STRING
- do
- Result := iup_open.get_attribute(Current, "TITLEIMAGEPOSITION")
- end
- set_title_image_spacing (value: INTEGER)
- -- (non inheritable): spacing between the image and the text.
- -- Default: "2".
- require
- value >= 0
- do
- iup_open.set_attribute(Current, "TITLEIMAGESPACING", value.out)
- end
- get_title_image_spacing: INTEGER
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "TITLEIMAGESPACING")
- Result := str.to_integer
- end
- set_title_alignment (value: STRING)
- -- (non inheritable): horizontal alignment. Possible values: "ALEFT",
- -- "ACENTER" and "ARIGHT". Default: "ACENTER".
- require
- is_valid_horizontal_alignment(value)
- do
- iup_open.set_attribute(Current, "TITLEALIGNMENT", value)
- end
- get_title_alignment: STRING
- do
- Result := iup_open.get_attribute(Current, "TITLEALIGNMENT")
- end
- set_title_text_alignment (value: STRING)
- -- (non inheritable): horizontal text alignment for multiple lines. Can
- -- be: ALEFT, ARIGHT or ACENTER. Default: ALEFT.
- require
- is_valid_horizontal_alignment(value)
- do
- iup_open.set_attribute(Current, "TITLETEXTALIGNMENT", value)
- end
- get_title_text_alignment: STRING
- do
- Result := iup_open.get_attribute(Current, "TITLETEXTALIGNMENT")
- end
- set_title_padding (horizontal, vertical: INTEGER)
- -- (non inheritable): title internal margin. Default value: "0x0".
- local
- str: STRING
- do
- create str.make_from_string(horizontal.out)
- str.append_string("x")
- str.append_string(vertical.out)
-
- iup_open.set_attribute(Current, "TITLEPADDING", str)
- end
- get_title_padding: TUPLE[INTEGER, INTEGER]
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "TITLEPADDING")
- Result := components_of (str, 'x')
- end
- -- Validations
- is_valid_position (value: STRING): BOOLEAN
- do
- if value.is_equal("LEFT") or
- value.is_equal("RIGHT") or
- value.is_equal("TOP") or
- value.is_equal("BOTTON") then
- Result := True
- else
- Result := False
- end
- end
- feature {NONE}
- -- Internals
-
- int_flat_frame (arguments: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupFlatFrame ($arguments);"
- end
- end
- -- The MIT License (MIT)
- -- Copyright (c) 2017, 2018, 2019, 2022 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.
|