File: n_svc_menu.sru
Size: 1640
Date: Mon, 07 Apr 2008 21:31:16 +0200
$PBExportHeader$n_svc_menu.sru
forward
global type n_svc_menu from n_svc_base
end type
end forward

global type n_svc_menu from n_svc_base
end type
global n_svc_menu n_svc_menu

forward prototypes
public subroutine of_createmenu (readonly str_menuitem astr[], readonly integer ai_popx, readonly integer ai_popy)
public subroutine of_createmenu (readonly m_dynamic am_root, readonly str_menuitem astr[])
end prototypes

public subroutine of_createmenu (readonly str_menuitem astr[], readonly integer ai_popx, readonly integer ai_popy);m_dynamic lm_root

//create root
lm_root = CREATE m_dynamic
//begin recurse
of_CreateMenu(lm_root, astr)
//pop it
lm_root.PopMenu(ai_popx, ai_popy)

DESTROY lm_root
end subroutine

public subroutine of_createmenu (readonly m_dynamic am_root, readonly str_menuitem astr[]);long ll_count, n
m_dynamic lm_item
str_menuitem lstr_subitems[]

ll_count = UPPERBOUND(astr)
FOR n = 1 to ll_count
   //create
   am_root.item[n] = CREATE m_dynamic
   //cast
   lm_item = am_root.item[n]
   //set props
   lm_item.text = astr[n].menutext
   lm_item.Enabled = NOT astr[n].disable
   lm_item.Checked = astr[n].checked
   IF ISVALID(astr[n].subscriber) THEN
      lm_item.of_setparent(astr[n].subscriber, astr[n].eventname, astr[n].data)
   END IF
   IF ISVALID(astr[n].items) THEN
      TRY
         //attempt cast
         lstr_subitems = astr[n].items
         //recurse
         of_CreateMenu(lm_item, lstr_subitems)
      CATCH (RuntimeError ex)
         //swallow and continue
      END TRY
   END IF
NEXT
end subroutine

on n_svc_menu.create
call super::create
end on

on n_svc_menu.destroy
call super::destroy
end on