Class: CWM::TreePager

Inherits:
Pager show all
Defined in:
library/cwm/src/lib/cwm/tree_pager.rb

Overview

A Pager that uses a Tree to select the Pages

Instance Attribute Summary

Attributes inherited from AbstractWidget

#handle_all_events, #widget_id

Instance Method Summary collapse

Methods inherited from Pager

#handle, #init, #initial_page, #page_order, #replace_point, #store_page, #switch_page

Methods inherited from CustomWidget

#cwm_contents, #cwm_definition, #find_ids, #ids_in_contents

Methods inherited from AbstractWidget

#cleanup, #cwm_definition, #disable, #enable, #enabled?, #fun_ref, #handle, #help, #init, #label, #my_event?, #opt, #refresh_help, #store, #validate, widget_type=

Constructor Details

#initialize(tree) ⇒ TreePager

Returns a new instance of TreePager

Parameters:



31
32
33
34
35
# File 'library/cwm/src/lib/cwm/tree_pager.rb', line 31

def initialize(tree)
  @tree = tree
  pages = tree.items.flat_map(&:pages)
  super(*pages)
end

Instance Method Details

#contentsObject



37
38
39
40
41
42
# File 'library/cwm/src/lib/cwm/tree_pager.rb', line 37

def contents
  HBox(
    HWeight(30, @tree),
    HWeight(70, replace_point)
  )
end

#mark_page(page) ⇒ Object (protected)



51
52
53
# File 'library/cwm/src/lib/cwm/tree_pager.rb', line 51

def mark_page(page)
  @tree.value = page.widget_id
end

#page_for_id(id) ⇒ Object (protected)



46
47
48
49
# File 'library/cwm/src/lib/cwm/tree_pager.rb', line 46

def page_for_id(id)
  id = @tree.value if id == @tree.widget_id
  super(id)
end