Class: Rubygoo::Label
Constant Summary
Constants inherited from Widget
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes inherited from Widget
#app, #container, #enabled, #focus_priority, #focussed, #goo_id, #h, #mouse_over, #opts, #padding_left, #padding_top, #parent, #relative, #visible, #w, #x, #y
Instance Method Summary collapse
- #added ⇒ Object
- #draw(adapter) ⇒ Object
-
#initialize(text, opts = {}) ⇒ Label
constructor
A new instance of Label.
- #set_text(text) ⇒ Object
- #tab_to? ⇒ Boolean
Methods inherited from Widget
#_draw, #_focus, #_key_pressed, #_key_released, #_mouse_down, #_mouse_drag, #_mouse_dragging, #_mouse_motion, #_mouse_up, #_unfocus, #_update, #contains?, #disable, #enable, #enabled?, #focus, #focussed?, #get, #get_color, goo_prop, #hide, inherited, #key_pressed, #key_released, #modal?, #mouse_down, #mouse_drag, #mouse_dragging, #mouse_enter, #mouse_exit, #mouse_motion, #mouse_over?, #mouse_up, #removed, #show, #theme_property, #unfocus, #update, #update_rect, #visible?
Methods included from Inflector
#camelize, #classify, #constantize, #dasherize, #demodulize, #foreign_key, #humanize, #inflections, #ordinalize, #pluralize, #singularize, #tableize, #titleize, #underscore
Constructor Details
#initialize(text, opts = {}) ⇒ Label
Returns a new instance of Label.
5 6 7 8 9 |
# File 'lib/rubygoo/label.rb', line 5 def initialize(text, opts={}) @font_size = opts[:font_size] super opts @text = text end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
4 5 6 |
# File 'lib/rubygoo/label.rb', line 4 def text @text end |
Instance Method Details
#added ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rubygoo/label.rb', line 11 def added() font = theme_property :font @font_size ||= theme_property :font_size @color = theme_property :color @bg_color = theme_property :bg_color @focus_color = theme_property :focus_color @border_color = theme_property :border_color @font_file ||= File.join(@app.theme_dir,font) set_text @text end |
#draw(adapter) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rubygoo/label.rb', line 31 def draw(adapter) x1 = @rect[0] y1 = @rect[1] x2 = @rect[2] + x1 y2 = @rect[3] + y1 if @focussed adapter.fill x1, y1, x2, y2, @focus_color elsif @bg_color adapter.fill x1, y1, x2, y2, @bg_color end if @border_color adapter.draw_box x1, y1, x2, y2, @border_color end adapter.draw_image @rendered_text, @x, @y, @color end |
#set_text(text) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/rubygoo/label.rb', line 23 def set_text(text) @text = text @rendered_text = @app.renderer.render_text @text, @font_file, @font_size, @color @w = @rendered_text.width @h = @rendered_text.height update_rect end |
#tab_to? ⇒ Boolean
49 50 51 |
# File 'lib/rubygoo/label.rb', line 49 def tab_to?() false end |