Class: Packet_Item::Fox_Item

Inherits:
FXIconItem
  • Object
show all
Defined in:
lib/Packet_Item.rb

Overview

Fox_Item is a very thin wrapper that calles Packet_Item functionality.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(packet_item, *args) ⇒ Fox_Item

Create a new item with packet_item as the parent. *args is passed to the FXIconItem.



25
26
27
28
29
30
31
# File 'lib/Packet_Item.rb', line 25

def initialize(packet_item, *args)
  @packet_item = packet_item
  @sort_key = nil
  @reversed = 1
  @is_deleted = false
  super(*args)
end

Instance Attribute Details

#reversedObject

Returns the value of attribute reversed.



22
23
24
# File 'lib/Packet_Item.rb', line 22

def reversed
  @reversed
end

#sort_keyObject

optimization: directly sort by sort_key and reversed



21
22
23
# File 'lib/Packet_Item.rb', line 21

def sort_key
  @sort_key
end

Instance Method Details

#<=>(other) ⇒ Object

Called from sortItems, uses packet_item’s comparison.



51
52
53
# File 'lib/Packet_Item.rb', line 51

def <=>(other)
  (@sort_key <=> other.sort_key) * @reversed
end

#dataObject

Pass-through method



61
62
63
# File 'lib/Packet_Item.rb', line 61

def data
  @packet_item.data
end

#deletedObject

Mark item as deleted, to prevent execution of draw afterwards this is called from Packet_List which uses the same mutex as draw.



46
47
48
# File 'lib/Packet_Item.rb', line 46

def deleted
  @is_deleted = true
end

#draw(*args) ⇒ Object

Sometimes draw is called AFTER the item has been removed. In this case: return immediately. Otherwise a Runtime Error would occur!



35
36
37
38
39
40
41
# File 'lib/Packet_Item.rb', line 35

def draw(*args)
  $fx_icon_item_remove_mutex.synchronize do
    #puts "draw"
    return if @is_deleted
    super
  end
end

#packet_itemObject

Get the packet item



56
57
58
# File 'lib/Packet_Item.rb', line 56

def packet_item
  @packet_item
end