Class: RubyCurses::Widget
- Includes:
- ConfigSetup, EventHandler, Io, Utils
- Defined in:
- lib/rbcurse/core/util/app.rb,
lib/rbcurse/core/widgets/rwidget.rb
Overview
TODO - / combo
-
popup
-
promptmenu
-
stack and flow should be objects in Form/App?, put in widget when creating
-
box / rect
-
para looks like a label that is more than one line, and calculates rows itself based on text
-
multicontainer
-
multitextview, multisplit
-
tabbedpane
/ table - more work regarding vim keys, also editable
-
margin - is left offset
http://lethain.com/entry/2007/oct/15/getting-started-shoes-os-x/
Direct Known Subclasses
ApplicationHeader, Box, Button, Container, Divider, Field, KeyLabelPrinter, Label, List, Progress, Scrollbar, StatusLine, TabbedPane, TabularWidget, TextArea, TextPad, TextView, Tree
Instance Attribute Summary collapse
-
#_object_created ⇒ Object
widget also has height and width as a method.
-
#col_offset ⇒ Object
readonly
where should the cursor be placed to start with.
-
#cols_panned ⇒ Object
moved from form, how many cols scrolled.panned 2010-02-11 15:26.
-
#config ⇒ Object
readonly
can be used for popping user objects too.
-
#curpos ⇒ Object
cursor position inside object - column, not row.
-
#focussed ⇒ Object
sometimes inside a container there’s no way of knowing if an individual comp is in focus other than the explicitly set it and inquire .
-
#form ⇒ Object
made accessor 2008-11-27 22:32 so menu can set.
-
#id ⇒ Object
, :zorder.
- #key_label ⇒ Object readonly
-
#parent_component ⇒ Object
attr_accessor :frozen # true false attr_accessor :frozen_list # list of attribs that cannot be changed I think parent_form was not a good idea since i can’t add parent widget offsets + thus we should use parent_comp and push up.
-
#row_offset ⇒ Object
readonly
where should the cursor be placed to start with.
-
#rows_panned ⇒ Object
tired of getting the cursor wrong and guessing, i am now going to try to get absolute coordinates - 2010-02-07 20:17 this should be updated by parent.
-
#state ⇒ Object
normal, selected, highlighted.
Instance Method Summary collapse
-
#action_manager ⇒ Object
return an object of actionmanager class, creating if required Widgets and apps may add_action and show_menu using the same.
- #changed(*args, &block) ⇒ Object
-
#click(*args, &block) ⇒ Object
actually we already have command() for buttons.
-
#color_pair(*val) ⇒ Object
2011-11-12 trying to make color setting a bit sane You may set as a color_pair using get_color which gives a fixnum or you may give 2 color symbols so i can update color, bgcolor and colorpair in one shot if one of them is nil, i just use the existing value.
-
#command(*args, &block) ⇒ Object
a general method for all widgets to override with their favorite or most meaninful event Ideally this is where the block in the constructor should land up.
- #destroy ⇒ Object
- #enter(*args, &block) ⇒ Object
- #event_list ⇒ Object
-
#focus ⇒ Object
moves focus to this field we must look into running on_leave of previous field.
- #get_preferred_size ⇒ Object
-
#getvalue ⇒ Object
return the value of the widget.
-
#getvalue_for_paint ⇒ Object
Am making a separate method since often value for print differs from actual value.
-
#handle_key(ch) ⇒ Object
to be added at end of handle_key of widgets so instlalled actions can be checked.
-
#height(*val) ⇒ val
getter and setter for height - 2009-10-30 12:25 Using dsl_property style SO WE’ve finally succumbed and added height to widget.
- #height=(val) ⇒ Object
- #hide ⇒ Object
- #init_vars ⇒ Object
-
#initialize(aform, aconfig = {}, &block) ⇒ Widget
constructor
A new instance of Widget.
- #leave(*args, &block) ⇒ Object
-
#modified? ⇒ Boolean
modified.
-
#move(row, col) ⇒ Object
is this required can we remove.
-
#on_enter ⇒ Object
got left out by mistake 2008-11-26 20:20.
-
#on_leave ⇒ Object
got left out by mistake 2008-11-26 20:20.
-
#override_graphic(gr) ⇒ Object
When an enclosing component creates a pad (buffer) and the child component + should write onto the same pad, then the enclosing component should override + the default graphic of child.
-
#process_key(keycode, object) ⇒ Object
e.g.
- #remove ⇒ Object
-
#repaint ⇒ Object
default repaint method.
- #repaint_all(tf = true) ⇒ Object
-
#repaint_required(tf = true) ⇒ Object
to give simple access to other components, (eg, parent) to tell a comp to either paint its data, or to paint all - borders, headers, footers due to a big change (ht/width).
-
#rowcol ⇒ Object
row and col is where a widget starts.
-
#set_buffer_modified(tf = true) ⇒ Object
Inform the system that the buffer has been modified and should be blitted over the screen or copied to parent.
-
#set_buffering(params) ⇒ Object
I was removing this altogether but vimsplit needs this, or masterdetail gives form and window to vimsplit.
-
#set_form(form) ⇒ Object
in those cases where we create widget without a form, and later give it to some other program which sets the form.
-
#set_form_col(col1 = @curpos) ⇒ Object
set cursor on correct column, widget Ideally, this should be overriden, as it is not likely to be correct.
-
#set_form_row ⇒ Object
puts cursor on correct row.
- #set_modified(tf = true) ⇒ Object (also: #modified)
-
#setformrowcol(r, c) ⇒ Object
passing a cursor up and adding col and row offsets Added 2010-01-13 13:27 I am checking this out.
-
#setrowcol(r, c) ⇒ Object
widget: i am putting one extra level of indirection so i can switch here between form#setrowcol and setformrowcol, since i am not convinced either are giving the accurate result.
- #show ⇒ Object
-
#text_variable(*val) ⇒ Object
getter and setter for text_variable.
-
#unbind_key(keycode) ⇒ Object
remove a binding that you don’t want.
-
#width(*val) ⇒ val
getter and setter for width - 2009-10-29 22:45 Using dsl_property style.
- #width=(val) ⇒ Object
Methods included from Io
#__create_footer_window, #clear_this, #get_file, #print_this, #rb_getchar, #rb_gets, #rbgetstr, #warn
Methods included from Utils
#OLDdefine_key, #_process_key, #bind_key, #bind_keys, #clean_string!, #define_key, #define_prefix_command, #display_app_help, #get_attrib, #get_color, #keycode_tos, #last_line, #one_line_window, #parse_formatted_text, #print_key_bindings, #repeatm, #run_command, #shell_out, #shell_output, #suspend, #view, #wrap_text
Methods included from ConfigSetup
#cget, #config_setup, #configure, #variable_set
Methods included from EventHandler
#bind, #fire_handler, #fire_property_change
Constructor Details
#initialize(aform, aconfig = {}, &block) ⇒ Widget
Returns a new instance of Widget.
837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 837 def initialize aform, aconfig={}, &block # I am trying to avoid passing the nil when you don't want to give a form. # I hope this does not create new issues 2011-11-20 if aform.is_a? Hash # presumable there's nothing coming in in hash, or else we will have to merge aconfig = aform @form = nil else #raise "got a #{aform.class} " @form = aform end @row_offset ||= 0 @col_offset ||= 0 #@ext_row_offset = @ext_col_offset = 0 # 2010-02-07 20:18 # removed on 2011-09-29 @state = :NORMAL #@attr = nil # 2011-11-5 i could be removing what's been entered since super is called @handler = nil # we can avoid firing if nil @event_args = {} # These are standard events for most widgets which will be fired by # Form. In the case of CHANGED, form fires if it's editable property is set, so # it does not apply to all widgets. @_events ||= [] @_events.push( *[:ENTER, :LEAVE, :CHANGED, :PROPERTY_CHANGE]) config_setup aconfig # @config.each_pair { |k,v| variable_set(k,v) } #instance_eval &block if block_given? if block_given? if block.arity > 0 yield self else self.instance_eval(&block) end end # 2010-09-20 13:12 moved down, so it does not create problems with other who want to set their # own default #@bgcolor ||= "black" # 0 #@color ||= "white" # $datacolor set_form(@form) if @form end |
Instance Attribute Details
#_object_created ⇒ Object
widget also has height and width as a method
815 816 817 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 815 def _object_created @_object_created end |
#col_offset ⇒ Object (readonly)
where should the cursor be placed to start with
804 805 806 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 804 def col_offset @col_offset end |
#cols_panned ⇒ Object
moved from form, how many cols scrolled.panned 2010-02-11 15:26
826 827 828 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 826 def cols_panned @cols_panned end |
#config ⇒ Object (readonly)
can be used for popping user objects too
801 802 803 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 801 def config @config end |
#curpos ⇒ Object
cursor position inside object - column, not row.
800 801 802 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 800 def curpos @curpos end |
#focussed ⇒ Object
sometimes inside a container there’s no way of knowing if an individual comp is in focus other than the explicitly set it and inquire . 2010-09-02 14:47 @since 1.1.5 NOTE state takes care of this and is set by form
831 832 833 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 831 def focussed @focussed end |
#form ⇒ Object
made accessor 2008-11-27 22:32 so menu can set
802 803 804 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 802 def form @form end |
#id ⇒ Object
, :zorder
799 800 801 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 799 def id @id end |
#key_label ⇒ Object (readonly)
835 836 837 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 835 def key_label @key_label end |
#parent_component ⇒ Object
attr_accessor :frozen # true false attr_accessor :frozen_list # list of attribs that cannot be changed I think parent_form was not a good idea since i can’t add parent widget offsets + thus we should use parent_comp and push up.
821 822 823 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 821 def parent_component @parent_component end |
#row_offset ⇒ Object (readonly)
where should the cursor be placed to start with
804 805 806 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 804 def row_offset @row_offset end |
#rows_panned ⇒ Object
tired of getting the cursor wrong and guessing, i am now going to try to get absolute coordinates - 2010-02-07 20:17 this should be updated by parent. attr_accessor :ext_col_offset, :ext_row_offset # 2010-02-07 20:16 to get abs position for cursor rem 2011-09-29
825 826 827 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 825 def rows_panned @rows_panned end |
#state ⇒ Object
normal, selected, highlighted
803 804 805 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 803 def state @state end |
Instance Method Details
#action_manager ⇒ Object
return an object of actionmanager class, creating if required Widgets and apps may add_action and show_menu using the same
1241 1242 1243 1244 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1241 def action_manager require 'rbcurse/core/include/actionmanager' @action_manager ||= ActionManager.new end |
#changed(*args, &block) ⇒ Object
45 46 47 |
# File 'lib/rbcurse/core/util/app.rb', line 45 def changed *args, &block bind :CHANGED, *args, &block end |
#click(*args, &block) ⇒ Object
actually we already have command() for buttons
55 56 57 |
# File 'lib/rbcurse/core/util/app.rb', line 55 def click *args, &block bind :PRESS, *args, &block end |
#color_pair(*val) ⇒ Object
2011-11-12 trying to make color setting a bit sane You may set as a color_pair using get_color which gives a fixnum or you may give 2 color symbols so i can update color, bgcolor and colorpair in one shot if one of them is nil, i just use the existing value
1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1206 def color_pair(*val) if val.empty? return @color_pair end oldvalue = @color_pair case val.size when 1 raise ArgumentError, "Expecting fixnum for color_pair." unless val[0].is_a? Fixnum @color_pair = val[0] @color, @bgcolor = ColorMap.get_colors_for_pair @color_pair when 2 @color = val.first if val.first @bgcolor = val.last if val.last @color_pair = get_color $datacolor, @color, @bgcolor end if oldvalue != @color_pair fire_property_change(:color_pair, oldvalue, @color_pair) @property_changed = true repaint_all true end self end |
#command(*args, &block) ⇒ Object
a general method for all widgets to override with their favorite or most meaninful event Ideally this is where the block in the constructor should land up.
1232 1233 1234 1235 1236 1237 1238 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1232 def command *args, &block if @_events.include? :PRESS bind :PRESS, *args, &block else bind :CHANGED, *args, &block end end |
#destroy ⇒ Object
959 960 961 962 963 964 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 959 def destroy $log.debug "DESTROY : widget #{@name} " panel = @window.panel Ncurses::Panel.del_panel(panel.pointer) if !panel.nil? @window.delwin if !@window.nil? end |
#enter(*args, &block) ⇒ Object
51 52 53 |
# File 'lib/rbcurse/core/util/app.rb', line 51 def enter *args, &block bind :ENTER, *args, &block end |
#event_list ⇒ Object
1198 1199 1200 1201 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1198 def event_list return @@events if defined? @@events nil end |
#focus ⇒ Object
moves focus to this field we must look into running on_leave of previous field
1018 1019 1020 1021 1022 1023 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1018 def focus return if !@focusable if @form.validate_field != -1 @form.select_field @id end end |
#get_preferred_size ⇒ Object
1046 1047 1048 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1046 def get_preferred_size return @preferred_height, @preferred_width end |
#getvalue ⇒ Object
return the value of the widget.
In cases where selection is possible, should return selected value/s
934 935 936 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 934 def getvalue @text_variable && @text_variable.value || @text end |
#getvalue_for_paint ⇒ Object
Am making a separate method since often value for print differs from actual value
939 940 941 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 939 def getvalue_for_paint getvalue end |
#handle_key(ch) ⇒ Object
to be added at end of handle_key of widgets so instlalled actions can be checked
1040 1041 1042 1043 1044 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1040 def handle_key(ch) ret = process_key ch, self return :UNHANDLED if ret == :UNHANDLED 0 end |
#height(*val) ⇒ val
getter and setter for height - 2009-10-30 12:25 Using dsl_property style SO WE’ve finally succumbed and added height to widget
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1101 def height(*val) #$log.debug " inside height() #{val[0]}" if val.empty? return @height else #$log.debug " inside #{@name} height()" oldvalue = @height || 0 # is this default okay, else later nil cries @height = val.size == 1 ? val[0] : val newvalue = @height @config[:height]=@height if oldvalue != newvalue @property_changed = true fire_property_change(:height, oldvalue, newvalue) repaint_all true end end end |
#height=(val) ⇒ Object
1118 1119 1120 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1118 def height=val height(val) end |
#hide ⇒ Object
1001 1002 1003 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1001 def hide @visible = false end |
#init_vars ⇒ Object
877 878 879 880 881 882 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 877 def init_vars # just in case anyone does a super. Not putting anything here # since i don't want anyone accidentally overriding @buffer_modified = false #@manages_cursor = false # form should manage it, I will pass row and col to it. end |
#leave(*args, &block) ⇒ Object
48 49 50 |
# File 'lib/rbcurse/core/util/app.rb', line 48 def leave *args, &block bind :LEAVE, *args, &block end |
#modified? ⇒ Boolean
modified
typically read will be overridden to check if value changed from what it was on enter. getter and setter for modified (added 2009-01-18 12:31 )
888 889 890 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 888 def modified? @modified end |
#move(row, col) ⇒ Object
is this required can we remove
1011 1012 1013 1014 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1011 def move row, col @row = row @col = col end |
#on_enter ⇒ Object
got left out by mistake 2008-11-26 20:20
909 910 911 912 913 914 915 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 909 def on_enter @state = :HIGHLIGHTED # duplicating since often these are inside containers @focussed = true if @handler && @handler.has_key?(:ENTER) fire_handler :ENTER, self end end |
#on_leave ⇒ Object
got left out by mistake 2008-11-26 20:20
917 918 919 920 921 922 923 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 917 def on_leave @state = :NORMAL # duplicating since often these are inside containers @focussed = false if @handler && @handler.has_key?(:LEAVE) fire_handler :LEAVE, self end end |
#override_graphic(gr) ⇒ Object
When an enclosing component creates a pad (buffer) and the child component + should write onto the same pad, then the enclosing component should override + the default graphic of child. This applies mainly to editor components in + listboxes and tables. added 2010-01-05 15:25
1139 1140 1141 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1139 def override_graphic gr @graphic = gr end |
#process_key(keycode, object) ⇒ Object
e.g. process_key ch, self returns UNHANDLED if no block for it after form handles basic keys, it gives unhandled key to current field, if current field returns unhandled, then it checks this map.
1035 1036 1037 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1035 def process_key keycode, object return _process_key keycode, object, @graphic end |
#remove ⇒ Object
1007 1008 1009 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1007 def remove @form.(self) end |
#repaint ⇒ Object
default repaint method. Called by form for all widgets.
widget does not have display_length.
945 946 947 948 949 950 951 952 953 954 955 956 957 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 945 def repaint r,c = rowcol @bgcolor ||= $def_bg_color # moved down 2011-11-5 @color ||= $def_fg_color $log.debug("widget repaint : r:#{r} c:#{c} col:#{@color}" ) value = getvalue_for_paint len = @display_length || value.length acolor = @color_pair || get_color($datacolor, @color, @bgcolor) @graphic.printstring r, c, "%-*s" % [len, value], acolor, @attr # next line should be in same color but only have @att so we can change att is nec #@form.window.mvchgat(y=r, x=c, max=len, Ncurses::A_NORMAL, @bgcolor, nil) #@buffer_modified = true # required for form to call buffer_to_screen CLEANUP end |
#repaint_all(tf = true) ⇒ Object
1126 1127 1128 1129 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1126 def repaint_all(tf=true) @repaint_all = tf @repaint_required = tf end |
#repaint_required(tf = true) ⇒ Object
to give simple access to other components, (eg, parent) to tell a comp to either paint its data, or to paint all - borders, headers, footers due to a big change (ht/width)
1123 1124 1125 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1123 def repaint_required(tf=true) @repaint_required = tf end |
#rowcol ⇒ Object
row and col is where a widget starts. offsets usually take into account borders. the offsets typically are where the cursor should be positioned inside, upon on_enter.
928 929 930 931 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 928 def rowcol # $log.debug "widgte rowcol : #{@row+@row_offset}, #{@col+@col_offset}" return @row+@row_offset, @col+@col_offset end |
#set_buffer_modified(tf = true) ⇒ Object
Inform the system that the buffer has been modified and should be blitted over the screen or copied to parent.
1054 1055 1056 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1054 def set_buffer_modified(tf=true) @buffer_modified = tf end |
#set_buffering(params) ⇒ Object
I was removing this altogether but vimsplit needs this, or masterdetail gives form and window to vimsplit. So i ‘ve removed everything but the form and window setting. 2011-09-29 SETBUFF move from TextView parameters relating to buffering - new 2010-02-12 12:09 RFED16 I am merging so i can call multiple times WARNING NOTE : this does not set Pad’s top and left since Pad may not be created yet, or at all
1189 1190 1191 1192 1193 1194 1195 1196 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1189 def set_buffering params @target_window ||= params[:target_window] @form = params[:form] unless @form if @graphic.nil? @graphic = @target_window end end |
#set_form(form) ⇒ Object
in those cases where we create widget without a form, and later give it to some other program which sets the form. Dirty, we should perhaps create widgets without forms, and add explicitly.
968 969 970 971 972 973 974 975 976 977 978 979 980 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 968 def set_form form raise "Form is nil in set_form" if form.nil? @form = form @id = form.(self) if !form.nil? and form.respond_to? :add_widget # 2009-10-29 15:04 use form.window, unless buffer created # should not use form.window so explicitly everywhere. # added 2009-12-27 20:05 BUFFERED in case child object needs a form. # We don;t wish to overwrite the graphic object if @graphic.nil? #$log.debug " setting graphic to form window for #{self.class}, #{form} " @graphic = form.window unless form.nil? # use screen for writing, not buffer end end |
#set_form_col(col1 = @curpos) ⇒ Object
set cursor on correct column, widget Ideally, this should be overriden, as it is not likely to be correct. NOTE: this is okay for some widgets but NOT for containers that will call their own components SFR and SFC
994 995 996 997 998 999 1000 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 994 def set_form_col col1=@curpos @curpos = col1 || 0 # 2010-01-14 21:02 #@form.col = @col + @col_offset + @curpos c = @col + @col_offset + @curpos $log.warn " #{@name} empty set_form_col #{c}, curpos #{@curpos} , #{@col} + #{@col_offset} #{@form} " setrowcol nil, c end |
#set_form_row ⇒ Object
puts cursor on correct row.
982 983 984 985 986 987 988 989 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 982 def set_form_row # @form.row = @row + 1 + @winrow #@form.row = @row + 1 r, c = rowcol $log.warn " empty set_form_row in widget #{self} r = #{r} , c = #{c} " #raise "trying to set 0, maybe called repaint before container has set value" if row <= 0 setrowcol row, nil end |
#set_modified(tf = true) ⇒ Object Also known as: modified
891 892 893 894 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 891 def set_modified tf=true @modified = tf @form.modified = true if tf end |
#setformrowcol(r, c) ⇒ Object
passing a cursor up and adding col and row offsets Added 2010-01-13 13:27 I am checking this out. I would rather pass the value down and store it than do this recursive call + for each cursor display
1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1148 def setformrowcol r, c @form.row = r unless r.nil? @form.col = c unless c.nil? # this is stupid, going through this route i was losing windows top and left # And this could get repeated if there are mult objects. if !@parent_component.nil? and @parent_component != self r+= @parent_component.form.window.top unless r.nil? c+= @parent_component.form.window.left unless c.nil? $log.debug " (#{@name}) calling parents setformrowcol #{r}, #{c} pa: #{@parent_component.name} self: #{name}, #{self.class}, poff #{@parent_component.row_offset}, #{@parent_component.col_offset}, top:#{@form.window.left} left:#{@form.window.left} " @parent_component.setformrowcol r, c else # no more parents, now set form $log.debug " name NO MORE parents setting #{r}, #{c} in #{@form} " @form.setrowcol r, c end end |
#setrowcol(r, c) ⇒ Object
widget: i am putting one extra level of indirection so i can switch here between form#setrowcol and setformrowcol, since i am not convinced either are giving the accurate result. i am not sure what the issue is.
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1167 def setrowcol r, c # 2010-02-07 21:32 is this where i should add ext_offsets #$log.debug " #{@name} w.setrowcol #{r} + #{@ext_row_offset}, #{c} + #{@ext_col_offset} " # commented off 2010-02-15 18:22 #r += @ext_row_offset unless r.nil? #c += @ext_col_offset unless c.nil? if @form @form.setrowcol r, c #elsif @parent_component else raise "Parent component not defined for #{self}, #{self.class} " unless @parent_component @parent_component.setrowcol r, c end #setformrowcol r,c end |
#show ⇒ Object
1004 1005 1006 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1004 def show @visible = true end |
#text_variable(*val) ⇒ Object
getter and setter for text_variable
898 899 900 901 902 903 904 905 906 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 898 def text_variable(*val) if val.empty? @text_variable else @text_variable = val[0] $log.debug " GOING TO CALL ADD DELPENDENT #{self}" @text_variable.add_dependent(self) end end |
#unbind_key(keycode) ⇒ Object
remove a binding that you don’t want
1026 1027 1028 1029 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1026 def unbind_key keycode @key_args.delete keycode unless @key_args.nil? @key_handler.delete keycode unless @key_handler.nil? end |
#width(*val) ⇒ val
getter and setter for width - 2009-10-29 22:45 Using dsl_property style
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1068 def width(*val) #$log.debug " inside width() #{val}" if val.empty? return @width else #$log.debug " inside width()" oldvalue = @width || 0 # is this default okay, else later nil cries #@width = val.size == 1 ? val[0] : val @width = val[0] newvalue = @width @config["width"]=@width if oldvalue != newvalue @property_changed = true fire_property_change(:width, oldvalue, newvalue) repaint_all(true) # added 2010-01-08 18:51 so widgets can redraw everything. end #if is_double_buffered? and newvalue != oldvalue # removed on 2011-09-29 #$log.debug " #{@name} w calling resize of screen buffer with #{newvalue}. WARNING: does not change buffering_params" #@screen_buffer.resize(0, newvalue) #end end end |
#width=(val) ⇒ Object
1090 1091 1092 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1090 def width=val width(val) end |