123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- class IUP_MESSAGE_DIALOG
- -- Creates the Message Dialog element. It is a predefined dialog for displaying
- -- a message. The dialog can be shown with the IupPopup function only.
- --
- -- The IupMessageDlg is a native pre-defined dialog not altered by
- -- IupSetLanguage.
- --
- -- In Windows the position (x,y) used in popup is ignored and the dialog is
- -- always centered on screen.
- --
- -- The IUP_MESSAGE function simply creates and popup a IUP_MESSAGE_DIALOG.
- --
- -- In Windows each different dialog type is always associated with a different
- -- beep sound.
- --
- -- In Windows, if PARENTDIALOG is specified then it will be modal relative only
- -- to its parent.
- inherit
- IUP_WIDGET
- redefine
- execute_help
- end
- IUP_WIDGET_TITLE
- IUP_WIDGET_POPUP
- IUP_WIDGET_ICON
- IUP_WIDGET_PARENT_DIALOG
- create {ANY}
- message_dialog
- feature {ANY}
- message_dialog
- -- New message dialog.
- local
- a_message_dialog: POINTER
- do
- a_message_dialog := int_message_dialog
- set_widget(a_message_dialog)
- end
- -- Attributes
- set_default_button (id: INTEGER)
- -- Number of the default button. Can be "1", "2" or "3". "2" is valid
- -- only for "RETRYCANCEL", "OKCANCEL" and "YESNO" button configurations.
- -- "3" is valid only for "YESNOCANCEL". Default: "1".
- require
- id >= 1
- id <= 3
- do
- iup_open.set_attribute(Current, "BUTTONDEFAULT", id.out)
- end
- set_buttons (buttons: STRING)
- -- Buttons configuration. Can have values: "OK", "OKCANCEL",
- -- "RETRYCANCEL", "YESNO", or "YESNOCANCEL". Default: "OK". Additionally
- -- the "Help" button is displayed if the HELP_CB callback is defined.
- require
- are_valid_buttons(buttons)
- do
- iup_open.set_attribute(Current, "BUTTONS", buttons)
- end
- set_dialog_type (type: STRING)
- -- Type of dialog defines which icon will be displayed besides the
- -- message text. Can have values: "MESSAGE" (No Icon), "ERROR"
- -- (Stop-sign), "WARNING" (Exclamation-point), "QUESTION"
- -- (Question-mark) or "INFORMATION" (Letter "i"). Default: "MESSAGE".
- require
- is_valid_type(type)
- do
- iup_open.set_attribute(Current, "DIALOGTYPE", type)
- end
- set_value (text: STRING)
- -- Message text.
- do
- iup_open.set_attribute(Current, "VALUE", text)
- end
- get_button_response: INTEGER
- -- Number of the pressed button. Can be "1", "2" or "3". Default: "1".
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "BUTTONRESPONSE")
- if str.is_integer then
- Result := str.to_integer
- end
- end
- -- Callbacks
- set_cb_help (act: detachable PROCEDURE[TUPLE[IUP_MESSAGE_DIALOG]])
- -- 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
- -- Validations
- are_valid_buttons(buttons: STRING): BOOLEAN
- do
- if buttons.is_equal("OK") or
- buttons.is_equal("OKCANCEL") or
- buttons.is_equal("RETRYCANCEL") or
- buttons.is_equal("YESNO") or
- buttons.is_equal("YESNOCANCEL") then
- Result := True
- else
- Result := False
- end
- end
- is_valid_type(type: STRING): BOOLEAN
- do
- if type.is_equal("MESSAGE") or
- type.is_equal("ERROR") or
- type.is_equal("WARNING") or
- type.is_equal("QUESTION") or
- type.is_equal("INFORMATION") then
- Result := True
- else
- Result := False
- end
- end
- feature {IUP}
- -- Common callbacks
- execute_help
- do
- if attached cb_help as int_cb then
- int_cb.call([Current])
- end
- end
-
- feature {NONE}
- -- For callback
- cb_help: detachable PROCEDURE[TUPLE[IUP_MESSAGE_DIALOG]]
- -- Internals
- int_message_dialog: POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupMessageDlg();"
- 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.
|