Class: LCDProc::Widgets::VBar
- Inherits:
-
Object
- Object
- LCDProc::Widgets::VBar
- Includes:
- LCDProc::Widget
- Defined in:
- lib/lcdproc/widgets/vbar.rb
Constant Summary collapse
- @@widget_count =
0
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Attributes included from LCDProc::Widget
Instance Method Summary collapse
-
#initialize(id = "VBarWidget_#{@@widget_count}", bar_height = 16, x_pos = 1, y_pos = 1) ⇒ VBar
constructor
Creates a new VBar widget which can then be displayed anywhere on the screen.
-
#update ⇒ Object
Sends to command to the LCDd server to update the widget on screen.
Methods included from LCDProc::Widget
add_support, #attach_to, #detach, #hide, new, #show, supported_types
Constructor Details
#initialize(id = "VBarWidget_#{@@widget_count}", bar_height = 16, x_pos = 1, y_pos = 1) ⇒ VBar
Creates a new VBar widget which can then be displayed anywhere on the screen.
-
:id
- A unique string which identifies this widget. Defaults to “VBarWidget_” + a sequence number. -
:bar_height
- The height of the bar. Default to 16 (half the height of a 20x4 character screen). -
:x_pos
- The row in which the bar should be positioned. Defaults to 1. -
:y_pos
- The column in which the bar should be positioned. Defaults to 1 (bottom of the screen).
Example:
w = VBar.new
or
w = VBar.new( 'TestBar', 32, 2, 4 )
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/lcdproc/widgets/vbar.rb', line 54 def initialize( id = "VBarWidget_#{@@widget_count}", = 16, x_pos = 1, y_pos = 1 ) if id.nil? id = "VBarWidget_#{@@widget_count}" end @id = id @type = :vbar @screen = nil @visible = false @height = @x = x_pos @y = y_pos @old_height = nil @old_x = nil @old_y = nil @@widget_count += 1 end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
35 36 37 |
# File 'lib/lcdproc/widgets/vbar.rb', line 35 def height @height end |
#x ⇒ Object
Returns the value of attribute x.
35 36 37 |
# File 'lib/lcdproc/widgets/vbar.rb', line 35 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
35 36 37 |
# File 'lib/lcdproc/widgets/vbar.rb', line 35 def y @y end |
Instance Method Details
#update ⇒ Object
Sends to command to the LCDd server to update the widget on screen
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/lcdproc/widgets/vbar.rb', line 77 def update # Don't update unless something has actually changed if @x == @old_x and @y == @old_y and @height == @old_height return true end if @screen = @height if @height < 1 = @height * 120 end response = @screen.client.send_command( Command.new( "widget_set #{@screen.id} #{self.id} #{@x} #{@y} #{}" ) ) if response.successful? @screen.client.( "Widget '#{@id}' was successfully updated" ) return true else @screen.client.( "Error: Widget '#{@id}' was NOT successfully updated (#{response.})" ) return true end else @screen.client.( "Error: Cannot update Widget '#{@id}' until it is attached to a screen" ) return false end end |