Posted: 6th Feb 2003 21:20
Here is the new menu I've made . . .
It run really fast and allow the use of separation items and thumbails icons for menus ( like windows does )

Here is small snapshot from it running :


+ Code Snippet
Rem
Rem DBv1 Project : My Menu v3.0 for Magic-Windows 1.2
Rem
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Rem FUNCTIONS TO USE MENU :
Rem MW_Check_Menu()                                                                Retrace menu to screen if needed.
Rem MW_Get_Choosen_Menu()                                       Give the number corresponding to the overlaped menu.
Rem MW_Get_Choosen_Option()                                                 Give the number of the option overlaped.
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Rem FUNCTIONS TO CREATE MENUS :
Rem MW_Set_Menu_Title(menu,title$)                                                                Define menu title.
Rem MW_Set_Menu_Option(menu,option,title$)                                                       Define menu option.
Rem MW_Set_Menu_Image(_menu,_option,_image)                                           define menu option's thumbail.
Rem MW_Set_Menu_Transition(menu,option)                        Define a menu option as transition (separation line).
Rem MW_Prepare_Menu_v3()                                                          Create full menu on hidden bitmap.
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Rem SYSTEM FUNCTIONS ! USER MUST NOT USE THEM ! ( THEY ARE CALLED BY OTHERS FUNCTIONS )
Rem MW_Refresh_Menu_Option(xmenu,ymenu,state) [SYSTEM]
Rem MW_Refresh_Menu_Title(xmenu,state) [SYSTEM]
Rem MW_Show_Title_Bar() [SYSTEM]
Rem MW_Show_Menu_Bar() [SYSTEM]
Rem
Dim _Menu_Option$(5,17) : Dim _Menu_State(5,17) : Dim _Menu_Logo(5,17) : Dim _Menu_sys(8)
Rem
Set Display Mode 640,480,16
sync rate 0 : Sync On : Sync
backdrop on : color backdrop 0
Rem

MW_Set_Menu_Title(1,"Disk")
MW_Set_Menu_Option(1,1,"Charger")
Rem MW_Set_Menu_Image(1,1,1)
MW_Set_Menu_Option(1,2,"Sauver")
Rem MW_Set_Menu_Image(1,2,2)
MW_Set_Menu_Transition(1,3)
MW_Set_Menu_Option(1,4,"Quitter")
Rem MW_Set_Menu_Image(1,4,3)

MW_Set_Menu_Title(2,"Edit")
MW_Set_Menu_Option(2,1,"Couper")
Rem MW_Set_Menu_Image(2,1,4)
MW_Set_Menu_Option(2,2,"Copier")
Rem MW_Set_Menu_Image(2,2,5)
MW_Set_Menu_Option(2,3,"Coller")
Rem MW_Set_Menu_Image(2,3,6)
MW_Set_Menu_Transition(2,4)
MW_Set_Menu_Option(2,5,"Préférences")
Rem MW_Set_Menu_Image(2,5,7)

MW_Prepare_Menu_v3()

Repeat
  _ACTIF=MW_Check_Menu()
  _MENU=MW_Get_Choosen_Menu()
  _OPTION=MW_Get_Choosen_Option()
  if mouseclick()=1
    if _MENU=1 and _OPTION=4 then _QUIT=1
   endif
  Set Current Bitmap 0
  ink rgb(255,255,255),0
  Set Cursor 0,300
  Print "Current Menu Overlaped : ",_MENU
  Print "Current Option overlaped : ",_OPTION
  print "FPS : ",screen fps()
  Sync
 Until _QUIT=1
End

Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
function MW_Get_Choosen_Menu()
  _LASTMENU=_Menu_Sys(4)
 EndFunction _LASTMENU
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Get_Choosen_Option()
  _LASTMENU=_Menu_Sys(4) : _LASTOPTION=_Menu_Sys(5)
  if _Menu_State(_LASTMENU,_LASTOPTION)=3 then _LASTOPTION=0
 EndFunction _LASTOPTION
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Check_Menu()
  xm=mousex() : ym=mousey() : mc=mouseclick()
  xmenu=(xm/128)+1
  _ACTIVE=_Menu_sys(2) : _LASTMENU=_Menu_Sys(4) : _LASTOPTION=_Menu_Sys(5)
  Rem ON réaffiche de couleur normale la dernière option surlignée.
  if _LASTMENU>0
    if _LASTOPTION=0 then MW_Refresh_Menu_Title(_LASTMENU,1)
    if _LASTOPTION>0 then MW_Refresh_Menu_Option(_LASTMENU,_LASTOPTION,1)
   Endif
  Rem Si le menu était en mode TITRE SELECTIONNE.
  if _ACTIVE=1
    if ( xm(xpos+127) ) and ym>11
      _ACTIVE=0
     else
      ymax=(_Menu_State(xmenu,0)+1)*12
      xpos=(_LASTMENU-1)*128
      if xmenu0 then MW_Refresh_Menu_Option(_LASTMENU,_LASTOPTION,2)
       Endif
      MW_Show_Title_Bar()
      MW_Show_Menu_Bar(_LASTMENU)
     endif
    if ym>(_Menu_State(xmenu,0)+1)*12 then _ACTIVE=0
   Endif
  Rem Si le menu était en mode INACTIF.
  if _ACTIVE=0
    _LASTMENU=0 : _LASTOPTION=0
    Rem Si la souris est bien placée alors on active le menu choisi.
    if ym0 and _menu0 and _menu0 and _option0 and _image0
      create bitmap _bitmap,640,480
      _Menu_Sys(6)=_bitmap
     endif
    Set Current Bitmap _bitmap
   Else
    Set current bitmap _Menu_Sys(6)
    Cls
   Endif
  Rem ON réalise les 5 menus en commençant par les titres . . .
  _Menu_Sys(3)=0
  for xmenu=1 to 5
    Rem Si le menu à un titre alors on crée le menu
    if _menu_state(xmenu,0)0 then _Menu_Sys(3)=xmenu
    MW_Refresh_Menu_Title(xmenu,1)
    Rem On vérifie le contenu des menus . . .
    for ymenu=1 to 16
      MW_Refresh_Menu_Option(xmenu,ymenu,1)
     next ymenu
   next xmenu
 EndFunction
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Refresh_Menu_Option(xmenu,ymenu,state)
  set current bitmap _Menu_Sys(6)
  Rem Si le menu contient un texte alors on le crée.
  if _Menu_State(xmenu,ymenu)>0
    xpos=((xmenu-1)*128)+64 : xm=(xmenu-1)*128 : ym=(ymenu)*12
    Rem On affiche le contenu de la boite de menu.
    if state=1 or _Menu_State(xmenu,ymenu)=3 then ink rgb(128,128,128),0 else ink rgb(16,32,64),0
    box xm,ym,xm+127,ym+11
    Rem Si le menu n'est pas une transition et qu'il possède un THUMBAIL , on l'affiche.
    if _Menu_State(xmenu,ymenu)0 then If Image exist(_img)=1 then paste image _img,xm+1,ym
     Else
      Rem Affichage de la transition . . .
      Ink rgb(160,160,160),0 : line xm+4,ym+5,xm+124,ym+5
      Ink rgb(64,64,64),0 : line xm+4,ym+6,xm+124,ym+6
     Endif
    if ymenu=1
      ink rgb(160,160,160),0 : line xm,ym,xm+127,ym
     Endif
    Rem On affiche alors le contour du menu
    ink rgb(160,160,160),0 : line xm,ym,xm,ym+11
    if state=1 then ink 0,0 else ink rgb(192,192,192),0
    Text xm+18,ym,_menu_option$(xmenu,ymenu)
    ink rgb(64,64,64),0 : line xm+127,ym,xm+127,ym+11
    Rem Si le menu suivant ne contient rien alors on affiche la barre sombre du bas.
    if _Menu_State(xmenu,ymenu+1)=0 and _Menu_State(xmenu,ymenu)0
      _Menu_State(xmenu,0)=ymenu
      line xm+127,ym,xm+127,ym+11 : line xm+127,ym+11,xm,ym+11
     endif
   Endif
 EndFunction
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Refresh_Menu_Title(xmenu,state)
  if xmenu>_Menu_Sys(3) then state=1
  set current bitmap _Menu_Sys(6)
  xpos=((xmenu-1)*128)+64 : xm=(xmenu-1)*128
  Rem Affichage du titre du menu
  if state=1 then ink rgb(128,128,128),0 else ink rgb(16,32,64),0
  box xm,0,xm+127,11
  if state=1 then ink 0,0 else ink rgb(192,192,192),0
  Text xm+2,0,_menu_option$(xmenu,0)
 EndFunction
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Posted: 6th Feb 2003 21:22
there was a miss . . .

+ Code Snippet
Rem
Rem DBv1 Project : My Menu v3.0 for Magic-Windows 1.2
Rem
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Rem FUNCTIONS TO USE MENU :
Rem MW_Check_Menu()                                                                Retrace menu to screen if needed.
Rem MW_Get_Choosen_Menu()                                       Give the number corresponding to the overlaped menu.
Rem MW_Get_Choosen_Option()                                                 Give the number of the option overlaped.
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Rem FUNCTIONS TO CREATE MENUS :
Rem MW_Set_Menu_Title(menu,title$)                                                                Define menu title.
Rem MW_Set_Menu_Option(menu,option,title$)                                                       Define menu option.
Rem MW_Set_Menu_Image(_menu,_option,_image)                                           define menu option's thumbail.
Rem MW_Set_Menu_Transition(menu,option)                        Define a menu option as transition (separation line).
Rem MW_Prepare_Menu_v3()                                                          Create full menu on hidden bitmap.
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Rem SYSTEM FUNCTIONS ! USER MUST NOT USE THEM ! ( THEY ARE CALLED BY OTHERS FUNCTIONS )
Rem MW_Refresh_Menu_Option(xmenu,ymenu,state) [SYSTEM]
Rem MW_Refresh_Menu_Title(xmenu,state) [SYSTEM]
Rem MW_Show_Title_Bar() [SYSTEM]
Rem MW_Show_Menu_Bar() [SYSTEM]
Rem
Dim _Menu_Option$(5,17) : Dim _Menu_State(5,17) : Dim _Menu_Logo(5,17) : Dim _Menu_sys(8)
Rem
Set Display Mode 640,480,16
sync rate 0 : Sync On : Sync
backdrop on : color backdrop 0
Rem
Restore _Image_liste
For boucle=1 to 7
  Read _fichier$
  load image "gfx\"+_fichier$,boucle
 next boucle

MW_Set_Menu_Title(1,"Disk")
MW_Set_Menu_Option(1,1,"Charger")
MW_Set_Menu_Image(1,1,1)
MW_Set_Menu_Option(1,2,"Sauver")
MW_Set_Menu_Image(1,2,2)
MW_Set_Menu_Transition(1,3)
MW_Set_Menu_Option(1,4,"Quitter")
MW_Set_Menu_Image(1,4,3)

MW_Set_Menu_Title(2,"Edit")
MW_Set_Menu_Option(2,1,"Couper")
MW_Set_Menu_Image(2,1,4)
MW_Set_Menu_Option(2,2,"Copier")
MW_Set_Menu_Image(2,2,5)
MW_Set_Menu_Option(2,3,"Coller")
MW_Set_Menu_Image(2,3,6)
MW_Set_Menu_Transition(2,4)
MW_Set_Menu_Option(2,5,"Préférences")
MW_Set_Menu_Image(2,5,7)

MW_Prepare_Menu_v3()

Repeat
  _ACTIF=MW_Check_Menu()
  _MENU=MW_Get_Choosen_Menu()
  _OPTION=MW_Get_Choosen_Option()
  if mouseclick()=1
    if _MENU=1 and _OPTION=4 then _QUIT=1
   endif
  Set Current Bitmap 0
  ink rgb(255,255,255),0
  Set Cursor 0,300
  Print "Current Menu Overlaped : ",_MENU
  Print "Current Option overlaped : ",_OPTION
  print "FPS : ",screen fps()
  Sync
 Until _QUIT=1
End

_image_liste:
Data "charger.bmp","sauver.bmp","quit.bmp"
Data "couper.bmp","copier.bmp","coller.bmp"
Data "preferences.bmp"

Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
function MW_Get_Choosen_Menu()
  _LASTMENU=_Menu_Sys(4)
 EndFunction _LASTMENU
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Get_Choosen_Option()
  _LASTMENU=_Menu_Sys(4) : _LASTOPTION=_Menu_Sys(5)
  if _Menu_State(_LASTMENU,_LASTOPTION)=3 then _LASTOPTION=0
 EndFunction _LASTOPTION
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Check_Menu()
  xm=mousex() : ym=mousey() : mc=mouseclick()
  xmenu=(xm/128)+1
  _ACTIVE=_Menu_sys(2) : _LASTMENU=_Menu_Sys(4) : _LASTOPTION=_Menu_Sys(5)
  Rem ON réaffiche de couleur normale la dernière option surlignée.
  if _LASTMENU>0
    if _LASTOPTION=0 then MW_Refresh_Menu_Title(_LASTMENU,1)
    if _LASTOPTION>0 then MW_Refresh_Menu_Option(_LASTMENU,_LASTOPTION,1)
   Endif
  Rem Si le menu était en mode TITRE SELECTIONNE.
  if _ACTIVE=1
    if ( xm<xpos or xm>(xpos+127) ) and ym>11
      _ACTIVE=0
     else
      ymax=(_Menu_State(xmenu,0)+1)*12
      xpos=(_LASTMENU-1)*128
      if xmenu<_Menu_Sys(3)+1 and ym<ymax
        _LASTOPTION=(ym/12) : _LASTMENU=xmenu
        if _LASTOPTION=0 then MW_Refresh_Menu_Title(_LASTMENU,2)
        if _LASTOPTION>0 then MW_Refresh_Menu_Option(_LASTMENU,_LASTOPTION,2)
       Endif
      MW_Show_Title_Bar()
      MW_Show_Menu_Bar(_LASTMENU)
     endif
    if ym>(_Menu_State(xmenu,0)+1)*12 then _ACTIVE=0
   Endif
  Rem Si le menu était en mode INACTIF.
  if _ACTIVE=0
    _LASTMENU=0 : _LASTOPTION=0
    Rem Si la souris est bien placée alors on active le menu choisi.
    if ym<12
      MW_Show_Title_Bar() : _ACTIVE=1
     Endif
   Endif
  _Menu_Sys(2)=_ACTIVE
  _Menu_Sys(4)=_LASTMENU : _Menu_Sys(5)=_LASTOPTION
  Rem On stoque les coordonnées des dernièrs options/menus sélectionnés.
 EndFunction _ACTIVE
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Show_Title_Bar()
  _bitmap=_Menu_Sys(6) : xmax=bitmap width(_bitmap)-1
  Copy Bitmap _bitmap,0,0,xmax-1,11,0,0,0,xmax-1,11
 EndFunction
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Show_Menu_Bar(menu)
  XStart=(menu-1)*128 : ymax=(_Menu_State(menu,0)+1)*12 : _bitmap=_Menu_Sys(6)
  Copy Bitmap _bitmap,xstart,11,xstart+127,ymax,0,xstart,11,xstart+127,ymax
 EndFunction
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Set_Menu_Title(_menu,_name$)
  _Menu_sys(1)=0
  if _menu>0 and _menu<6
    _menu_option$(_menu,0)=_name$ : _Menu_State(_menu,0)=1
   endif
 EndFunction
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Set_Menu_Option(_menu,_option,_name$)
  _Menu_sys(1)=0
  if _menu>0 and _menu<6
    if _option>0 and _option<17
      _menu_option$(_menu,_option)=_name$ : _Menu_State(_menu,_option)=1
     endif
   endif
 EndFunction
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Set_Menu_Image(_menu,_option,_image)
  if _image>0 and _image<65536
    if image exist(_image)=1
      _Menu_Logo(_menu,_option)=_image
     endif
   endif
 EndFunction
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Set_Menu_Transition(_menu,_option)
  _Menu_sys(1)=0
  _Menu_State(_menu,_option)=3 : _Menu_Logo(_menu,_option)=0 : _menu_option$(_menu,_option)=""
 EndFunction
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Prepare_Menu_v3()
  _Menu_sys(1)=1
  Set Text Font "arial"
  Set text size 12
  Rem We look for a free bitmap to store menu graphics.
  if _Menu_Sys(6)=0
    _bitmap=16
    Repeat
      dec _bitmap,1
     until bitmap exist(_bitmap)=0 or _bitmap=0
    if _bitmap>0
      create bitmap _bitmap,640,480
      _Menu_Sys(6)=_bitmap
     endif
    Set Current Bitmap _bitmap
   Else
    Set current bitmap _Menu_Sys(6)
    Cls
   Endif
  Rem ON réalise les 5 menus en commençant par les titres . . .
  _Menu_Sys(3)=0
  for xmenu=1 to 5
    Rem Si le menu à un titre alors on crée le menu
    if _menu_state(xmenu,0)<>0 then _Menu_Sys(3)=xmenu
    MW_Refresh_Menu_Title(xmenu,1)
    Rem On vérifie le contenu des menus . . .
    for ymenu=1 to 16
      MW_Refresh_Menu_Option(xmenu,ymenu,1)
     next ymenu
   next xmenu
 EndFunction
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Refresh_Menu_Option(xmenu,ymenu,state)
  set current bitmap _Menu_Sys(6)
  Rem Si le menu contient un texte alors on le crée.
  if _Menu_State(xmenu,ymenu)>0
    xpos=((xmenu-1)*128)+64 : xm=(xmenu-1)*128 : ym=(ymenu)*12
    Rem On affiche le contenu de la boite de menu.
    if state=1 or _Menu_State(xmenu,ymenu)=3 then ink rgb(128,128,128),0 else ink rgb(16,32,64),0
    box xm,ym,xm+127,ym+11
    Rem Si le menu n'est pas une transition et qu'il possède un THUMBAIL , on l'affiche.
    if _Menu_State(xmenu,ymenu)<3
      Rem Affichage de l'image
      _img=_Menu_Logo(xmenu,ymenu)
      if _img>0 then If Image exist(_img)=1 then paste image _img,xm+1,ym
     Else
      Rem Affichage de la transition . . .
      Ink rgb(160,160,160),0 : line xm+4,ym+5,xm+124,ym+5
      Ink rgb(64,64,64),0 : line xm+4,ym+6,xm+124,ym+6
     Endif
    if ymenu=1
      ink rgb(160,160,160),0 : line xm,ym,xm+127,ym
     Endif
    Rem On affiche alors le contour du menu
    ink rgb(160,160,160),0 : line xm,ym,xm,ym+11
    if state=1 then ink 0,0 else ink rgb(192,192,192),0
    Text xm+18,ym,_menu_option$(xmenu,ymenu)
    ink rgb(64,64,64),0 : line xm+127,ym,xm+127,ym+11
    Rem Si le menu suivant ne contient rien alors on affiche la barre sombre du bas.
    if _Menu_State(xmenu,ymenu+1)=0 and _Menu_State(xmenu,ymenu)<>0
      _Menu_State(xmenu,0)=ymenu
      line xm+127,ym,xm+127,ym+11 : line xm+127,ym+11,xm,ym+11
     endif
   Endif
 EndFunction
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------
Function MW_Refresh_Menu_Title(xmenu,state)
  if xmenu>_Menu_Sys(3) then state=1
  set current bitmap _Menu_Sys(6)
  xpos=((xmenu-1)*128)+64 : xm=(xmenu-1)*128
  Rem Affichage du titre du menu
  if state=1 then ink rgb(128,128,128),0 else ink rgb(16,32,64),0
  box xm,0,xm+127,11
  if state=1 then ink 0,0 else ink rgb(192,192,192),0
  Text xm+2,0,_menu_option$(xmenu,0)
 EndFunction
Rem ------------------------------------------------------------------------------------- MENU SYSTEM --------------


why can't we edit messages !
When error occurs , that should be good.