Class: Drx::TkGUI::Scrolled

Inherits:
TkFrame
  • Object
show all
Defined in:
lib/drx/tk/app.rb

Overview

Wraps scrollbars around a widget.

Instance Method Summary collapse

Constructor Details

#initialize(parent, the_widget, opts = { :vertical => true, :horizontal => true }) ⇒ Scrolled

Returns a new instance of Scrolled.



546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
# File 'lib/drx/tk/app.rb', line 546

def initialize(parent, the_widget, opts = { :vertical => true, :horizontal => true })
  super(parent)
  @the_widget = the_widget
  if opts[:vertical]
    TkScrollbar.new(self) { |s|
      grid(:row => 0, :column => 1, :rowspan => 1, :columnspan => 1, :sticky => 'news')
      command { |*args| the_widget.yview *args }
      the_widget.yscrollcommand { |first,last| s.set first,last }
    }
  end
  if opts[:horizontal]
    TkScrollbar.new(self) { |s|
      orient 'horizontal'
      grid(:row => 1, :column => 0, :rowspan => 1, :columnspan => 1, :sticky => 'news')
      command { |*args| the_widget.xview *args }
      the_widget.xscrollcommand { |first,last| s.set first,last }
    }
  end
  the_widget.raise  # Since the frame is created after the widget, it obscures it by default.
  the_widget.grid(:in => self, :row => 0, :column => 0, :rowspan => 1, :columnspan => 1, :sticky => 'news')
  TkGrid.rowconfigure(self, 0, :weight => 1, :minsize => 0)
  TkGrid.columnconfigure(self, 0, :weight => 1, :minsize => 0)
end

Instance Method Details

#raiseObject



569
570
571
572
# File 'lib/drx/tk/app.rb', line 569

def raise
  super
  @the_widget.raise
end