123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- deferred class IUP_WIDGET_TEXT_SPIN
- -- Commands to handle the attributes related with spin.
- -- In Windows, the increment is multiplied by 5 after 2 seconds and multiplied
- -- by 20 after 5 seconds of a spin button pressed. In GTK, the increment change
- -- is progressively accelerated when a spin button is pressed.
- inherit
- IUP_WIDGET_INTERNALS
-
- feature {ANY}
- set_spin (state: BOOLEAN)
- -- (non inheritable, creation only): enables a spin control attached
- -- to the element. Default: False. The spin increments and decrements
- -- an integer number. The editing in the element is still available.
- do
- iup_open.set_attribute(Current, "SPIN", boolean_to_yesno(state))
- end
- set_spin_value (value: INTEGER)
- -- (non inheritable): the current value of the spin. The value is
- -- limited to the minimum and maximum values.
- do
- iup_open.set_attribute(Current, "SPINVALUE", value.out)
- end
- get_spin_value: INTEGER
- -- Return the spin value.
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "SPINVALUE")
- if str.is_integer then
- Result := str.to_integer
- end
- end
- set_spin_max (value: INTEGER)
- -- (non inheritable): the maximum value. Default: 100.
- do
- iup_open.set_attribute(Current, "SPINMAX", value.out)
- end
- set_spin_min (value: INTEGER)
- -- (non inheritable): the minimum value. Default: 0.
- do
- iup_open.set_attribute(Current, "SPINMIN", value.out)
- end
- set_spin_increment (value: INTEGER)
- -- (non inheritable): the increment value. Default: 1.
- do
- iup_open.set_attribute(Current, "SPININC", value.out)
- end
- set_spin_right_alignment
- -- (creation only): set spin at right position. This is the default
- -- value. In GTK is always right.
- do
- iup_open.set_attribute(Current, "SPINALIGN", "RIGHT")
- end
- set_spin_left_alignment
- -- (creation only): set spin at left position. In GTK is always
- -- right.
- do
- iup_open.set_attribute(Current, "SPINALIGN", "LEFT")
- end
- set_spin_wrap (state: BOOLEAN)
- -- (creation only): if the position reach a limit it continues from the
- -- opposite limit. Default: False.
- do
- iup_open.set_attribute(Current, "SPINWRAP", boolean_to_yesno(state))
- end
- set_spin_auto (state: BOOLEAN)
- -- (creation only): enables the automatic update of the text contents.
- -- Default: True. Use SPINAUTO=False and the VALUE attribute during
- -- SPIN_CB to control the text contents when the spin is incremented.
- do
- iup_open.set_attribute(Current, "SPINAUTO", boolean_to_yesno(state))
- end
- -- Callback
- set_cb_spin (act: detachable FUNCTION[TUPLE[IUP_WIDGET, INTEGER], STRING])
- -- Called each time the user clicks in the buttons. It will increment 1
- -- and decrement -1 by default. Holding the Shift key will set a factor
- -- of 2, holding Ctrl a factor of 10, and both a factor of 100.
- local
- operation: INTEGER
- do
- cb_spin := act
- if cb_spin /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "SPIN_CB", "NONEEDED", operation)
- end
- feature {IUP}
-
- execute_spin (inc: INTEGER): STRING
- do
- if attached cb_spin as int_cb then
- Result := int_cb.item([Current, inc])
- else
- Result := "IUP_DEFAULT"
- end
- end
- feature {NONE}
- -- For callback
- cb_spin: detachable FUNCTION[TUPLE[IUP_WIDGET, INTEGER], STRING]
- 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.
|