Class: LCDProc::Widgets::Scroller
- Inherits:
-
Object
- Object
- LCDProc::Widgets::Scroller
- Includes:
- LCDProc::Widget
- Defined in:
- lib/lcdproc/widgets/scroller.rb
Constant Summary collapse
- @@widget_count =
0
Instance Attribute Summary collapse
-
#bottom ⇒ Object
Returns the value of attribute bottom.
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#left ⇒ Object
Returns the value of attribute left.
-
#right ⇒ Object
Returns the value of attribute right.
-
#speed ⇒ Object
Returns the value of attribute speed.
-
#text ⇒ Object
Returns the value of attribute text.
-
#top ⇒ Object
Returns the value of attribute top.
Attributes included from LCDProc::Widget
Instance Method Summary collapse
-
#attach_to(screen) ⇒ Object
Allows a widget to be attached to a screen.
-
#initialize(id = "ScrollerWidget_#{@@widget_count}", left = 1, top = 1, right = 10, bottom = 2, direction = "h", speed = 1, text = "Hello, here is some really long text.") ⇒ Scroller
constructor
Creates a new Scroller 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, #detach, #hide, new, #show, supported_types
Constructor Details
#initialize(id = "ScrollerWidget_#{@@widget_count}", left = 1, top = 1, right = 10, bottom = 2, direction = "h", speed = 1, text = "Hello, here is some really long text.") ⇒ Scroller
Creates a new Scroller widget which can then be displayed anywhere on the screen.
-
:id
- A unique string which identifies this widget. Defaults to “ScrollerWidget_” + a sequence number. -
:left
- The column in which to begin the scrolling text. Defaults to 1. -
:top
- The row in which to begin the scrolling text. Defaults to 1. -
:right
- The column in which to end the scrolling text. Defaults to 10 until attached to a screen, then defaults to the width of the screen. -
:bottom
- The row in which to end the scrolling text. Defaults to 2 until attached to a screen, then defaults to the height of the screen. -
:direction
- The direction that the text should scroll. One of “h” for horizontal, “v” for vertical, or “m” for marquee. -
:speed
- The number of movements per rendering stroke (8 times per second). -
:text
- The text that you wish to display on the screen. Default to “Hello, here is some really long text.”. Note that if this string is shorter than the allotted width or height, no scrolling occurs.
Example:
w = Scroller.new
or
w = Scroller.new( 'TestScroller', 1, 1, 20, 4, "h", 1, "Some Scrolling Text")
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/lcdproc/widgets/scroller.rb', line 58 def initialize( id = "ScrollerWidget_#{@@widget_count}", left = 1, top = 1, right = 10, bottom = 2, direction = "h", speed = 1, text = "Hello, here is some really long text." ) if id.nil? id = "ScrollerWidget_#{@@widget_count}" end @id = id @type = :scroller @screen = nil @visible = false @left = left @top = top @right = right @bottom = bottom @direction = direction @speed = speed @text = text @@widget_count += 1 end |
Instance Attribute Details
#bottom ⇒ Object
Returns the value of attribute bottom.
35 36 37 |
# File 'lib/lcdproc/widgets/scroller.rb', line 35 def bottom @bottom end |
#direction ⇒ Object
Returns the value of attribute direction.
35 36 37 |
# File 'lib/lcdproc/widgets/scroller.rb', line 35 def direction @direction end |
#left ⇒ Object
Returns the value of attribute left.
35 36 37 |
# File 'lib/lcdproc/widgets/scroller.rb', line 35 def left @left end |
#right ⇒ Object
Returns the value of attribute right.
35 36 37 |
# File 'lib/lcdproc/widgets/scroller.rb', line 35 def right @right end |
#speed ⇒ Object
Returns the value of attribute speed.
35 36 37 |
# File 'lib/lcdproc/widgets/scroller.rb', line 35 def speed @speed end |
#text ⇒ Object
Returns the value of attribute text.
35 36 37 |
# File 'lib/lcdproc/widgets/scroller.rb', line 35 def text @text end |
#top ⇒ Object
Returns the value of attribute top.
35 36 37 |
# File 'lib/lcdproc/widgets/scroller.rb', line 35 def top @top end |
Instance Method Details
#attach_to(screen) ⇒ Object
Allows a widget to be attached to a screen.
81 82 83 84 85 86 |
# File 'lib/lcdproc/widgets/scroller.rb', line 81 def attach_to( screen ) @right = screen.client.width @bottom = screen.client.height return super(screen ) end |
#update ⇒ Object
Sends to command to the LCDd server to update the widget on screen
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/lcdproc/widgets/scroller.rb', line 89 def update if @screen response = @screen.client.send_command( Command.new( "widget_set #{@screen.id} #{self.id} #{@left} #{@top} #{@right} #{@bottom} #{@direction} #{@speed} \"#{@text}\"" ) ) 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 |