Class: Packet_Item
- Inherits:
-
Object
- Object
- Packet_Item
- Defined in:
- lib/Packet_Item.rb
Overview
An item for Packet_List. This is a convenient wrapper for the FXIconItem.
Defined Under Namespace
Classes: Fox_Item
Instance Attribute Summary collapse
-
#searchable ⇒ Object
Returns the value of attribute searchable.
Instance Method Summary collapse
-
#[](column_nr) ⇒ Object
Get the content of the given column number.
-
#[]=(column_nr, newVal) ⇒ Object
Set new text for the given column number.
-
#clear ⇒ Object
Removes the item from its parent.
-
#data ⇒ Object
Get user data.
-
#data=(data) ⇒ Object
Allows to set user data.
-
#fox_item ⇒ Object
Get the wrapper item.
-
#icon ⇒ Object
The icon of this item.
-
#initialize(newParent, icon, *content) ⇒ Packet_Item
constructor
Creates a Packet_Item with newParent as the parent list, which is allowed to be nil.
-
#parent ⇒ Object
Get the parent list for this item.
-
#parent=(newParent) ⇒ Object
Set a new parent.
-
#show ⇒ Object
Shows item on parent without updating the search index.
-
#sortable(pos) ⇒ Object
Get the sortable representation of this column’s content.
-
#update_sort_key ⇒ Object
update FXIconItem’s sort key and reversed status.
Constructor Details
#initialize(newParent, icon, *content) ⇒ Packet_Item
Creates a Packet_Item with newParent as the parent list, which is allowed to be nil. You can also use Packet_List#add_item instead.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/Packet_Item.rb', line 68 def initialize(newParent, icon, *content) @content = content @sortable = Array.new(@content.size) @icon = icon @data = nil @parent = nil @sort_key = nil @searchable = nil # call parent=, don't forget the self!! self.parent = newParent show if newParent # update sortable @content.each_index do |pos| update_sortable(pos, @content[pos]) if parent end end |
Instance Attribute Details
#searchable ⇒ Object
Returns the value of attribute searchable.
16 17 18 |
# File 'lib/Packet_Item.rb', line 16 def searchable @searchable end |
Instance Method Details
#[](column_nr) ⇒ Object
Get the content of the given column number.
86 87 88 |
# File 'lib/Packet_Item.rb', line 86 def [](column_nr) @content[column_nr] end |
#[]=(column_nr, newVal) ⇒ Object
Set new text for the given column number.
91 92 93 94 95 96 97 |
# File 'lib/Packet_Item.rb', line 91 def []=(column_nr, newVal) @content[column_nr] = newVal return unless @parent @item.text = @content.join("\t") update_sortable(column_nr, newVal) @parent.recalc end |
#clear ⇒ Object
Removes the item from its parent.
149 150 151 |
# File 'lib/Packet_Item.rb', line 149 def clear @parent = nil end |
#data ⇒ Object
Get user data.
144 145 146 |
# File 'lib/Packet_Item.rb', line 144 def data @data end |
#data=(data) ⇒ Object
Allows to set user data.
139 140 141 |
# File 'lib/Packet_Item.rb', line 139 def data=(data) @data = data end |
#fox_item ⇒ Object
Get the wrapper item.
134 135 136 |
# File 'lib/Packet_Item.rb', line 134 def fox_item @item end |
#icon ⇒ Object
The icon of this item.
154 155 156 |
# File 'lib/Packet_Item.rb', line 154 def icon @icon end |
#parent ⇒ Object
Get the parent list for this item.
111 112 113 |
# File 'lib/Packet_Item.rb', line 111 def parent @parent end |
#parent=(newParent) ⇒ Object
Set a new parent. This removes this item from the current list and adds itself to the new one.
117 118 119 120 121 122 123 124 |
# File 'lib/Packet_Item.rb', line 117 def parent=(newParent) return if newParent == @parent remove_item if @parent @parent = newParent @content.each_index do |pos| update_sortable(pos, @content[pos]) if @parent end end |
#show ⇒ Object
Shows item on parent without updating the search index. This can be used if an item is removed and added to the same list.
128 129 130 131 |
# File 'lib/Packet_Item.rb', line 128 def show create_item @parent.add_item(self) end |
#sortable(pos) ⇒ Object
Get the sortable representation of this column’s content.
100 101 102 |
# File 'lib/Packet_Item.rb', line 100 def sortable(pos) @sortable[pos] end |
#update_sort_key ⇒ Object
update FXIconItem’s sort key and reversed status
105 106 107 108 |
# File 'lib/Packet_Item.rb', line 105 def update_sort_key @item.sort_key = @sortable[@parent.sort_index] @item.reversed = @parent.reversed? ? -1 : 1 end |