# File tst/tst_locana.rb, line 484
def tst_scrollbar()
   # :position is the location of the scroller button as a percentage (0-99) of the total size

   # :value is the location of the scroller button in pixels

   # :client_size is the amount of pixels that are available.  It defaults to size of the parent's client area.

   # :total_size is the total number of pixels the scrollbar is covering.  It defaults to size of the parent's client area.

   Lwindow.new(:TestScrollBar, :text=>'Test Scrollbars', :width=>410, :height=>245) {
      sv = Lscrollbar.new(:sb_v, :otype=>:vertical, :total_size=>400, :position=>50)    # The :client_size will default to the height of the scrollbar (height of the window in this case), this is about 50% of the :total_height

      sh = Lscrollbar.new(:sb_h, :otype=>:horizontal, :total_size=>1600, :position=>50)  # The :client_size will default to the width of the scrollbar (width of the window in this case), this is about 25% of the :total_width

      b = button(:b1, :text=>'Ok', :allow_sizing=>true, :help=>'You can resize this button by clicking and dragging on any border')
      add(sh)
      add(sv)
      # Are want the scroll bar to work naturally in an unnatural condition.

      # We are mocking up a total width of 1600 and a total height of 400.

      # We have a client width of 400 (1/4 the total size), and a client height of 200 (1/2 the total size)

      # To get the scroll bars to move the buttons, we need adjust the position of the button based on:

      # * the x position of the button = the value in the scroller / 4 so the button is always visible because the client size is 1/4 the total horizontal size

      # * the y position of the button = the value in the scroller / 2 so the button is always visible because the client size is 1/2 the total vertical size

      # * we add 200 (1/2 the client size) to the x position so the button appears balanced in the window

      # * we add 100 (1/2 the client size) to the y position so the button appears balanced in the window

      balance_x = 0
      balance_y = 0
      self.on_open = proc {|levent| b.move(sh.value/4+balance_x, sv.value/2+balance_y)} # set the initial position of the button to match the scroll bars

      b.on_click = proc{|levent| close}
      self.on_resize = proc{|levent| b.move(sh.value/4+balance_x, sv.value/2+balance_y)}
      sh.on_scroll = proc{|levent| b.move(levent[:value]/4+balance_x, b.y)}
      sv.on_scroll = proc{|levent| b.move(b.x, levent[:value]/2+balance_y)}
      def sh.scroll_distance()
         return 8          # otherwise the button moves too slowly when clicking on a scroller button

      end
      def sv.scroll_distance()
         return 4          # otherwise the button moves too slowly when clicking on a scroller button

      end
   }
end