123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- deferred class IUP_WIDGET_FLAT_TEXT
- -- Command to handle the additional features to text in flat controls.
- inherit
- IUP_WIDGET_INTERNALS
-
- feature {ANY}
- set_alignment (horizontal, vertical: STRING)
- -- (non inheritable): horizontal and vertical alignment. Possible values:
- -- "ALEFT", "ACENTER" and "ARIGHT", combined to "ATOP", "ACENTER" and
- -- "ABOTTOM". Default: "ALEFT:ACENTER". In Motif, vertical alignment is
- -- restricted to "ACENTER".
- require
- is_valid_alignment(horizontal, vertical)
- local
- str: STRING
- do
- create str.make_from_string(horizontal)
- str.append_string(":")
- str.append_string(vertical)
-
- iup_open.set_attribute(Current, "ALIGNMENT", str)
- end
- set_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, "TEXTALIGNMENT", value)
- end
- set_text_wrap (state: BOOLEAN)
- -- (non inheritable): For single line texts if the text is larger than
- -- its box the line will be automatically broken in multiple lines.
- -- Notice that this is done internally by the system, the element natural
- -- size will still use only a single line. For the remaining lines to be
- -- visible the element should use EXPAND=VERTICAL or set a
- -- SIZE/RASTERSIZE with enough height for the wrapped lines.
- do
- iup_open.set_attribute(Current, "TEXTWRAP", boolean_to_yesno(state))
- end
- set_text_ellipsis (state: BOOLEAN)
- -- (non inheritable): If the text is larger that its box, an ellipsis
- -- ("...") will be placed near the last visible part of the text and
- -- replace the invisible part. It will be ignored when TEXTWRAP=True.
- do
- iup_open.set_attribute(Current, "TEXTELLIPSIS", boolean_to_yesno(state))
- end
- set_text_orientation (value: REAL_64)
- -- (non inheritable): text angle in degrees and counterclockwise. The
- -- text size will adapt to include the rotated space.
- do
- iup_open.set_attribute(Current, "TEXTORIENTATION", value.out)
- end
- -- Validations
- is_valid_alignment (horizontal, vertical: STRING): BOOLEAN
- do
- if is_valid_vertical_alignment(vertical) and
- is_valid_horizontal_alignment(horizontal) then
- Result := True
- else
- Result := False
- end
- end
- is_valid_vertical_alignment (value: STRING): BOOLEAN
- do
- if value.is_equal("ATOP") or
- value.is_equal("ACENTER") or
- value.is_equal("ABOTTOM") then
- Result := True
- else
- Result := False
- end
- end
- is_valid_horizontal_alignment (value: STRING): BOOLEAN
- do
- if value.is_equal("ALEFT") or
- value.is_equal("ACENTER") or
- value.is_equal("ARIGHT") then
- Result := True
- else
- Result := False
- end
- end
-
- end
- -- The MIT License (MIT)
- -- Copyright (c) 2018, 2019 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.
|