123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- class IUP_LINK
- -- Creates a label that displays an underlined clickable text. It inherits from
- -- IUP_LABEL. When the cursor is over the text, it is changed to the HAND
- -- cursor. By default the text color (fore ground color) is the global
- -- attribute LINKFGCOLOR.
- --
- -- If the callback is not defined the iup_help function is called with the given
- -- URL.
- --
- -- The IUP_LABEL callbacks BUTTON_CB, ENTERWINDOW_CB and LEAVEWINDOW_CB are
- -- used internally.
- inherit
- IUP_LABEL
- redefine
- execute_click
- end
- create {ANY}
- link
- feature {ANY}
- link (url, title: STRING)
- -- Make a link widget.
- --
- -- url: the destination address of the link. Can be any text. If IupHelp
- -- is used should be a valid URL. It can be Void. It will set the URL
- -- attribute.
- -- title: Text to be shown on the link. It can be Void. It will set the
- -- TITLE attribute.
- local
- a_link: POINTER
- do
- a_link := int_link (get_pointer(url.to_c), get_pointer(title.to_c))
- set_widget(a_link)
- end
-
- -- Attributes
- set_url (state: BOOLEAN)
- -- If set to "False" disables the link. The default value is "True".
- do
- iup_open.set_attribute(Current, "URL", boolean_to_yesno(state))
- end
- -- Callbacks
- set_cb_click (act: detachable FUNCTION[TUPLE[IUP_LINK, STRING], STRING])
- -- Action generated when the link is activated.
- -- ih: identifier of the element that activated the event.
- -- url: the destination address of the link.
- --
- -- Returns: IUP_CLOSE will be processed. If returns IUP_DEFAULT or it is
- -- not defined, the iup_help function will be called.
- local
- operation: INTEGER
- do
- cb_click := act
-
- if cb_click /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "ACTION", "Fns", operation)
- end
- feature {IUP}
- execute_click (url: STRING): STRING
- do
- if attached cb_click as int_cb then
- Result := int_cb.item([Current, url])
- else
- Result := "IUP_DEFAULT"
- end
- end
- feature {NONE}
- -- For callback
-
- cb_click: detachable FUNCTION[TUPLE[IUP_LINK, STRING], STRING]
- -- Internals
- int_link (url, title: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupLink ($url, $title);"
- 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.
|