Class: RubyCurses::MultiSplit
- Inherits:
-
Widget
- Object
- Widget
- RubyCurses::MultiSplit
- Defined in:
- lib/rbcurse/extras/widgets/rmultisplit.rb
Overview
A MultiSplit allows user to split N components vertically or horizontally. such as 3 listboxes, each dependent on what is selected in previous. This is the column-browse pattern, as in ruby’s rdoc when seen in a browser. Also, this can be used for directory browsing, as in OSX Finder. One can keep adding components, and scroll back and forth, so we can have more components than are visible. See testmultispl.rb for a demo of this.
This class allows for adding components in one direction, vertical or horizontal. It differs from Vimsplit in that you can have offscreen windows and scroll through. Vimsplit shows all windows but allows stacking and flowing of components.
TODO -
[ ] Don't print title if width less than title XXX or truncate - listbox
x user specify max panes to show (beyond that hide and pan)
x how many can be created
- to squeeze panes and fit all or hide and pan
x allow resize of panes
- allow orientation change or not
x some anamoly reg LEAVE and ENTER from last object
x should we not be managing on_enter of listboxes when tabbing ?
x how many panes to show, max to create
x increase size - currently i recalc each time!
x print more marker
- allow user to specify preferred sizes and respect that
x don't move to an empty list, can have a crash
Instance Attribute Summary collapse
- #components ⇒ Object readonly
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#add(comp) ⇒ Object
(also: #<<)
adds a component to the multisplit When you add a component to a container such as multisplit, be sure you create it with a nil form object, or else the main form will try to manage it.
-
#compute_component(comp, index) ⇒ Object
compute component dimensions in one place XXX if called from outside balance can have last value !!! FIXME for last component, take as much as is left height or width otherwise odd figures will leave on row unoccupied.
-
#decrease ⇒ Object
decrease size of current component.
-
#exchange ⇒ Object
exchange 2 splits, bound to C-w x TODO.
-
#expand ⇒ Object
expand a split to maximum.
-
#get_next_component ⇒ widget
Next component or nil if no next.
-
#get_prev_component ⇒ widget
Prev component or nil if no next.
-
#getvalue ⇒ Object
:nodoc:.
-
#goto_next_component ⇒ 0, :UNHANDLED
take focus to next pane (component in it) if its the last, return UNHANDLED so form can take to next field.
-
#goto_prev_component ⇒ 0, :UNHANDLED
take focus to prev pane (component in it) if its the first, return UNHANDLED so form can take to prev field.
-
#handle_key(ch) ⇒ Object
Handles key for splitpanes By default, first component gets focus, not the SPL itself.
-
#height(*val) ⇒ int
change height of splitpane.
- #increase ⇒ Object
-
#init_vars ⇒ Object
:nodoc:.
-
#initialize(form, config = {}, &block) ⇒ MultiSplit
constructor
attr_accessor :one_touch_expandable # boolean, default true # XXX.
-
#on_enter ⇒ Object
this is executed when the component gets focus and will happen each time on traversal Used to place the focus on correct internal component and place cursor where component should have it.
- #on_first_component? ⇒ Boolean
- #on_last_component? ⇒ Boolean
-
#paint ⇒ Object
:nodoc:.
-
#repaint ⇒ Object
multisplitpane #:nodoc:.
-
#reset_to_preferred_sizes ⇒ Object
resets divider location based on preferred size of first component You may want to check for ERROR and if so, resize_weight to 0.50.
- #same ⇒ Object
-
#set_form_col ⇒ Object
added 2010-02-09 10:10 sets the forms cursor column correctly earlier the super was being called which missed out on child’s column.
-
#set_form_row ⇒ Object
sets cursor on correct row, col should we raise error or throw exception if can;t enter.
- #size ⇒ Object (also: #length)
-
#tile ⇒ Object
tmp = @first_component reset_to_preferred_sizes.
-
#unexpand ⇒ Object
after expanding one split, revert to original - actually i reset, rather than revert This only works after expand has been done.
-
#update_components ⇒ Object
recalculates components and calls repaint.
-
#width(*val) ⇒ int
change width of splitpane NOTE: if VERTICAL, then expand or contract only second If HORIZ then expand / contract both Actually this is very complicated since reducing should take into account min_width.
Constructor Details
#initialize(form, config = {}, &block) ⇒ MultiSplit
attr_accessor :one_touch_expandable # boolean, default true # XXX
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 87 def initialize form, config={}, &block @focusable = true @editable = false @cyclic_behavior = true @row = 0 @col = 0 @split_count = nil # this is the list of components @components = [] # need to recalculate offsets and dimensions of all comps since new one added # to be done once in repaint, and whenever a new one added (in repaint) @recalc_required = true @row_offset = @col_offset = 1 @suppress_borders = false super @orig_col = @col @use_absolute = true; # set to true if not using subwins XXX CLEAN THIS init_vars end |
Instance Attribute Details
#components ⇒ Object (readonly)
81 82 83 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 81 def components @components end |
Instance Method Details
#[](index) ⇒ Object
189 190 191 192 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 189 def [](index) raise "MultiSplit: Please add components first" unless @components @components[index] end |
#add(comp) ⇒ Object Also known as: <<
adds a component to the multisplit When you add a component to a container such as multisplit, be sure you create it with a nil form object, or else the main form will try to manage it. Containers typically manage their own components such as navigation and they give it the form/graphic object they were created with.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 143 def add comp # for starters to make life simple, we force user to specify how many splits # This is largely because i don;t know much about the buffering thing, is it still # needed here or what. If we can postpone it, then we can compute this in a loop # in repaint raise "split_count must be given first. How many splits there will be." unless @split_count $log.debug " multisplit: Adding a component #{@components.size} " # until we hide those outside bounds, or are able to scroll, lets not allow add if # exceeds if @components.size >= @split_count if @unlimited #@split_count = @components.size + 1 # calc of width depending on ths else Ncurses.beep return end end @recalc_required = true @components = [] if @components.nil? @components << comp #comp.height = nil # nuking listboxes height since it gets calculated comp.parent_component = self # dang ! this can go out of bounds ! XXX tab goes out index = @components.size - 1 # expected as base 0 in compute #index = @max_visible - 1 if index > @max_visible - 1 # all this ado to prevent cursor going out in the first display # when index exceeds visible, since compute now uses running balance if index > @max_visible - 1 # we copy the coords of the previous one prev = @components[index-1] comp.row = prev.row comp.col = prev.col comp.width = prev.width comp.height = prev.height else compute_component comp, index end comp.set_buffering(:target_window => @target_window || @form.window, :bottom => comp.height-1, :right => comp.width-1, :form => @form ) # removed on 2011-09-29 comp.min_height ||= 5 comp.min_width ||= 5 return self end |
#compute_component(comp, index) ⇒ Object
compute component dimensions in one place XXX if called from outside balance can have last value !!! FIXME for last component, take as much as is left height or width otherwise odd figures will leave on row unoccupied
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 204 def compute_component comp, index @balance ||= 0 if @orientation == :HORIZONTAL_SPLIT # XXX NOT TESTED TODO @comp_height = (@height / @split_count) - 0 @comp_width = @width h = @comp_height if @recalc_required comp.height = h # listboxes etal calculate a height so that will stand !! XXX else comp.height ||= h # listboxes etal calculate a height so that will stand !! XXX end w = @comp_width #r = @row + ( comp.height * index) r = @row + @balance if r > @row + @height r = @row + @height end #alert "r #{@row} h #{@height} ::: comp row #{r} h #{h} bal:#{@balance} " @balance += comp.height c = @col comp.width = w comp.row = r comp.col = c else @comp_height = @height @comp_width = (@width / @split_count) - 0 h = @comp_height w = @comp_width if @recalc_required comp.width = w else comp.width ||= w end #c = @col + ( w * index) # this makes them all equal c = @col + @balance if c > @col + @width c = @col + @width end $log.debug "XXXX index #{index} , w #{comp.width} , c = #{c} , bal #{@balance} c+w:#{@col+@width} " #if index < @max_visible - 1 @balance += comp.width #end r = @row comp.height = h comp.row = r comp.col = c #$log.debug " XXXX index r c #{r} #{c} " end comp end |
#decrease ⇒ Object
decrease size of current component. if last one, then border printing exceeds right boundary. values look okay dunno why XXX FIXME
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 279 def decrease _multiplier = ($multiplier == 0 ? 1 : $multiplier ) delta = _multiplier $log.debug "XXXX decrease got mult #{$_multiplier} " c = @current_component # if decreasing last component then increase previous # otherwise always increase the next n = get_next_component || get_prev_component return unless n # if no other, don't allow if @orientation == :HORIZONTAL_SPLIT c.height -= delta n.height += delta # TODO else if c.width > 3 + delta c.width -= delta n.width += delta end end @repaint_required = true self end |
#exchange ⇒ Object
exchange 2 splits, bound to C-w x TODO
698 699 700 701 702 703 704 705 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 698 def exchange alert "TODO" #tmp = @first_component #@first_component = @second_component #@second_component = tmp #@repaint_required = true #reset_to_preferred_sizes end |
#expand ⇒ Object
expand a split to maximum. This is the one_touch_expandable feature Currently mapped to C-w 1 (mnemonic for one touch), or C-w o (vim’s only) To revert, you have to unexpand Note: basically, i nil the component that we don’t want to see
659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 659 def return unless @one_touch_expandable # TODO #@is_expanding = true # this is required so i don't check for min_width later #$log.debug " callign expand " #if @current_component == @first_component #@saved_component = @second_component #@second_component = nil #if @orientation == :VERTICAL_SPLIT #set_divider_location @width - 1 #else #set_divider_location @height - 1 #end #$log.debug " callign expand 2 nil #{@divider_location}, h:#{@height} w: #{@width} " #else #@saved_component = @first_component #@first_component = nil #set_divider_location 1 #$log.debug " callign expand 1 nil #{@divider_location}, h:#{@height} w: #{@width} " #end #@repaint_required = true end |
#get_next_component ⇒ widget
Returns next component or nil if no next.
310 311 312 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 310 def get_next_component return @components[@current_index+1] end |
#get_prev_component ⇒ widget
Returns prev component or nil if no next.
314 315 316 317 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 314 def get_prev_component return nil if @current_index == 0 return @components[@current_index-1] end |
#getvalue ⇒ Object
:nodoc:
469 470 471 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 469 def getvalue #:nodoc: # TODO end |
#goto_next_component ⇒ 0, :UNHANDLED
take focus to next pane (component in it) if its the last, return UNHANDLED so form can take to next field
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 476 def goto_next_component if @current_component != nil @current_component.on_leave if on_last_component? return :UNHANDLED end @current_index += 1 @current_component = @components[@current_index] # is it visible #@current_index.between?(_first_column_print, _last_column_print) if @current_index > @_last_column_print # TODO need to check for exceeding @_first_column_print += 1 @_last_column_print += 1 @repaint_required = true end # shoot if this this put on a form with other widgets # we would never get out, should return nil -1 in handle key unless @current_component $log.debug " CAME HERE unless @current_component setting to first" raise " CAME HERE unless @current_component setting to first" @current_index = 0 @current_component = @components[@current_index] end else # this happens in one_tab_expand #@current_component = @second_component if @first_component.nil? #@current_component = @first_component if @second_component.nil? # XXX not sure what to do here, will it come $log.debug " CAME HERE in else clause MSP setting to first" raise" CAME HERE in else clause MSP setting to first" @current_index = 0 @current_component = @components[@current_index] end return set_form_row end |
#goto_prev_component ⇒ 0, :UNHANDLED
take focus to prev pane (component in it) if its the first, return UNHANDLED so form can take to prev field
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 516 def goto_prev_component if @current_component != nil @current_component.on_leave if on_first_component? return :UNHANDLED end @current_index -= 1 @current_component = @components[@current_index] if @current_index < @_first_column_print # TODO need to check for zero @_first_column_print -= 1 @_last_column_print -= 1 @repaint_required = true end # shoot if this this put on a form with other widgets # we would never get out, should return nil -1 in handle key unless @current_component @current_index = 0 @current_component = @components[@current_index] end else # this happens in one_tab_expand #@current_component = @second_component if @first_component.nil? #@current_component = @first_component if @second_component.nil? # XXX not sure what to do here, will it come @current_index = 0 @current_component = @components[@current_index] end set_form_row return 0 end |
#handle_key(ch) ⇒ Object
Handles key for splitpanes By default, first component gets focus, not the SPL itself. + Mostly passing to child, and handling child’s left-overs. please use bind_key for all mappings. Avoid adding code in here. Let this be generic
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 558 def handle_key ch #:nodoc: _multiplier = ($multiplier == 0 ? 1 : $multiplier ) @current_component ||= @first_component @current_index ||= 0 ## 2010-01-15 12:57 this helps me switch between highest level ## However, i should do as follows: ## If tab on second component, return UNHA so form can take to next field ## If B_tab on second comp, switch to first ## If B_tab on first comp, return UNHA so form can take to prev field if ch == KEY_TAB return goto_next_component #return 0 elsif ch == KEY_BTAB return goto_prev_component end if @current_component != nil ret = @current_component.handle_key ch return ret if ret != :UNHANDLED else ## added 2010-01-07 18:59 in case nothing in there. $log.debug " SPLP #{@name} - no component installed in splitpane" #return :UNHANDLED end $log.debug " mmplitpane #{@name} gets KEY #{ch}" case ch when ?\C-c.getbyte(0) $multiplier = 0 return 0 when ?0.getbyte(0)..?9.getbyte(0) $multiplier *= 10 ; $multiplier += (ch-48) return 0 end ret = process_key ch, self return :UNHANDLED if ret == :UNHANDLED $multiplier = 0 return 0 end |
#height(*val) ⇒ int
change height of splitpane
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 323 def height(*val) return @height if val.empty? oldvalue = @height || 0 super @height = val[0] return if @components.nil? || @components.empty? delta = @height - oldvalue @repaint_required = true if !@cascade_boundary_changes.nil? # must tell children if height changed which will happen in nested splitpanes # must adjust to components own offsets too if @orientation == :VERTICAL_SPLIT @components.each do |e| e.height += delta end else e = @components.first e.height += delta end end end |
#increase ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 255 def increase _multiplier = ($multiplier == 0 ? 1 : $multiplier ) delta = _multiplier c = @current_component n = get_next_component n = get_prev_component unless n return unless n if @orientation == :HORIZONTAL_SPLIT if n.height > 3 + delta c.height += delta n.height -= delta end else if n.width > 3 + delta c.width += delta n.width -= delta end end @repaint_required = true self end |
#init_vars ⇒ Object
:nodoc:
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 106 def init_vars #:nodoc: @_first_column_print = 0 # added 2009-10-07 11:25 @max_visible ||= @split_count @_last_column_print = @_first_column_print + @max_visible - 1 # cascade_changes keeps the child exactly sized as per the pane which looks nice #+ but may not really be what you want. @cascade_changes=true ## if this splp is increased (ht or wid) then expand the child @cascade_boundary_changes = true @orientation ||= :HORIZONTAL_SPLIT # added 2010-01-13 15:05 since not set # true means will request child to create a buffer, since cropping will be needed # FIXME: if true then increases in size are not having effect !!! @_child_buffering = false # private, internal. not to be changed by callers. #@one_touch_expandable = true #@is_expanding = false @row_offset = @col_offset = 0 if @suppress_borders #bind_key([?\C-w, ?o], :expand) #bind_key([?\C-w, ?1], :expand) #bind_key([?\C-w, ?2], :unexpand) #bind_key([?\C-w, ?x], :exchange) bind_key(?w, :goto_next_component) bind_key(?b, :goto_prev_component) bind_key([?\C-w, ?-], :decrease) bind_key([?\C-w, ?+], :increase) bind_key([?\C-w, ?=], :same) end |
#on_enter ⇒ Object
this is executed when the component gets focus and will happen each time on traversal Used to place the focus on correct internal component and place cursor where component should have it. User can press tab, to come here, or it could be first field of form, or he could press a mnemonic.
606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 606 def on_enter return if @components.nil? # cyclic means it always lands into first comp just as in rdoc # otherwise it will always land in last visited component if @cyclic_behavior # if user backtabbed in place him on last comp # else place him in first. if $current_key == KEY_BTAB @current_component = @components[@_last_column_print] @current_index = @_last_column_print else @current_component = @components[@_first_column_print] @current_index = @_first_column_print end end @current_component ||= @components.first set_form_row end |
#on_first_component? ⇒ Boolean
547 548 549 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 547 def on_first_component? @current_component == @components.first end |
#on_last_component? ⇒ Boolean
550 551 552 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 550 def on_last_component? @current_component == @components.last end |
#paint ⇒ Object
:nodoc:
597 598 599 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 597 def paint #:nodoc: #@repaint_required = false end |
#repaint ⇒ Object
multisplitpane #:nodoc:
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 404 def repaint # multisplitpane #:nodoc: if @graphic.nil? @graphic = @target_window || @form.window raise "graphic nil in rsplitpane #{@name} " unless @graphic end if @repaint_required # repaint all ? @components.each { |e| e.repaint_all(true) } end if @repaint_required ## paint border and divider $log.debug "MULTISPLP #{@name} repaint split H #{@height} W #{@width} " bordercolor = @border_color || $datacolor borderatt = @border_attrib || Ncurses::A_NORMAL absrow = abscol = 0 if @use_absolute absrow = @row abscol = @col end if @use_absolute $log.debug " #{@graphic} #{name} calling print_border #{@row} #{@col} #{@height}-1 #{@width}-1 " @graphic.print_border(@row, @col, @height-1, @width-1, bordercolor, borderatt) if !@suppress_borders else $log.debug " #{@graphic} calling print_border 0,0" @graphic.print_border(0, 0, @height-1, @width-1, bordercolor, borderatt) unless @suppress_borders end rc = -1 @graphic.attron(Ncurses.COLOR_PAIR(bordercolor) | borderatt) # 2010-02-14 18:23 - non buffered, have to make relative coords into absolute #+ by adding row and col count = @components.nil? ? @split_count : @components.size count = @components.empty? ? @split_count : @components.size if @orientation == :VERTICAL_SPLIT @comp_height ||= @height @comp_width ||= (@width / @split_count) - 0 $log.debug "SPLP #{@name} prtingign split vline divider 1, rc: #{rc}, h:#{@height} - 2 " #@graphic.mvvline(absrow+1, rc+abscol, 0, @height-2) # (1...count).each(){|i| @graphic.mvvline(absrow+1, (i*@comp_width)+abscol, 0, @height-2) } # TODO put vlines here # commented off since it uses fixed values and we are increaseing and dec else @comp_height ||= (@height / @split_count) - 1 @comp_width ||= @width #$log.debug "SPLP #{@name} prtingign split hline divider rc: #{rc} , 1 , w:#{@width} - 2" #@graphic.mvhline(rc+absrow, abscol+1, 0, @width-2) # XXX in next line -2 at end was causing an overlap into final border col, # this need correction in splitpane XXX #(1...count).each(){|i| @graphic.mvhline((i*@comp_height)+absrow, abscol+1, 0, @width-3) } # TODO put hlines here end @graphic.attroff(Ncurses.COLOR_PAIR(bordercolor) | borderatt) update_components _print_more_columns_marker true @graphic.wrefresh # 2010-02-14 20:18 SUBWIN ONLY ??? what is this doing here ? XXX else # repaint only those components that may have changed @components.each { |e| e.repaint } end ## XXX do not paint what is outside of bounds. See tabbedpane or scrollform #paint @repaint_required = false end |
#reset_to_preferred_sizes ⇒ Object
resets divider location based on preferred size of first component You may want to check for ERROR and if so, resize_weight to 0.50
381 382 383 384 385 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 381 def reset_to_preferred_sizes alert "TODO THIS reset_to " return if @components.nil? @repaint_required = true end |
#same ⇒ Object
301 302 303 304 305 306 307 308 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 301 def same @components.each do |comp| comp.height = @comp_height comp.width = @comp_width end @repaint_required = true self end |
#set_form_col ⇒ Object
added 2010-02-09 10:10 sets the forms cursor column correctly earlier the super was being called which missed out on child’s column. Note: splitpane does not use the cursor, so it does not know where cursor should be displayed, + the child has to decide where it should be displayed.
650 651 652 653 654 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 650 def set_form_col #:nodoc: return if @current_component.nil? #$log.debug " #{@name} set_form_col calling sfc for #{@current_component.name} " @current_component.set_form_col end |
#set_form_row ⇒ Object
sets cursor on correct row, col should we raise error or throw exception if can;t enter
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 626 def set_form_row #:nodoc: if !@current_component.nil? c=@current_component $log.debug "XXXXX #{@name} set_form_row calling sfr for #{@current_component.name}, #{c.row}, #{c.col} " #@current_component.set_form_row # trigger the on_enter handler # my god XXX this assumes a listbox !! FIXME # on enter should return a false or error so we don't proceed # or throw exception if @current_component.row_count > 0 @current_component.on_enter # typically on enter does a set_form_row # XXX another assumption that is has this !!! @current_component.set_form_col return 0 end # end return :UNHANDLED end |
#size ⇒ Object Also known as: length
193 194 195 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 193 def size @components.size end |
#tile ⇒ Object
tmp = @first_component reset_to_preferred_sizes
706 707 708 709 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 706 def tile return unless @tiling_allowed # TODO end |
#unexpand ⇒ Object
after expanding one split, revert to original - actually i reset, rather than revert This only works after expand has been done
683 684 685 686 687 688 689 690 691 692 693 694 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 683 def #$log.debug " inside unexpand " #return unless @saved_component #if @first_component.nil? #@first_component = @saved_component #else #@second_component = @saved_component #end #@saved_component = nil #@repaint_required = true #reset_to_preferred_sizes end |
#update_components ⇒ Object
recalculates components and calls repaint
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 387 def update_components # #:nodoc: @balance = 0 @max_visible ||= @split_count @_first_column_print ||= 0 @_last_column_print = @_first_column_print + @max_visible - 1 $log.debug " XXXX #{@_first_column_print} , last print #{@_last_column_print} " @components.each_with_index do |comp,index| next if index < @_first_column_print break if index > @_last_column_print compute_component comp, index comp.set_buffering(:target_window => @target_window || @form.window, :form => @form ) # 2011-09-29 #comp.set_buffering(:target_window => @target_window || @form.window, :bottom => comp.height-1, :right => comp.width-1, :form => @form ) comp.repaint end #@balance = 0 @recalc_required = false end |
#width(*val) ⇒ int
change width of splitpane NOTE: if VERTICAL, then expand or contract only second If HORIZ then expand / contract both Actually this is very complicated since reducing should take into account min_width
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/rbcurse/extras/widgets/rmultisplit.rb', line 351 def width(*val) return @width if val.empty? # must tell children if height changed which will happen in nested splitpanes oldvalue = @width || 0 super @width = val[0] delta = @width - oldvalue $log.debug " SPLP #{@name} width #{oldvalue}, #{@width}, #{delta} " @repaint_required = true if !@cascade_boundary_changes.nil? # must adjust to components own offsets too # NOTE: 2010-01-10 20:11 if we increase width by one, each time will both components get increased by one. if @orientation == :HORIZONTAL_SPLIT @components.each do |e| e.width += delta end else # any change in width must effect col of others too ! 2010-08-31 21:57 AUG2010 # which is why this should be done in repaint and not here # ## next change should only happen if sc w < ... # if @second_component.width < @width - (rc + @col_offset + @divider_offset + 1) last = @components.last last.width += delta end end end |