Class: RubyCurses::Widget
- Includes:
- Io, ConfigSetup, EventHandler, 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.
825 826 827 828 829 830 831 832 833 834 835 836 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 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 825 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
803 804 805 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 803 def _object_created @_object_created end |
#col_offset ⇒ Object (readonly)
where should the cursor be placed to start with
792 793 794 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 792 def col_offset @col_offset end |
#cols_panned ⇒ Object
moved from form, how many cols scrolled.panned 2010-02-11 15:26
814 815 816 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 814 def cols_panned @cols_panned end |
#config ⇒ Object (readonly)
can be used for popping user objects too
789 790 791 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 789 def config @config end |
#curpos ⇒ Object
cursor position inside object - column, not row.
788 789 790 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 788 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
819 820 821 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 819 def focussed @focussed end |
#form ⇒ Object
made accessor 2008-11-27 22:32 so menu can set
790 791 792 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 790 def form @form end |
#id ⇒ Object
, :zorder
787 788 789 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 787 def id @id end |
#key_label ⇒ Object (readonly)
823 824 825 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 823 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.
809 810 811 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 809 def parent_component @parent_component end |
#row_offset ⇒ Object (readonly)
where should the cursor be placed to start with
792 793 794 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 792 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
813 814 815 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 813 def rows_panned @rows_panned end |
#state ⇒ Object
normal, selected, highlighted
791 792 793 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 791 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
1229 1230 1231 1232 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1229 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
1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1194 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.
1220 1221 1222 1223 1224 1225 1226 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1220 def command *args, &block if @_events.include? :PRESS bind :PRESS, *args, &block else bind :CHANGED, *args, &block end end |
#destroy ⇒ Object
947 948 949 950 951 952 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 947 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
1186 1187 1188 1189 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1186 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
1006 1007 1008 1009 1010 1011 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1006 def focus return if !@focusable if @form.validate_field != -1 @form.select_field @id end end |
#get_preferred_size ⇒ Object
1034 1035 1036 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1034 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
922 923 924 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 922 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
927 928 929 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 927 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
1028 1029 1030 1031 1032 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1028 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
1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1089 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
1106 1107 1108 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1106 def height=val height(val) end |
#hide ⇒ Object
989 990 991 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 989 def hide @visible = false end |
#init_vars ⇒ Object
865 866 867 868 869 870 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 865 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 )
876 877 878 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 876 def modified? @modified end |
#move(row, col) ⇒ Object
is this required can we remove
999 1000 1001 1002 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 999 def move row, col @row = row @col = col end |
#on_enter ⇒ Object
got left out by mistake 2008-11-26 20:20
897 898 899 900 901 902 903 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 897 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
905 906 907 908 909 910 911 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 905 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
1127 1128 1129 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1127 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.
1023 1024 1025 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1023 def process_key keycode, object return _process_key keycode, object, @graphic end |
#remove ⇒ Object
995 996 997 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 995 def remove @form.(self) end |
#repaint ⇒ Object
default repaint method. Called by form for all widgets.
widget does not have display_length.
933 934 935 936 937 938 939 940 941 942 943 944 945 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 933 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
1114 1115 1116 1117 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1114 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)
1111 1112 1113 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1111 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.
916 917 918 919 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 916 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.
1042 1043 1044 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1042 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
1177 1178 1179 1180 1181 1182 1183 1184 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1177 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.
956 957 958 959 960 961 962 963 964 965 966 967 968 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 956 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
982 983 984 985 986 987 988 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 982 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.
970 971 972 973 974 975 976 977 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 970 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
879 880 881 882 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 879 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
1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1136 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.
1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1155 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
992 993 994 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 992 def show @visible = true end |
#text_variable(*val) ⇒ Object
getter and setter for text_variable
886 887 888 889 890 891 892 893 894 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 886 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
1014 1015 1016 1017 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1014 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
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1056 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
1078 1079 1080 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1078 def width=val width(val) end |