Class: ArcadiaExt

Inherits:
Object
  • Object
show all
Defined in:
lib/a-commons.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_arcadia, _name = nil) ⇒ ArcadiaExt

Returns a new instance of ArcadiaExt.



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# 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")
  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

Instance Attribute Details

#arcadiaObject (readonly)

Returns the value of attribute arcadia.



214
215
216
# File 'lib/a-commons.rb', line 214

def arcadia
  @arcadia
end

#nameObject (readonly)

Returns the value of attribute name.



215
216
217
# File 'lib/a-commons.rb', line 215

def name
  @name
end

Instance Method Details

#add_to_conf_property(_name, _value) ⇒ Object



264
265
266
267
268
269
270
# File 'lib/a-commons.rb', line 264

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) ⇒ Object



250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/a-commons.rb', line 250

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) ⇒ Object



356
357
358
359
360
361
# File 'lib/a-commons.rb', line 356

def conf(_property, _value=nil)
  if !_value.nil?
    @arcadia['conf'][@name+'.'+_property] = _value
  end
  @arcadia['conf'][@name+'.'+_property]
end

#conf_array(_name) ⇒ Object



242
243
244
245
246
247
248
# File 'lib/a-commons.rb', line 242

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) ⇒ Object



363
364
365
# File 'lib/a-commons.rb', line 363

def conf_default(_property)
  @arcadia['conf_without_local'][@name+'.'+_property]
end

#del_from_conf_property(_name, _value) ⇒ Object



272
273
274
275
276
# File 'lib/a-commons.rb', line 272

def del_from_conf_property(_name, _value)
  a = conf_array(_name)
  a.delete(_value)
  array_conf(_name,a)
end

#destroy_frame(_n = 0) ⇒ Object



238
239
240
# File 'lib/a-commons.rb', line 238

def destroy_frame(_n=0)
  Arcadia.layout.unregister_panel(frame(_n), true, true)
end

#exec(_method, _args = nil) ⇒ Object

def conf_global(_property)

 @arcadia['conf'][_property]
end


377
378
379
380
381
# File 'lib/a-commons.rb', line 377

def exec(_method, _args=nil)
  if self.respond_to(_method)
    self.send(_method, _args)
  end
end

#float_frame(_n = 0, _args = nil) ⇒ Object



348
349
350
351
352
353
354
# File 'lib/a-commons.rb', line 348

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) ⇒ Object



291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/a-commons.rb', line 291

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)
  end
  return @frames[_n]
end

#frame_def_visible?(_n = 0) ⇒ Boolean

Returns:

  • (Boolean)


282
283
284
285
# File 'lib/a-commons.rb', line 282

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) ⇒ Object



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/a-commons.rb', line 304

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) ⇒ Object



335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/a-commons.rb', line 335

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_title(_n = 0) ⇒ Object



278
279
280
# File 'lib/a-commons.rb', line 278

def frame_title(_n=0)
  @frames_labels[_n] if @frames[_n] != nil
end

#frame_visible?(_n = 0) ⇒ Boolean

Returns:

  • (Boolean)


287
288
289
# File 'lib/a-commons.rb', line 287

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) ⇒ Object



234
235
236
# File 'lib/a-commons.rb', line 234

def hide_frame(_n=0)
  Arcadia.layout.unregister_panel(frame(_n), false, true)
end

#maximize(_n = 0) ⇒ Object



389
390
391
# File 'lib/a-commons.rb', line 389

def maximize(_n=0)
  @frames[_n].maximize if @frames[_n]
end

#maximized?(_n = 0) ⇒ Boolean

Returns:

  • (Boolean)


383
384
385
386
387
# File 'lib/a-commons.rb', line 383

def maximized?(_n=0)
  ret= false
  ret=@frames[_n].maximized? if @frames[_n]
  ret
end

#resize(_n = 0) ⇒ Object



393
394
395
# File 'lib/a-commons.rb', line 393

def resize(_n=0)
  @frames[_n].resize if @frames[_n]
end

#restore_default_conf(_property) ⇒ Object



367
368
369
370
371
# File 'lib/a-commons.rb', line 367

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