Class: InspectList

Inherits:
Object
  • Object
show all
Defined in:
ext/ae-rad/ae-rad-inspector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_family, _host, _left_width = 85, show_scrollbar = true) ⇒ InspectList

Returns a new instance of InspectList.



547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# File 'ext/ae-rad/ae-rad-inspector.rb', line 547

def initialize(_family, _host, _left_width = 85, show_scrollbar=true)
  @lasthandlervalue = 0;
  @family = _family
  #@pwind = AGTkVSplittedFrames.new(_host,_left_width)
  if show_scrollbar
  #  @pwind.place('width' => -15)
    @bar = TkScrollbar.new(_host, Arcadia.style('scrollbar')).pack('side'=>'right', 'fill'=>'y')
  end
  @pwind = AGTkVSplittedFrames.new(_host,_host,_left_width)
  
  background = _host.cget('background')
  common_properties = {'relief'=>'flat','state'=>'disabled', 'borderwidth'=>0, 'background'=>background}
  @left_text = TkText.new(@pwind.left_frame, common_properties).pack('expand'=>'yes', 'fill'=>'both')
  @right_text = TkText.new(@pwind.right_frame, common_properties).pack('expand'=>'yes', 'fill'=>'both')
  
  @left_text.configure('selectbackground'=>@left_text.cget('background'))
@right_text.configure('selectbackground'=>@right_text.cget('background'))

  if show_scrollbar
    @bar.command(proc { |*args|
     @left_text.yview(*args)
     @right_text.yview(*args)
    })
    @left_text.yscrollcommand(proc { |first, last|
       @bar.set(first, last)
    })
    @right_text.yscrollcommand(proc { |first, last|
       @bar.set(first, last)
    })
  end
  @right_text.bind("Configure", 
  		proc{
          new_width = new_right_width
          if new_width
            @proplines.values.each do | _value|
              _value.valueobj.labelkey.configure('width'=>(new_width))
            end
          end
  					
  					},"%w")
  @proplines = Hash.new
end

Instance Attribute Details

#agobjObject (readonly)

Returns the value of attribute agobj.



543
544
545
# File 'ext/ae-rad/ae-rad-inspector.rb', line 543

def agobj
  @agobj
end

#familyObject

Returns the value of attribute family.



543
544
545
# File 'ext/ae-rad/ae-rad-inspector.rb', line 543

def family
  @family
end

#lasthandlervalueObject

Returns the value of attribute lasthandlervalue.



545
546
547
# File 'ext/ae-rad/ae-rad-inspector.rb', line 545

def lasthandlervalue
  @lasthandlervalue
end

#left_textObject (readonly)

Returns the value of attribute left_text.



546
547
548
# File 'ext/ae-rad/ae-rad-inspector.rb', line 546

def left_text
  @left_text
end

#pwindObject (readonly)

Returns the value of attribute pwind.



543
544
545
# File 'ext/ae-rad/ae-rad-inspector.rb', line 543

def pwind
  @pwind
end

#right_textObject (readonly)

Returns the value of attribute right_text.



546
547
548
# File 'ext/ae-rad/ae-rad-inspector.rb', line 546

def right_text
  @right_text
end

Instance Method Details

#clearObject



606
607
608
609
610
611
612
# File 'ext/ae-rad/ae-rad-inspector.rb', line 606

def clear
  @proplines.values.each do | _value|
    _value.free
  end
  @lasthandlervalue = 0;
  @proplines.clear
end

#deleteObject



656
657
658
# File 'ext/ae-rad/ae-rad-inspector.rb', line 656

def delete
  @pwind.destroy
end

#modProp(_name, _newvalue) ⇒ Object



653
654
655
# File 'ext/ae-rad/ae-rad-inspector.rb', line 653

def modProp(_name, _newvalue)
  @proplines[_name].setvalue(_newvalue)
end

#new_right_widthObject



590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
# File 'ext/ae-rad/ae-rad-inspector.rb', line 590

def new_right_width
  new_width = 0
	font_size = TkFont.new(@right_text.cget('font')).size
   w=TkPlace.info(@pwind.right_frame)['width']
   dw = TkPlace.info(@pwind.left_frame)['width']
   p = @pwind
   while p != nil && !p.kind_of?(AGTkVSplittedFrames) || p == @pwind
     p= TkWinfo.parent(p)
   end 
   if p
     dwp = TkPlace.info(p.left_frame)['width']
     new_width = ((dwp+w)/(font_size-2)).round
	end
	return new_width
end

#updatelines(_agobj, _properties = nil) ⇒ Object



614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
# File 'ext/ae-rad/ae-rad-inspector.rb', line 614

def updatelines(_agobj, _properties=nil)
  @left_text.configure('state'=>'normal')             
  @right_text.configure('state'=>'normal')             
  if _properties == nil
    clear
    return
  else
    @lasthandlervalue.free(false) if @lasthandlervalue != 0
    @lasthandlervalue = 0;
  end
  @agobj = _agobj
  _propvalues = []
  @proplines.keys.sort.each{|key|
    _propvalues << @proplines[key]
  }
  @proplines.clear
  _inf = 0
  _sup = _propvalues.length
  @array_key = _properties.keys
  @array_key.sort.each do |key|
    if _inf < _sup # reuse it
      _propvalues[_inf].updatekeyvalue(@agobj, key, _properties[key])
      @proplines[key] = _propvalues[_inf]
      _inf = _inf.next
    else # create new
      #Tk.messageBox('message'=>key)
      @proplines[key] = PropLine.new(self, key, _properties[key])
      @proplines[key].valueobj.labelkey.configure('width'=>(new_right_width)) 
    end
  end
  if _sup > _inf
    _inf.upto(_sup -1 ) {|i|
      _propvalues[i].free
    }
  end
  @left_text.configure('state'=>'disabled')             
  @right_text.configure('state'=>'disabled')             
end