Class: VRControl

Inherits:
VRWinComponent show all
Defined in:
lib/vr/vruby.rb

Constant Summary collapse

WINCLASSINFO =
[nil,0]

Instance Attribute Summary collapse

Attributes inherited from VRWinComponent

#screen

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from VRWinComponent

#_init, #exwinstyle, #hide, #maximizebox, #maximizebox=, #minimizebox, #minimizebox=, #setscreen, #sizebox, #sizebox=, #tabstop, #tabstop=, #vrinit, #winstyle

Instance Attribute Details

#handlersObject (readonly)

VRControl

Base class for controls.

Methods

— add_parentcall(funcname)

Makes event handlers to be passed through to its parent window.
For example, add_parentcall("btn1_clicked") provides a new event 
((| ????_btn1_clicked |)) on its parent window.
(???? is the name of the control).

— call_parenthandler(handlername,*arg)

Calls event handler of parent window in ctrlname_handlername(*arg) style.

— setFont(font,redraw=true)

Sets drawing font to ((|font|)). Control will be re-drawn if redraw flag.


625
626
627
# File 'lib/vr/vruby.rb', line 625

def handlers
  @handlers
end

#nameObject (readonly)

Returns the value of attribute name.



627
628
629
# File 'lib/vr/vruby.rb', line 627

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



626
627
628
# File 'lib/vr/vruby.rb', line 626

def parent
  @parent
end

Class Method Details

.ControltypeObject



631
632
633
# File 'lib/vr/vruby.rb', line 631

def self.Controltype()
  self::WINCLASSINFO
end

Instance Method Details

#add_parentcall(func) ⇒ Object



641
642
643
644
645
646
647
648
649
650
# File 'lib/vr/vruby.rb', line 641

def add_parentcall(func)
  funcname=@name+"_"+func
  evalstr=
    "def self_"+func+"(*arg) "+
      "if parent.respond_to?('"+funcname+"') then "+
        "parent.__send__('"+funcname+"',*arg) "+
      "end "+
    "end"
  instance_eval(evalstr)
end

#call_parenthandler(handlername, *arg) ⇒ Object



664
665
666
# File 'lib/vr/vruby.rb', line 664

def call_parenthandler(handlername,*arg)
  @parent.controlmsg_dispatching(self,handlername,*arg)
end

#createObject



635
636
637
638
639
# File 'lib/vr/vruby.rb', line 635

def create
  super
  self_created if respond_to?("self_created")
  self
end

#setFont(font, redraw = true) ⇒ Object



652
653
654
655
656
657
658
659
660
661
662
# File 'lib/vr/vruby.rb', line 652

def setFont(font,redraw=true)
  if self.dopaint then
    super font
  end
  if font.is_a?(SWin::Font) then
    self.properties["font"]=font
    sendMessage WMsg::WM_SETFONT,font.hfont, ( (redraw)? 1 : 0 )
  else
    raise "#{font} is not a font."
  end
end