# File tst/tst_locana.rb, line 649
def tst_window()
   win = Lwindow.new(:TestWindow, :text=>'test window') { #, :font=>[:times,12], :bg=>:aliceblue, :fg=>:blue) {

      self.on_mouse_ldn = %{print "left mouse button was pressed\n"}
      #self.on_mouse_rdn= %q{print "right mouse button was pressed\n"}

      self.on_mouse_mdn = %{print "middle mouse button was pressed\n"}
      self.on_enter = %{print "activating #{name}\n"}
      self.on_exit  = %{print "deactivating #{name}\n"}
      self.on_resize= %{print "This window has been resized, new size: w:#{event[:new_w]}, h:#{event[:new_h]}\n"}
      self.on_move  = %{print "This window has moved to, new position: x:#{event[:x]}, y:#{event[:y]}\n"}
      self.on_close = %{Tst_MonitorEvents.close}
      self.on_load = %{load(Locana::find_valid_path('tst_locana.rb', 'tst')) if (!defined?Tst_MonitorEvents)}

      button(:b_testeditbox, :pos=>[ 20, 20], :text=>'Test editbox', :tab_order=>1, :help=>'This will open a window with an editbox')
      #b_testeditbox.on_click = "Locana.open(:TestEditBox, get_lstore_name)"

      b_testeditbox.on_click = 'Locana.open(:TestEditBox, get_lstore_name)'
      button(:b_testlistbox, :pos=>[140, 20], :text=>'Test listbox', :tab_order=>1, :help=>'This will open a window with some list boxes')
      b_testlistbox.on_click = "Locana.open(:TestListBox, get_lstore_name)"
      button(:b_testborders, :pos=>[ 20, 50], :text=>'Test borders', :tab_order=>1, :help=>'This will open a window with various combination of different objects and different borders so you can see how the borders look on each object')
      b_testborders.on_click = "Locana.open(:TestBorders, get_lstore_name)"
      button(:b_testcolor,   :pos=>[140, 50], :spanw=>:b_testlistbox, :text=>'Test color', :tab_order=>1, :help=>'This will open a window with many objects using color.  Some objects have a specific color while other object inheret their color form the parent object')
      b_testcolor.on_click = "Locana.open(:TestColor, get_lstore_name)"
      button(:b_testpacker,  :pos=>[260, 20], :spanw=>:b_testspanning, :text=>'Test packing', :tab_order=>1, :help=>'This will open a window showing some of the many ways you can pack objects into a window using the :sticky, :after, :above, :below, :before attributes.')
      b_testpacker.on_click = "Locana.open(:TestPacking, get_lstore_name)"
      button(:b_testspanning,:pos=>[260, 50], :text=>'Test spanning', :tab_order=>1, :help=>'This will open a window showing how to get the size of an object to match the size of another object by using the :spanw, :spanh, :startx, and :starty attributes')
      b_testspanning.on_click = "Locana.open(:TestSpanning, get_lstore_name)"

      line(:l1,  :pady=>5, :below=>:prev, :sticky=>:new, :startx=>0, :bwidth=>3, :fg=>:red)   # span the window's width

      line(:l2,  :pos=>[10, 92, 380, 0])

      label(:label1,      :pos=>[  3, 102], :text=>'Text1:')
      textbox(:t_text1,   :pos=>[ 50, 100, 200], :tab_order=>1, :max_size=>20, :value=>'starting value')
      label(:label2,      :pos=>[  3, 127], :text=>'Pass:', :allow_dragging=>true)
      #textbox(:t_password,  :pos=>[ 50, 125, 200], :tab_order=>2, :display_char=>'*', :allow_dragging=>true)

      password(:t_password,  :pos=>[ 50, 125, 200], :tab_order=>2, :allow_dragging=>true)
      label(:label111,    :pos=>[260, 127], :text=>'<-- drag this', :allow_dragging=>true)
      button(:b_tstfont,  :pos=>[280, 100], :text=>'Test fonts', :tab_order=>3)
      button(:b_open,     :pos=>[ 50, 160], :text=>'Open a Form', :tab_order=>3)
      button(:b_tstimage, :pos=>[220, 160], :text=>'Test Images', :tab_order=>3)
      label(:label21,     :pos=>[5, 190], :text=>'label opens message box')
      label(:label22,     :pos=>[200, 190], :text=>'label opens form')

      # the %q~proc{|~  stores the binding as a string so it can be edited with the GUI builder

      # see bind() in l_event.rb for more details


      t_text1.on_enter     = %~print "entering textbox 1\n"~
      t_text1.on_exit      = %~print "leaving textbox 1\n"~
      t_text1.on_before_update = %{print "textbox 1 before update, curr value: '#{event[:value]}'\n"}
      t_text1.on_after_update  = %{print "textbox 1 after update, new value: '#{event[:value]}'\n"}
      #t_text1.on_mouse_ldn  = "print 'lmb down\n'"

      #t_text1.on_mouse_lup  = "print 'lmb up\n'"

      #t_text1.on_mouse_move = "print 'mouse move\n'"

      t_text1.on_resize    = %{print "text1 has been resized, new size: w:#{event[:new_w]}, h:#{event[:new_h]}\n"}
      t_text1.on_move      = %{print "text1 has moved to, new position: x:#{event[:x]}, y:#{event[:y]}\n"}
      t_password.on_enter     = %{print "entering textbox 2\n"}
      t_password.on_exit      = %{print "leaving textbox 2\n"}
      t_password.on_before_update = %{print "textbox 2 before update, curr value: '#{event[:value]}'\n"}
      t_password.on_after_update  = %{print "textbox 2 after update, new value: '#{event[:value]}'\n"}
      t_password.on_key_press = %{print "key press in textbox 2: '#{event[:value]}'\n"}
      b_open.on_click      = %{Locana.open(:TestPopUpWindow, get_lstore_name)}
      b_tstimage.on_click  = %{Locana.open(:TestImages, get_lstore_name)}
      label21.on_click     = %{rc = Locana.msgbox('This message box was opened by clicking on the "label opens message box" label')
                                print "You clicked on the ", rc, "button\n"
                               }
      label22.on_click     = %~Locana.open(:TestPopUpWindow, get_lstore_name)~

      group(:g_TestCheckBox, :pos=>[60, 220], :text=>'Test Check Boxes', :tab_order=>5, :border=>:sunken, :ipadx=>2, :ipady=>2) {
         checkbox(:c_check1, :sticky=>:nw, :below=>:prev, :text=>'check1', :help=>'The tab_order is specified in check 2 which alters the normal tab order')
         checkbox(:c_check2, :sticky=>:nw, :below=>:prev, :text=>'check 2', :tab_order=>-1, :help=>'The tab_order is specified here to alter the normal tab order')
         checkbox(:c_check3, :sticky=>:nw, :below=>:prev, :text=>'check box 3', :help=>'The tab_order is specified in check 2 which alters the normal tab order')
         # This shows the different ways to bind Ruby code to events:

         c_check1.on_after_update = %{puts "check1, after update, new value: '#{event[:value]}'"}
         c_check1.on_change       = %{puts "check1, on_change, new value:#{event[:value]}"}
         c_check2.on_after_update = %{puts "check 2, after update, new value: '#{event[:value]}'"}
         c_check2.on_change       = %{puts "check 2, on_change, new value:#{event[:value]}"}
         c_check3.on_after_update = %{puts "check box3, after update, new value: '#{event[:value]}'"}
         c_check3.on_change       = %{puts "check 3, on_change, new value:#{event[:value]}"}
      }

      group(:g_TestRadioBox, :pos=>[220, 220], :text=>'Test Radio Boxes', :tab_order=>5, :border=>:ridge, :ipadx=>2, :ipady=>2) {
         radiobox(:r_radio1, :sticky=>:nw, :below=>:prev, :text=>'radio1', :help=>'The tab_order is specified in radio 2 which alters the normal tab order')
         radiobox(:r_radio2, :sticky=>:nw, :below=>:prev, :text=>'radio 2', :tab_order=>-1, :help=>'The tab_order is specified here to alter the normal tab order')
         radiobox(:r_radio3, :sticky=>:nw, :below=>:prev, :text=>'radio box 3', :help=>'The tab_order is specified in radio 2 which alters the normal tab order')
         r_radio1.on_after_update = %{puts "radio1, after update, new value: '#{event[:value]}'"}
         r_radio2.on_after_update = %{puts "radio 2, after update, new value: '#{event[:value]}'"}
         r_radio3.on_after_update = %{puts "radio box 3, after update, new value: '#{event[:value]}'"}
      }

      label(:label3,       :pos=>[20,  310], :text=>'date:', :help=>'Label for allowing you to enter a date')
      datebox(:d_date,     :sticky=>:nw, :after=>:prev, :padx=>5, :value=>Time.now, :tab_order=>5, :help=>'Allows you to enter a date')
      d_date.on_after_update = "puts 'You selected ', event[:value]"
      d_date.on_error = %{msgbox("We have trapped an error for the datebox object.\nError Type: #{event[:error].inspect}\nError Message: #{event[:error_message].inspect}\nCall Stack:\n#{event[:call_stack].join(\"\n\")}")}
      datebox(:d_time,     :sticky=>:nw, :otype=>:include_time, :below=>:prev, :padx=>5, :pady=>5, :value=>Time.now, :tab_order=>5, :help=>'Allows you to enter a date')
      d_time.on_after_update = "puts 'You selected ', event[:value]"

      label(:label43,      :pos=>[200,  310], :text=>'combo box:', :help=>'Label for a basic combobox')
      combobox(:c_combo1,  :sticky=>:nw, :after=>:prev, :padx=>5, :text=>['hello world', 'text string', 'test1', 'text2'], :tab_order=>5, :help=>'A basic combobox')
      c_combo1.on_before_update = "puts 'combobox on_before_update, current value: ' + event[:value].inspect"
      c_combo1.on_after_update = "puts 'combobox on_after_Update, new_value: ' + event[:value].inspect"

      label(:label44,      :sticky=>:nw, :below=>:d_time, :text=>'spinner:', :help=>'Label for a basic spinner')
      spinner(:s_spinner,  :sticky=>:nw, :width=>60, :after=>:prev, :padx=>5, :tab_order=>5, :help=>'A basic spinner')
      label(:label45,      :sticky=>:nw, :after=>:prev, :text=>'spinner2:', :help=>'Label for a spinner that provides a :text attributes')
      spinner(:s_spinner2,  :sticky=>:nw, :after=>:prev, :padx=>5, :text=>['value1', 'value2', 'value3', 'value4'], :tab_order=>5, :help=>'A spinner that provides a :text attributes')

      group(:g0, :sticky=>:ews, :pady=>5, :tab_order=>5) {
         button(:b_Tst_MonitorEvents,  :sticky=>:nw, :text=>'Monitor Events', :padx=>5, :help=>'This will open the event monitor window allowing you to see Locana events as they occur')
         checkbox(:c_show_mouse_moves, :sticky=>:n , :text=>'MouseMove?', :padx=>5, :help=>'Since mouse move events are frequent, they are disabled by default.  Click this on to see the mouse move events.  This only works when the events monitor window is open.')
         button(:b_close, :sticky=>:ne, :text=>'&Close', :tab_order=>5, :padx=>5, :help=>'Close this window')
      }

      b_tstfont.on_click = %{tst_fonts().open}  # This has to be outsize the win{} block to make tst_fonts() available to the proc object

      g0.b_Tst_MonitorEvents.on_click = %{Tst_MonitorEvents.open}    # FYI: bindings with proc objects are not saved

      g0.c_show_mouse_moves.on_change = %{Tst_MonitorEvents.show_mouse_moves = event[:value]}  # FYI: bindings with proc objects are not saved

      g0.b_close.on_click = 'close'
      g0.b_close.on_mouse_over = proc{|levent| puts 'close button on_mouse_over event'}  # this is lost when the object is saved

      g0.b_close.on_mouse_out = proc{|levent| puts 'close button on_mouse_out event'}    # this is lost when the object is saved

      tst_add_menus(self)
      if (__FILE__ == $0 && !defined?(LocanaServer))
         save
      end
  }
  return win
end