class ArcadiaExt

Attributes

arcadia[R]
name[R]

Public Class Methods

new(_arcadia, _name=nil) click to toggle source
# File lib/a-commons.rb, line 216
def initialize(_arcadia, _name=nil)
  @arcadia = _arcadia
  @name = _name
  @arcadia.register(self)
  @frames = Array.new
  @frames_points = conf_array("frames")
  @frames_labels = conf_array("frames.labels")
  @frames_names = conf_array("frames.names")
  @float_frames = Array.new
  @float_geometries = conf_array("float_frames")
  @float_labels = conf_array("float_labels")
  @hinner_dialogs = []
  Arcadia.attach_listener(self, BuildEvent)
  Arcadia.attach_listener(self, InitializeEvent)
  Arcadia.attach_listener(self, ExitQueryEvent)
  Arcadia.attach_listener(self, FinalizeEvent)
  #ObjectSpace.define_finalizer(self, self.method(:finalize).to_proc)
end

Public Instance Methods

add_to_conf_property(_name, _value) click to toggle source
# File lib/a-commons.rb, line 265
def add_to_conf_property(_name, _value)
  a = conf_array(_name)
  if !a.include?(_value)
    a << _value
    array_conf(_name,a)
  end
end
array_conf(_name, _array) click to toggle source
# File lib/a-commons.rb, line 251
  def array_conf(_name, _array)
#    value = ''
#    _array.each{|e|
#      if value.length > 0
#        value = "#{value},#{e}"
#      else
#        value = "#{e}"
#      end
#    }
#    @arcadia['conf'][_name]=value
#    value
    Application.array_conf("#{@name}.#{_name}", _array)
  end
conf(_property, _value=nil) click to toggle source
# File lib/a-commons.rb, line 385
def conf(_property, _value=nil)
  if !_value.nil?
    @arcadia['conf'][@name+'.'+_property] = _value
  end
  @arcadia['conf'][@name+'.'+_property]
end
conf_array(_name) click to toggle source
# File lib/a-commons.rb, line 243
  def conf_array(_name)
#    res = []
#    value = @arcadia['conf'][_name]
#    res.concat(value.split(',')) if value
#    res
    Application.conf_array("#{@name}.#{_name}")
  end
conf_default(_property) click to toggle source
# File lib/a-commons.rb, line 392
def conf_default(_property)
  @arcadia['conf_without_local'][@name+'.'+_property]
end
del_from_conf_property(_name, _value) click to toggle source
# File lib/a-commons.rb, line 273
def del_from_conf_property(_name, _value)
  a = conf_array(_name)
  a.delete(_value)
  array_conf(_name,a)
end
destroy_frame(_n=0) click to toggle source
# File lib/a-commons.rb, line 239
def destroy_frame(_n=0)
  Arcadia.layout.unregister_panel(frame(_n), true, true)
end
exec(_method, _args=nil) click to toggle source

def conf_global(_property)

@arcadia['conf'][_property]

end

# File lib/a-commons.rb, line 406
def exec(_method, _args=nil)
  if self.respond_to(_method)
    self.send(_method, _args)
  end
end
float_frame(_n=0, _args=nil) click to toggle source
# File lib/a-commons.rb, line 377
def float_frame(_n=0, _args=nil)
  if @float_frames[_n].nil?
    (@float_labels[_n].nil?)? _label = @name : _label = @float_labels[_n]
    @float_frames[_n] =  FloatFrameWrapper.new(@arcadia, @float_geometries[_n], _label)
  end
  @float_frames[_n]
end
frame(_n=0,create_if_not_exist=true) click to toggle source
# File lib/a-commons.rb, line 296
def frame(_n=0,create_if_not_exist=true)
  if @frames_points[_n].nil?
    @frames_points[_n] = '0.0'
    Arcadia['conf']["#{@name}.frames"]+=',0.0'
  end  
  if @frames[_n] == nil && @frames_points[_n] && create_if_not_exist
    (@frames_labels[_n].nil?)? _label = @name : _label = @frames_labels[_n]
    (@frames_names[_n].nil?)? _name = @name : _name = @frames_names[_n]
    @frames[_n] = FixedFrameWrapper.new(self, @frames_points[_n], _name, _label, _n)
    @frames[_n].hinner_frame.bind_append("Enter", proc{self.frame.root.shift_on if self.frame_visible?})
  end
  return @frames[_n]
end
frame_def_visible?(_n=0) click to toggle source
# File lib/a-commons.rb, line 283
def frame_def_visible?(_n=0)
  @arcadia.layout.domains.include?(@frames_points[_n])
  #@frames_points[_n] != '-1.-1'
end
frame_domain(_n=0, _value=nil) click to toggle source
# File lib/a-commons.rb, line 333
def frame_domain(_n=0, _value=nil)
  if conf('frames')
    frs = conf('frames').split(',')
  else
    frs = Array.new
  end
  ret = nil
  if frs.length > _n
    if _value != nil
      ret = _value
      conf_value = ''
      frs.each_with_index{|v,i| 
        if i==_n
          cv = _value 
        else
          cv = v
        end
        if conf_value.length > 0
          conf_value+=",#{cv}"
        else
          conf_value+=cv
        end
      }
      conf('frames', conf_value)
    else
      ret = frs[_n]
    end
  end
  ret
end
frame_domain_default(_n=0) click to toggle source
# File lib/a-commons.rb, line 364
def frame_domain_default(_n=0)
  if conf_default('frames')
    frs = conf_default('frames').split(',')
  else
    frs = Array.new
  end
  ret = nil
  if frs.length > _n
    ret = frs[_n]
  end
  ret
end
frame_raised?(_n=0) click to toggle source
# File lib/a-commons.rb, line 292
def frame_raised?(_n=0)
  @arcadia.layout.raised?(frame_domain(_n), @name)
end
frame_title(_n=0) click to toggle source
# File lib/a-commons.rb, line 279
def frame_title(_n=0)
  @frames_labels[_n] if @frames[_n] != nil
end
frame_visible?(_n=0) click to toggle source
# File lib/a-commons.rb, line 288
def frame_visible?(_n=0)
  @frames != nil && @frames[_n] != nil && @frames[_n].hinner_frame && TkWinfo.mapped?(@frames[_n].hinner_frame)
end
hide_frame(_n=0) click to toggle source
# File lib/a-commons.rb, line 235
def hide_frame(_n=0)
  Arcadia.layout.unregister_panel(frame(_n), false, true)
end
hinner_dialog(_n=0, side='top', args=nil) click to toggle source
# File lib/a-commons.rb, line 310
def hinner_dialog(_n=0, side='top', args=nil)
  if @hinner_dialogs[0].nil?
    @hinner_dialogs[_n] = @arcadia.layout.add_hinner_dialog(side, args)
    @hinner_dialogs[_n].pack('side' =>side,'padx'=>0, 'pady'=>0, 'fill'=>'x', 'expand'=>'1')
  end
  @hinner_dialogs[_n]
end
hinner_splitted_dialog(_n=0, _side='top', _height=100, _args=nil) click to toggle source
# File lib/a-commons.rb, line 318
def hinner_splitted_dialog(_n=0, _side='top', _height=100, _args=nil)
  if @hinner_dialogs[0].nil?
    @hinner_dialogs[_n] = @arcadia.layout.add_hinner_splitted_dialog(_side, _height, _args)
  end
  @hinner_dialogs[_n]
end
hinner_splitted_dialog_titled(_title=nil, _n=0, _side='top', _height=100, _args=nil) click to toggle source
# File lib/a-commons.rb, line 325
def hinner_splitted_dialog_titled(_title=nil, _n=0, _side='top', _height=100, _args=nil)
  if @hinner_dialogs[0].nil?
    @hinner_dialogs[_n] = @arcadia.layout.add_hinner_splitted_dialog_titled(_title, _side, _height, _args)
  end
  @hinner_dialogs[_n]
end
maximize(_n=0) click to toggle source
# File lib/a-commons.rb, line 418
def maximize(_n=0)
  @frames[_n].maximize if @frames[_n]
end
maximized?(_n=0) click to toggle source
# File lib/a-commons.rb, line 412
def maximized?(_n=0)
  ret= false
  ret=@frames[_n].maximized? if @frames[_n]
  ret
end
resize(_n=0) click to toggle source
# File lib/a-commons.rb, line 422
def resize(_n=0)
  @frames[_n].resize if @frames[_n]
end
restore_default_conf(_property) click to toggle source
# File lib/a-commons.rb, line 396
def restore_default_conf(_property)
  if  @arcadia['conf'][@name+'.'+_property] && @arcadia['conf_without_local'][@name+'.'+_property]
    @arcadia['conf'][@name+'.'+_property] = @arcadia['conf_without_local'][@name+'.'+_property]
  end
end