Module: VRParent
- Included in:
- VRDialogComponent, VRForm, VRGroupbox, VRInputboxDialog, VRModalDialog, VRModelessDialog, VRPanel, VRRebar, VRTabControl, VRTabbedPanel, VRTwoPane
- Defined in:
- lib/vr/vruby.rb
Constant Summary collapse
- DEFAULT_FONT =
VRParent
This module provides the features to be the parent of the child windows.
Constants
— DEFAULT_FONT
Each control created by addControl method is invoked setFont(font) method. Default font of child controls can be set with this constants in the class.
Method
— addControl(ctype,name,caption, x=0,y=0,w=10,h=10, style=0)
Adds a child window(control) of ((|ctype|)) named ((|name|)) with ((|caption|)) at ( ((|x|)) , ((|y|)) ) whose width and height is ( ((|w|)) , ((|h|)) ). ((|ctype|)) is not an instance of the control-class but the class of the child window. ((|style|)) is additional styles for the childwindow such as WMsg::WS_BORDER. You can set nil or "" for ((|name|)). "" is for nameless control, and nil is for the control which is nothing to do with vruby's control management.
— addArrayedControl(index,ctype,name,caption,x=0,y=0,w=10,h=10,style=0)
Adds an indexed child window(control) of ((|ctype|)) named ((|name|)).
— countControls
Returns the number of controls added on the window.
— deleteControls(cntl)
Deletes a control ((|cntl|)) as VRControl.
— clearControls
Deletes all controls on the window.
— send_parent(cname,func)
Sends to parent an event from control. ((|cname|)) is controlname and ((|func|)) is event handler name.
Callback Methods(event handler)
— construct
You can add controls and set menues for the window in this method.
Event handlers
— self_created
Fired when all of child windows is created.
nil
- VR_ADDCONTROL_FEWARGS =
false
Instance Attribute Summary collapse
-
#screen ⇒ Object
readonly
Returns the value of attribute screen.
Instance Method Summary collapse
- #addArrayedControl(num, type, name, caption, x = 0, y = 0, w = 10, h = 10, style = 0) ⇒ Object
- #addControl(type, name, caption, x = 10, y = 10, w = 10, h = 10, style = 0) ⇒ Object (also: #vr_addControlOriginal)
- #clearControls ⇒ Object
-
#construct ⇒ Object
###########################.
- #countControls ⇒ Object
- #create ⇒ Object
- #createControl(type, name, caption, x = 0, y = 0, w = 10, h = 10, style = 0) ⇒ Object
- #deleteControl(cntl) ⇒ Object
- #newControlID ⇒ Object
- #parentinit(screen) ⇒ Object
- #registerControl(c, name, cid) ⇒ Object
- #registerControlAsArrayed(num, c, name, cid) ⇒ Object
- #self_created ⇒ Object
- #send_parent(cname, func) ⇒ Object
Instance Attribute Details
#screen ⇒ Object (readonly)
Returns the value of attribute screen.
467 468 469 |
# File 'lib/vr/vruby.rb', line 467 def screen @screen end |
Instance Method Details
#addArrayedControl(num, type, name, caption, x = 0, y = 0, w = 10, h = 10, style = 0) ⇒ Object
546 547 548 549 550 551 552 553 554 555 |
# File 'lib/vr/vruby.rb', line 546 def addArrayedControl(num,type,name,,x=0,y=0,w=10,h=10,style=0) #p method(:addControl).arity if self.class::VR_ADDCONTROL_FEWARGS then c = addControl(type,"",,style) else c = addControl(type,"",,x,y,w,h,style) end registerControlAsArrayed(num,c,name,c.etc) c end |
#addControl(type, name, caption, x = 10, y = 10, w = 10, h = 10, style = 0) ⇒ Object Also known as: vr_addControlOriginal
533 534 535 536 537 538 539 540 541 542 543 544 |
# File 'lib/vr/vruby.rb', line 533 def addControl(type,name,, x=10,y=10,w=10,h=10, style=0) c = createControl(type,name,, x,y,w,h,style) cid=newControlID registerControl(c,name,cid) c.parent=self c.setscreen(screen) c.parentinit(screen) if c.respond_to?("parentinit") c.create font = self.class::DEFAULT_FONT c.setFont(font) if font.is_a?(SWin::Font) c end |
#clearControls ⇒ Object
571 572 573 574 575 576 |
# File 'lib/vr/vruby.rb', line 571 def clearControls @controls.each do |key,cntl| deleteControl(cntl) end @_vr_cid=0 end |
#construct ⇒ Object
###########################
593 594 595 |
# File 'lib/vr/vruby.rb', line 593 def construct # placeholder end |
#countControls ⇒ Object
559 560 561 |
# File 'lib/vr/vruby.rb', line 559 def countControls @controls.size end |
#create ⇒ Object
507 508 509 510 511 512 |
# File 'lib/vr/vruby.rb', line 507 def create super construct self_created self end |
#createControl(type, name, caption, x = 0, y = 0, w = 10, h = 10, style = 0) ⇒ Object
520 521 522 523 524 525 526 527 528 529 530 |
# File 'lib/vr/vruby.rb', line 520 def createControl(type,name,, x=0,y=0,w=10,h=10, style=0) c=@screen.factory.newwindow(self,type) # c.extend type info = type.Controltype c.classname= info[0] if info[0] c.= c.style=WStyle::WS_VISIBLECHILD | info[1] | style c.exstyle = info[2] if info.size>2 c.move x,y,w,h c end |
#deleteControl(cntl) ⇒ Object
563 564 565 566 567 568 569 |
# File 'lib/vr/vruby.rb', line 563 def deleteControl(cntl) if instance_eval("@controls[cntl.etc]==@#{cntl.name}") then instance_eval("@#{cntl.name}=nil") end @controls.delete(cntl.etc) cntl.close if cntl.alive? end |
#newControlID ⇒ Object
469 470 471 472 473 |
# File 'lib/vr/vruby.rb', line 469 def newControlID r=@_vr_cid + $VRCONTROL_STARTID @_vr_cid+=1 return r end |
#parentinit(screen) ⇒ Object
514 515 516 517 518 |
# File 'lib/vr/vruby.rb', line 514 def parentinit(screen) @screen=screen @controls={} @_vr_cid=0 end |
#registerControl(c, name, cid) ⇒ Object
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 |
# File 'lib/vr/vruby.rb', line 475 def registerControl(c,name,cid) c.etc= cid if name.is_a?(String) then if name.length>0 then atname = instance_eval("@" + name + " ||= nil") raise "Already used name '#{name}'" unless atname.nil? begin instance_eval("@"+name+"=c") if name rescue end end c.name = name @controls[cid]= c end c end |
#registerControlAsArrayed(num, c, name, cid) ⇒ Object
492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
# File 'lib/vr/vruby.rb', line 492 def registerControlAsArrayed(num,c,name,cid) instance_eval("@#{name}=[] unless defined? @#{name}") if instance_eval("@#{name}[#{num}]") raise "Already used number #{num} for #{name}" end begin instance_eval("@#{name}[#{num}]=c") rescue end c.name=name c.extend VRMessageHandler::VRArrayedComponent c._vr_arrayednumber=num c end |
#self_created ⇒ Object
597 598 599 |
# File 'lib/vr/vruby.rb', line 597 def self_created # placeholder end |
#send_parent(cname, func) ⇒ Object
578 579 580 581 582 583 584 585 586 587 588 |
# File 'lib/vr/vruby.rb', line 578 def send_parent(cname,func) defname=cname+"_"+func funcname = self.name + "_" + defname evalstr= "def "+defname+"(*arg) " << "if parent.respond_to?('"+funcname+"') then " << "parent.__send__('"+funcname+"',*arg) " << "end " << "end" instance_eval(evalstr) end |