1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057 |
- class IUP_LIST
- -- Creates an interface element that displays a list of items. The list can be
- -- visible or can be dropped down. It also can have an edit box for text input.
- -- So it is a 4 in 1 element. In native systems the dropped down case is called
- -- Combo Box.
- --
- -- Text is always left aligned.
- --
- -- When the list has focus use the arrow keys to move focus from one item to
- -- another. When DROPDOWN=Yes use the Alt+Down key combination to show the
- -- dropdown list. While the dropdown is shown the arrow key may change the
- -- current value depending on the system, on Windows will directly change the
- -- current value, on GTK will change the current value only if Enter is pressed.
- -- In all systems the dropdown list is closed by using the Alt+Up key
- -- combination, or by pressing Enter or Esc keys ( while the dropdown list
- -- dropdown list the DEFAULTENTER and DEFAULTESC buttons will not be called
- -- (fixed in 3.14)).
- --
- -- The GETFOCUS_CB and KILLFOCUS_CB callbacks behave differently depending on
- -- the list configuration and on the native system:
- --
- -- If DROPDOWN=NO and EDITBOX=YES, then the list never gets the focus, the
- -- callbacks are called only when the edit box is clicked.
- -- In Motif if DROPDOWN=YES then when the dropdown button is clicked the list
- -- looses its focus and when the dropped list is closed the list regain the
- -- focus, also when that happen if the list looses its focus to another control
- -- the kill focus callback is not called.
- -- In GTK, if DROPDOWN=YES and EDITBOX=NO, both callbacks are called only when
- -- navigating with the keyboard (tip: if you need those callbacks with mouse
- -- navigation set EDITBOX=YES and READONLY=YES). Also in GTK, if DROPDOWN=YES
- -- and EDITBOX=YES then when the dropdown button is clicked the list looses its
- -- focus and it gets it back only if the edit box is clicked.
- --
- -- In Windows, if EDITBOX=YES then the tooltips are shown only when the cursor
- -- is near the control border or at the dropdown arrow. Also the selection and
- -- caret attributes are not preserved if the list loses its focus, or in other
- -- words these attributes are only useful in Windows if the list has the focus.
- --
- -- IMPORTANT: In Windows when DROPDOWN=Yes the vertical size is controlled by
- -- the system, and has the height just right to include the borders and the
- -- text. So the User height from RASTERSIZE or SIZE will be always ignored.
- --
- -- In Windows, list items are limited to 255 pixels height.
- --
- -- In GTK older than 2.12, the editbox of a dropdown will not follow the list
- -- attributes: FONT, BGCOLOR, FGCOLOR and SPACING.
- --
- -- Clicking and dragging a item: if SHOWDRAGDROP=Yes starts a drag. When mouse
- -- is released, the DRAGDROP_CB callback is called. If the callback does not
- -- exist or if it returns IUP_CONTINUE then the item is moved to the new
- -- position. If Ctrl is pressed then the node is copied instead of moved. In
- -- Windows and GTK, drag is performed with the left mouse button. In Motif, the
- -- middle mouse button is used to drag. (since 3.7)
- inherit
- IUP_WIDGET
- undefine
- execute_dragbegin,
- execute_dragdatasize,
- execute_dragdata,
- execute_dragend,
- execute_dropdata,
- execute_dropmotion
- redefine
- execute_map,
- execute_unmap,
- execute_destroy,
- execute_getfocus,
- execute_killfocus,
- execute_enterwindow,
- execute_leavewindow,
- execute_k_any,
- execute_help,
- execute_action_fnsii,
- execute_caret,
- execute_dblclick,
- execute_dragdrop,
- execute_dropdown,
- execute_edit,
- execute_multiselect,
- execute_motion,
- execute_button,
- execute_dropfiles,
- execute_valuechanged
- end
- IUP_TEXT_CARET
- IUP_TEXT_COMMON
- IUP_TEXT_SELECTION
- IUP_WIDGET_BGCOLOR
- IUP_WIDGET_FGCOLOR
- IUP_WIDGET_SIZE
- IUP_WIDGET_ACTIVE
- IUP_WIDGET_FONT
- IUP_WIDGET_EXPAND
- IUP_WIDGET_SCREENPOSITION
- IUP_WIDGET_POSITION
- IUP_WIDGET_MAXMIN_SIZE
- IUP_WIDGET_TIP
- IUP_WIDGET_RASTERSIZE
- IUP_WIDGET_USERSIZE
- IUP_WIDGET_ZORDER
- IUP_WIDGET_VISIBLE
- IUP_WIDGET_CHILD
- IUP_WIDGET_SPACING
- redefine
- set_spacing
- end
- IUP_WIDGET_FOCUS
- IUP_WIDGET_PROPAGATEFOCUS
- IUP_WIDGET_NAME
- IUP_DRAG_AND_DROP
- IUP_WIDGET_CUSTOM_ATTRIBUTES
- create {ANY}
- list
- feature {ANY}
- list
- -- Create an empty list.
- local
- a_list, p: POINTER
- do
- a_list := int_list(p)
- set_widget(a_list)
- end
- -- Attributes
- set_auto_hide (state: BOOLEAN)
- -- Scrollbars are shown only if they are necessary. Default: "True".
- do
- iup_open.set_attribute(Current, "AUTOHIDE", boolean_to_yesno(state))
- end
- set_auto_redraw (state: BOOLEAN)
- -- [Windows] (non inheritable): automatically redraws the list when
- -- something has change. Set to False to add many items to the list
- -- without updating the display. Default: "True".
- do
- iup_open.set_attribute(Current, "AUTOREDRAW", boolean_to_yesno(state))
- end
- set_can_focus (state: BOOLEAN)
- -- (creation only) (non inheritable): enables the focus traversal of the
- -- control. In Windows the control will still get the focus when clicked.
- -- Default: True.
- do
- iup_open.set_attribute(Current, "CANFOCUS", boolean_to_yesno(state))
- end
- get_count: INTEGER
- -- (read-only) (non inheritable): returns the number of items. Before
- -- mapping it counts the number of non NULL items before the first NULL
- -- item.
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "COUNT")
- if str.is_integer then
- Result := str.to_integer
- end
- end
- set_drag_drop_list (state: BOOLEAN)
- -- (non inheritable): enable or disable the drag and drop of items
- -- between lists, in the same IUP application. Drag & Drop attributes
- -- must be set in order to activate the drag & drop support. On the other
- -- hand, it is not necessary to register drag & drop callbacks.
- -- Default: False.
- do
- iup_open.set_attribute(Current, "DRAGDROPLIST", boolean_to_yesno(state))
- end
- set_drop_files_target (state: BOOLEAN)
- -- [Windows and GTK Only] (non inheritable): Enable or disable the drop
- -- of files. Default: NO, but if DROPFILES_CB is defined when the element
- -- is mapped then it will be automatically enabled.
- do
- iup_open.set_attribute(Current, "DROPFILESTARGET", boolean_to_yesno(state))
- end
- set_drop_down (state: BOOLEAN)
- -- (creation only): Changes the appearance of the list for the user: only
- -- the selected item is shown beside a button with the image of an arrow
- -- pointing down. To select another option, the user must press this
- -- button, which displays all items in the list. Can be "True" or "False".
- -- Default "False".
- do
- iup_open.set_attribute(Current, "DROPDOWN", boolean_to_yesno(state))
- end
- set_drop_expand (state: BOOLEAN)
- -- [Windows Only]: When DROPDOWN=Yes the size of the dropped list will
- -- expand to include the largest text. Can be "YES" or "NO".
- -- Default: "True".
- do
- iup_open.set_attribute(Current, "DROPEXPAND", boolean_to_yesno(state))
- end
- set_edit_box (state: BOOLEAN)
- -- (creation only): Adds an edit box to the list. Can be "True" or
- -- "False". Default "False".
- do
- iup_open.set_attribute(Current, "EDITBOX", boolean_to_yesno(state))
- end
- set_image_at (imagename: STRING; position: INTEGER)
- -- (non inheritable) (write only) [Windows and GTK Only]: image name to
- -- be used in the specified item, where position is the specified item
- -- starting at 1. The item must already exist. Use set_attribute_handle
- -- to associate an image to a name. See also IupImage. The image is
- -- always displayed at the left of the text and only when SHOWIMAGE=Yes.
- -- When EDITBOX=Yes the image is not display at the edit box. Images
- -- don't need to have the same size. In Windows, list items are limited
- -- to 255 pixels height.
- require
- position > 0
- local
- str: STRING
- do
- str := "IMAGE" + position.to_string
- iup_open.set_attribute(Current, str, imagename)
- end
- set_multiple (state: BOOLEAN)
- -- (creation only): Allows selecting several items simultaneously
- -- (multiple list). Default: "False". Only valid when EDITBOX=False and
- -- DROPDOWN=False.
- do
- iup_open.set_attribute(Current, "MULTIPLE", boolean_to_yesno(state))
- end
- set_scroll_bar (state: BOOLEAN)
- -- (creation only): Associates automatic scrollbars to the list when
- -- DROPDOWN=False. Can be: "True" or "False" (none). Default: "True". For
- -- all systems, when SCROLLBAR=True the natural size will always include
- -- its size even if the native system hides the scrollbars. If
- -- AUTOHIDE=True scrollbars are shown only if they are necessary, by
- -- default AUTOHIDE=True. In Motif, SCROLLBAR=False is not supported and
- -- if EDITBOX=True the horizontal scrollbar is never shown.
- --
- -- When DROPDOWN=True the scrollbars are system dependent, and do NOT
- -- depend on the SCROLLBAR or AUTOHIDE attributes. Usually the scrollbars
- -- are shown if necessary. In GTK, scrollbars are never shown and all
- -- items are always visible. In Motif, the horizontal scrollbar is never
- -- shown. In Windows, if DROPEXPAND=True then the horizontal scrollbar is
- -- never shown.
- do
- iup_open.set_attribute(Current, "SCROLLBAR", boolean_to_yesno(state))
- end
- set_show_drag_drop (state: BOOLEAN)
- -- (creation only) (non inheritable): enables the internal drag and drop
- -- of items, and enables the DRAGDROP_CB callback. Default: "False".
- -- Works only if DROPDOWN=False and MULTIPLE=False.ç
- do
- iup_open.set_attribute(Current, "SHOWDRAGDROP", boolean_to_yesno(state))
- end
- set_show_drop_down (state: BOOLEAN)
- -- (write-only): opens or closes the dropdown list. Can be "True" or
- -- "False". Valid only when DROPDOWN=True. Ignored if set before map.
- do
- iup_open.set_attribute(Current, "SHOWDROPDOWN", boolean_to_yesno(state))
- end
- set_show_image (state: BOOLEAN)
- -- (creation only) [Windows and GTK Only]: enables the use of an image
- -- for each item. Can be "True" or "False". Ignored if set before map.
- do
- iup_open.set_attribute(Current, "SHOWIMAGE", boolean_to_yesno(state))
- end
- set_sort (state: BOOLEAN)
- -- (creation only): force the list to be alphabetically sorted. When
- -- using insert_item or append_item the position will be ignored.
- do
- iup_open.set_attribute(Current, "SORT", boolean_to_yesno(state))
- end
- set_top_item (item: STRING)
- -- (write-only): position the given item at the top of the list or near
- -- to make it visible. Valid only when DROPDOWN=False.
- do
- iup_open.set_attribute(Current, "TOPITEM", item)
- end
- set_spacing (value: INTEGER)
- -- internal padding for each item. Notice that vertically the distance
- -- between each item will be actually 2x the spacing. It also affects the
- -- horizontal margin of the item. In Windows, the text is aligned at the
- -- top left of the item always. Valid only when DROPDOWN=False.
- do
- Precursor (value)
- end
- set_value (value: STRING)
- -- (non inheritable): Depends on the DROPDOWN+EDITBOX
- -- combination:
- --
- -- EDITBOX=True: Text entered by the user.
- -- DROPDOWN=True or MULTIPLE=False: Integer number representing the
- -- selected item in the list (begins at 1). It can be zero if there is no
- -- selected item. The value can be Void for no item selected (In Motif
- -- when DROPDOWN=True there is always an item selected, except only when
- -- the list is empty).
- -- MULTIPLE=True: Sequence of '+' and '-' symbols indicating the state of
- -- each item. When setting this value, the user must provide the same
- -- amount of '+' and '-' symbols as the amount of items in the list,
- -- otherwise the specified items will be deselected.
- --
- -- Observations: always returns a non Void value, event if the list is
- -- empty or the text box is empty. It can be an empty string when no
- -- item selected.
- do
- iup_open.set_attribute(Current, "VALUE", value)
- end
- get_value: STRING
- -- Return the selected value. See set_value.
- do
- Result := iup_open.get_attribute(Current, "VALUE")
- end
- set_value_string (value: STRING)
- -- Search for the first item with the same string and select it.
- -- Works only when EDITBOX=False and DROPDOWN=True and MULTIPLE=False.
- do
- iup_open.set_attribute(Current, "VALUESTRING", value)
- end
- get_value_string (position: INTEGER): STRING
- -- Return the selected item.
- -- Works only when EDITBOX=False and DROPDOWN=True and MULTIPLE=False.
- do
- Result := iup_open.get_attribute(Current, "VALUESTRING")
- end
- set_value_masked (value: STRING)
- -- (non inheritable) (write-only): sets VALUE but first checks if it is
- -- validated by MASK. If not does nothing. Works only when EDITBOX=True.
- do
- iup_open.set_attribute(Current, "VALUEMASKED", value)
- end
- set_visible_items (value: INTEGER)
- -- [Windows and Motif Only]: Number of items that are visible when
- -- DROPDOWN=True is used for the dropdown list. Default: 5.
- require
- value > 0
- do
- iup_open.set_attribute(Current, "VISIBLEITEMS", value.to_string)
- end
- set_visible_columns (value: INTEGER)
- -- Defines the number of visible columns for the Natural Size, this means
- -- that will act also as minimum number of visible columns. It uses a
- -- wider character size then the one used for the SIZE attribute so
- -- strings will fit better without the need of extra columns. Set this
- -- attribute to speed Natural Size computation for very large lists.
- require
- value > 0
- do
- iup_open.set_attribute(Current, "VISIBLECOLUMNS", value.to_string)
- end
- set_visible_lines (value: INTEGER)
- -- When DROPDOWN=False defines the number of visible lines for the
- -- Natural Size, this means that will act also as minimum number of
- -- visible lines.
- require
- value > 0
- do
- iup_open.set_attribute(Current, "VISIBLELINES", value.to_string)
- end
- -- SCROLLTO, SCROLLTOPOS: Skip since don't have sense here.
- -- Operations
- add_item_at (item: STRING; position: INTEGER)
- -- Add an item. If "position" is between the first and the last item, the
- -- current item is replaced. The effect is the same as removing the old
- -- item and inserting a new one at the old position.
- -- If "position=COUNT+1" then it is appended after the last item.
- require
- position > 0
- do
- iup_open.set_attribute(Current, position.to_string, item)
- end
- append_item (item: STRING)
- -- (write-only): inserts an item after the last item. Ignored if set
- -- before map.
- do
- iup_open.set_attribute(Current, "APPENDITEM", item)
- end
- insert_item_at (item: STRING; position: INTEGER)
- -- (write-only): inserts an item before the given position. position
- -- starts at 1. If position=COUNT+1 then it will append after the last
- -- item. Ignored if out of bounds. Ignored if set before map.
- require
- position > 0
- do
- iup_open.set_attribute_id(Current, "INSERTITEM", position, item)
- end
- remove_item_at (position: INTEGER)
- -- (write-only): removes the given position. position starts at 1.
- -- Ignored if set before map.
- do
- iup_open.set_attribute(Current, "REMOVEITEM", position.to_string)
- end
- remove_all
- -- Removes all the items.
- do
- iup_open.set_attribute(Current, "REMOVEITEM", "ALL")
- end
- -- Coordination to pos
- convert_xt_to_pos (x, y: INTEGER): INTEGER
- -- Converts a (x,y) coordinate in an item position.
- -- Returns: the position starting at 1. If fails returns -1.
- do
- Result := iup_open.iup_convert_xy_to_pos (Current, x, y)
- end
- -- Callbacks
- -- Common
- set_cb_map (act: FUNCTION[TUPLE[IUP_LIST], 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: FUNCTION[TUPLE[IUP_LIST], 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: FUNCTION[TUPLE[IUP_LIST], 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
- set_cb_get_focus (act: FUNCTION[TUPLE[IUP_LIST], STRING])
- -- Action generated when an element is given keyboard focus.
- -- This callback is called after the KILLFOCUS_CB of the element
- -- that loosed the focus. The {IUP}.get_focus function during the
- -- callback returns the element that loosed the focus.
- local
- operation: INTEGER
- do
- cb_getfocus := act
- if cb_getfocus /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "GETFOCUS_CB", "NONEEDED", operation)
- end
- set_cb_kill_focus (act: FUNCTION[TUPLE[IUP_LIST], STRING])
- -- Action generated when an element loses keyboard focus. This
- -- callback is called before the GETFOCUS_CB of the element that
- -- gets the focus.
- local
- operation: INTEGER
- do
- cb_killfocus := act
- if cb_killfocus /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "KILLFOCUS_CB", "NONEEDED", operation)
- end
- set_cb_enter_window (act: FUNCTION[TUPLE[IUP_LIST], STRING])
- -- Action generated when the mouse enters the native element.
- local
- operation: INTEGER
- do
- cb_enterwindow := act
- if cb_enterwindow /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "ENTERWINDOW_CB", "NONEEDED", operation)
- end
- set_cb_leave_window (act: FUNCTION[TUPLE[IUP_LIST], STRING])
- -- Action generated when the mouse leaves the native element.
- local
- operation: INTEGER
- do
- cb_leavewindow := act
- if cb_leavewindow /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "LEAVEWINDOW_CB", "NONEEDED", operation)
- end
- set_cb_k_any (act: FUNCTION[TUPLE[IUP_LIST, INTEGER], STRING])
- -- Action generated when a keyboard event occurs.
- -- IUP_WIDGET the element that activated the event.
- -- INTEGER identifier of typed key. Please refer to the Keyboard
- -- Codes table for a list of possible values.
- --
- -- Returns: If IUP_IGNORE is returned the key is ignored and not
- -- processed by the control and not propagated. If returns
- -- IUP_CONTINUE, the key will be processed and the event will be
- -- propagated to the parent of the element receiving it, this is
- -- the default behavior. If returns IUP_DEFAULT the key is processed
- -- but it is not propagated. IUP_CLOSE will be processed.
- local
- operation: INTEGER
- do
- cb_k_any := act
- if cb_k_any /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "K_ANY", "NONEEDED", operation)
- end
- set_cb_help (act: PROCEDURE[TUPLE[IUP_LIST]])
- -- Action generated when the user press F1 at a control. In Motif
- -- is also activated by the Help button in some workstations
- -- keyboard.
- -- Returns: IUP_CLOSE will be processed.
- local
- operation: INTEGER
- do
- cb_help := act
- if cb_help /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "HELP_CB", "NONEEDED", operation)
- end
- -- Extra
- set_cb_action (act: FUNCTION[TUPLE[IUP_LIST, STRING, INTEGER, INTEGER], STRING])
- -- Action generated when the state of an item in the list is changed.
- -- Also provides information on the changed item:
- -- ih: identifier of the element that activated the event.
- -- text: Text of the changed item.
- -- item: Number of the changed item starting at 1.
- -- state: Equal to 1 if the option was selected or to 0 if the option was
- -- deselected.
- --
- -- The state=0 is simulated internally by IUP in all systems. If you add
- -- or remove items to/from the list and you count on the state=0 value,
- -- then after adding/removing items set the VALUE attribute to ensure
- -- proper state=0 value.
- local
- operation: INTEGER
- do
- cb_action := act
- if cb_action /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "ACTION", "Fnsii", operation)
- end
- set_cb_button (act: FUNCTION[TUPLE[IUP_LIST, INTEGER, INTEGER, INTEGER, INTEGER, STRING], STRING])
- -- Action generated when any mouse button is pressed and when it is
- -- released. Both calls occur before the ACTION callback when button 1 is
- -- being used.
- --
- -- IUP_BUTTON: identifies the element that activated the event.
- -- button: identifies the activated mouse button:
- --
- -- 1 - left mouse button (button 1);
- -- 2 - middle mouse button (button 2);
- -- 3 - right mouse button (button 3).
- --
- -- pressed: indicates the state of the button:
- --
- -- 0 - mouse button was released;
- -- 1 - mouse button was pressed.
- --
- -- x, y: position in the canvas where the event has occurred, in pixels.
- --
- -- status: status of the mouse buttons and some keyboard keys at the
- -- moment the event is generated. The following IUP features must be used
- -- for verification:
- --
- -- is_shift(status)
- -- is_control(status)
- -- is_button_1(status)
- -- is_button_2(status)
- -- is_button_3(status)
- -- is_button_4(status)
- -- is_button_5(status)
- -- is_double(status)
- -- is_alt(status)
- -- is_sys(status)
- --
- -- Returns: IUP_CLOSE will be processed. On some controls if IUP_IGNORE
- -- is returned the action is ignored (this is system dependent).
- local
- operation: INTEGER
- do
- cb_button := act
- if cb_button /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "BUTTON_CB", "NONEEDED", operation)
- end
- set_cb_caret (act: FUNCTION[TUPLE[IUP_LIST, INTEGER, INTEGER, INTEGER], STRING])
- -- Action generated when the caret/cursor position is changed. Valid
- -- only when EDITBOX=True.
- --
- -- ih: identifier of the element that activated the event.
- -- lin, col: line and column number (start at 1).
- -- pos: 0 based character position.
- --
- -- For lists lin is always 1, and pos is always "col-1".
- local
- operation: INTEGER
- do
- cb_caret := act
- if cb_caret /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "CARET_CB", "NONEEDED", operation)
- end
- set_cb_double_click (act: FUNCTION[TUPLE[IUP_LIST, INTEGER, STRING], STRING])
- -- Action generated when the user double click an item. Called only when
- -- DROPDOWN=False.
- -- ih: identifier of the element that activated the event.
- -- item: Number of the selected item starting at 1.
- -- text: Text of the selected item.
- local
- operation: INTEGER
- do
- cb_dblclick := act
- if cb_dblclick /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "DBLCLICK_CB", "NONEEDED", operation)
- end
- set_cb_drag_drop (act: FUNCTION[TUPLE[IUP_LIST, INTEGER, INTEGER, INTEGER, INTEGER], STRING])
- -- Action generated when an internal drag and drop is executed. Only
- -- active if SHOWDRAGDROP=True.
- --
- -- ih: identifier of the element that activated the event.
- -- drag_id: Identifier of the clicked item where the drag start.
- -- drop_id: Identifier of the clicked item where the drop were executed.
- -- -1 indicates a drop in a blank area.
- -- isshift: flag indicating the shift key state.
- -- iscontrol: flag indicating the control key state.
- --
- -- Returns: if returns IUP_CONTINUE, or if the callback is not defined
- -- and SHOWDRAGDROP=True, then the item is moved to the new position. If
- -- Ctrl is pressed then the item is copied instead of moved.
- local
- operation: INTEGER
- do
- cb_dragdrop := act
- if cb_dragdrop /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "DRAGDROP_CB", "NONEEDED", operation)
- end
- set_cb_drop_down (act: FUNCTION[TUPLE[IUP_LIST, INTEGER], STRING])
- -- Action generated when the list of a dropdown is shown or hidden.
- -- Called only when DROPDOWN=True.
- -- ih: identifier of the element that activated the event.
- -- state: state of the list 1=shown, 0=hidden.
- local
- operation: INTEGER
- do
- cb_dropdown := act
- if cb_dropdown /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "DROPDOWN_CB", "NONEEDED", operation)
- end
- set_cb_drop_files (act: FUNCTION[TUPLE[IUP_LIST, STRING, INTEGER, INTEGER, INTEGER], STRING])
- -- Action called when a file is "dropped" into the control. When several
- -- files are dropped at once, the callback is called several times, once
- -- for each file.
- --
- -- If defined after the element is mapped then the attribute
- -- DROPFILESTARGET must be set to True. [Windows and GTK Only]
- --
- -- ih: identifier of the element that activated the event.
- -- filename: Name of the dropped file.
- -- num: Number index of the dropped file. If several files are dropped,
- -- num is the index of the dropped file starting from "total-1" to "0".
- -- x: X coordinate of the point where the user released the mouse button.
- -- y: Y coordinate of the point where the user released the mouse button.
- --
- -- Returns: If IUP_IGNORE is returned the callback will NOT be called for
- -- the next dropped files, and the processing of dropped files will be
- -- interrupted.
- local
- operation: INTEGER
- do
- cb_dropfiles := act
- if cb_dropfiles /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "DROPFILES_CB", "NONEEDED", operation)
- end
- set_cb_edit (act: FUNCTION[TUPLE[IUP_LIST, INTEGER, STRING], STRING])
- -- Action generated when the text in the text box is manually changed by
- -- the user, but before its value is actually updated. Valid only when
- -- EDITBOX=True.
- --
- -- ih: identifier of the element that activated the event.
- -- c: valid alphanumeric character or 0.
- -- new_value: Represents the new text value.
- --
- -- Returns: IUP_CLOSE will be processed, but the change will be ignored.
- -- If IUP_IGNORE, the system will ignore the new value. If c is valid and
- -- returns a valid alpha numeric character, this new character will be
- -- used instead. The VALUE attribute can be changed only if IUP_IGNORE is
- -- returned.
- local
- operation: INTEGER
- do
- cb_edit := act
- if cb_edit /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "EDIT_CB", "NONEEDED", operation)
- end
- set_cb_motion (act: FUNCTION[TUPLE[IUP_LIST, INTEGER, INTEGER, STRING], STRING])
- -- Action generated when the mouse moves.
- -- ih: identifier of the element that activated the event.
- -- x, y: position in the canvas where the event has occurred, in pixels.
- -- status: status of mouse buttons and certain keyboard keys at the
- -- moment the event was generated. The same macros used for BUTTON_CB can
- -- be used for this status.
- local
- operation: INTEGER
- do
- cb_motion := act
- if cb_motion /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "MOTION_CB", "NONEEDED", operation)
- end
- set_cb_multi_select (act: FUNCTION[TUPLE[IUP_LIST, STRING], STRING])
- -- Action generated when the state of an item in the multiple selection
- -- list is changed. But it is called only when the interaction is
- -- over.
- --
- -- ih: identifier of the element that activated the event.
- -- value: Similar to the VALUE attribute for a multiple selection list.
- -- Items selected are marked with '+', items deselected are marked with
- -- '-', and non changed items are marked with an 'x'.
- --
- -- This callback is called only when MULTIPLE=True. If this callback is
- -- defined the CHANGE callback will not be called.
- --
- -- The non changed items marked with 'x' are simulated internally by IUP
- -- in all systems. If you add or remove items to/from the list and you
- -- count on the 'x' values, then after adding/removing items set the
- -- VALUE attribute to ensure proper 'x' values.
- local
- operation: INTEGER
- do
- cb_multiselect := act
- if cb_multiselect /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "MULTISELECT_CB", "NONEEDED", operation)
- end
- set_cb_value_changed (act: FUNCTION[TUPLE[IUP_LIST], STRING])
- -- Called after the value was interactively changed by the user.
- local
- operation: INTEGER
- do
- cb_valuechanged := act
- if cb_valuechanged /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "VALUECHANGED_CB", "NONEEDED", operation)
- end
- feature {IUP}
- execute_map: STRING
- do
- Result := cb_map.item([Current])
- end
- execute_unmap: STRING
- do
- Result := cb_unmap.item([Current])
- end
- execute_destroy: STRING
- do
- Result := cb_destroy.item([Current])
- end
- execute_getfocus: STRING
- do
- Result := cb_getfocus.item([Current])
- end
- execute_killfocus: STRING
- do
- Result := cb_getfocus.item([Current])
- end
- execute_enterwindow: STRING
- do
- Result := cb_enterwindow.item([Current])
- end
- execute_leavewindow: STRING
- do
- Result := cb_leavewindow.item([Current])
- end
- execute_k_any (c: INTEGER): STRING
- do
- Result := cb_k_any.item([Current, c])
- end
- execute_help
- do
- cb_help.call([Current])
- end
- execute_action_fnsii (text: STRING; item, state: INTEGER): STRING
- do
- Result := cb_action.item([Current, text, item, state])
- end
- execute_button (btn, pressed, x, y: INTEGER; status: STRING): STRING
- do
- Result := cb_button.item([Current, btn, pressed, x, y, status])
- end
- execute_caret (lin, col, pos: INTEGER): STRING
- do
- Result := cb_caret.item([Current, lin, col, pos])
- end
- execute_dblclick (item: INTEGER; text: STRING): STRING
- do
- Result := cb_dblclick.item([Current, item, text])
- end
- execute_dragdrop (drag_id, drop_id, isshift, iscontrol: INTEGER): STRING
- do
- Result := cb_dragdrop.item([Current, drag_id, drop_id, isshift, iscontrol])
- end
- execute_dropdown (state: INTEGER): STRING
- do
- Result := cb_dropdown.item([Current, state])
- end
- execute_dropfiles (filename: STRING; num: INTEGER; x: INTEGER; y: INTEGER): STRING
- do
- Result := cb_dropfiles.item([Current, filename, num, x, y])
- end
- execute_edit (c: INTEGER; new_value: STRING): STRING
- do
- Result := cb_edit.item([Current, c, new_value])
- end
- execute_motion (x, y: INTEGER; status: STRING): STRING
- do
- Result := cb_motion.item([Current, x, y, status])
- end
- execute_multiselect (value: STRING): STRING
- do
- Result := cb_multiselect.item([Current, value])
- end
- execute_valuechanged: STRING
- do
- Result := cb_valuechanged.item([Current])
- end
-
- feature {}
- -- For callbacks
-
- cb_map: FUNCTION[TUPLE[IUP_LIST], STRING]
- cb_unmap: FUNCTION[TUPLE[IUP_LIST], STRING]
- cb_destroy: FUNCTION[TUPLE[IUP_LIST], STRING]
- cb_getfocus: FUNCTION[TUPLE[IUP_LIST], STRING]
- cb_killfocus: FUNCTION[TUPLE[IUP_LIST], STRING]
- cb_enterwindow: FUNCTION[TUPLE[IUP_LIST], STRING]
- cb_leavewindow: FUNCTION[TUPLE[IUP_LIST], STRING]
- cb_k_any: FUNCTION[TUPLE[IUP_LIST, INTEGER], STRING]
- cb_help: PROCEDURE[TUPLE[IUP_LIST]]
- cb_action: FUNCTION[TUPLE[IUP_LIST, STRING, INTEGER, INTEGER], STRING]
- cb_button: FUNCTION[TUPLE[IUP_LIST, INTEGER, INTEGER, INTEGER, INTEGER, STRING], STRING]
- cb_caret: FUNCTION[TUPLE[IUP_LIST, INTEGER, INTEGER, INTEGER], STRING]
- cb_dblclick: FUNCTION[TUPLE[IUP_LIST, INTEGER, STRING], STRING]
- cb_dragdrop: FUNCTION[TUPLE[IUP_LIST, INTEGER, INTEGER, INTEGER, INTEGER], STRING]
- cb_dropdown: FUNCTION[TUPLE[IUP_LIST, INTEGER], STRING]
- cb_dropfiles: FUNCTION[TUPLE[IUP_LIST, STRING, INTEGER, INTEGER, INTEGER], STRING]
- cb_edit: FUNCTION[TUPLE[IUP_LIST, INTEGER, STRING], STRING]
- cb_motion: FUNCTION[TUPLE[IUP_LIST, INTEGER, INTEGER, STRING], STRING]
- cb_multiselect: FUNCTION[TUPLE[IUP_LIST, STRING], STRING]
- cb_valuechanged: FUNCTION[TUPLE[IUP_LIST], STRING]
- -- Internals
-
- int_list (wgt: POINTER): POINTER
- external "plug_in"
- alias "{
- location: "${sys}/plugins"
- module_name: "iup"
- feature_name: "IupList"
- }"
- end
- end
- -- The MIT License (MIT)
- -- Copyright (c) 2016, 2017 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.
|