Class: TkComponent::Builder::ScrollBar

Inherits:
TkItem
  • Object
show all
Defined in:
lib/tk_component/builder/tk_item.rb

Direct Known Subclasses

HScrollbar, VScrollbar

Instance Attribute Summary

Attributes inherited from TkItem

#native_item

Instance Method Summary collapse

Methods inherited from TkItem

#apply_internal_grid, #built, create, #create_native_item, #focus, #initialize, #native_item_class, #remove, #set_grid

Constructor Details

This class inherits a constructor from TkComponent::Builder::TkItem

Instance Method Details

#apply_option(option, v, to_item = self.native_item) ⇒ Object



346
347
348
349
350
351
352
353
# File 'lib/tk_component/builder/tk_item.rb', line 346

def apply_option(option, v, to_item = self.native_item)
  case option.to_sym
  when :linked_to
    @linked_to = v
  else
    super
  end
end

#apply_options(options, to_item = self.native_item) ⇒ Object



364
365
366
367
# File 'lib/tk_component/builder/tk_item.rb', line 364

def apply_options(options, to_item = self.native_item)
  options.merge!(orient: orient)
  super
end

#bind_linked_toObject



374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/tk_component/builder/tk_item.rb', line 374

def bind_linked_to
  return unless @linked_to.present?
  items = @linked_to.is_a?(Array) ? @linked_to.map(&:native_item) : [ @linked_to.native_item ]
  self.native_item.command proc { |*args|
    items.each do |item|
      item.send(scroll_command, *args)
    end
  }
  items.each do |item|
    item.send(linked_scroll_command, proc { |*args| self.native_item.send(linked_scroll_event, *args) })
  end
end

#linked_scroll_commandObject



395
396
397
# File 'lib/tk_component/builder/tk_item.rb', line 395

def linked_scroll_command
  raise "#{self.class.to_s} shouldn't be instantiated directly. Use 'H' or 'V' subclasses"
end

#linked_scroll_eventObject



399
400
401
# File 'lib/tk_component/builder/tk_item.rb', line 399

def linked_scroll_event
  raise "#{self.class.to_s} shouldn't be instantiated directly. Use 'H' or 'V' subclasses"
end

#orientObject



387
388
389
# File 'lib/tk_component/builder/tk_item.rb', line 387

def orient
  raise "#{self.class.to_s} shouldn't be instantiated directly. Use 'H' or 'V' subclasses"
end

#scroll_commandObject



391
392
393
# File 'lib/tk_component/builder/tk_item.rb', line 391

def scroll_command
  raise "#{self.class.to_s} shouldn't be instantiated directly. Use 'H' or 'V' subclasses"
end

#set_event_handler(event_handler) ⇒ Object



355
356
357
358
359
360
361
362
# File 'lib/tk_component/builder/tk_item.rb', line 355

def set_event_handler(event_handler)
  case event_handler.name
  when :change
    Event.Event.bind_command(event_handler.name, self, event_handler.options, event_handler.lambda)
  else
    super
  end
end

#set_event_handlers(event_handlers) ⇒ Object



369
370
371
372
# File 'lib/tk_component/builder/tk_item.rb', line 369

def set_event_handlers(event_handlers)
  bind_linked_to
  super
end