Class: TkTitledFrame

Inherits:
TkBaseTitledFrame show all
Defined in:
lib/a-tkcommons.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TkBaseTitledFrame

#add_fixed_button, #add_fixed_menu_button, #add_fixed_panel, #add_fixed_progress, #add_fixed_sep, #create_frame, #menu_button, #visible?

Constructor Details

#initialize(parent = nil, title = nil, img = nil, keys = nil) ⇒ TkTitledFrame

Returns a new instance of TkTitledFrame.



1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
# File 'lib/a-tkcommons.rb', line 1375

def initialize(parent=nil, title=nil, img=nil , keys=nil)
  super(parent, keys)
  @state = 'normal'
  @title = title
  @img = img
#    @left_label = create_left_label
  @left_label = create_left_title
  @right_label = create_right_label
  @right_labels_text = Hash.new
  @right_labels_image = Hash.new
  @ap = Array.new
  @apx = Array.new
  @apy = Array.new
  @apw = Array.new
  @aph = Array.new
  @top.bind_append("Double-Button-1", proc{resize})
  #@left_label.bind_append("Double-Button-1", proc{resize})
  @right_label.bind_append("Double-Button-1", proc{resize})
end

Instance Attribute Details

#frameObject

Returns the value of attribute frame.



1372
1373
1374
# File 'lib/a-tkcommons.rb', line 1372

def frame
  @frame
end

#parentObject (readonly)

Returns the value of attribute parent.



1374
1375
1376
# File 'lib/a-tkcommons.rb', line 1374

def parent
  @parent
end

#topObject (readonly)

Returns the value of attribute top.



1373
1374
1375
# File 'lib/a-tkcommons.rb', line 1373

def top
  @top
end

Instance Method Details

#__create_right_label(_frame) ⇒ Object

def __create_left_label(_frame)

  @title.nil??_text_title ='':_text_title = @title+' :: '
  _img=@img
  TkLabel.new(_frame, Arcadia.style('titlelabel')){
    text _text_title
    anchor  'w'
    compound 'left'
    image  TkAllPhotoImage.new('file' => _img) if _img
    pack('side'=> 'left','anchor'=> 'e')
  }
end


1415
1416
1417
1418
1419
1420
1421
1422
1423
# File 'lib/a-tkcommons.rb', line 1415

def __create_right_label(_frame)
  TkLabel.new(_frame, Arcadia.style('titlelabel')){
    anchor  'w'
    font "#{Arcadia.conf('titlelabel.font')} italic"
    foreground  Arcadia.conf('titlecontext.foreground')
    compound 'left'
    pack('side'=> 'left','anchor'=> 'e')
  }
end

#create_right_labelObject

def create_left_label

  __create_left_label(@top)
end


1399
1400
1401
# File 'lib/a-tkcommons.rb', line 1399

def create_right_label
  __create_right_label(@top)
end

#head_buttonsObject

def top_text(_text)

  @right_label.text(_text)
end


1511
1512
1513
1514
# File 'lib/a-tkcommons.rb', line 1511

def head_buttons
  @bmaxmin = add_fixed_button('[ ]',proc{resize}, W_MAX_GIF)
  #@bmaxmin = add_button('[ ]',proc{resize}, EXPAND_GIF)
end

#last_caption(_name) ⇒ Object



1491
1492
1493
# File 'lib/a-tkcommons.rb', line 1491

def last_caption(_name)
  @right_labels_text[_name]
end

#last_caption_image(_name) ⇒ Object



1495
1496
1497
# File 'lib/a-tkcommons.rb', line 1495

def last_caption_image(_name)
  @right_labels_image[_name]
end

#maximizeObject



1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
# File 'lib/a-tkcommons.rb', line 1538

def maximize
  if @state == 'normal'
    p = TkWinfo.parent(self)
    while (p != nil) && (TkWinfo.manager(p)=='place')
      Arcadia.dialog(self, 'msg'=>p.to_s)
      #Tk.messageBox('message'=>p.to_s)
      @ap << p
      @apx << TkPlace.info(p)['x']
      @apy << TkPlace.info(p)['y']
      @apw << TkPlace.info(p)['width']
      @aph << TkPlace.info(p)['height']
      p.place('x'=>0, 'y'=>0,'relheight'=>1, 'relwidth'=>1)
      p.raise
      p = TkWinfo.parent(p)
    end
    @state = 'maximize'
    self.raise
  else
    @ap.each_index{|i|
      @ap[i].place('x'=>@apx[i], 'y'=>@apy[i],'width'=>@apw[i], 'height'=>@aph[i],'relheight'=>1, 'relwidth'=>1)
      @ap[i].raise
    }
    self.raise
    @ap.clear
    @apx.clear
    @apy.clear
    @state = 'normal'
  end
end

#maximized?Boolean

Returns:

  • (Boolean)


1534
1535
1536
# File 'lib/a-tkcommons.rb', line 1534

def maximized?
  @state == 'maximize'
end

#resizeObject



1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
# File 'lib/a-tkcommons.rb', line 1516

def resize
  p = TkWinfo.parent(@parent)
  if @state == 'normal'
    if p.kind_of?(AGTkSplittedFrames)
      p.maximize(@parent)
      @bmaxmin.image(Arcadia.image_res(W_NORM_GIF))
    end
    @state = 'maximize'
  else
    if p.kind_of?(AGTkSplittedFrames)
      p.minimize(@parent)
      @bmaxmin.image(Arcadia.image_res(W_MAX_GIF))
    end
    @state = 'normal'
  end
  self.raise
end

#restore_caption(_name) ⇒ Object



1499
1500
1501
1502
1503
1504
1505
# File 'lib/a-tkcommons.rb', line 1499

def restore_caption(_name)
  if @right_labels_text[_name]
    top_text(@right_labels_text[_name], @right_labels_image[_name])
  else
    top_text_clear
  end
end

#save_caption(_name, _caption, _image = nil) ⇒ Object



1486
1487
1488
1489
# File 'lib/a-tkcommons.rb', line 1486

def save_caption(_name, _caption, _image=nil)
  @right_labels_text[_name] = _caption
  @right_labels_image[_name] = _image
end

#top_text(_text = nil, _image = nil) ⇒ Object



1454
1455
1456
1457
1458
1459
1460
1461
1462
# File 'lib/a-tkcommons.rb', line 1454

def top_text(_text=nil, _image=nil)
  if _text.nil? && _image.nil?
    return @right_label.text
  elsif !_text.nil? && _image.nil?
    @right_label.text(_text)
  else
    @right_label.configure('text'=>_text, 'image'=>_image)
  end
end

#top_text_bind_append(_tkevent, _proc = nil) ⇒ Object



1464
1465
1466
# File 'lib/a-tkcommons.rb', line 1464

def top_text_bind_append(_tkevent, _proc=nil)
  @right_label.bind_append(_tkevent, _proc)
end

#top_text_bind_remove(_tkevent) ⇒ Object



1468
1469
1470
# File 'lib/a-tkcommons.rb', line 1468

def top_text_bind_remove(_tkevent)
  @right_label.bind_remove(_tkevent)
end

#top_text_clearObject

def title(_text=nil)

  if _text.nil?
    return @title
  else
    @title=_text
    if _text.strip.length == 0
      @left_label.text('')
    else
      @left_label.text(_text+'::')
    end
  end
end


1446
1447
1448
# File 'lib/a-tkcommons.rb', line 1446

def top_text_clear
  @right_label.configure('text'=>'', 'image'=>nil)
end

#top_text_hideObject



1450
1451
1452
# File 'lib/a-tkcommons.rb', line 1450

def top_text_hide
  @right_label.unpack
end

#top_text_hint(_text = nil) ⇒ Object



1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
# File 'lib/a-tkcommons.rb', line 1472

def top_text_hint(_text=nil)
  if _text.nil?
    res = ''
    res = @right_label_hint_variable.value if defined?(@right_label_hint_variable)
    res
  else
    if !defined?(@right_label_hint_variable)
      @right_label_hint_variable = TkVariable.new
      Tk::BWidget::DynamicHelp::add(@right_label, 'variable'=>@right_label_hint_variable)
    end      
    @right_label_hint_variable.value=_text
  end
end