Class: Wads::Text

Inherits:
Widget show all
Defined in:
lib/wads/widgets.rb

Overview

Displays a text label on the screen at the specific x, y location. The font specified by the current theme is used. The theme text color is used, unless the color parameter specifies an override. The small font is used by default, unless the use_large_font parameter is true.

Direct Known Subclasses

ErrorMessage

Instance Attribute Summary collapse

Attributes inherited from Widget

#base_z, #children, #gui_theme, #height, #is_selected, #layout, #overlay_widget, #override_color, #text_input_fields, #visible, #width, #x, #y

Instance Method Summary collapse

Methods inherited from Widget

#add, #add_axis_lines, #add_button, #add_child, #add_delete_button, #add_document, #add_graph_display, #add_image, #add_multi_select_table, #add_overlay, #add_panel, #add_plot, #add_single_select_table, #add_table, #add_text, #border_color, #bottom_edge, #button_down, #button_up, #center_children, #center_x, #center_y, #clear_children, #contains_click, #debug, #disable_background, #disable_border, #draw, #draw_background, #draw_border, #enable_background, #enable_border, #error, #get_layout, #get_theme, #graphics_color, #handle_key_held_down, #handle_key_press, #handle_key_up, #handle_mouse_down, #handle_mouse_up, #handle_right_mouse, #handle_update, #info, #intercept_widget_event, #left_edge, #move_recursive_absolute, #move_recursive_delta, #overlaps_with, #pad, #relative_x, #relative_y, #relative_z_order, #remove_child, #remove_children, #remove_children_by_type, #right_edge, #selection_color, #set_absolute_position, #set_dimensions, #set_layout, #set_selected, #set_theme, #text_color, #top_edge, #unset_selected, #update, #uses_layout, #warn, #x_pixel_to_screen, #y_pixel_to_screen, #z_order

Constructor Details

#initialize(x, y, label, args = {}) ⇒ Text

Returns a new instance of Text.



1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
# File 'lib/wads/widgets.rb', line 1828

def initialize(x, y, label, args = {}) 
    super(x, y) 
    @label = label
    if args[ARG_THEME]
        @gui_theme = args[ARG_THEME]
    end
    if args[ARG_USE_LARGE_FONT]
        @use_large_font = args[ARG_USE_LARGE_FONT] 
    end
    if args[ARG_COLOR]
        @override_color = args[ARG_COLOR]
    end
    disable_border
    if @use_large_font 
        set_dimensions(@gui_theme.font_large.text_width(@label) + 10, 20)
    else 
        set_dimensions(@gui_theme.font.text_width(@label) + 10, 20)
    end
end

Instance Attribute Details

#labelObject

Returns the value of attribute label.



1826
1827
1828
# File 'lib/wads/widgets.rb', line 1826

def label
  @label
end

Instance Method Details

#change_text(new_text) ⇒ Object



1852
1853
1854
# File 'lib/wads/widgets.rb', line 1852

def change_text(new_text)
    set_text(new_text)
end

#renderObject



1856
1857
1858
1859
1860
1861
1862
# File 'lib/wads/widgets.rb', line 1856

def render 
    if @use_large_font 
        get_theme.font_large.draw_text(@label, @x, @y, z_order, 1, 1, text_color)
    else
        get_theme.font.draw_text(@label, @x, @y, z_order, 1, 1, text_color)
    end 
end

#set_text(new_text) ⇒ Object



1848
1849
1850
# File 'lib/wads/widgets.rb', line 1848

def set_text(new_text)
    @label = new_text
end

#widget_zObject



1864
1865
1866
# File 'lib/wads/widgets.rb', line 1864

def widget_z 
    Z_ORDER_TEXT
end