Class: RubyCurses::SplitPane
- Defined in:
- lib/rbcurse/rsplitpane.rb,
lib/rbcurse/rsplitpane2.rb
Overview
A simpler SplitPane allows user to split 2 components vertically or horizontally. such as textarea, table or a list. Besides components, it allows user to set position of divider using divider_at (fraction). TODO -
Constant Summary
Constants included from Io
Io::ERROR_COLOR_PAIR, Io::FOOTER_COLOR_PAIR, Io::LINEONE, Io::MAIN_WINDOW_COLOR_PAIR
Instance Attribute Summary collapse
- #divider_location ⇒ Object readonly
- #last_divider_location ⇒ Object writeonly
-
#one_touch_expandable ⇒ Object
boolean, default true.
-
#orientation(*val) ⇒ Object
readonly
dsl_property` :orientation # :VERTICAL_SPLIT or :HORIZONTAL_SPLIT # changed 2010.
- #resize_weight ⇒ Object readonly
Attributes inherited from Widget
#_object_created, #col_offset, #cols_panned, #config, #curpos, #focussed, #form, #id, #parent_component, #row_offset, #rows_panned, #state
Instance Method Summary collapse
-
#c1 ⇒ Object
faster access to the 2 components.
- #c2 ⇒ Object
-
#divider_at(*val) ⇒ Float
sets a fraction to use to determine placement of divider_location and consequently size of components.
-
#first_component(comp) ⇒ true, false
Sets the first component (top or left) XXX This originally working fine if the child was also a splitpane Now with other comps, it works fine with them if they create a buffer in const but now SPLP bombs since it creates a buffer in repaint.
-
#getvalue ⇒ Object
TODO.
-
#goto_next_component ⇒ Object
we forgot to call the on_enter and on_leave this switches between components.
- #goto_prev_component ⇒ Object
- #h? ⇒ Boolean
-
#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.
- #init_vars ⇒ Object
-
#initialize(form, config = {}, &block) ⇒ SplitPane
constructor
A new instance of SplitPane.
-
#OLDheight(*val) ⇒ int
change height of splitpane.
- #OLDset_divider_location(rc) ⇒ Object
-
#OLDwidth(*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.
-
#on_enter ⇒ Object
on entering this component place user on first child TODO if he backtabs in then place on last.
- #paint ⇒ Object
-
#repaint ⇒ Object
splitpane.
-
#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.
-
#second_component(comp) ⇒ true, false
Sets the second component (bottom or right).
-
#set_divider_location(rc) ⇒ Object
set location of divider (row or col depending on orientation) internally sets the second components row or col also to set widths or heights Check minimum sizes are not disrespected + when pane size exceeds buffer size, so in these cases we increase size of component + and therefore buffer size.
-
#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
used to set form to whatever was current last now we set to first so user can cycle through.
-
#set_resize_weight(wt) ⇒ Object
calculate divider location based on weight Weight implies weight of first component, e.g.
- #update_first_component ⇒ Object
- #update_second_component ⇒ Object
-
#v? ⇒ Boolean
is vertical.
-
#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.
Methods inherited from Widget
#changed, #click, #destroy, #enter, #event_list, #focus, #get_preferred_size, #getvalue_for_paint, #height=, #hide, #leave, #modified?, #move, #on_leave, #override_graphic, #printstring, #process_key, #remove, #repaint_all, #repaint_required, #rowcol, #set_buffer_modified, #set_buffering, #set_form, #set_modified, #setformrowcol, #setrowcol, #show, #text_variable, #unbind_key, #width=
Methods included from Io
#askchoice, #askyesno, #askyesnocancel, #clear_error, #clear_this, #get_string, #newaskyesno, #old_print_header, #old_print_top_right, #print_action, #print_error, #print_footer_help, #print_header, #print_headers, #print_help, #print_help_page, #print_in_middle, #print_key_labels, #print_key_labels_row, #print_screen_labels, #print_status, #print_this, #print_top_right, #rbgetstr, #warn
Methods included from Utils
#_process_key, #bind_key, #clean_string!, #get_color, #keycode_tos, #repeatm, #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(form, config = {}, &block) ⇒ SplitPane
Returns a new instance of SplitPane.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rbcurse/rsplitpane.rb', line 51 def initialize form, config={}, &block @focusable = true @editable = false #@left_margin = 1 @row = 0 @col = 0 super @row_offset = @col_offset = 1 @orig_col = @col @use_absolute = true; # set to true if not using subwins XXX init_vars @subwin_created = true # set to true if you don't want subwins created @@ctr ||= 0 if @@ctr == 0 if @subwin_created == false #layout = { :height => @height, :width => @width, :top => @row, :left => @col } layout = { :height => @height-1, :width => @width-1, :top => @row+1, :left => @col+1 } @graphic = @graphic._subwin(layout) fw = form.window raise "graphic nil #{@name} " unless @graphic $log.debug " SUBWIN CREATED " @subwin_created = true @target_window = @graphic @@ctr += 1 @use_absolute = false bordercolor = @border_color || $datacolor borderatt = @border_attrib || Ncurses::A_NORMAL end end end |
Instance Attribute Details
#divider_location ⇒ Object (readonly)
44 45 46 |
# File 'lib/rbcurse/rsplitpane.rb', line 44 def divider_location @divider_location end |
#last_divider_location=(value) ⇒ Object (writeonly)
46 47 48 |
# File 'lib/rbcurse/rsplitpane.rb', line 46 def last_divider_location=(value) @last_divider_location = value end |
#one_touch_expandable ⇒ Object
boolean, default true
49 50 51 |
# File 'lib/rbcurse/rsplitpane.rb', line 49 def end |
#orientation(*val) ⇒ Object (readonly)
dsl_property` :orientation # :VERTICAL_SPLIT or :HORIZONTAL_SPLIT # changed 2010
48 49 50 |
# File 'lib/rbcurse/rsplitpane2.rb', line 48 def orientation @orientation end |
#resize_weight ⇒ Object (readonly)
45 46 47 |
# File 'lib/rbcurse/rsplitpane.rb', line 45 def resize_weight @resize_weight end |
Instance Method Details
#c1 ⇒ Object
faster access to the 2 components
213 |
# File 'lib/rbcurse/rsplitpane.rb', line 213 def c1; @first_component; end |
#divider_at(*val) ⇒ Float
sets a fraction to use to determine placement of divider_location and consequently size of components
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/rbcurse/rsplitpane2.rb', line 122 def divider_at(*val) if val.empty? return @divider_at else where = val[0] raise ArgumentError "divider_at value should be between 0.2 and 0.8" if where < 0.2 || where > 0.8 @divider_at = where @repaint_required = true end self end |
#first_component(comp) ⇒ true, false
Sets the first component (top or left)
XXX This originally working fine if the child was also a splitpane Now with other comps, it works fine with them if they create a buffer in const but now SPLP bombs since it creates a buffer in repaint.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 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 |
# File 'lib/rbcurse/rsplitpane.rb', line 117 def first_component(comp) screen_col = 1 screen_row = 1 # offset for copying pad 2010-02-09 19:02 @first_component = comp; @first_component.parent_component = self ## added 2010-01-13 12:54 ## These setting are quite critical, otherwise on startup ##+ it can create 2 tiled buffers. a = 0 # =1 @first_component.row(@row + a) @first_component.col(@col + a) comp.should_create_buffer = @_child_buffering # adding ext_offsets 2010-02-09 13:39 # setting the form is again adding top and left which are the row and col from here. #$log.debug "SPLP exp_row #{@name}, #{comp} #{comp.ext_row_offset} += #{@ext_row_offset} + #{@row} " #$log.debug "SPLP exp_col #{@name} #{comp.ext_col_offset} += #{@ext_col_offset} + #{@col} " #XXX comp.ext_row_offset += @ext_row_offset + @row - @subform1.window.top #0# screen_row #XXX comp.ext_col_offset += @ext_col_offset + @col [email protected] # 0# screen_col comp.ext_row_offset += @ext_row_offset + @row #- @subform1.window.top #0# screen_row comp.ext_col_offset += @ext_col_offset + @col #[email protected] # 0# screen_col # The suggestd heights depend on orientation. a = 0 # = 2 if @orientation == :HORIZONTAL_SPLIT $log.debug "H FC ht #{comp.height} , w #{comp.width} #{comp.name}, #{comp.class} " @first_component.height ||= @first_component.preferred_height || @height/2 - 1 #1 @first_component.width ||= @first_component.preferred_width || @width - a $log.debug " FC2 ht #{comp.height} , w #{comp.width} #{comp.name} " else $log.debug "V FC ht #{comp.height} , w #{comp.width} #{comp.name} " @first_component.height ||= @first_component.preferred_height || @height - a @first_component.width ||= @first_component.preferred_width || @width/2 -1 $log.debug " FC2 ht #{comp.height} , w #{comp.width} #{comp.name} " end #layout = { :height => @height-1, :width => @width-1, :top => @row, :left => @col } # form may not be available at this point if setting internal componnedts FC first #comp.set_buffering(:target_window => @target_window || @form.window, :bottom => comp.height-1, :right => comp.width-1, :form => @form ) # added 2010-09-13 23:33 XXX raise "first components height or preferred height is required" unless comp.height raise "first components width or preferred width is required" unless comp.width comp.set_buffering(:screen_top => @row, :screen_left => @col) @first_component.min_height ||= 5 @first_component.min_width ||= 5 # if i set the above 2 to 0, it starts fine but then on any action loses the first row. # Just begun happeing suddenly! 2010-01-11 23:38 # 2010-01-11 22:32 dang, if component is like splitpane which sets in repaint # 2010-01-12 11:15 : for those who've created in constructor, i need to do this # so they don't print off. i need to find a way to have create_buffer pick an # explicit top and left. if !@first_component.get_buffer().nil? @first_component.get_buffer().set_screen_row_col(screen_row, screen_col) # check this out XXX #@first_component.get_buffer().top=1; # 2010-01-08 13:24 trying out #@first_component.get_buffer().left=1; # 2010-01-08 13:24 trying out end @current_component ||= @first_component # added 2010-01-13 15:39 end |
#getvalue ⇒ Object
TODO
668 669 670 |
# File 'lib/rbcurse/rsplitpane.rb', line 668 def getvalue # TODO end |
#goto_next_component ⇒ Object
we forgot to call the on_enter and on_leave this switches between components. Now we tab out after last.
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
# File 'lib/rbcurse/rsplitpane.rb', line 673 def goto_next_component if @current_component != nil if @current_component == @first_component @current_component.on_leave if @second_component @current_component = @second_component @current_component.on_enter else return :UNHANDLED end else #@current_component = @first_component @current_component.on_leave return :UNHANDLED # try to get him out. end set_form_row else # this happens in one_tab_expand @current_component = @second_component if @first_component.nil? @current_component = @first_component if @second_component.nil? set_form_row end 0 end |
#goto_prev_component ⇒ Object
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 |
# File 'lib/rbcurse/rsplitpane.rb', line 697 def goto_prev_component if @current_component != nil if @current_component == @second_component @current_component.on_leave if @first_component @current_component = @first_component @current_component.on_enter else return :UNHANDLED end else #@current_component = @first_component @current_component.on_leave return :UNHANDLED # try to get him out. end set_form_row else # this happens in one_tab_expand @current_component = @second_component if @first_component.nil? @current_component = @first_component if @second_component.nil? set_form_row end 0 end |
#h? ⇒ Boolean
652 653 654 |
# File 'lib/rbcurse/rsplitpane2.rb', line 652 def h? !v? 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. NOTE: How do we switch to the other outer SPL?
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 |
# File 'lib/rbcurse/rsplitpane.rb', line 725 def handle_key ch _multiplier = ($multiplier == 0 ? 1 : $multiplier ) @current_component ||= @first_component ## 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 == 9 #return goto_next_component #return 0 end if @current_component != nil # give the child the key to handle, this is the last current child 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 " splitpane #{@name} gets KEY #{ch}" case ch when KEY_TAB return goto_next_component when KEY_BTAB return goto_prev_component #return 0 when ?\M-w.getbyte(0) # switch panes if @current_component != nil if @current_component == @first_component @current_component = @second_component else @current_component = @first_component end set_form_row else return goto_next_component #return 0 # if i've expanded bottom pane, tabbed to opposite higher level, tabbing back # brings me to null first pane and i can't go to second, so switch # this was added for a non-realistic test program with embedded splitpanes #+ but no component inside them. At least one can go from one outer to another. #+ In real life, this should not come. return :UNHANDLED end when ?\M-V.getbyte(0) self.orientation(:VERTICAL_SPLIT) @repaint_required = true when ?\M-H.getbyte(0) self.orientation(:HORIZONTAL_SPLIT) @repaint_required = true when ?\M--.getbyte(0) self.set_divider_location(self.divider_location-_multiplier) when ?\M-\+.getbyte(0) self.set_divider_location(self.divider_location+_multiplier) when ?\M-\=.getbyte(0) self.set_resize_weight(0.50) #when ?\C-u.getbyte(0) ## multiplier. Series is 4 16 64 #@multiplier = (@multiplier == 0 ? 4 : @multiplier *= 4) #return 0 when ?\C-c.getbyte(0) $multiplier = 0 return 0 else # check for bindings, these cannot override above keys since placed at end ret = process_key ch, self return :UNHANDLED if ret == :UNHANDLED end $multiplier = 0 return 0 end |
#height(*val) ⇒ int
change height of splitpane
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/rbcurse/rsplitpane.rb', line 221 def height(*val) return @height if val.empty? oldvalue = @height || 0 super @height = val[0] return if @first_component.nil? or @second_component.nil? 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 @first_component.height += delta @second_component.height += delta # RFED16 2010-02-16 20:44 whenever we change dimensions need to update # buffering_params since we are not using Pad's buffer_to_screen @second_component.set_buffering(:bottom => @second_component.height-1) @first_component.set_buffering(:bottom => @first_component.height-1) else @second_component.height += delta @second_component.set_buffering(:bottom => @second_component.height-1) end end end |
#init_vars ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rbcurse/rsplitpane.rb', line 81 def init_vars #should_create_buffer(true) #if should_create_buffer().nil? @divider_location ||= 10 #@divider_offset ||= 1 @divider_offset ||= 0 #@curpos = @pcol = @toprow = @current_index = 0 # 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 @_child_buffering = false # private, internal. not to be changed by callers. = true = false bind_key([?\C-w, ?o], :expand) bind_key([?\C-w, ?1], :expand) bind_key([?\C-w, ?2], :unexpand) bind_key([?\C-w, ?x], :exchange) end |
#OLDheight(*val) ⇒ int
change height of splitpane
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/rbcurse/rsplitpane2.rb', line 250 def OLDheight(*val) return @height if val.empty? oldvalue = @height || 0 super @height = val[0] return if @first_component.nil? or @second_component.nil? 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 @first_component.height += delta @second_component.height += delta # RFED16 2010-02-16 20:44 whenever we change dimensions need to update # buffering_params since we are not using Pad's buffer_to_screen @second_component.set_buffering(:bottom => @second_component.height-1) @first_component.set_buffering(:bottom => @first_component.height-1) else @second_component.height += delta @second_component.set_buffering(:bottom => @second_component.height-1) end end end |
#OLDset_divider_location(rc) ⇒ Object
400 401 402 403 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 469 470 471 472 473 474 475 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 512 513 514 515 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 547 548 549 550 551 552 553 554 555 556 557 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 597 598 599 600 601 602 603 604 605 606 607 608 609 |
# File 'lib/rbcurse/rsplitpane2.rb', line 400 def OLDset_divider_location rc $log.debug " SPLP #{@name} setting divider to #{rc} " # add a check for out of bounds since no buffering v = 1 # earlier 2 if @orientation == :HORIZONTAL_SPLIT if rc < v || rc > @height - v return :ERROR end else if rc < v || rc > @width - v return :ERROR end end @repaint_required = true old_divider_location = @divider_location || 0 # we first check against min_sizes # the calculation is repeated here, and in the actual change # so if modifying, be sure to do in both places. if ! # if expanding then i can't check against min_width if rc > old_divider_location if @second_component != nil if @orientation == :VERTICAL_SPLIT # check second comps width if @width - (rc + @col_offset + @divider_offset+1) < @second_component.min_width $log.debug " #{@name} SORRY 2c min width prevents further resizing: #{@width} #{rc}" return :ERROR end else # check second comps ht $log.debug " YYYY SORRY 2c H:#{@height} rc: #{rc} 2cmh: #{@second_component.name} " if @height - rc -2 < @second_component.min_height $log.debug " #{@name} SORRY 2c min height prevents further resizing" return :ERROR end end end elsif rc < old_divider_location if @first_component != nil $log.debug " #{@name} fc min width #{rc}, #{@first_component.min_width} " if @orientation == :VERTICAL_SPLIT # check first comps width if rc-1 < @first_component.min_width $log.debug " SORRY fc min width prevents further resizing" return :ERROR end else if rc-1 < @first_component.min_height $log.debug " SORRY fc min height prevents further resizing" return :ERROR end end end end end # expanding = false @old_divider_location = @divider_location @divider_location = rc if @first_component != nil ## added in case not set. it will be set to a sensible default @first_component.height ||= 0 @first_component.width ||= 0 $log.debug " #{@name} set div location, setting first comp width #{rc}" if !@cascade_changes.nil? if @orientation == :VERTICAL_SPLIT $log.warn " SPLP height nil in #{@name} #{@first_component.name} " unless @height @height ||= 23 @first_component.width(rc-0) #+ @col_offset + @divider_offset @first_component.height(@height-0) #2+ @col_offset + @divider_offset else $log.warn " SPLP width nil in #{@name} #{@first_component.name} " unless @width @first_component.height(rc+0) #-1) #1+ @col_offset + @divider_offset @first_component.width(@width-0) #2+ @col_offset + @divider_offset end else if @orientation == :VERTICAL_SPLIT $log.debug " DOES IT COME HERE compare fc wt #{@first_component.width} to match #{rc}-1 " # added 2010-01-09 19:00 increase fc to avoid copywin crashing process if @first_component.width < rc -0 then $log.debug " INCRease fc wt #{@first_component.width} to match #{rc}-1 " @first_component.width(rc-0) #+ @col_offset + @divider_offset @first_component.repaint_all(true) if !@first_component.nil? @repaint_required = true end ## added this condition 2010-01-11 21:44 again switching needs this a = 0 #2 if @first_component.height < @height - a then $log.debug " INCRease fc ht #{@first_component.height} to match #{@height}- #{a} " @first_component.height(@height-a) #+ @col_offset + @divider_offset end else # added 2010-01-09 19:00 increase fc to avoid copywin crashing process a = 0 #1 if @first_component.height < rc -a then $log.debug " INCRease fc ht #{@first_component.height} to match #{rc}-1 " @first_component.height(rc-a) #+ @col_offset + @divider_offset @first_component.repaint_all(true) if !@first_component.nil? @repaint_required = true end # added 2010-01-11 19:24 to match c2. Sometimes switching from V to H means # fc's width needs to be expanded. if @first_component.width < @width - 1 #+ @col_offset + @divider_offset $log.debug " INCRease fc wi #{@first_component.width} to match #{@width}-2 " @first_component.width = @width - 1 #+ @col_offset + @divider_offset @first_component.repaint_all(true) @repaint_required = true end end end $log.debug " #{@name} TA set C1 H W RC #{@first_component.height} #{@first_component.width} #{rc} " @first_component.set_buffering(:bottom => @first_component.height-1, :right => @first_component.width-1, :form => @form ) end if !@second_component.nil? ## added 2010-01-11 23:09 since some cases don't set, like splits within split. @second_component.height ||= 0 @second_component.width ||= 0 if @orientation == :VERTICAL_SPLIT #@second_component.col = rc + @col_offset + @divider_offset #@second_component.row = 0 # 1 @second_component.col = @col + rc #+ @col_offset + @divider_offset @second_component.row = @row # 1 if !@cascade_changes.nil? #@second_component.width = @width - (rc + @col_offset + @divider_offset + 1) #@second_component.height = @height-2 #+ @row_offset + @divider_offset @second_component.width = @width - rc #+ @col_offset + @divider_offset + 1) @second_component.height = @height #+ @row_offset + @divider_offset else # added 2010-01-09 22:49 to be tested XXX # In a vertical split, if widgets w and thus buffer w is less than #+ pane, a copywin can crash process, so we must expand component, and thus buffer $log.debug " #{@name} 2c width does it come here? #{@second_component.name} #{@second_component.width} < #{@width} -( #{rc}+#{@col_offset}+#{@divider_offset} +1 " if @second_component.width < @width - rc #+ @col_offset + @divider_offset + 1) $log.debug " YES 2c width " @second_component.width = @width - rc #+ @col_offset + @divider_offset + 1) @second_component.repaint_all(true) @repaint_required = true end # adding 2010-01-17 19:33 since when changing to VERT, it was not expanding if @second_component.height < @height-0 #+ @row_offset + @divider_offset $log.debug " JUST ADDED 2010-01-17 19:35 HOPE DOES NOT BREAK ANYTHING " @second_component.height = @height-0 #+ @row_offset + @divider_offset end end else #rc += @row ## HORIZ SPLIT offrow = offcol = 0 #@second_component.row = offrow + rc + 0 #1 #@row_offset + @divider_offset #@second_component.col = 0 + offcol # was 1 offrow = @row; offcol = @col @second_component.row = offrow + rc + 0 #1 #@row_offset + @divider_offset $log.debug "C2 Horiz row #{@second_component.row} = #{offrow} + #{rc} " @second_component.col = 0 + offcol # was 1 if !@cascade_changes.nil? #@second_component.width = @width - 2 #+ @col_offset + @divider_offset #@second_component.height = @height - rc -2 #+ @row_offset + @divider_offset @second_component.width = @width - 0 #+ @col_offset + @divider_offset @second_component.height = @height - rc -0 #+ @row_offset + @divider_offset else # added 2010-01-16 19:14 -rc since its a HORIZ split # 2010-01-16 20:45 made 2 to 3 for scrollpanes within splits!!! hope it doesnt # break, and why 3. # 2010-01-17 13:33 reverted to 2. 3 was required since i was not returning when error in set_screen_max. if @second_component.height < @height-rc-1 #2 #+ @row_offset + @divider_offset $log.debug " #{@name} INCRease 2c #{@second_component.name} ht #{@second_component.height} to match #{@height}-2- #{rc} " @second_component.height = @height-rc-1 #2 #+ @row_offset + @divider_offset @second_component.repaint_all(true) @repaint_required = true end # # added 2010-01-10 15:36 still not expanding if @second_component.width < @width - 2 #+ @col_offset + @divider_offset $log.debug " #{@name} INCRease 2c #{@second_component.name} wi #{@second_component.width} to match #{@width}-2 " @second_component.width = @width - 2 #+ @col_offset + @divider_offset @second_component.repaint_all(true) @repaint_required = true end end end raise "2nd components height or preferred height is required (#{@second_component.name})" unless @second_component.height raise "2nd components width or preferred width is required(#{@second_component.name})" unless @second_component.width # i need to keep top and left sync for print_border which uses it UGH !!! if !@second_component.get_buffer().nil? # now that TV and others are creating a buffer in repaint we need another way to set #$log.debug " setting second comp row col offset - i think it doesn't come here till much later " #XXX @second_component.get_buffer().set_screen_row_col(@second_component.row+@ext_row_offset+@row, @second_component.col+@ext_col_offset+@col) # 2010-02-13 09:15 RFED16 @second_component.get_buffer().set_screen_row_col(@second_component.row, @second_component.col) end #@second_component.set_buffering(:screen_top => @row, :screen_left => @col) #@second_component.set_buffering(:screen_top => @row+@second_component.row, :screen_left => @col+@second_component.col) #@second_component.set_buffering(:screen_top => @row+@second_component.row, :screen_left => @col+@second_component.col) $log.debug "sdl: #{@name} setting C2 screen_top n left to #{@second_component.row}, #{@second_component.col} " @second_component.set_buffering(:screen_top => @second_component.row, :screen_left => @second_component.col) @second_component.set_buffering(:bottom => @second_component.height-1, :right => @second_component.width-1, :form => @form ) #@second_component.ext_row_offset = @row + @ext_row_offset #@second_component.ext_col_offset = @col + @ext_col_offset $log.debug " #{@name} 2 set div location, rc #{rc} width #{@width} height #{@height}" $log.debug " 2 set div location, setting r #{@second_component.row}, #{@ext_row_offset}, #{@row} " $log.debug " 2 set div location, setting c #{@second_component.col}, #{@ext_col_offset}, #{@col} " $log.debug " C2 set div location, setting w #{@second_component.width} " $log.debug " C2 set div location, setting h #{@second_component.height} " end fire_property_change("divider_location", old_divider_location, @divider_location) end |
#OLDwidth(*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
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/rbcurse/rsplitpane2.rb', line 281 def OLDwidth(*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 if @first_component != nil old = @first_component.width #@first_component.width = @width - @col_offset + @divider_offset @first_component.width += delta $log.debug "width() #{@name} set fc width to #{@first_component.width}, old was #{old} " @first_component.set_buffering(:right => @first_component.width-1) end # added 2010-01-11 23:02 horiz 2c not displaying since width issue if @second_component != nil old = @second_component.width #@first_component.width = @width - @col_offset + @divider_offset @second_component.width += delta @second_component.set_buffering(:right => @second_component.width-1) $log.debug "width() #{@name} set 2c width to #{@second_component.width}, old was #{old} " end else rc = @divider_location # ## next change should only happen if sc w < ... # 2010-01-11 22:11 # if @second_component.width < @width - (rc + @col_offset + @divider_offset + 1) if @second_component != nil if @second_component.width < @width - (rc + @col_offset + @divider_offset + 1) old = @second_component.width #@second_component.width = @width - @col_offset + @divider_offset @second_component.width += delta @second_component.set_buffering(:right => @second_component.width-1) $log.debug "width() #{@name} set 2c width to #{@second_component.width} , old was #{old} " end end end end end |
#on_enter ⇒ Object
on entering this component place user on first child TODO if he backtabs in then place on last
807 808 809 810 811 812 813 814 815 816 817 |
# File 'lib/rbcurse/rsplitpane.rb', line 807 def on_enter # 2010-09-14 00:58 forcing first always if $current_key == KEY_BTAB @current_component = @second_component else @current_component = @first_component end @current_component.on_enter if @current_component set_form_row end |
#paint ⇒ Object
801 802 803 |
# File 'lib/rbcurse/rsplitpane.rb', line 801 def paint @repaint_required = false end |
#repaint ⇒ Object
splitpane
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
# File 'lib/rbcurse/rsplitpane.rb', line 580 def repaint # splitpane if @graphic.nil? @graphic = @target_window || @form.window raise "graphic nil in rsplitpane #{@name} " unless @graphic end #XXX safe_create_buffer # this is in case, not called by form # we need to clip components # note that splitpanes can be nested if @repaint_required # Note: this only if major change #XXX @graphic.wclear @first_component.repaint_all(true) if !@first_component.nil? @second_component.repaint_all(true) if !@second_component.nil? end if @repaint_required ## paint border and divider $log.debug "SPLP #{@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} calling print_border #{@row} #{@col} " @graphic.print_border(@row, @col, @height-1, @width-1, bordercolor, borderatt) else $log.debug " #{@graphic} calling print_border 0,0" @graphic.print_border(0, 0, @height-1, @width-1, bordercolor, borderatt) end rc = @divider_location @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 if @orientation == :VERTICAL_SPLIT $log.debug "SPLP #{@name} prtingign split vline divider 1, rc: #{rc}, h:#{@height} - 2 " @graphic.mvvline(absrow+1, rc+abscol, 0, @height-2) else $log.debug "SPLP #{@name} prtingign split hline divider rc: #{rc} , 1 , w:#{@width} - 2" @graphic.mvhline(rc+absrow, abscol+1, 0, @width-2) end @graphic.attroff(Ncurses.COLOR_PAIR(bordercolor) | borderatt) end if @first_component != nil $log.debug " SPLP #{@name} repaint 1c ..." # this means that some components will create a buffer with default top and left of 0 the # first time. Is there no way we can tell FC what top and left to use. update_first_component @first_component.repaint # earlier before repaint but bombs since some chaps create buffer in repaint #XXX @first_component.get_buffer().set_screen_row_col(1, 1) # check this out XXX ## the next block is critical for when we switch from one orientation to the other ##+ We want first component to expand as much as possible if @orientation == :VERTICAL_SPLIT #XXX @first_component.get_buffer().set_screen_max_row_col(@height-2, @divider_location-1) else #XXX @first_component.get_buffer().set_screen_max_row_col(@divider_location-1, @width-2) end #XXX ret = @first_component.buffer_to_screen(@graphic) #XXX $log.debug " SPLP repaint #{@name} fc ret = #{ret} " end if @second_component != nil $log.debug " SPLP repaint #{@name} 2c ... dl: #{@divider_location} " # this is required since c2 gets its row and col only after divider has been set update_second_component @second_component.repaint unless @divider_location == 0 # we need to keep top and left of buffer synced with components row and col. # Since buffer has no link to comp therefore it can't check back. #XXX @second_component.get_buffer().set_screen_row_col(@second_component.row, @second_component.col) if @orientation == :VERTICAL_SPLIT #XXX @second_component.get_buffer().set_screen_max_row_col(@height-2, @width-2) else #XXX @second_component.get_buffer().set_screen_max_row_col(@height-2, @width-2) end #XXX ret = @second_component.buffer_to_screen(@graphic) #XXX $log.debug " SPLP repaint #{@name} 2c ret = #{ret} " end #XXX @buffer_modified = true @graphic.wrefresh # 2010-02-14 20:18 SUBWIN ONLY ??? what is this doing here ? XXX paint # TODO 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
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
# File 'lib/rbcurse/rsplitpane.rb', line 539 def reset_to_preferred_sizes return if @first_component.nil? @repaint_required = true ph, pw = @first_component.get_preferred_size if @orientation == :VERTICAL_SPLIT pw ||= @width/2-1 # added 2010-01-16 12:31 so easier to use, 1 to 2 2010-01-16 22:13 rc = pw+1 ## added 1 2010-01-11 23:26 else divider overlaps comp @first_component.width ||= pw ## added 2010-01-11 23:19 else ph ||= @height/2 - 0 # 1 # added 2010-01-16 12:31 so easier to use rc = ph+0 #1 ## added 1 2010-01-11 23:26 else divider overlaps comp @first_component.height ||= ph ## added 2010-01-11 23:19 end set_divider_location rc end |
#second_component(comp) ⇒ true, false
Sets the second component (bottom or right)
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/rbcurse/rsplitpane.rb', line 181 def second_component(comp) @second_component = comp; @second_component.parent_component = self ## added 2010-01-13 12:54 comp.should_create_buffer = @_child_buffering ## jeez, we;ve postponed create of buffer XX ## trying out 2010-01-16 12:11 so component does not have to set size # The suggestd heights really depend on orientation. if @orientation == :HORIZONTAL_SPLIT @second_component.row(@row+@divider_location) @second_component.col(@col+@col_offset) @second_component.height ||= @second_component.preferred_height || @height/2 - 1 #1 @second_component.width ||= @second_component.preferred_width || @width - 0 # 2 else @second_component.row(@row+@row_offset) @second_component.col(@col+@divider_location) @second_component.height ||= @second_component.preferred_height || @height - 0 # 2 @second_component.width ||= @second_component.preferred_width || @width/2 -4 # 1 to 4 2010-01-16 22:10 TRYING COULD BREAK STUFF testsplit3a;s right splitpane # added 2010-01-16 23:55 end comp.ext_row_offset += @ext_row_offset + @row $log.debug "SPLP exp_col #{@name} 2 #{comp}: #{comp.ext_col_offset} += #{@ext_col_offset} + #{@col} " comp.ext_col_offset += @ext_col_offset + @col #layout = { :height => @height-1, :width => @width-1, :top => comp.row, :left => comp.col } #comp.set_buffering(:target_window => @target_window || @form.window, :bottom => comp.height-1, #:right => comp.width-1, :form => @form ) $log.debug " setting c2 screen_top n left to #{@row} #{@col} " @second_component.set_buffering(:screen_top => @row, :screen_left => @col) @second_component.min_height ||= 5 # added 2010-01-16 12:37 @second_component.min_width ||= 5 # added 2010-01-16 12:37 end |
#set_divider_location(rc) ⇒ Object
set location of divider (row or col depending on orientation) internally sets the second components row or col also to set widths or heights Check minimum sizes are not disrespected + when pane size exceeds buffer size, so in these cases we increase size of component + and therefore buffer size. Needs to be tested for VERTICAL. If this returns :ERROR, caller may avoid repainting form needlessly. We may give more meaningful error retval in future. TODO
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 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 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 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 469 470 471 472 473 474 475 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 512 513 514 515 516 |
# File 'lib/rbcurse/rsplitpane.rb', line 307 def set_divider_location rc $log.debug " SPLP #{@name} setting divider to #{rc} " # add a check for out of bounds since no buffering v = 1 # earlier 2 if @orientation == :HORIZONTAL_SPLIT if rc < v || rc > @height - v return :ERROR end else if rc < v || rc > @width - v return :ERROR end end @repaint_required = true old_divider_location = @divider_location || 0 # we first check against min_sizes # the calculation is repeated here, and in the actual change # so if modifying, be sure to do in both places. if ! # if expanding then i can't check against min_width if rc > old_divider_location if @second_component != nil if @orientation == :VERTICAL_SPLIT # check second comps width if @width - (rc + @col_offset + @divider_offset+1) < @second_component.min_width $log.debug " #{@name} SORRY 2c min width prevents further resizing: #{@width} #{rc}" return :ERROR end else # check second comps ht $log.debug " YYYY SORRY 2c H:#{@height} rc: #{rc} 2cmh: #{@second_component.name} " if @height - rc -2 < @second_component.min_height $log.debug " #{@name} SORRY 2c min height prevents further resizing" return :ERROR end end end elsif rc < old_divider_location if @first_component != nil $log.debug " #{@name} fc min width #{rc}, #{@first_component.min_width} " if @orientation == :VERTICAL_SPLIT # check first comps width if rc-1 < @first_component.min_width $log.debug " SORRY fc min width prevents further resizing" return :ERROR end else if rc-1 < @first_component.min_height $log.debug " SORRY fc min height prevents further resizing" return :ERROR end end end end end # expanding = false @old_divider_location = @divider_location @divider_location = rc if @first_component != nil ## added in case not set. it will be set to a sensible default @first_component.height ||= 0 @first_component.width ||= 0 $log.debug " #{@name} set div location, setting first comp width #{rc}" if !@cascade_changes.nil? if @orientation == :VERTICAL_SPLIT $log.warn " SPLP height nil in #{@name} #{@first_component.name} " unless @height @height ||= 23 @first_component.width(rc-0) #+ @col_offset + @divider_offset @first_component.height(@height-0) #2+ @col_offset + @divider_offset else $log.warn " SPLP width nil in #{@name} #{@first_component.name} " unless @width @first_component.height(rc+0) #-1) #1+ @col_offset + @divider_offset @first_component.width(@width-0) #2+ @col_offset + @divider_offset end else if @orientation == :VERTICAL_SPLIT $log.debug " DOES IT COME HERE compare fc wt #{@first_component.width} to match #{rc}-1 " # added 2010-01-09 19:00 increase fc to avoid copywin crashing process if @first_component.width < rc -0 then $log.debug " INCRease fc wt #{@first_component.width} to match #{rc}-1 " @first_component.width(rc-0) #+ @col_offset + @divider_offset @first_component.repaint_all(true) if !@first_component.nil? @repaint_required = true end ## added this condition 2010-01-11 21:44 again switching needs this a = 0 #2 if @first_component.height < @height - a then $log.debug " INCRease fc ht #{@first_component.height} to match #{@height}- #{a} " @first_component.height(@height-a) #+ @col_offset + @divider_offset end else # added 2010-01-09 19:00 increase fc to avoid copywin crashing process a = 0 #1 if @first_component.height < rc -a then $log.debug " INCRease fc ht #{@first_component.height} to match #{rc}-1 " @first_component.height(rc-a) #+ @col_offset + @divider_offset @first_component.repaint_all(true) if !@first_component.nil? @repaint_required = true end # added 2010-01-11 19:24 to match c2. Sometimes switching from V to H means # fc's width needs to be expanded. if @first_component.width < @width - 1 #+ @col_offset + @divider_offset $log.debug " INCRease fc wi #{@first_component.width} to match #{@width}-2 " @first_component.width = @width - 1 #+ @col_offset + @divider_offset @first_component.repaint_all(true) @repaint_required = true end end end $log.debug " #{@name} TA set C1 H W RC #{@first_component.height} #{@first_component.width} #{rc} " @first_component.set_buffering(:bottom => @first_component.height-1, :right => @first_component.width-1, :form => @form ) end if !@second_component.nil? ## added 2010-01-11 23:09 since some cases don't set, like splits within split. @second_component.height ||= 0 @second_component.width ||= 0 if @orientation == :VERTICAL_SPLIT #@second_component.col = rc + @col_offset + @divider_offset #@second_component.row = 0 # 1 @second_component.col = @col + rc #+ @col_offset + @divider_offset @second_component.row = @row # 1 if !@cascade_changes.nil? #@second_component.width = @width - (rc + @col_offset + @divider_offset + 1) #@second_component.height = @height-2 #+ @row_offset + @divider_offset @second_component.width = @width - rc #+ @col_offset + @divider_offset + 1) @second_component.height = @height #+ @row_offset + @divider_offset else # added 2010-01-09 22:49 to be tested XXX # In a vertical split, if widgets w and thus buffer w is less than #+ pane, a copywin can crash process, so we must expand component, and thus buffer $log.debug " #{@name} 2c width does it come here? #{@second_component.name} #{@second_component.width} < #{@width} -( #{rc}+#{@col_offset}+#{@divider_offset} +1 " if @second_component.width < @width - rc #+ @col_offset + @divider_offset + 1) $log.debug " YES 2c width " @second_component.width = @width - rc #+ @col_offset + @divider_offset + 1) @second_component.repaint_all(true) @repaint_required = true end # adding 2010-01-17 19:33 since when changing to VERT, it was not expanding if @second_component.height < @height-0 #+ @row_offset + @divider_offset $log.debug " JUST ADDED 2010-01-17 19:35 HOPE DOES NOT BREAK ANYTHING " @second_component.height = @height-0 #+ @row_offset + @divider_offset end end else #rc += @row ## HORIZ SPLIT offrow = offcol = 0 #@second_component.row = offrow + rc + 0 #1 #@row_offset + @divider_offset #@second_component.col = 0 + offcol # was 1 offrow = @row; offcol = @col @second_component.row = offrow + rc + 0 #1 #@row_offset + @divider_offset $log.debug "C2 Horiz row #{@second_component.row} = #{offrow} + #{rc} " @second_component.col = 0 + offcol # was 1 if !@cascade_changes.nil? #@second_component.width = @width - 2 #+ @col_offset + @divider_offset #@second_component.height = @height - rc -2 #+ @row_offset + @divider_offset @second_component.width = @width - 0 #+ @col_offset + @divider_offset @second_component.height = @height - rc -0 #+ @row_offset + @divider_offset else # added 2010-01-16 19:14 -rc since its a HORIZ split # 2010-01-16 20:45 made 2 to 3 for scrollpanes within splits!!! hope it doesnt # break, and why 3. # 2010-01-17 13:33 reverted to 2. 3 was required since i was not returning when error in set_screen_max. if @second_component.height < @height-rc-1 #2 #+ @row_offset + @divider_offset $log.debug " #{@name} INCRease 2c #{@second_component.name} ht #{@second_component.height} to match #{@height}-2- #{rc} " @second_component.height = @height-rc-1 #2 #+ @row_offset + @divider_offset @second_component.repaint_all(true) @repaint_required = true end # # added 2010-01-10 15:36 still not expanding if @second_component.width < @width - 2 #+ @col_offset + @divider_offset $log.debug " #{@name} INCRease 2c #{@second_component.name} wi #{@second_component.width} to match #{@width}-2 " @second_component.width = @width - 2 #+ @col_offset + @divider_offset @second_component.repaint_all(true) @repaint_required = true end end end raise "2nd components height or preferred height is required (#{@second_component.name})" unless @second_component.height raise "2nd components width or preferred width is required(#{@second_component.name})" unless @second_component.width # i need to keep top and left sync for print_border which uses it UGH !!! if !@second_component.get_buffer().nil? # now that TV and others are creating a buffer in repaint we need another way to set #$log.debug " setting second comp row col offset - i think it doesn't come here till much later " #XXX @second_component.get_buffer().set_screen_row_col(@second_component.row+@ext_row_offset+@row, @second_component.col+@ext_col_offset+@col) # 2010-02-13 09:15 RFED16 @second_component.get_buffer().set_screen_row_col(@second_component.row, @second_component.col) end #@second_component.set_buffering(:screen_top => @row, :screen_left => @col) #@second_component.set_buffering(:screen_top => @row+@second_component.row, :screen_left => @col+@second_component.col) #@second_component.set_buffering(:screen_top => @row+@second_component.row, :screen_left => @col+@second_component.col) $log.debug "sdl: #{@name} setting C2 screen_top n left to #{@second_component.row}, #{@second_component.col} " @second_component.set_buffering(:screen_top => @second_component.row, :screen_left => @second_component.col) @second_component.set_buffering(:bottom => @second_component.height-1, :right => @second_component.width-1, :form => @form ) #@second_component.ext_row_offset = @row + @ext_row_offset #@second_component.ext_col_offset = @col + @ext_col_offset $log.debug " #{@name} 2 set div location, rc #{rc} width #{@width} height #{@height}" $log.debug " 2 set div location, setting r #{@second_component.row}, #{@ext_row_offset}, #{@row} " $log.debug " 2 set div location, setting c #{@second_component.col}, #{@ext_col_offset}, #{@col} " $log.debug " C2 set div location, setting w #{@second_component.width} " $log.debug " C2 set div location, setting h #{@second_component.height} " end fire_property_change("divider_location", old_divider_location, @divider_location) 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.
833 834 835 836 837 838 |
# File 'lib/rbcurse/rsplitpane.rb', line 833 def set_form_col if !@current_component.nil? $log.debug " #{@name} set_form_col calling sfc for #{@current_component.name} " @current_component.set_form_col end end |
#set_form_row ⇒ Object
used to set form to whatever was current last now we set to first so user can cycle through. User does not see it as a split within split, just as panes.
821 822 823 824 825 826 827 |
# File 'lib/rbcurse/rsplitpane.rb', line 821 def set_form_row if !@current_component.nil? $log.debug " #{@name} set_form_row calling sfr for #{@current_component.name} " @current_component.set_form_row @current_component.set_form_col end end |
#set_resize_weight(wt) ⇒ Object
calculate divider location based on weight Weight implies weight of first component, e.g. .70 for 70% of splitpane
521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
# File 'lib/rbcurse/rsplitpane.rb', line 521 def set_resize_weight wt raise ArgumentError if wt < 0 or wt >1 @repaint_required = true oldvalue = @resize_weight @resize_weight = wt if @orientation == :VERTICAL_SPLIT rc = (@width||@preferred_width) * wt else rc = (@height||@preferred_height) * wt end fire_property_change("resize_weight", oldvalue, @resize_weight) rc = rc.ceil set_divider_location rc end |
#update_first_component ⇒ Object
554 555 556 557 558 559 560 561 562 563 |
# File 'lib/rbcurse/rsplitpane.rb', line 554 def update_first_component $log.debug " #{@name} update+first dl: #{@divider_location} " return if @divider_location == 0 @first_component.row(@row) @first_component.col(@col) $log.debug "UCF #{@name} #{@first_component.row} #{@first_component.col} " comp = @first_component comp.set_buffering(:target_window => @target_window || @form.window, :bottom => comp.height-1, :right => comp.width-1, :form => @form ) @first_component.set_buffering(:screen_top => @first_component.row, :screen_left => @first_component.col) end |
#update_second_component ⇒ Object
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 |
# File 'lib/rbcurse/rsplitpane.rb', line 564 def update_second_component $log.debug " #{@name} update+secoond dl: #{@divider_location} " comp = @second_component return if @divider_location == 0 if @orientation == :HORIZONTAL_SPLIT @second_component.row(@row+@divider_location) @second_component.col(@col) else @second_component.row(@row) @second_component.col(@col+@divider_location) end $log.debug "UCS #{@name} #{@second_component.row} #{@second_component.col} " comp.set_buffering(:target_window => @target_window || @form.window, :bottom => comp.height-1, :right => comp.width-1, :form => @form ) @second_component.set_buffering(:screen_top => @second_component.row, :screen_left => @second_component.col) end |
#v? ⇒ Boolean
is vertical
649 650 651 |
# File 'lib/rbcurse/rsplitpane2.rb', line 649 def v? @orientation == :VERTICAL_SPLIT 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
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/rbcurse/rsplitpane.rb', line 252 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 if @first_component != nil old = @first_component.width #@first_component.width = @width - @col_offset + @divider_offset @first_component.width += delta $log.debug "width() #{@name} set fc width to #{@first_component.width}, old was #{old} " @first_component.set_buffering(:right => @first_component.width-1) end # added 2010-01-11 23:02 horiz 2c not displaying since width issue if @second_component != nil old = @second_component.width #@first_component.width = @width - @col_offset + @divider_offset @second_component.width += delta @second_component.set_buffering(:right => @second_component.width-1) $log.debug "width() #{@name} set 2c width to #{@second_component.width}, old was #{old} " end else rc = @divider_location # ## next change should only happen if sc w < ... # 2010-01-11 22:11 # if @second_component.width < @width - (rc + @col_offset + @divider_offset + 1) if @second_component != nil if @second_component.width < @width - (rc + @col_offset + @divider_offset + 1) old = @second_component.width #@second_component.width = @width - @col_offset + @divider_offset @second_component.width += delta @second_component.set_buffering(:right => @second_component.width-1) $log.debug "width() #{@name} set 2c width to #{@second_component.width} , old was #{old} " end end end end end |