123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- class IUP_PROGRESS_BAR
- -- Creates a progress bar control. Shows a percent value that can be updated to
- -- simulate a progression.
- inherit
- IUP_WIDGET
- redefine
- execute_map,
- execute_unmap,
- execute_destroy
- end
- IUP_WIDGET_BGCOLOR
- IUP_WIDGET_FGCOLOR
- IUP_WIDGET_RASTERSIZE
- IUP_WIDGET_USERSIZE
- IUP_WIDGET_ACTIVE
- IUP_WIDGET_EXPAND
- IUP_WIDGET_FONT
- IUP_WIDGET_SCREENPOSITION
- IUP_WIDGET_POSITION
- IUP_WIDGET_MAXMIN_SIZE
- IUP_WIDGET_TIP
- IUP_WIDGET_SIZE
- IUP_WIDGET_ZORDER
- IUP_WIDGET_VISIBLE
- IUP_WIDGET_CHILD
- IUP_WIDGET_NAME
- IUP_WIDGET_CUSTOM_ATTRIBUTES
- create {ANY}
- progress_bar
-
- feature {ANY}
- progress_bar
- -- Create a new progress bar.
- local
- a_progress_bar: POINTER
- do
- min := 0
- max := 1
-
- a_progress_bar := int_progress_bar
- set_widget(a_progress_bar)
- end
- -- Attributes
- set_dashed (state: BOOLEAN)
- -- (creation only in Windows) [Windows and GTK only]: Changes the style
- -- of the progress bar for a dashed pattern. Default is "False".
- do
- iup_open.set_attribute(Current, "DASHED", boolean_to_yesno(state))
- end
- set_marquee (state: BOOLEAN)
- -- (creation): displays an undefined state. Default: False. You can set
- -- the attribute after map but only to start or stop the animation. In
- -- Windows it will work only if using Visual Styles.
- do
- iup_open.set_attribute(Current, "MARQUEE", boolean_to_yesno(state))
- end
- set_max (value: REAL_64)
- -- (non inheritable): Contains the maximum value. Default is "1". The
- -- control display is not updated, must set VALUE attribute to
- -- update.
- require
- value > min
- do
- iup_open.set_attribute(Current, "MAX", value.out)
- -- Update value
- max := value
- ensure
- updated: max = value
- end
- set_min (value: REAL_64)
- -- (non inheritable): Contains the minimum value. Default is "0". The
- -- control display is not updated, must set VALUE attribute to
- -- update.
- require
- value < max
- do
- iup_open.set_attribute(Current, "MIN", value.out)
- -- Update value
- min := value
- ensure
- updated: min = value
- end
- set_horizontal_orientation
- -- (creation only): Set an horizontal orientation (from left to
- -- right). This is the default value.
- do
- iup_open.set_attribute(Current, "ORIENTATION", "HORIZONTAL")
- end
- set_vertical_orientation
- -- (creation only): Set a vertical orientation (from bottom to
- -- top). By default the progress bar has an horizontal
- -- orientation (from left to right).
- do
- iup_open.set_attribute(Current, "ORIENTATION", "VERTICAL")
- end
- set_value (value: REAL_64)
- -- (non inheritable): Contains a number between "MIN" and "MAX",
- -- controlling the current position.
- do
- iup_open.set_attribute(Current, "VALUE", value.out)
- end
- get_value: REAL_64
- -- (non inheritable): Contains a number between "MIN" and "MAX",
- -- controlling the current position.
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "VALUE")
- if str.is_real then
- Result := str.to_real
- end
- end
- -- Callbacks
- set_cb_map (act: detachable FUNCTION[TUPLE[IUP_PROGRESS_BAR], STRING])
- -- Called right after an element is mapped and its attributes updated.
- local
- operation: INTEGER
- do
- cb_map := act
-
- if cb_map /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "MAP_CB", "NONEEDED", operation)
- end
- set_cb_unmap (act: detachable FUNCTION[TUPLE[IUP_PROGRESS_BAR], STRING])
- -- Called right before an element is unmapped.
- local
- operation: INTEGER
- do
- cb_unmap := act
- if cb_unmap /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "UNMAP_CB", "NONEEDED", operation)
- end
- set_cb_destroy (act: detachable FUNCTION[TUPLE[IUP_PROGRESS_BAR], STRING])
- -- Called right before an element is destroyed.
- local
- operation: INTEGER
- do
- cb_destroy := act
- if cb_destroy /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "DESTROY_CB", "NONEEDED", operation)
- end
- -- For limits
-
- min: REAL_64
- max: REAL_64
- feature {IUP} -- Internal handle of callbacks
- execute_map: STRING
- do
- if attached cb_map as int_cb then
- Result := int_cb.item([Current])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_unmap: STRING
- do
- if attached cb_unmap as int_cb then
- Result := int_cb.item([Current])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_destroy: STRING
- do
- if attached cb_destroy as int_cb then
- Result := int_cb.item([Current])
- else
- Result := "IUP_DEFAULT"
- end
- end
- feature {NONE}
- -- For callbacks
- cb_map: detachable FUNCTION[TUPLE[IUP_PROGRESS_BAR], STRING]
- cb_unmap: detachable FUNCTION[TUPLE[IUP_PROGRESS_BAR], STRING]
- cb_destroy: detachable FUNCTION[TUPLE[IUP_PROGRESS_BAR], STRING]
- -- Internals
- int_progress_bar: POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupProgressBar();"
- end
- invariant
- max > min
- end
- -- 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.
|