Class: VRMenuItem

Inherits:
Object show all
Defined in:
lib/vr/vrcontrol.rb

Overview

VRMenuTemplate

If you don't like using Array for VRMenu#set, this will help you.

Methods

--- caption --- caption= Represents the caption of the menu. --- item --- item= When ((|item|)) is String, ((|item|)) means the name of menu item. This name is used for the event handler name like ((|item|))_clicked. ((|item|)) can be also an instance of VRMenuTemplate. In this case ((|item|)) represents its submenu.

example

a=VRMenuTemplate.new a.caption,a.item = "Test1","test1"

b=VRMenuTemplate.new("Test2","test2")
c=VRMenuTemplate.new("Test3","test3",VRMenuItem::GRAYED)

d1=VRMenuTemplate.new("Test4-1","test41")
d2=VRMenuTemplate.new("Test4-2","test42")
d3=VRMenuTemplate.new("Test4-3","test43")

d = VRMenuTemplate.new
d.caption , d.item = "Test4" , [d1,d2,d3]

Constant Summary collapse

GRAYED =
1
DISABLED =
2
CHECKED =
8

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(menu) ⇒ VRMenuItem

Returns a new instance of VRMenuItem.



981
982
983
# File 'lib/vr/vrcontrol.rb', line 981

def initialize(menu)
  @menu=menu
end

Instance Attribute Details

#etc ⇒ Object (readonly)

Returns the value of attribute etc.



975
976
977
# File 'lib/vr/vrcontrol.rb', line 975

def etc
  @etc
end

#name ⇒ Object (readonly)

VRMenuItem

This is a wrapper of SWin::Menu

Methods

--- new(menu) ((|menu|)) must be the instance of SWin::Menu. --- state Returns the state of the menu item. --- state= Sets the state of the menu item. state means * 0 MF_ENABLED * 1 MF_GRAYED * 2 MF_DISABLED * 8 MF_CHECKED --- checked? Returns true if the menu item is checked. --- checked= Sets true/false whether the menu item is checked or not. --- modify(text) Modifies the text of the menu item.



974
975
976
# File 'lib/vr/vrcontrol.rb', line 974

def name
  @name
end

Instance Method Details

#_vr_cmdhandlers ⇒ Object



984
985
986
987
# File 'lib/vr/vrcontrol.rb', line 984

def _vr_cmdhandlers
  {0=>[["clicked",MSGTYPE::ARGNONE,nil]],    # for menu
   1=>[["clicked",MSGTYPE::ARGNONE,nil]]}    # for key accelerator
end

#checked=(f) ⇒ Object



995
996
997
# File 'lib/vr/vrcontrol.rb', line 995

def checked=(f)
  @menu.setChecked(@etc,f)
end

#checked? ⇒ Boolean

Returns:

  • (Boolean)


998
999
1000
# File 'lib/vr/vrcontrol.rb', line 998

def checked?
  (self.state&8)==8
end

#modify(text) ⇒ Object



1001
1002
1003
# File 'lib/vr/vrcontrol.rb', line 1001

def modify(text)
  @menu.modify @etc,text
end

#state ⇒ Object



992
993
994
# File 'lib/vr/vrcontrol.rb', line 992

def state
  @menu.getState(@etc)
end

#state=(st) ⇒ Object



989
990
991
# File 'lib/vr/vrcontrol.rb', line 989

def state= (st)
  @menu.setState(@etc,st)
end