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.



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/a-commons.rb', line 209

def initialize(_arcadia, _name=nil)
  @arcadia = _arcadia
  @arcadia.register(self)
  Arcadia.attach_listener(self, BuildEvent)
  Arcadia.attach_listener(self, ExitQueryEvent)
  Arcadia.attach_listener(self, FinalizeEvent)
  @name = _name
  @frames = Array.new
  @frames_points = conf_array("#{_name}.frames")
  @frames_labels = conf_array("#{_name}.frames.labels")
  @frames_names = conf_array("#{_name}.frames.names")
  @float_frames = Array.new
  @float_geometries = conf_array("#{_name}.float_frames")
  @float_labels = conf_array("#{_name}.float_labels")
  #ObjectSpace.define_finalizer(self, self.method(:finalize).to_proc)
end

Instance Attribute Details

#arcadiaObject (readonly)

Returns the value of attribute arcadia.



207
208
209
# File 'lib/a-commons.rb', line 207

def arcadia
  @arcadia
end

#nameObject (readonly)

Returns the value of attribute name.



208
209
210
# File 'lib/a-commons.rb', line 208

def name
  @name
end

Instance Method Details

#conf(_property) ⇒ Object



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

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

#conf_array(_name) ⇒ Object



227
228
229
230
231
232
# File 'lib/a-commons.rb', line 227

def conf_array(_name)
  res = []
  value = @arcadia['conf'][_name]
  res.concat(value.split(',')) if value
  res
end

#conf_default(_property) ⇒ Object



290
291
292
# File 'lib/a-commons.rb', line 290

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

#exec(_method, _args = nil) ⇒ Object

def conf_global(_property)

 @arcadia['conf'][_property]
end


304
305
306
307
308
# File 'lib/a-commons.rb', line 304

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

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



278
279
280
281
282
283
284
# File 'lib/a-commons.rb', line 278

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



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

def frame(_n=0,create_if_not_exist=true)
 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)


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

def frame_def_visible?(_n=0)
  @arcadia.layout.domains.include?(@frames_points[_n])
  #@frames_points[_n] != '-1.-1'
end

#frame_domain(_n = 0) ⇒ Object



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

def frame_domain(_n=0)
  if conf('frames')
     frs = conf('frames').split(',') 
  else 
    frs = Array.new
  end
  ret = nil
  if frs.length > _n
    ret = frs[_n]
  end
  ret
end

#frame_domain_default(_n = 0) ⇒ Object



265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/a-commons.rb', line 265

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_visible?(_n = 0) ⇒ Boolean

Returns:

  • (Boolean)


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

def frame_visible?(_n=0)
  @frames[_n] != nil && @frames[_n].hinner_frame && TkWinfo.mapped?(@frames[_n].hinner_frame)
end

#maximize(_n = 0) ⇒ Object



316
317
318
# File 'lib/a-commons.rb', line 316

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

#maximized?(_n = 0) ⇒ Boolean

Returns:

  • (Boolean)


310
311
312
313
314
# File 'lib/a-commons.rb', line 310

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

#resize(_n = 0) ⇒ Object



320
321
322
# File 'lib/a-commons.rb', line 320

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

#restore_default_conf(_property) ⇒ Object



294
295
296
297
298
# File 'lib/a-commons.rb', line 294

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