/***************************************************************************************/
/*                                                                                     */
/*  SCS editor Version 2                                                               */
/*  File : Menu.pkg                                                                    */
/*  Version : 14 juin 2000                                                             */
/*  Menu functions                                                                     */
/*                                                                                     */
/***************************************************************************************/

var MAINWIN_mainposx=10;;
var MAINWIN_mainposy=100;;

var RECENT_FILES = 101;;
var MENU_MODULE = 103;;
var MENU_ZONE = 104;;

var MENU_ONGLET_HEIGHT = 20;;

struct MenuData =
  [
    MENUname       : S                     , /* menu name */
    MENUkey        : I                     , /* menu identity */
    MENUmenuItem   : ObjMenuItem           , /* menu item object */
    MENUmenuFather : ObjMenu               , /* menu object father */
    MENUstate      : I                     , /* menu state : ME_ENABLED, ME_DISABLED, ME_SEPARATOR */
    MENUfunction   : fun [] I                /* action fonction */
  ] mkMenuData
;;


proto MAINWIN_Refresh = fun [ObjContainer [[I ObjContainer I] r1]] ObjContainer;;

/* MAC ICI : berk !! */
typeof tmpRecentFilesList = [ObjMenuItem r1];;

typeof tmpSiteOngletList = [[Site CompCheck] r1];;

fun MENU_Search (menuDat, key) =
  menuDat.MENUkey == key
;;

fun MENU_ChangeState (listMenu, key) =
  if listMenu == nil
  then
    nil
  else
    let hd listMenu -> menuDat in
      if menuDat.MENUkey == key
      then
        _CHKmenu menuDat.MENUmenuItem (-1)
      else
        MENU_ChangeState tl listMenu key
;;  

fun MENU_ActivateDeactivate (menuDat, param) =
  let param -> [codeActivate codeDeactivate] in
    if menuDat.MENUkey == codeActivate
    then
      _ENmenuItem menuDat.MENUmenuItem
    else if menuDat.MENUkey == codeDeactivate
    then
      _DImenuItem menuDat.MENUmenuItem
    else
      nil
;;

fun _MENU_ItemCB (item, param) =
  let param -> [menuDat] in
  (
    MAINWIN_Refresh scsgui.SCSGUIwindowManager.WINMANAGmainCont scsgui.SCSGUIwindowManager.WINMANAGwinList;
    exec menuDat.MENUfunction with []
  )
;;


fun MENU_DestroyItem (menu, param) =
  _DSmenuItem menu
;;

fun MENU_DestroyRecentFiles (listmenu) =
  apply_on_list listmenu @MENU_DestroyItem nil
;;

fun MENU_SelectRecent (menuItem, param) =
  let param -> [val] in
  (      
    MAINWIN_Refresh scsgui.SCSGUIwindowManager.WINMANAGmainCont scsgui.SCSGUIwindowManager.WINMANAGwinList;
    SITE_Open val scsgui.SCSGUIchannel;
  )
;;

fun MENU_CreateRecentFiles (listfiles, Channel, menu) =
  if listfiles == nil
  then
    nil
  else
  (
    _CBmenu _APPitem Channel menu ME_ENABLED (hd listfiles)
            @MENU_SelectRecent [hd listfiles]
  )::
  MENU_CreateRecentFiles tl listfiles Channel menu
;;

fun MENU_CreateMenuItems (Channel, listMenu) =
  if listMenu == nil
  then
    nil
  else
  (
    let hd listMenu -> menuDat in
      if menuDat.MENUkey == RECENT_FILES
      then /* special Recent file menu */
      (
        set menuDat.MENUmenuFather = _APPpopup Channel menuDat.MENUmenuFather (_locSCS "menu-RFILES" nil);
        set tmpRecentFilesList = MENU_CreateRecentFiles SITE_GetRecentFiles Channel menuDat.MENUmenuFather;
        0
      )
      else
      (
        set menuDat.MENUmenuItem = _APPitem Channel menuDat.MENUmenuFather menuDat.MENUstate menuDat.MENUname;
        if menuDat.MENUfunction == nil
        then
          if menuDat.MENUstate == ME_ENABLED
          then
          (
            set menuDat.MENUstate = ME_DISABLED;
            _DImenuItem menuDat.MENUmenuItem;
            0
          )
          else
            nil
        else
        (
          _CBmenu menuDat.MENUmenuItem @_MENU_ItemCB [menuDat];
          0
        );
      );
    MENU_CreateMenuItems Channel tl listMenu;
    0
  )
;;  

fun MENU_GetRecentList (menuList) =
  search_in_list menuList @MENU_Search RECENT_FILES
;;


fun MENU_UpdateRecentFiles (listMenu, Channel) =
  MENU_DestroyRecentFiles tmpRecentFilesList;
  let MENU_GetRecentList listMenu -> menuDat in
    set tmpRecentFilesList = MENU_CreateRecentFiles SITE_GetRecentFiles Channel menuDat.MENUmenuFather;
  0
;;

fun MENU_WriteTextOnAlphaBmp2 (abmp, text, x, y, w, h) =
  let _GETalphaBitmaps abmp -> [bmp _] in
  (
    set text = UTILSGUI_CutTextToFitSize text w ".." scsgui.SCSGUIfont;
    _DRAWtext bmp scsgui.SCSGUIfont x+w/2 y-2 TD_CENTER|TD_BASELINE make_rgb 0 0 0 text;
    _DRAWtext bmp scsgui.SCSGUIfont x+w/2 h+y-2   TD_CENTER|TD_BASELINE make_rgb 240 240 255 text;
    _DRAWtext bmp scsgui.SCSGUIfont x+w/2 (2*h)+y-2 TD_CENTER|TD_BASELINE make_rgb 240 240 255 text;
    abmp
  )
;;

fun MENU_DisableCheck (compCheck, param, val) =
  _CHANGEobjNodeFlags _CONVERTcompCheckToObjNode compCheck 
    (if val == CHK_CHECKED then OBJ_DISABLE else OBJ_ENABLE)|OBJ_VISIBLE 0
;;

fun MENU_Onglet (Check, param, ww, hh) =
  let param -> [channel funcgetinfo paraminfo] in
  let [ww/2 hh/3] -> [w h] in
  let _CRbitmap  channel ww hh -> newbmp in
  let ["ONGLET_OFF" "ONGLET_ON"] -> [ongletoff ongleton] in
  (
    GD_PasteGraphicObject16 GD_THEME ongletoff channel newbmp 0 0    w h;
    GD_PasteGraphicObject16 GD_THEME ongletoff channel newbmp 0 h    w h;
    GD_PasteGraphicObject16 GD_THEME ongletoff channel newbmp 0 h*2  w h;
    GD_PasteGraphicObject16 GD_THEME ongleton  channel newbmp w 0    w h;
    GD_PasteGraphicObject16 GD_THEME ongleton  channel newbmp w h    w h;
    GD_PasteGraphicObject16 GD_THEME ongleton  channel newbmp w h*2  w h;
    let _CRalphaBitmap channel newbmp nil GD_DEFAULT_BACKGROUNDCOLOR GD_DEFAULT_TRANSPARENCYCOLOR -> abmp in
    let exec funcgetinfo with [paraminfo] -> info in
    (
      _DSbitmap  newbmp ;
      MENU_WriteTextOnAlphaBmp2 (MENU_WriteTextOnAlphaBmp2 abmp info 3 15 w-6 h) info w+3 15 w-6 h
    )
  )
;;

fun MENU_CreateSiteOnglet (funcgetinfo, paraminfo, channel, cont, x, y, w)=
  let MENU_ONGLET_HEIGHT -> h in
  let [channel funcgetinfo paraminfo] -> data in
  let _CRcompCheck
        channel cont nil [x y]
        OBJ_ENABLE|OBJ_VISIBLE
        OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|(OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_KEYDOWN) 
        MENU_Onglet nil data w*2 h*3
  -> check in
  (
    _CBcompCheckResizeResource check @MENU_Onglet data;
    _CBcompCheckStateChanged check @MENU_DisableCheck nil;
    check
  )
;;

fun MENU_ResetOnglet (check, x, y, w) =
  let _CONVERTcompCheckToObjNode check -> node in
  (
    _CHANGEobjNodeCoordinates node [x y] 0;
    _SIZEobjNode node w MENU_ONGLET_HEIGHT 0;
  )
;;

fun MENU_UpdateSiteOnglet2 (siteOngletList, curx, inity, width) =
  if siteOngletList == nil then
    [curx inity width]
  else
  (
    let hd siteOngletList -> [_ check] in
      MENU_ResetOnglet check curx inity width;
    MENU_UpdateSiteOnglet2 tl siteOngletList curx+width+1 inity width
  )
;;

fun MENU_UpdateSiteOnglets (size, cont) =
  if size == 0 then
    nil
  else
    let _GETcontainerPositionSize cont -> [_ _ contW _] in
    let contW - 6*MAINWIN_mainposx - size -> totalW in
    let MAINWIN_mainposy-MENU_ONGLET_HEIGHT+2 -> inity in
    let totalW / size -> initw in
      MENU_UpdateSiteOnglet2 tmpSiteOngletList 3*MAINWIN_mainposx inity initw
;;

fun MENU_LaunchSelectSite (check, site, x, y, btn, mask) = SELECT_NewSite site;;

fun MENU_TOOLTIP_Text (site) = SITE_GetCompleteName site;;

fun MENU_SiteAdded (site, param, listMenu, Channel, cont) =
  let MENU_UpdateSiteOnglets (sizelist tmpSiteOngletList)+1 cont -> [curx inity initw] in
  let MENU_CreateSiteOnglet @SITE_GetCompleteName site Channel cont curx inity initw -> check in
  (
    TOOLTIP_DynamicLink cont _CONVERTcompCheckToObjNode check scsgui.SCSGUIdynamicToolTip mkfun1 @MENU_TOOLTIP_Text site;
    _CBcompCheckUnClick check @MENU_LaunchSelectSite site;
    set tmpSiteOngletList = listcat tmpSiteOngletList
                                    [site check]::nil
  );
  _PAINTcontainer cont;
  MENU_UpdateRecentFiles listMenu Channel;
  0
;;

fun MENU_RemoveSiteOnglet (siteOngletList, site) =
  if siteOngletList == nil then
    nil
  else
    let siteOngletList -> [cur next] in
    let cur -> [currSite check] in
      if currSite == site then
      (
        _DScompCheck check;
        next
      )
      else
        cur::(MENU_RemoveSiteOnglet next site)
;;

fun MENU_UpdateRootOnglet (rootOnglet) =
  UTILSGUI_ForceCBresize _CONVERTcompBitmapToObjNode rootOnglet;
  0
;;

fun MENU_SiteRemoved (site, param, cont) =
  set tmpSiteOngletList = MENU_RemoveSiteOnglet tmpSiteOngletList site;
  MENU_UpdateSiteOnglets (sizelist tmpSiteOngletList) cont;
  _PAINTcontainer cont;
  0
;;

fun MENU_SelectSiteOnglets (siteOngletList, site) =
  if siteOngletList == nil then
    0
  else
  (
    let hd siteOngletList -> [currsite check] in
      _SETcompCheckState check if currsite == site then CHK_CHECKED else CHK_UNCHECKED;
    MENU_SelectSiteOnglets tl siteOngletList site
  )
;;

fun MENU_SiteSelected (site, param, cont, multibtn) =
  if param & REFLEX_SELECTION then
  (
    GRAPHICDRESSING_ShowCompRollOver multibtn (SITE_HasServer site);
    MENU_SelectSiteOnglets tmpSiteOngletList site
  )
  else
    nil;
  _PAINTcontainer cont;
  0
;;

fun MENU_SiteOngletCompareSite (siteO, site) =
  let siteO -> [theSite _] in
    theSite == site
;;


fun MENU_UpdateSiteOngletName (site) =
  let search_in_list tmpSiteOngletList @MENU_SiteOngletCompareSite site -> [_ cmpcheck] in
    UTILSGUI_ForceCBresize _CONVERTcompCheckToObjNode cmpcheck
;;

fun MENU_ViewChange (view ,listMenu) =
  if view == MAINWIN_MODULE then
    apply_on_list listMenu @MENU_ActivateDeactivate [MENU_MODULE MENU_ZONE]
  else
    apply_on_list listMenu @MENU_ActivateDeactivate [MENU_ZONE MENU_MODULE]
;;

fun MENU_ZoneSelected (zone, par, rootOnglet) =
  MENU_UpdateRootOnglet rootOnglet
;;

fun MENU_SiteModified (site, param, listMenu, Channel, rootOnglet, multibtn) =
  if param == REFLEX_FILENAME then
    MENU_UpdateRecentFiles listMenu Channel
  else
    nil;
  if param == REFLEX_NAME || param == REFLEX_STATUS || param == REFLEX_FILENAME then
    MENU_UpdateSiteOngletName site
  else
    nil;
  if param == REFLEX_NAME then
    MENU_UpdateRootOnglet rootOnglet
  else
    nil;
  if param == REFLEX_SERVER then
    GRAPHICDRESSING_ShowCompRollOver multibtn (SITE_HasServer site)
  else
    nil;
  0
;;

fun MENU_BBChange (bb, rootOnglet) =
  MENU_UpdateRootOnglet rootOnglet;
  0
;;

fun MENU_SetMenuCB (listMenu, Channel, cont, rootOnglet,multibtn) =
  REFLEX_CBsiteAdded mkfun3 mkfun4 mkfun5 @MENU_SiteAdded cont Channel listMenu;
  REFLEX_CBsiteRemoved mkfun3 @MENU_SiteRemoved cont;
  REFLEX_CBsiteModified mkfun3 mkfun4 mkfun5 mkfun6 @MENU_SiteModified multibtn rootOnglet Channel listMenu;
  REFLEX_CBsiteSelected mkfun3 mkfun4 @MENU_SiteSelected multibtn cont;
  SCSGUI_CBviewChange mkfun2 @MENU_ViewChange listMenu;
  SCSGUI_CBviewBBChange mkfun2 @MENU_BBChange rootOnglet;
  REFLEX_CBzoneSelected mkfun3 @MENU_ZoneSelected rootOnglet;
  0
;;

fun MENU_OpenMenu(compRollOver, param, posx, posy, btn, mask)=
  let param -> [menu cont] in
  let _GETcontainerPositionSize cont -> [x y w h] in
  let _GETobjNodePositionSizeInContainerRef _CONVERTcompRollOverToObjNode compRollOver -> [cx cy cw ch] in
      _DRAWmenu nil menu x+cx y+cy+ch PM_LEFT_ALIGN|PM_TOP_ALIGN|PM_SCREEN
;;


fun MENU_WriteTextOnAlphaBmp (abmp, text, palette) =
  let _GETalphaBitmapSize abmp -> [w h] in
    let _GETalphaBitmaps abmp -> [bmp alpha] in
    (
      set text = UTILSGUI_CutTextToFitSize text w ".." scsgui.SCSGUIsmallFont;
      _SETbitmapPalette alpha palette;
      _DRAWtext bmp scsgui.SCSGUIsmallFont w/2 11*h/48 TD_CENTER make_rgb 0 0 0 text;
      _DRAWtext8 alpha scsgui.SCSGUIsmallFont w/2 11*h/48 TD_CENTER make_rgb 255 255 255 text;
      _DRAWtext bmp scsgui.SCSGUIsmallFont w/2 27*h/48 TD_CENTER make_rgb 100 100 100 text;
      _DRAWtext8 alpha scsgui.SCSGUIsmallFont w/2 27*h/48 TD_CENTER make_rgb 255 255 255 text;
      _DRAWtext bmp scsgui.SCSGUIsmallFont w/2 43*h/48 TD_CENTER make_rgb 100 100 100 text;
      _DRAWtext8 alpha scsgui.SCSGUIsmallFont w/2 43*h/48 TD_CENTER make_rgb 255 255 255 text;
      abmp
    )
;;

/****************************************************************************************
   E: structure du menu, la fenêtre mère de l'objet graphique, un alphabitmap un popup menu
   S: le container contenant le rollover
****************************************************************************************/
fun MENU_CreateImageMenu(channel, cont, bmp1, menu, x, y, info)=
  let UTILSGUI_BuildPalette -> palette in
  let MENU_WriteTextOnAlphaBmp bmp1 info palette -> abmp in
  let _CRcompRollOver 
        _channel 
        cont 
        nil 
        [x y] 
        OBJ_ENABLE|OBJ_VISIBLE|ROL_CLICK
        OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|(OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_KEYDOWN) 
        abmp 
  -> roll in
  (
    _CBcompRollOverClick roll @MENU_OpenMenu [menu cont];
    let _GETcontainerPositionSize cont -> [x y w h] in
      let _GETobjNodePositionSizeInContainerRef _CONVERTcompRollOverToObjNode roll -> [cx cy cw ch] in
        let _CONVERTcompRollOverToObjNode roll -> obnode in
          TOOLTIP_StaticLink cont obnode scsgui.SCSGUIstaticToolTip info;
        roll
  )
;;
  

fun MENU_LaunchShortcut(compRollOver, activation_function, posx, posy, btn, mask)=
  exec activation_function with [];;

fun MENU_CreateImageShortcut(channel, cont, bmp1, activation_function, x, y, info, info2)= 
  let UTILSGUI_BuildPalette -> palette in
  let MENU_WriteTextOnAlphaBmp bmp1 info palette -> abmp in
  let _CRcompRollOver
        _channel 
        cont 
        nil 
        [x y] 
        OBJ_ENABLE|OBJ_VISIBLE|ROL_CLICK
        OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|(OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_KEYDOWN) 
        abmp 
  -> roll in
  (
    _CBcompRollOverClick roll @MENU_LaunchShortcut activation_function;
/*    let _GETcontainerPositionSize cont -> [x y w h] in
      let _GETobjNodePositionSizeInContainerRef _CONVERTcompRollOverToObjNode roll -> [cx cy cw ch] in*/
    let _CONVERTcompRollOverToObjNode roll -> obnode in
      TOOLTIP_StaticLink cont obnode scsgui.SCSGUIstaticToolTip if info2 == nil then info else info2;
    roll
  );;

fun MENU_rflCLICKbuttons (action, bx, by, bw, bh, cont, menus) =
  let _GETcontainerPositionSize cont -> [cx cy _ _] in
  let [bx+cx by+cy+bh] -> [x y] in
  let menus -> [fileMenu editMenu viewMenu projectMenu helpMenu] in
         if !strcmp action "FILE"    then (_DRAWmenu nil fileMenu x y PM_LEFT_ALIGN|PM_TOP_ALIGN|PM_SCREEN;0)
    else if !strcmp action "EDIT"    then (_DRAWmenu nil editMenu x y PM_LEFT_ALIGN|PM_TOP_ALIGN|PM_SCREEN;0)
    else if !strcmp action "VIEW"    then (_DRAWmenu nil viewMenu x y PM_LEFT_ALIGN|PM_TOP_ALIGN|PM_SCREEN;0)
    else if !strcmp action "PROJECT" then (_DRAWmenu nil projectMenu x y PM_LEFT_ALIGN|PM_TOP_ALIGN|PM_SCREEN;0)
    else if !strcmp action "HELP"    then (_DRAWmenu nil helpMenu x y PM_LEFT_ALIGN|PM_TOP_ALIGN|PM_SCREEN;0)
    else if !strcmp action "WINMODULE"      then (GUI_ShowHide MAINWIN_MODULE;0)
    else if !strcmp action "WINZONECLIENT"  then (GUI_ShowHide MAINWIN_ZONE_CLIENT;0)
    else if !strcmp action "WINZONESERVEUR" then (GUI_ShowHide MAINWIN_ZONE_SERVER;0)
    else if !strcmp action "RUN" then (GUI_Run;0)
    else 0
;;

fun MENU_GetRootText () =
  if SCSGUI_GetCurrentView == MAINWIN_MODULE then
    strcatn (_locSCS "menu-CURBLACKBOX" nil)::" : "::
            (MODULE_GetName SITE_GetModuleCurrentBlackBox SELECT_GetSite)::
            nil
  else
    strcatn (_locSCS "menu-CURDOCUMENT" nil)::" : "::
            (ZONE_GetName (ZONE_GetFirstPopupParent SELECT_GetSite (hd SELECT_GetZone REFLEX_PRIORITY_ONE)))::
            nil
;;

fun MENU_ResetRootOnglet (cmpbmp, channel, ww, hh, other) =
  let _CRbitmap channel ww hh -> newbmp in
  let MENU_GetRootText -> text in
  (
    set text = UTILSGUI_CutTextToFitSize text ww ".." scsgui.SCSGUIfont;
    GD_PasteGraphicObject16 GD_THEME "REVERSEONGLET" channel newbmp 0 0 ww hh;
    _DRAWtext newbmp scsgui.SCSGUIfont ww/2 0 TD_CENTER make_rgb 0 0 0 text;
    let _CRalphaBitmap channel newbmp nil GD_DEFAULT_BACKGROUNDCOLOR GD_DEFAULT_TRANSPARENCYCOLOR -> abmp in
    (
      _DSbitmap newbmp;
      [abmp [0 0 ww hh]]
    )
  )
;;

fun MENU_ResizeRootOnglet (cmpbmp, cont, w, h) =
  MENU_UpdateSiteOnglets (sizelist tmpSiteOngletList) cont
;;

fun MENU_CreateRootOnglet (channel, cont)=
  let _GETcontainerPositionSize cont -> [_ _ contW contH] in
  let 3*MAINWIN_mainposx -> x in
  let contH - 3*MAINWIN_mainposx - 4 -> y in
  let contW - 6*MAINWIN_mainposx -> w in
  let MENU_ONGLET_HEIGHT -> h in
  let _CRbitmap  channel w h -> newbmp in
  (
    GD_PasteGraphicObject16 GD_THEME "REVERSEONGLET" channel newbmp 0 0 w h;
    let _CRalphaBitmap channel newbmp nil GD_DEFAULT_BACKGROUNDCOLOR GD_DEFAULT_TRANSPARENCYCOLOR -> abmp in
    (
      _DSbitmap newbmp ;
      _CBcompBitmapResize
        _CBcompBitmapResizeResource
          _CRcompBitmap
            channel cont nil [x y]
            OBJ_ENABLE|OBJ_VISIBLE|OBJ_MW_FLEX|OBJ_LH_FLEX
            OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|(OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_KEYDOWN) 
            abmp
            0 0 w h
          @MENU_ResetRootOnglet
          channel
        @MENU_ResizeRootOnglet
        cont
    )
  )
;;


fun MENU_Create (chan, cont) =
  let _CRpopupMenu chan -> fileMenu in
  let _CRpopupMenu chan -> editMenu in
  let _CRpopupMenu chan -> viewMenu in
  let _CRpopupMenu chan -> projectMenu in
  let _CRpopupMenu chan -> helpMenu in
  (
    let (mkMenuData [(_locSCS "menu-NEW" nil) nil nil fileMenu ME_ENABLED @SITE_New])::
        (mkMenuData [(_locSCS "menu-OPEN" nil) nil nil fileMenu ME_ENABLED @GUI_Open])::
        (mkMenuData [nil RECENT_FILES nil fileMenu nil nil]):: /* for Recent file Menu */
        (mkMenuData ["" nil nil fileMenu ME_SEPARATOR nil])::
        (mkMenuData [(_locSCS "menu-CLOSE" nil) nil nil fileMenu ME_ENABLED @GUI_Close])::
        (mkMenuData [(_locSCS "menu-SAVE" nil) nil nil fileMenu ME_ENABLED @GUI_Save])::
        (mkMenuData [(_locSCS "menu-SAVEAS" nil) nil nil fileMenu ME_ENABLED @GUI_SaveAs])::
        (mkMenuData ["" nil nil fileMenu ME_SEPARATOR nil])::
        (mkMenuData [(_locSCS "menu-WIZARD" nil) nil nil fileMenu ME_ENABLED (mkfun1 @GUI_QuickWizard 1)])::
        (mkMenuData [(_locSCS "menu-QUIT" nil) nil nil fileMenu ME_ENABLED @quit])::
        
        (mkMenuData [(_locSCS "menu-DELETE" nil) nil nil editMenu ME_ENABLED @GUI_Delete])::
        (mkMenuData ["" nil nil editMenu ME_SEPARATOR nil])::
        (mkMenuData [(_locSCS "menu-UNDO" nil) nil nil editMenu ME_ENABLED @GUI_Undo])::
        (mkMenuData [(_locSCS "menu-REDO" nil) nil nil editMenu ME_ENABLED @GUI_Redo])::
        (mkMenuData ["" nil nil editMenu ME_SEPARATOR nil])::
        (mkMenuData [(_locSCS "menu-CUT" nil) MENU_MODULE nil editMenu ME_ENABLED @GUI_Cut])::
        (mkMenuData [(_locSCS "menu-COPY" nil) MENU_MODULE nil editMenu ME_ENABLED @GUI_Copy])::
        (mkMenuData [(_locSCS "menu-PASTE" nil) MENU_MODULE nil editMenu ME_ENABLED @GUI_Paste])::
        (mkMenuData ["" nil nil editMenu ME_SEPARATOR nil])::
        (mkMenuData [(_locSCS "menu-IMPORT" nil) MENU_MODULE nil editMenu ME_ENABLED @GUI_Import])::
        (mkMenuData [(_locSCS "menu-EXPORT" nil) MENU_MODULE nil editMenu ME_ENABLED @GUI_Export])::

        (mkMenuData [(_locSCS "menu-TREE" nil) POPUPWIN_SITETREE nil viewMenu ME_ENABLED (mkfun1 @GUI_ShowHide POPUPWIN_SITETREE)])::
        (mkMenuData [(_locSCS "menu-CREATEALLOC" nil) POPUPWIN_CREATIONTREE nil viewMenu ME_ENABLED (mkfun1 @GUI_ShowHide POPUPWIN_CREATIONTREE)])::
        (mkMenuData [(_locSCS "menu-PROPERTIES" nil) POPUPWIN_PROPERTIES nil viewMenu ME_ENABLED (mkfun1 @GUI_ShowHide POPUPWIN_PROPERTIES)])::
        (mkMenuData ["" nil nil viewMenu ME_SEPARATOR nil])::
        (mkMenuData [(_locSCS "menu-SITEOPTIONS" nil) POPUPWIN_SITEOPTIONS nil viewMenu ME_ENABLED (mkfun1 @GUI_ShowHide POPUPWIN_SITEOPTIONS)])::
        /*(mkMenuData [(_locSCS "menu-SITESERVERS" nil) POPUPWIN_SITESERVERS nil viewMenu ME_ENABLED (mkfun1 @GUI_ShowHide POPUPWIN_SITESERVERS)])::*/
        (mkMenuData [(_locSCS "menu-UPLOAD" nil) nil nil viewMenu ME_ENABLED @GUI_OnMenuUpload])::
        (mkMenuData ["" nil nil viewMenu ME_SEPARATOR nil])::
        (mkMenuData [(_locSCS "menu-ERRLOG" nil) POPUPWIN_ERRORLOG nil viewMenu ME_ENABLED (mkfun1 @GUI_ShowHide POPUPWIN_ERRORLOG)])::
        (mkMenuData [(_locSCS "menu-HIST" nil) POPUPWIN_HISTORYLOG nil viewMenu ME_ENABLED (mkfun1 @GUI_ShowHide POPUPWIN_HISTORYLOG)])::
        (mkMenuData ["" nil nil viewMenu ME_SEPARATOR nil])::
        (mkMenuData [(_locSCS "menu-PREFERENCES" nil) POPUPWIN_SCSPREF nil viewMenu ME_ENABLED (mkfun1 @GUI_ShowHide POPUPWIN_SCSPREF)])::

        (mkMenuData [(_locSCS "menu-CREATEBLACKBOX" nil) MENU_MODULE nil projectMenu ME_ENABLED @GUI_CreateBB])::
        (mkMenuData [(_locSCS "menu-ENTERBLACKBOX" nil) MENU_MODULE nil projectMenu ME_ENABLED @GUI_EnterBB])::
        (mkMenuData [(_locSCS "menu-CREATEPOPUP" nil) MENU_ZONE nil projectMenu ME_ENABLED (mkfun1 @GUI_CreateZone ZONE_POPUP)])::
        (mkMenuData [(_locSCS "menu-CREATEZONE" nil) MENU_ZONE nil projectMenu ME_ENABLED (mkfun1 @GUI_CreateZone ZONE_ZONE)])::
        (mkMenuData [(_locSCS "menu-SELECTFATHER" nil) nil nil projectMenu ME_ENABLED @GUI_SelectFather])::

        (mkMenuData [(_locSCS "menu-HELP" nil) nil nil helpMenu ME_ENABLED @GUI_Help])::
        (mkMenuData [(_locSCS "menu-SCOLWEB" nil) nil nil helpMenu ME_ENABLED @GUI_ScolWeb])::
        (mkMenuData [(_locSCS "menu-SCSWEB" nil) nil nil helpMenu ME_ENABLED @GUI_SCSWeb])::
        (mkMenuData [(_locSCS "menu-ABOUT" nil) nil nil helpMenu ME_ENABLED @GUI_OnMenuAbout])::
        nil
    -> listMenu in
    ( 
      let THEME_getParamsByTheme GD_THEME "MENUFILE" -> [pathMFILE _ _ _ _ _ _ _ _ ]in
      let exec GD_FUNCTIONHANDLER_LOADBITMAP with [pathMFILE chan] -> bmp1 in
      let _GETalphaBitmapSize bmp1 -> [BmpWidth height] in
      let 2 * BmpWidth / 3 -> width in
      let 20 -> initXposition in
      let 33 -> initYposition in
      let MENU_CreateRootOnglet chan cont -> rootOnglet in
      (
        MENU_CreateMenuItems chan listMenu;
        let THEME_getParamsByTheme GD_THEME "MENUEDIT" -> [pathMEDIT _ _ _ _ _ _ _ _ ]in
        let exec GD_FUNCTIONHANDLER_LOADBITMAP with [pathMEDIT chan] -> bmp2 in
        let THEME_getParamsByTheme GD_THEME "MENUVIEW" -> [pathMVIEW _ _ _ _ _ _ _ _ ]in
        let exec GD_FUNCTIONHANDLER_LOADBITMAP with [pathMVIEW chan] -> bmp3 in
        let THEME_getParamsByTheme GD_THEME "MENUPROJECT" -> [pathMPROJECT _ _ _ _ _ _ _ _ ]in
        let exec GD_FUNCTIONHANDLER_LOADBITMAP with [pathMPROJECT chan] -> bmp4 in
        let THEME_getParamsByTheme GD_THEME "MENUHELP" -> [pathMHELP _ _ _ _ _ _ _ _ ]in
        let exec GD_FUNCTIONHANDLER_LOADBITMAP with [pathMHELP chan] -> bmp5 in                
        let THEME_getParamsByTheme GD_THEME "MENUGRAPH" -> [pathMGRAPH _ _ _ _ _ _ _ _ ]in
        let exec GD_FUNCTIONHANDLER_LOADBITMAP with [pathMGRAPH chan] -> bmp6 in                
        let THEME_getParamsByTheme GD_THEME "MENUCLIENT" -> [pathMCLIENT _ _ _ _ _ _ _ _ ]in
        let exec GD_FUNCTIONHANDLER_LOADBITMAP with [pathMCLIENT chan] -> bmp7 in 
        let THEME_getParamsByTheme GD_THEME "MENUSERVER" -> [pathMSERVER _ _ _ _ _ _ _ _ ]in
        let exec GD_FUNCTIONHANDLER_LOADBITMAP with [pathMSERVER chan] -> bmp8 in 
        let THEME_getParamsByTheme GD_THEME "MENURUN" -> [pathMRUN _ _ _ _ _ _ _ _ ]in
        let exec GD_FUNCTIONHANDLER_LOADBITMAP with [pathMRUN chan] -> bmp9 in
        let THEME_getParamsByTheme GD_THEME "MENURUNMULTI" -> [pathMRUNMULTI _ _ _ _ _ _ _ _ ]in
        let exec GD_FUNCTIONHANDLER_LOADBITMAP with [pathMRUNMULTI chan] -> bmp10 in 
        (
          MENU_CreateImageMenu chan cont bmp1 fileMenu initXposition initYposition _locSCS "menu-FILE" nil ;/*before site window */
          MENU_CreateImageMenu chan cont bmp2 editMenu 2*initXposition+width initYposition _locSCS "menu-EDIT" nil ;
          MENU_CreateImageMenu chan cont bmp3 viewMenu 3*initXposition+2*width initYposition _locSCS "menu-VIEW" nil ;
          MENU_CreateImageMenu chan cont bmp4 projectMenu 4*initXposition+3*width initYposition _locSCS "menu-PROJECT" nil ;
          MENU_CreateImageMenu chan cont bmp5 helpMenu 5*initXposition+4*width initYposition _locSCS "menu-HELP" nil ;
          MENU_CreateImageShortcut chan cont bmp6 (mkfun1 @GUI_ShowHide MAINWIN_MODULE) 7*initXposition+6*width initYposition _locSCS "menu-EDMOD" nil nil;
          MENU_CreateImageShortcut chan cont bmp7 (mkfun1 @GUI_ShowHide MAINWIN_ZONE_CLIENT) 8*initXposition+7*width initYposition _locSCS "menu-EDCLII" nil nil;
          MENU_CreateImageShortcut chan cont bmp8 (mkfun1 @GUI_ShowHide MAINWIN_ZONE_SERVER) 9*initXposition+8*width initYposition _locSCS "menu-EDSERI" nil nil;
          MENU_CreateImageShortcut chan cont bmp9 @GUI_Run 10*initXposition+10*width initYposition _locSCS "menu-RUN" nil nil;
          let
            MENU_CreateImageShortcut chan cont bmp10 @GUI_RunSingle 11*initXposition+11*width initYposition _locSCS "menu-RUNSINGLE" nil _locSCS "menu-RUNSINGLE2" nil
          -> multibtn in
          (
            GRAPHICDRESSING_ShowCompRollOver multibtn 0;
            MENU_SetMenuCB listMenu chan cont rootOnglet multibtn 
          )
        )
      );
      listMenu
    )
  )
;;