module TkComponent::Builder::Scrollable
Constants
- ROOT_FRAME_OPTIONS
Public Class Methods
new(parent_item, name, options = {}, grid = {}, event_handlers = [])
click to toggle source
Calls superclass method
# File lib/tk_component/builder/tk_item.rb, line 190 def initialize(parent_item, name, options = {}, grid = {}, event_handlers = []) return super unless (s_options = options.delete(:scrollers)) && s_options.present? && s_options != 'none' frame_item = TK_CLASSES[:frame].new(parent_item.native_item) # Containing frame real_native_item = create_native_item(frame_item, name, options, grid, event_handlers) f_options = options.extract!(*ROOT_FRAME_OPTIONS) apply_options(f_options, frame_item) # Apply the applicable options to the enclosing frame @native_item = real_native_item apply_options(options, real_native_item) set_grid(grid, frame_item) real_native_item.grid( :column => 0, :row => 0, :sticky => 'nwes') if s_options.include?('x') h_scrollbar = TK_CLASSES[:hscroll_bar].new(frame_item) h_scrollbar.orient('horizontal') h_scrollbar.command proc { |*args| real_native_item.xview(*args) } real_native_item['xscrollcommand'] = proc { |*args| h_scrollbar.set(*args) } h_scrollbar.grid( :column => 0, :row => 1, :sticky => 'wes') end if s_options.include?('y') v_scrollbar = TK_CLASSES[:vscroll_bar].new(frame_item) v_scrollbar.orient('vertical') v_scrollbar.command proc { |*args| real_native_item.yview(*args) } real_native_item['yscrollcommand'] = proc { |*args| v_scrollbar.set(*args) } v_scrollbar.grid( :column => 1, :row => 0, :sticky => 'nse') end TkGrid.columnconfigure(frame_item, 0, :weight => 1) TkGrid.columnconfigure(frame_item, 1, :weight => 0) if v_scrollbar.present? TkGrid.rowconfigure(frame_item, 0, :weight => 1) TkGrid.rowconfigure(frame_item, 1, :weight => 0) if h_scrollbar.present? @native_item = real_native_item set_event_handlers(event_handlers) end
Public Instance Methods
remove()
click to toggle source
We need to remove the parent native item, as it's the container we put in place initially
# File lib/tk_component/builder/tk_item.rb, line 223 def remove @native_item.winfo_parent.destroy end