Class: Wads::Text
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
Instance Attribute Summary collapse
-
#label ⇒ Object
Returns the value of attribute label.
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
- #change_text(new_text) ⇒ Object
-
#initialize(x, y, label, args = {}) ⇒ Text
constructor
A new instance of Text.
- #render ⇒ Object
- #set_text(new_text) ⇒ Object
- #widget_z ⇒ Object
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_press, #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, #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.
1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 |
# File 'lib/wads/widgets.rb', line 1797 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
#label ⇒ Object
Returns the value of attribute label.
1795 1796 1797 |
# File 'lib/wads/widgets.rb', line 1795 def label @label end |
Instance Method Details
#change_text(new_text) ⇒ Object
1821 1822 1823 |
# File 'lib/wads/widgets.rb', line 1821 def change_text(new_text) set_text(new_text) end |
#render ⇒ Object
1825 1826 1827 1828 1829 1830 1831 |
# File 'lib/wads/widgets.rb', line 1825 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
1817 1818 1819 |
# File 'lib/wads/widgets.rb', line 1817 def set_text(new_text) @label = new_text end |
#widget_z ⇒ Object
1833 1834 1835 |
# File 'lib/wads/widgets.rb', line 1833 def Z_ORDER_TEXT end |