Class: Canis::CheckBoxMenuItem

Inherits:
MenuItem show all
Defined in:
lib/canis/core/widgets/rmenu.rb

Overview

menubar

Instance Attribute Summary collapse

Attributes inherited from MenuItem

#accelerator, #active_index, #bgcolor, #coffset, #col, #color, #color_pair, #enabled, #mnemonic, #parent, #row, #text, #width

Instance Method Summary collapse

Methods inherited from MenuItem

#command, #destroy, #highlight, #on_enter, #on_leave

Constructor Details

#initialize(text, mnemonic = nil, &block) ⇒ CheckBoxMenuItem

Returns a new instance of CheckBoxMenuItem.



925
926
927
928
929
# File 'lib/canis/core/widgets/rmenu.rb', line 925

def initialize text, mnemonic=nil, &block
  @checkbox = CheckBox.new nil
  @checkbox.text text
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



960
961
962
963
964
965
966
967
# File 'lib/canis/core/widgets/rmenu.rb', line 960

def method_missing(sym, *args)
  if checkbox.respond_to? sym
    #$log.debug("calling CHECKBOXMENU #{sym} called #{args[0]}")
    checkbox.send(sym, args)
  else
    $log.error("ERROR CHECKBOXMENU #{sym} called")
  end
end

Instance Attribute Details

#checkboxObject (readonly)

Returns the value of attribute checkbox.



924
925
926
# File 'lib/canis/core/widgets/rmenu.rb', line 924

def checkbox
  @checkbox
end

Instance Method Details

#fireObject



948
949
950
951
952
953
# File 'lib/canis/core/widgets/rmenu.rb', line 948

def fire
  checkbox.toggle
  super
  repaint
  highlight true
end

#getvalueObject



942
943
944
# File 'lib/canis/core/widgets/rmenu.rb', line 942

def getvalue
  checkbox.getvalue
end

#getvalue_for_paintObject



945
946
947
# File 'lib/canis/core/widgets/rmenu.rb', line 945

def getvalue_for_paint
  "|%-*s|" % [@width, checkbox.getvalue_for_paint]
end

#offvalueObject



933
934
935
# File 'lib/canis/core/widgets/rmenu.rb', line 933

def offvalue
  @checkbox.onvalue offvalue
end

#onvalueObject



930
931
932
# File 'lib/canis/core/widgets/rmenu.rb', line 930

def onvalue
  @checkbox.onvalue onvalue
end

#repaintObject

checkbox



954
955
956
957
958
959
# File 'lib/canis/core/widgets/rmenu.rb', line 954

def repaint # checkbox
  # FIXME need @color_pair here
    @color_pair  ||= get_color($reversecolor, @color, @bgcolor)
  @parent.window.printstring( row, 0, getvalue_for_paint, @color_pair)
  parent.window.wrefresh
end

#text=(t) ⇒ Object

stack level too deep if no = .????



936
937
938
# File 'lib/canis/core/widgets/rmenu.rb', line 936

def text=(t) # stack level too deep if no = .????
 @checkbox.text t
end

#to_sObject



939
940
941
# File 'lib/canis/core/widgets/rmenu.rb', line 939

def to_s
  "    #{text} "
end