123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- class IUP_MENU
- inherit
- IUP_WIDGET
- redefine
- execute_map,
- execute_unmap,
- execute_destroy,
- execute_open,
- execute_menuclose
- end
- IUP_WIDGET_BGCOLOR
- IUP_WIDGET_POPUP
- IUP_WIDGET_NAME
- create {ANY}
- menu_empty,
- menu
- feature {ANY}
- menu_empty
-
- local
- p, a_menu: POINTER
- do
- a_menu := int_empty_menu (p)
- set_widget(a_menu)
- end
-
- menu (col: ARRAY[IUP_MENU_ELEMENT])
-
- local
- i: INTEGER; arg: ARRAY[POINTER]; s: IUP_WIDGET; a_menu: POINTER
- do
- i := col.count
- create arg.make_filled(default_pointer, 1, i + 1)
- i := 0
-
- across
- col as ic
- loop
- i := i + 1
- s := ic.item
- arg.put(s.widget, i)
- end
- a_menu := int_menu (get_pointer(arg.to_c))
- set_widget(a_menu)
- end
-
- set_radio (state: BOOLEAN)
-
-
-
-
- do
- iup_open.set_attribute(Current, "RADIO", boolean_to_yesno(state))
- end
-
-
- append (new_child: IUP_WIDGET): detachable IUP_WIDGET
-
-
-
-
-
- do
- Result := iup_open.iup_append(Current, new_child)
- end
- insert (ref_child: IUP_WIDGET; new_child: IUP_WIDGET): detachable IUP_WIDGET
-
-
-
-
-
- do
- Result := iup_open.iup_insert(Current, ref_child, new_child)
- end
-
- popup_mouse_position: STRING
-
-
- do
- Result := iup_open.popup_predefined_xy(Current, "IUP_MOUSEPOS", "IUP_MOUSEPOS")
- end
- set_popup_alignment (horizontal: STRING; vertical: STRING)
-
-
-
- require
- is_valid_alignment(horizontal, vertical)
- local
- str: STRING
- do
- create str.make_from_string(horizontal)
- str.append_string(":")
- str.append_string(vertical)
-
- iup_open.set_attribute(Current, "POPUPALIGN", str)
- end
-
-
- set_cb_map (act: detachable FUNCTION[TUPLE[IUP_MENU], STRING])
-
- 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_MENU], STRING])
-
- 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_MENU], STRING])
-
- 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_open (act: detachable FUNCTION[TUPLE[IUP_MENU], STRING])
-
- local
- operation: INTEGER
- do
- cb_open := act
- if cb_open /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "OPEN_CB", "NONEEDED", operation)
- end
- set_cb_menu_close (act: detachable FUNCTION[TUPLE[IUP_MENU], STRING])
-
- local
- operation: INTEGER
- do
- cb_menuclose := act
- if cb_menuclose /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "MENUCLOSE_CB", "NONEEDED", operation)
- end
-
- is_valid_alignment (horizontal, vertical: STRING): BOOLEAN
- local
- h, v: BOOLEAN
- do
- if horizontal.is_equal("ALEFT") or
- horizontal.is_equal("ACENTER") or
- horizontal.is_equal("ARIGHT") then
- h := True
- else
- h := False
- end
- if vertical.is_equal("ATOP") or
- vertical.is_equal("ACENTER") or
- vertical.is_equal("ABOTTOM") then
- v := True
- else
- v := False
- end
- if h and v then
- Result := True
- else
- Result := False
- end
- 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_open: STRING
- do
- if attached cb_open as int_cb then
- Result := int_cb.item([Current])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_menuclose: STRING
- do
- if attached cb_menuclose as int_cb then
- Result := int_cb.item([Current])
- else
- Result := "IUP_DEFAULT"
- end
- end
- feature {NONE}
-
-
- cb_map: detachable FUNCTION[TUPLE[IUP_MENU], STRING]
- cb_unmap: detachable FUNCTION[TUPLE[IUP_MENU], STRING]
- cb_destroy: detachable FUNCTION[TUPLE[IUP_MENU], STRING]
- cb_open: detachable FUNCTION[TUPLE[IUP_MENU], STRING]
- cb_menuclose: detachable FUNCTION[TUPLE[IUP_MENU], STRING]
-
-
- int_empty_menu (list: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupMenu ($list);"
- end
-
- int_menu (list: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupMenuv ($list)"
- end
- end
|