Class: RubyCurses::Tab

Inherits:
Object show all
Defined in:
lib/rbcurse/core/widgets/rtabbedpane.rb

Overview

class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, parent_component, aconfig = {}, &block) ⇒ Tab

Returns a new instance of Tab.



533
534
535
536
537
538
539
540
541
542
# File 'lib/rbcurse/core/widgets/rtabbedpane.rb', line 533

def initialize text, parent_component,  aconfig={}, &block
  @text   = text
  @items  = []
  @config = aconfig
  @parent_component = parent_component
  @row_offset ||= 2
  @col_offset ||= 2
  @config.each_pair { |k,v| variable_set(k,v) }
  instance_eval &block if block_given?
end

Instance Attribute Details

#buttonObject

so you can set an event on it 2011-10-4



530
531
532
# File 'lib/rbcurse/core/widgets/rtabbedpane.rb', line 530

def button
  @button
end

#col_offsetObject

Returns the value of attribute col_offset.



532
533
534
# File 'lib/rbcurse/core/widgets/rtabbedpane.rb', line 532

def col_offset
  @col_offset
end

#configObject (readonly)

Returns the value of attribute config.



526
527
528
# File 'lib/rbcurse/core/widgets/rtabbedpane.rb', line 526

def config
  @config
end

#indexObject

Returns the value of attribute index.



529
530
531
# File 'lib/rbcurse/core/widgets/rtabbedpane.rb', line 529

def index
  @index
end

#itemsObject (readonly)

Returns the value of attribute items.



527
528
529
# File 'lib/rbcurse/core/widgets/rtabbedpane.rb', line 527

def items
  @items
end

#parent_componentObject

Returns the value of attribute parent_component.



528
529
530
# File 'lib/rbcurse/core/widgets/rtabbedpane.rb', line 528

def parent_component
  @parent_component
end

#row_offsetObject

Returns the value of attribute row_offset.



531
532
533
# File 'lib/rbcurse/core/widgets/rtabbedpane.rb', line 531

def row_offset
  @row_offset
end

#textObject

Returns the value of attribute text.



525
526
527
# File 'lib/rbcurse/core/widgets/rtabbedpane.rb', line 525

def text
  @text
end

Instance Method Details

#item(widget) ⇒ Object



543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
# File 'lib/rbcurse/core/widgets/rtabbedpane.rb', line 543

def item widget
  widget.form = @parent_component.form
  widget.override_graphic @parent_component.form.window
  # these will fail if TP put inside some other container. NOTE
  widget.row ||= 0
  widget.col ||= 0
  # If we knew it was only widget we could expand it
  if widget.kind_of?(RubyCurses::Container) #|| widget.respond_to?(:width)
    widget.width ||= @parent_component.width-3
  end
  # Darn ! this was setting Label to fully height
  if widget.kind_of?(RubyCurses::Container) #|| widget.respond_to?(:height)
    widget.height ||= @parent_component.height-3
  end
  # i don't know button_offset as yet
  widget.row += @row_offset + @parent_component.row  + 1
  widget.col += @col_offset + @parent_component.col
  @items << widget
end