123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210(**************************************************************************)(* Lablgtk *)(* *)(* This program is free software; you can redistribute it *)(* and/or modify it under the terms of the GNU Library General *)(* Public License as published by the Free Software Foundation *)(* version 2, with the exception described in file COPYING which *)(* comes with the library. *)(* *)(* This program is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Library General Public License for more details. *)(* *)(* You should have received a copy of the GNU Library General *)(* Public License along with this program; if not, write to the *)(* Free Software Foundation, Inc., 59 Temple Place, Suite 330, *)(* Boston, MA 02111-1307 USA *)(* *)(* *)(**************************************************************************)(* $Id$ *)openGauxopenGobjectopenGtkopenGtkDataopenGtkBaseopenGtkContainersopenGtkMenuopenOgtkBasePropsopenOgtkMenuPropsopenGObjopenGContainer(* Menu type *)classmenu_shell_signalsobj=object(self)inheritcontainer_signals_implobjmethoddeactivate=self#connectMenuShell.S.deactivateendclasstypevirtual['a]pre_menu=objectinherit['a]item_containermethodas_menu:Gtk.menuGtk.objmethoddeactivate:unit->unitmethodconnect:menu_shell_signalsmethodevent:event_opsmethodpopup:button:int->time:int32->unitmethodpopdown:unit->unitmethodset_accel_group:accel_group->unitmethodset_accel_path:string->unitend(* Menu items *)classmenu_item_signalsobj=object(self)inheritcontainer_signals_impl(obj:[>menu_item]obj)methodactivate=self#connectMenuItem.S.activateendclass['a]pre_menu_item_skelobj=objectinheritcontainerobjmethodas_item=(obj:>Gtk.menu_itemobj)methodset_submenu(w:'apre_menu)=MenuItem.set_submenuobj(Somew#as_menu)methodremove_submenu()=MenuItem.set_submenuobjNonemethodget_submenu=may_map(newGObj.widget)(MenuItem.get_submenuobj)methodactivate()=MenuItem.activateobjmethodselect()=MenuItem.selectobjmethoddeselect()=MenuItem.deselectobjmethodadd_accelerator~group?modi:m?flagskey=Widget.add_acceleratorobj~sgn:MenuItem.S.activategroup?flags?modi:m~keyendclassmenu_itemobj=objectinherit[menu_item]pre_menu_item_skelobjmethodconnect=newmenu_item_signalsobjmethodevent=newGObj.event_opsobjendclassmenu_item_skel=[menu_item]pre_menu_item_skelletpack_item?packing?(show=true)self=maypacking~f:(funf->(f(self:>menu_item):unit));ifshowthenself#misc#show();selfletmenu_item?use_mnemonic?label?packing?show()=letw=MenuItem.create?use_mnemonic?label()inpack_item(newmenu_itemw)?packing?showletseparator_item?packing?show()=letw=MenuItem.separator_create()inpack_item(newmenu_itemw)?packing?showclasscheck_menu_item_signalsobj=object(self)inheritmenu_item_signalsobjmethodtoggled=self#connectCheckMenuItem.S.toggledendclasscheck_menu_itemobj=objectinheritmenu_item_skelobjmethodset_active=setCheckMenuItem.P.activeobjmethodset_inconsistent=setCheckMenuItem.P.inconsistentobjmethodinconsistent=getCheckMenuItem.P.inconsistentobjmethodactive=getCheckMenuItem.P.activeobjmethodtoggled()=CheckMenuItem.toggledobjmethodconnect=newcheck_menu_item_signalsobjmethodevent=newGObj.event_opsobjendletcheck_menu_item?label?use_mnemonic?active?packing?show()=letw=CheckMenuItem.create?use_mnemonic?label()inCheckMenuItem.setw?active;pack_item(newcheck_menu_itemw)?packing?showclassradio_menu_itemobj=objectinheritcheck_menu_item(obj:Gtk.radio_menu_itemobj)methodgroup=Someobjmethodset_group=RadioMenuItem.set_groupobjendletradio_menu_item?group?label?use_mnemonic?active?packing?show()=letw=RadioMenuItem.create?use_mnemonic?group?label()inCheckMenuItem.setw?active;pack_item(newradio_menu_itemw)?packing?show(* Menus *)classmenu_shellobj=objectinherit[menu_item]item_containerobjmethodprivatewrapw=newmenu_item(MenuItem.castw)methodinsertw=MenuShell.insertobjw#as_itemmethoddeactivate()=MenuShell.deactivateobjmethodconnect=newmenu_shell_signalsobjmethodevent=newGObj.event_opsobjendclassmenuobj=objectinheritmenu_shellobjmethodpopup=Menu.popupobjmethodpopdown()=Menu.popdownobjmethodas_menu:Gtk.menuobj=objmethodset_accel_group=Menu.set_accel_groupobjmethodset_accel_path=Menu.set_accel_pathobjendletmenu?accel_path?border_width?packing?show()=letw=Menu.create[]inmayborder_width~f:(setContainer.P.border_widthw);mayaccel_path~f:(funap->Menu.set_accel_pathwap);letself=newmenuwinmaypacking~f:(funf->(fself:unit));ifshow<>Somefalsethenself#misc#show();self(* Menu Bar *)letmenu_bar=pack_container[]~create:(funp->newmenu_shell(MenuBar.createp))(* Menu Factory *)class['a]factory?(accel_group=AccelGroup.create())?(accel_path="<DEFAULT ROOT>/")?(accel_modi=[`CONTROL])?(accel_flags=[`VISIBLE])(menu_shell:'a)=object(self)valmenu_shell:#menu_shell=menu_shellvalgroup=accel_groupvalm=accel_modivalflags=(accel_flags:Gtk.Tags.accel_flaglist)valaccel_path=accel_pathmethodmenu=menu_shellmethodaccel_group=groupmethodprivatebind?(modi=m)?key?callback(item:menu_item)label=menu_shell#appenditem;letaccel_path=accel_path^label^"/"in(* Default accel path value *)GtkData.AccelMap.add_entryaccel_path?key~modi:m;(* Register this accel path *)GtkBase.Widget.set_accel_pathitem#as_widgetaccel_pathaccel_group;maycallback~f:(funcallback->item#connect#activate~callback)methodadd_item?key?callback?submenulabel=letitem=menu_item~use_mnemonic:true~label()inself#binditem?key?callbacklabel;may(submenu:menuoption)~f:item#set_submenu;itemmethodadd_check_item?active?key?callbacklabel=letitem=check_menu_item~label~use_mnemonic:true?active()inself#bind(item:check_menu_item:>menu_item)label?key?callback:(may_mapcallback~f:(funf()->fitem#active));itemmethodadd_radio_item?group?active?key?callbacklabel=letitem=radio_menu_item~label~use_mnemonic:true?group?active()inself#bind(item:radio_menu_item:>menu_item)label?key?callback:(may_mapcallback~f:(funf()->fitem#active));itemmethodadd_separator()=separator_item~packing:menu_shell#append()methodadd_submenu?keylabel=letitem=menu_item~use_mnemonic:true~label()inself#binditem?keylabel;menu~packing:item#set_submenu()end