123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- deferred class IUP_WIDGET_TEXT_COMMON
- -- Common attributes related with text controls.
- inherit
- IUP_WIDGET_INTERNALS
- IUP_WIDGET_PADDING
-
- feature {ANY}
- clipboard (option: STRING)
- -- (write-only): clear, cut, copy or paste the selection to or from the
- -- clipboard. Values: "CLEAR", "CUT", "COPY" or "PASTE". In Windows UNDO
- -- is also available, and REDO is available when FORMATTING=True.
- require
- is_valid_option(option)
- do
- iup_open.set_attribute(Current, "CLIPBOARD", option)
- end
- set_cue_banner (txt: STRING)
- -- [Windows and GTK Only] (non inheritable): a text that is displayed
- -- when there is no text at the control. It works as a textual cue, or
- -- tip to prompt the user for input. Valid only for MULTILINE=False, and
- -- works only when Visual Styles are enabled. (since 3.0) [GTK 3.2] (GTK
- -- support added in IUP 3.20).
- do
- iup_open.set_attribute(Current, "CUEBANNER", txt)
- end
- set_filter (filter: STRING)
- -- [Windows Only] (non inheritable): allows a custom filter to process
- -- the characters: Can be LOWERCASE, UPPERCASE or NUMBER (only numbers
- -- allowed).
- require
- is_valid_filter(filter)
- do
- iup_open.set_attribute(Current, "FILTER", filter)
- end
- set_mask (mask: STRING)
- -- (non inheritable): Defines a mask that will filter interactive text
- -- input. Use "REMOVE" to remove the mask.
- --
- -- Since the validation process is performed key by key when the user is
- -- typing, an intermediate value cannot be typed if it does not follow
- -- the mask rules.
- --
- -- If you set the VALUE attribute any text can be used. To set a value
- -- that is validated by the current MASK use VALUEMASKED.
- --
- -- Pre-Defined Masks
- --
- -- Definition Value Description
- -- IUP_MASK_INT "[+/-]?/d+" integer number
- -- IUP_MASK_UINT "/d+" unsigned integer number
- -- IUP_MASK_FLOAT "[+/-]?(/d+/.?/d*|/./d+)" floating point number
- -- IUP_MASK_UFLOAT "(/d+/.?/d*|/./d+)" unsigned floating point number
- -- IUP_MASK_EFLOAT "[+/-]?(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?" floating
- -- point number with exponential notation
- -- IUP_MASK_FLOATCOMMA "[+/-]?(/d+/,?/d*|/,/d+)" floating point number
- -- IUP_MASK_UFLOATCOMMA "(/d+/,?/d*|/,/d+)" unsigned floating point number
- --
- -- For more information see:
- -- http://webserver2.tecgraf.puc-rio.br/iup/en/attrib/iup_mask.html
- do
- if mask.is_equal("REMOVE") then
- iup_open.set_attribute_null(Current, "MASK")
- elseif mask.is_equal("IUP_MASK_FLOAT") then
- iup_open.set_attribute(Current, "MASK", "[+/-]?(/d+/.?/d*|/./d+)")
- elseif mask.is_equal("IUP_MASK_UFLOAT") then
- iup_open.set_attribute(Current, "MASK", "(/d+/.?/d*|/./d+)")
- elseif mask.is_equal("IUP_MASK_EFLOAT") then
- iup_open.set_attribute(Current, "MASK", "[+/-]?(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?")
- elseif mask.is_equal("IUP_MASK_FLOATCOMMA") then
- iup_open.set_attribute(Current, "MASK", "[+/-]?(/d+/,?/d*|/,/d+)")
- elseif mask.is_equal("IUP_MASK_UFLOATCOMMA") then
- iup_open.set_attribute(Current, "MASK", "(/d+/,?/d*|/,/d+)")
- elseif mask.is_equal("IUP_MASK_INT") then
- iup_open.set_attribute(Current, "MASK", "[+/-]?/d+")
- elseif mask.is_equal("IUP_MASK_UINT") then
- iup_open.set_attribute(Current, "MASK", "/d+")
- else
- iup_open.set_attribute(Current, "MASK", mask)
- end
- end
- set_mask_case_insesitive (state: BOOLEAN)
- -- If True, will turn the filter case insensitive. Default: False.
- do
- iup_open.set_attribute(Current, "MASKCASEI", boolean_to_yesno(state))
- end
- set_mask_no_empty (state: BOOLEAN)
- -- If True, value can NOT be Void or empty. Default: False (can be
- -- empty or Void).
- do
- iup_open.set_attribute(Current, "MASKNOEMPTY", boolean_to_yesno(state))
- end
- set_mask_decimal_symbol (value: STRING)
- -- The decimal symbol for string/float conversion. Can be "." or ",".
- -- Must be set before MASKFLOAT.
- require
- is_valid_symbol (value)
- do
- iup_open.set_attribute(Current, "MASKDECIMALSYMBOL", value)
- end
- set_mask_integer (min, max: INTEGER)
- -- Defines an integer mask with limits "min-max". It will replace MASK
- -- using one of the pre-defined masks.
- local
- str: STRING
- do
- str := min.out
- str.append_string(":")
- str.append_string(max.out)
- iup_open.set_attribute(Current, "MASKINT", str)
- end
- set_mask_float (min, max: REAL_64)
- -- Defines a floating point mask with limits "min:max". It will replace
- -- MASK using one of the pre-defined masks.
- local
- str: STRING
- do
- str := min.out
- str.append_string(":")
- str.append_string(max.out)
- iup_open.set_attribute(Current, "MASKFLOAT", str)
- end
- set_number_of_characters (num: INTEGER)
- -- Maximum number of characters allowed for keyboard input, larger text
- -- can still be set using attributes. The maximum value is the limit of
- -- the VALUE attribute. The "0" value don't impose a limit. Default: "0".
- require
- num >= 0
- do
- iup_open.set_attribute(Current, "NC", num.out)
- end
- set_readonly (state: BOOLEAN)
- -- Allows the user only to read the contents, without changing it.
- -- Restricts keyboard input only, text value can still be changed using
- -- attributes. Navigation keys are still available. Possible values:
- -- "True", "False". Default: False.
- do
- iup_open.set_attribute(Current, "READONLY", boolean_to_yesno(state))
- end
- set_selected_text (value: STRING)
- -- Replaces the current selection. Similar to INSERT, but does nothing if
- -- there is no selection.
- do
- iup_open.set_attribute(Current, "SELECTEDTEXT", value)
- end
- get_selected_text: STRING
- -- Selected text. Returns "" if there is no selection.
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "SELECTEDTEXT")
- if str /= Void then
- Result := str
- else
- Result := ""
- end
- end
- select_all
- -- Select all the text.
- do
- iup_open.set_attribute(Current, "SELECTION", "ALL")
- end
- deselect_all
- -- Deselect.
- do
- iup_open.set_attribute(Current, "SELECTION", "NONE")
- end
- -- Changes
- append (txt: STRING)
- -- Inserts a text at the end of the current text.
- do
- iup_open.set_attribute(Current, "APPEND", txt)
- end
- insert (txt: STRING)
- -- (write-only): Inserts a text in the caret's position, also replaces
- -- the current selection if any. Ignored if set before map.
- do
- iup_open.set_attribute(Current, "INSERT", txt)
- end
- -- Internals
- is_valid_option (value: STRING): BOOLEAN
- do
- if value.is_equal("CLEAR") or
- value.is_equal("CUT") or
- value.is_equal("COPY") or
- value.is_equal("PASTE") or
- value.is_equal("UNDO") or
- value.is_equal("REDO") then
- Result := True
- else
- Result := False
- end
- end
- is_valid_filter (value: STRING): BOOLEAN
- do
- if value.is_equal("LOWERCASE") or
- value.is_equal("UPPERCASE") or
- value.is_equal("NUMBER") then
- Result := True
- else
- Result := False
- end
- end
- is_valid_symbol (value: STRING): BOOLEAN
- do
- if value.is_equal(".") or
- value.is_equal(",") then
- Result := True
- else
- Result := False
- end
- end
- end
- -- The MIT License (MIT)
- -- Copyright (c) 2016, 2017, 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.
|