12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133 |
- 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_WIDGET_TEXT_CARET
- IUP_WIDGET_TEXT_COMMON
- IUP_WIDGET_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_widget_name
- -- 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.out
- 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.out)
- 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.out)
- 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.out)
- 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.out, 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.out)
- 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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
- 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
- execute_getfocus: STRING
- do
- if attached cb_getfocus as int_cb then
- Result := int_cb.item([Current])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_killfocus: STRING
- do
- if attached cb_killfocus as int_cb then
- Result := int_cb.item([Current])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_enterwindow: STRING
- do
- if attached cb_enterwindow as int_cb then
- Result := int_cb.item([Current])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_leavewindow: STRING
- do
- if attached cb_leavewindow as int_cb then
- Result := int_cb.item([Current])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_k_any (c: INTEGER): STRING
- do
- if attached cb_k_any as int_cb then
- Result := int_cb.item([Current, c])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_help
- do
- if attached cb_help as int_cb then
- int_cb.call([Current])
- end
- end
- execute_action_fnsii (text: STRING; item, state: INTEGER): STRING
- do
- if attached cb_action as int_cb then
- Result := int_cb.item([Current, text, item, state])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_button (btn, pressed, x, y: INTEGER; status: STRING): STRING
- do
- if attached cb_button as int_cb then
- Result := int_cb.item([Current, btn, pressed, x, y, status])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_caret (lin, col, pos: INTEGER): STRING
- do
- if attached cb_caret as int_cb then
- Result := int_cb.item([Current, lin, col, pos])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_dblclick (item: INTEGER; text: STRING): STRING
- do
- if attached cb_dblclick as int_cb then
- Result := int_cb.item([Current, item, text])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_dragdrop (drag_id, drop_id, isshift, iscontrol: INTEGER): STRING
- do
- if attached cb_dragdrop as int_cb then
- Result := int_cb.item([Current, drag_id, drop_id, isshift, iscontrol])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_dropdown (state: INTEGER): STRING
- do
- if attached cb_dropdown as int_cb then
- Result := int_cb.item([Current, state])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_dropfiles (filename: STRING; num: INTEGER; x: INTEGER; y: INTEGER): STRING
- do
- if attached cb_dropfiles as int_cb then
- Result := int_cb.item([Current, filename, num, x, y])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_edit (c: INTEGER; new_value: STRING): STRING
- do
- if attached cb_edit as int_cb then
- Result := int_cb.item([Current, c, new_value])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_motion (x, y: INTEGER; status: STRING): STRING
- do
- if attached cb_motion as int_cb then
- Result := int_cb.item([Current, x, y, status])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_multiselect (value: STRING): STRING
- do
- if attached cb_multiselect as int_cb then
- Result := int_cb.item([Current, value])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_valuechanged: STRING
- do
- if attached cb_valuechanged 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_LIST], STRING]
- cb_unmap: detachable FUNCTION[TUPLE[IUP_LIST], STRING]
- cb_destroy: detachable FUNCTION[TUPLE[IUP_LIST], STRING]
- cb_getfocus: detachable FUNCTION[TUPLE[IUP_LIST], STRING]
- cb_killfocus: detachable FUNCTION[TUPLE[IUP_LIST], STRING]
- cb_enterwindow: detachable FUNCTION[TUPLE[IUP_LIST], STRING]
- cb_leavewindow: detachable FUNCTION[TUPLE[IUP_LIST], STRING]
- cb_k_any: detachable FUNCTION[TUPLE[IUP_LIST, INTEGER], STRING]
- cb_help: detachable PROCEDURE[TUPLE[IUP_LIST]]
- cb_action: detachable FUNCTION[TUPLE[IUP_LIST, STRING, INTEGER, INTEGER], STRING]
- cb_button: detachable FUNCTION[TUPLE[IUP_LIST, INTEGER, INTEGER, INTEGER, INTEGER, STRING], STRING]
- cb_caret: detachable FUNCTION[TUPLE[IUP_LIST, INTEGER, INTEGER, INTEGER], STRING]
- cb_dblclick: detachable FUNCTION[TUPLE[IUP_LIST, INTEGER, STRING], STRING]
- cb_dragdrop: detachable FUNCTION[TUPLE[IUP_LIST, INTEGER, INTEGER, INTEGER, INTEGER], STRING]
- cb_dropdown: detachable FUNCTION[TUPLE[IUP_LIST, INTEGER], STRING]
- cb_dropfiles: detachable FUNCTION[TUPLE[IUP_LIST, STRING, INTEGER, INTEGER, INTEGER], STRING]
- cb_edit: detachable FUNCTION[TUPLE[IUP_LIST, INTEGER, STRING], STRING]
- cb_motion: detachable FUNCTION[TUPLE[IUP_LIST, INTEGER, INTEGER, STRING], STRING]
- cb_multiselect: detachable FUNCTION[TUPLE[IUP_LIST, STRING], STRING]
- cb_valuechanged: detachable FUNCTION[TUPLE[IUP_LIST], STRING]
- -- Internals
-
- int_list (wgt: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupList ($wgt);"
- end
- 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.
|