tkxxs 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
 - data/CONTRIBUTORS +2 -1
 - data/History.txt +10 -0
 - data/Manifest.txt +1 -1
 - data/{README.txt → README.rdoc} +36 -4
 - data/ext/tkballoonhelp.rb +332 -332
 - data/ext/tkballoonhelp_ORIGINAL.rb +208 -208
 - data/lib/tkxxs.rb +710 -708
 - data/lib/tkxxs/conf.rb +259 -259
 - data/lib/tkxxs/tkxxs_classes.rb +1567 -1571
 - data/lib/tkxxs/version.rb +1 -1
 - data/rdoc_developers_hanna.bat +14 -14
 - data/rdoc_users_hanna.bat +16 -16
 - data/samples/big_example.rb +521 -521
 - metadata +12 -13
 - data/.gemtest +0 -0
 
    
        data/lib/tkxxs/version.rb
    CHANGED
    
    
    
        data/rdoc_developers_hanna.bat
    CHANGED
    
    | 
         @@ -1,15 +1,15 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            @echo off
         
     | 
| 
       2 
     | 
    
         
            -
            cd
         
     | 
| 
       3 
     | 
    
         
            -
            :: Setting working dir to the dir of this .bat file:
         
     | 
| 
       4 
     | 
    
         
            -
            cd %0\..
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            if "%OS%"=="Windows_NT" ((cd /d %~dp0)&(goto next))
         
     | 
| 
       7 
     | 
    
         
            -
            echo %0 | find.exe ":" >nul
         
     | 
| 
       8 
     | 
    
         
            -
            if not errorlevel 1 %0\
         
     | 
| 
       9 
     | 
    
         
            -
            cd %0\..
         
     | 
| 
       10 
     | 
    
         
            -
            :next
         
     | 
| 
       11 
     | 
    
         
            -
            echo Working dir:
         
     | 
| 
       12 
     | 
    
         
            -
            cd
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            call pik sw 193
         
     | 
| 
      
 1 
     | 
    
         
            +
            @echo off
         
     | 
| 
      
 2 
     | 
    
         
            +
            cd
         
     | 
| 
      
 3 
     | 
    
         
            +
            :: Setting working dir to the dir of this .bat file:
         
     | 
| 
      
 4 
     | 
    
         
            +
            cd %0\..
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            if "%OS%"=="Windows_NT" ((cd /d %~dp0)&(goto next))
         
     | 
| 
      
 7 
     | 
    
         
            +
            echo %0 | find.exe ":" >nul
         
     | 
| 
      
 8 
     | 
    
         
            +
            if not errorlevel 1 %0\
         
     | 
| 
      
 9 
     | 
    
         
            +
            cd %0\..
         
     | 
| 
      
 10 
     | 
    
         
            +
            :next
         
     | 
| 
      
 11 
     | 
    
         
            +
            echo Working dir:
         
     | 
| 
      
 12 
     | 
    
         
            +
            cd
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            call pik sw 193
         
     | 
| 
       15 
15 
     | 
    
         
             
            rdoc.bat -t TKXXS --force-update -f hanna --op ./doc -x lib/tkxxs/samples --main ./README.rdoc ./README.rdoc ./lib
         
     | 
    
        data/rdoc_users_hanna.bat
    CHANGED
    
    | 
         @@ -1,16 +1,16 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            @echo off
         
     | 
| 
       2 
     | 
    
         
            -
            cd
         
     | 
| 
       3 
     | 
    
         
            -
            :: Setting working dir to the dir of this .bat file:
         
     | 
| 
       4 
     | 
    
         
            -
            cd %0\..
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            if "%OS%"=="Windows_NT" ((cd /d %~dp0)&(goto next))
         
     | 
| 
       7 
     | 
    
         
            -
            echo %0 | find.exe ":" >nul
         
     | 
| 
       8 
     | 
    
         
            -
            if not errorlevel 1 %0\
         
     | 
| 
       9 
     | 
    
         
            -
            cd %0\..
         
     | 
| 
       10 
     | 
    
         
            -
            :next
         
     | 
| 
       11 
     | 
    
         
            -
            echo Working dir:
         
     | 
| 
       12 
     | 
    
         
            -
            cd
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            call pik sw 193
         
     | 
| 
       15 
     | 
    
         
            -
            rdoc.bat -t TKXXS --force-update -f hanna --op ./doc  -x lib/tkxxs/tkxxs_classes.rb -x lib/tkxxs/samples --main ./README. 
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            @echo off
         
     | 
| 
      
 2 
     | 
    
         
            +
            cd
         
     | 
| 
      
 3 
     | 
    
         
            +
            :: Setting working dir to the dir of this .bat file:
         
     | 
| 
      
 4 
     | 
    
         
            +
            cd %0\..
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            if "%OS%"=="Windows_NT" ((cd /d %~dp0)&(goto next))
         
     | 
| 
      
 7 
     | 
    
         
            +
            echo %0 | find.exe ":" >nul
         
     | 
| 
      
 8 
     | 
    
         
            +
            if not errorlevel 1 %0\
         
     | 
| 
      
 9 
     | 
    
         
            +
            cd %0\..
         
     | 
| 
      
 10 
     | 
    
         
            +
            :next
         
     | 
| 
      
 11 
     | 
    
         
            +
            echo Working dir:
         
     | 
| 
      
 12 
     | 
    
         
            +
            cd
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            call pik sw 193
         
     | 
| 
      
 15 
     | 
    
         
            +
            rdoc.bat -t TKXXS --force-update -f hanna --op ./doc  -x lib/tkxxs/tkxxs_classes.rb -x lib/tkxxs/samples --main ./README.rdoc ./README.rdoc ./lib/tkxxs.rb
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
    
        data/samples/big_example.rb
    CHANGED
    
    | 
         @@ -1,521 +1,521 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # encoding: Windows-1252 :encoding=Windows-1252: 
         
     | 
| 
       2 
     | 
    
         
            -
            begin
         
     | 
| 
       3 
     | 
    
         
            -
              require 'tkxxs'
         
     | 
| 
       4 
     | 
    
         
            -
            rescue LoadError
         
     | 
| 
       5 
     | 
    
         
            -
              require( File.dirname( File.dirname(__FILE__)) +'/lib/tkxxs')
         
     | 
| 
       6 
     | 
    
         
            -
            end
         
     | 
| 
       7 
     | 
    
         
            -
            include TKXXS
         
     | 
| 
       8 
     | 
    
         
            -
            $VERBOSE = false
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
            ##################################################################
         
     | 
| 
       11 
     | 
    
         
            -
            ##################################################################
         
     | 
| 
       12 
     | 
    
         
            -
            # Example for TKXXS
         
     | 
| 
       13 
     | 
    
         
            -
            # 
         
     | 
| 
       14 
     | 
    
         
            -
            # Tested on Windows with Ruby 1.9.3-installer.
         
     | 
| 
       15 
     | 
    
         
            -
            class MyTinyUI
         
     | 
| 
       16 
     | 
    
         
            -
              
         
     | 
| 
       17 
     | 
    
         
            -
              def initialize(  )
         
     | 
| 
       18 
     | 
    
         
            -
                #< # #  CREATE OUTPUT WINDOW  # # # 
         
     | 
| 
       19 
     | 
    
         
            -
                @outW = OutW.new
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                #< # # REDIRECT "puts" to Output Window
         
     | 
| 
       22 
     | 
    
         
            -
                # Hence, you can simply write "puts" instead of "@outW.puts" 
         
     | 
| 
       23 
     | 
    
         
            -
                $stdout = @outW # BUT: Doesn't work with OCRA!!
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                @outW.puts "Ruby#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
         
     | 
| 
       26 
     | 
    
         
            -
                
         
     | 
| 
       27 
     | 
    
         
            -
                run
         
     | 
| 
       28 
     | 
    
         
            -
              end # initialize
         
     | 
| 
       29 
     | 
    
         
            -
              
         
     | 
| 
       30 
     | 
    
         
            -
              
         
     | 
| 
       31 
     | 
    
         
            -
              def explain_puts(  )
         
     | 
| 
       32 
     | 
    
         
            -
                @outW.puts "'puts' writes to the Output Window."
         
     | 
| 
       33 
     | 
    
         
            -
                
         
     | 
| 
       34 
     | 
    
         
            -
                @outW.puts_h2 "@outW.puts_h2 writes formated text to the Output Window"
         
     | 
| 
       35 
     | 
    
         
            -
                
         
     | 
| 
       36 
     | 
    
         
            -
                @outW.puts "Other formatings can be implemented."
         
     | 
| 
       37 
     | 
    
         
            -
                puts
         
     | 
| 
       38 
     | 
    
         
            -
              end # explain_puts
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
              def explain_window_size(  )
         
     | 
| 
       41 
     | 
    
         
            -
                @outW.puts_h2 "WINDOW SIZE"
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                @outW.puts <<-HERE.margin
         
     | 
| 
       44 
     | 
    
         
            -
                  # When using this little app the first time, you should resize
         
     | 
| 
       45 
     | 
    
         
            -
                  # and position all popup windows to your desire. This will be
         
     | 
| 
       46 
     | 
    
         
            -
                  # saved for the next start of this app.
         
     | 
| 
       47 
     | 
    
         
            -
                HERE
         
     | 
| 
       48 
     | 
    
         
            -
                
         
     | 
| 
       49 
     | 
    
         
            -
              end # explain_window_size
         
     | 
| 
       50 
     | 
    
         
            -
              
         
     | 
| 
       51 
     | 
    
         
            -
              def explain_ask_single_line(  )
         
     | 
| 
       52 
     | 
    
         
            -
                @outW.puts_h2 "ask_single_line( question, help, :defaultEntry=>DefaultAnswer )"
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                help = "This dialog is named 'ask_single_line'"
         
     | 
| 
       55 
     | 
    
         
            -
                ans = ask_single_line(
         
     | 
| 
       56 
     | 
    
         
            -
                  "Want to know more?\nPoint the mouse at the entry field!",
         
     | 
| 
       57 
     | 
    
         
            -
                  help,
         
     | 
| 
       58 
     | 
    
         
            -
                  :defaultEntry =>"Of course"
         
     | 
| 
       59 
     | 
    
         
            -
                )
         
     | 
| 
       60 
     | 
    
         
            -
                
         
     | 
| 
       61 
     | 
    
         
            -
                puts
         
     | 
| 
       62 
     | 
    
         
            -
                @outW.puts help
         
     | 
| 
       63 
     | 
    
         
            -
                @outW.puts 
         
     | 
| 
       64 
     | 
    
         
            -
                print "The answer from 'ask_single_line' was: "
         
     | 
| 
       65 
     | 
    
         
            -
                @outW.puts ans.inspect
         
     | 
| 
       66 
     | 
    
         
            -
                puts
         
     | 
| 
       67 
     | 
    
         
            -
                @outW.puts "'Cancel' returns nil."
         
     | 
| 
       68 
     | 
    
         
            -
                puts
         
     | 
| 
       69 
     | 
    
         
            -
                puts
         
     | 
| 
       70 
     | 
    
         
            -
              end # explain_ask_single_line
         
     | 
| 
       71 
     | 
    
         
            -
              
         
     | 
| 
       72 
     | 
    
         
            -
              def explain_single_choice(  )
         
     | 
| 
       73 
     | 
    
         
            -
                @outW.puts_h2 "single_choice( aryWithChoices, help=nil, hash=nil )"
         
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
                help0 = <<-HERE.margin
         
     | 
| 
       76 
     | 
    
         
            -
                  # single_choice( aryWithChoices, help=nil, hash=nil )
         
     | 
| 
       77 
     | 
    
         
            -
                  # 
         
     | 
| 
       78 
     | 
    
         
            -
                  # *Params*:
         
     | 
| 
       79 
     | 
    
         
            -
                  # * +aryWithChoices+ - (Array) one of the following formats:
         
     | 
| 
       80 
     | 
    
         
            -
                  #   * [ choiceStrA, choiceStrB, ...]
         
     | 
| 
       81 
     | 
    
         
            -
                  #   * [ [choiceStrA,objectA], [choiceStrB,objectB], ...  ]
         
     | 
| 
       82 
     | 
    
         
            -
                  #   * [ [choiceStrA,objectA,helpStrA], [choiceStrB,objectB,helpStrB], ...]
         
     | 
| 
       83 
     | 
    
         
            -
                  #   Quite usefull: a Proc for object.
         
     | 
| 
       84 
     | 
    
         
            -
                  # * +help+ - (String, optional) Array, with one help-String for each choice element!;  +nil+ => No help text 
         
     | 
| 
       85 
     | 
    
         
            -
                  # * +hash+ - (Hash, optional) 
         
     | 
| 
       86 
     | 
    
         
            -
                  #   * <tt>:question</tt> - Like above.
         
     | 
| 
       87 
     | 
    
         
            -
                  #   * <tt>:help</tt> - Like above. 
         
     | 
| 
       88 
     | 
    
         
            -
                  #   * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
         
     | 
| 
       89 
     | 
    
         
            -
                  #     important. Sets the section in the config-file, where for example the
         
     | 
| 
       90 
     | 
    
         
            -
                  #     window size and position is stored.
         
     | 
| 
       91 
     | 
    
         
            -
                  #   * <tt>:title</tt> - (String) Title of the dialog window
         
     | 
| 
       92 
     | 
    
         
            -
                  #   * <tt>:bd</tt> - (Number as String) ?
         
     | 
| 
       93 
     | 
    
         
            -
                  #   * <tt>:searchFieldHelp</tt> - (String) Ballon help of the search field,
         
     | 
| 
       94 
     | 
    
         
            -
                  #   * <tt>:returnChoiceAndClient</tt> - returns the right side (+false+) or both sides (+true+) of +aryWithChoices+.
         
     | 
| 
       95 
     | 
    
         
            -
                  # 
         
     | 
| 
       96 
     | 
    
         
            -
                  # *Returns:* 
         
     | 
| 
       97 
     | 
    
         
            -
                  # * The right side of +aryWithChoices+ if :returnChoiceAndClient == +false+ (default),
         
     | 
| 
       98 
     | 
    
         
            -
                  # * both sides of +aryWithChoices+ if :returnChoiceAndClient == +true+,
         
     | 
| 
       99 
     | 
    
         
            -
                  # * +nil+, if 'Cancel' was clicked.
         
     | 
| 
       100 
     | 
    
         
            -
                HERE
         
     | 
| 
       101 
     | 
    
         
            -
                
         
     | 
| 
       102 
     | 
    
         
            -
                
         
     | 
| 
       103 
     | 
    
         
            -
                help = ['#1: ' + help0, '#2: ' + help0, '#3: ' + help0]
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
                ans = single_choice(
         
     | 
| 
       106 
     | 
    
         
            -
                  [
         
     | 
| 
       107 
     | 
    
         
            -
                    [ "You want 1?", 1],
         
     | 
| 
       108 
     | 
    
         
            -
                    [ "You want 2?", 2],
         
     | 
| 
       109 
     | 
    
         
            -
                    [ "You want 3?", 3],
         
     | 
| 
       110 
     | 
    
         
            -
                  ],
         
     | 
| 
       111 
     | 
    
         
            -
                  help
         
     | 
| 
       112 
     | 
    
         
            -
                )
         
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
                @outW.puts "single_choice returned: #{ ans.inspect }"
         
     | 
| 
       115 
     | 
    
         
            -
                puts
         
     | 
| 
       116 
     | 
    
         
            -
                @outW.puts help0
         
     | 
| 
       117 
     | 
    
         
            -
              end # explain_single_choice
         
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
              def explain_multi_choice(  )
         
     | 
| 
       120 
     | 
    
         
            -
                @outW.puts_h2 "multi_choice(aryWithChoices, help=nil, hash=nil)"
         
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
                help0 = <<-HERE.margin
         
     | 
| 
       123 
     | 
    
         
            -
              # multi_choice( aryWithChoices, help=nil, hash=nil )
         
     | 
| 
       124 
     | 
    
         
            -
              # 
         
     | 
| 
       125 
     | 
    
         
            -
              # *Params*:
         
     | 
| 
       126 
     | 
    
         
            -
              # * +aryWithChoices+ - (Array) one of the following formats:
         
     | 
| 
       127 
     | 
    
         
            -
              #   * [ choiceStrA, choiceStrB, ...]
         
     | 
| 
       128 
     | 
    
         
            -
              #   * [ [choiceStrA,objectA], [choiceStrB,objectB], ...  ]
         
     | 
| 
       129 
     | 
    
         
            -
              #   * [ [choiceStrA,objectA,helpStrA], [choiceStrB,objectB,helpStrB], ...]
         
     | 
| 
       130 
     | 
    
         
            -
              #   Quite usefull: a Proc for object.
         
     | 
| 
       131 
     | 
    
         
            -
              # * +help+ - (String, optional) Array, with one help-String for each choice element!;  +nil+ => No help text 
         
     | 
| 
       132 
     | 
    
         
            -
              # * +hash+ - (Hash, optional) 
         
     | 
| 
       133 
     | 
    
         
            -
              #   * <tt>:question</tt> - Like above.
         
     | 
| 
       134 
     | 
    
         
            -
              #   * <tt>:help</tt> - Like above. 
         
     | 
| 
       135 
     | 
    
         
            -
              #   * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
         
     | 
| 
       136 
     | 
    
         
            -
              #     important. Sets the section in the config-file, where for example the
         
     | 
| 
       137 
     | 
    
         
            -
              #     window size and position is stored.
         
     | 
| 
       138 
     | 
    
         
            -
              #   * <tt>:title</tt> - (String) Title of the dialog window
         
     | 
| 
       139 
     | 
    
         
            -
              #   * <tt>:bd</tt> - (Number as String) ?
         
     | 
| 
       140 
     | 
    
         
            -
              #   * <tt>:selectmode => :multiple</tt> - Obsolet?
         
     | 
| 
       141 
     | 
    
         
            -
              #   * <tt>:searchFieldHelp</tt> - (String) Ballon help of the search field, searchField not implemented yet
         
     | 
| 
       142 
     | 
    
         
            -
              #   * <tt>:returnChoiceAndClient</tt> - returns the right side (+false+) or both sides (+true+) of +aryWithChoices+.
         
     | 
| 
       143 
     | 
    
         
            -
              # 
         
     | 
| 
       144 
     | 
    
         
            -
              # *Returns:* 
         
     | 
| 
       145 
     | 
    
         
            -
              # * An Array of the chosen right sides of +aryWithChoices+ if :returnChoiceAndClient == +false+ (default),
         
     | 
| 
       146 
     | 
    
         
            -
              # * An Array of the chosen right and left sides of +aryWithChoices+ if :returnChoiceAndClient == +true+,
         
     | 
| 
       147 
     | 
    
         
            -
              # * +nil+, if 'Cancel' was clicked.
         
     | 
| 
       148 
     | 
    
         
            -
              # 
         
     | 
| 
       149 
     | 
    
         
            -
              # *Example:*   
         
     | 
| 
       150 
     | 
    
         
            -
              #    help = ['Help #1', 'Help #2', 'Help #3']
         
     | 
| 
       151 
     | 
    
         
            -
              #    ans = single_choice(
         
     | 
| 
       152 
     | 
    
         
            -
              #      [
         
     | 
| 
       153 
     | 
    
         
            -
              #        [ "You want 1?", 1],
         
     | 
| 
       154 
     | 
    
         
            -
              #        [ "You want 2?", 2],
         
     | 
| 
       155 
     | 
    
         
            -
              #        [ "You want 3?", 3],
         
     | 
| 
       156 
     | 
    
         
            -
              #      ],
         
     | 
| 
       157 
     | 
    
         
            -
              #      help
         
     | 
| 
       158 
     | 
    
         
            -
              #    )
         
     | 
| 
       159 
     | 
    
         
            -
                HERE
         
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
                help = [help0, help0, help0]
         
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
                ans = multi_choice(
         
     | 
| 
       164 
     | 
    
         
            -
                  [
         
     | 
| 
       165 
     | 
    
         
            -
                    [ "You want 1?", 1],
         
     | 
| 
       166 
     | 
    
         
            -
                    [ "You want 2?", 2],
         
     | 
| 
       167 
     | 
    
         
            -
                    [ "You want 3?", 3],
         
     | 
| 
       168 
     | 
    
         
            -
                  ],
         
     | 
| 
       169 
     | 
    
         
            -
                  help
         
     | 
| 
       170 
     | 
    
         
            -
                )
         
     | 
| 
       171 
     | 
    
         
            -
             
     | 
| 
       172 
     | 
    
         
            -
                @outW.puts "multi_choice returned: #{ ans.inspect }"
         
     | 
| 
       173 
     | 
    
         
            -
                puts
         
     | 
| 
       174 
     | 
    
         
            -
                @outW.puts help0
         
     | 
| 
       175 
     | 
    
         
            -
              end # explain_multi_choice
         
     | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
       177 
     | 
    
         
            -
              def explain_choose_dir(  )
         
     | 
| 
       178 
     | 
    
         
            -
                @outW.puts_h2 "choose_dir( initialdir=nil,help=nil,hash=nil)"
         
     | 
| 
       179 
     | 
    
         
            -
             
     | 
| 
       180 
     | 
    
         
            -
                help = <<-HERE.margin
         
     | 
| 
       181 
     | 
    
         
            -
                  # choose_dir( initialdir=nil,help=nil,hash=nil )
         
     | 
| 
       182 
     | 
    
         
            -
                  # 
         
     | 
| 
       183 
     | 
    
         
            -
                  # To get this dialog explain, run the example and point the mouse
         
     | 
| 
       184 
     | 
    
         
            -
                  # at each button.
         
     | 
| 
       185 
     | 
    
         
            -
                  #
         
     | 
| 
       186 
     | 
    
         
            -
                  # *Params*:
         
     | 
| 
       187 
     | 
    
         
            -
                  # * +initialdir+ - (String, optional) Initial dir; default = +nil+
         
     | 
| 
       188 
     | 
    
         
            -
                  #   -> Working dir at the time of calling this method.
         
     | 
| 
       189 
     | 
    
         
            -
                  # * +help+ - (String, optional) ; Text used in the BalloonHelp;
         
     | 
| 
       190 
     | 
    
         
            -
                  #   default = +nil+ -> No help.
         
     | 
| 
       191 
     | 
    
         
            -
                  # * +hash+ - (Hash, optional) 
         
     | 
| 
       192 
     | 
    
         
            -
                  #   * <tt>:initialdir</tt> - Like above. 
         
     | 
| 
       193 
     | 
    
         
            -
                  #   * <tt>:help</tt> - Like above. 
         
     | 
| 
       194 
     | 
    
         
            -
                  #   * <tt>:mode</tt> - Don't modify this!
         
     | 
| 
       195 
     | 
    
         
            -
                  #   * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
         
     | 
| 
       196 
     | 
    
         
            -
                  #   * <tt>:title</tt> - (String) Title of the dialog window.
         
     | 
| 
       197 
     | 
    
         
            -
                  #   * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field. 
         
     | 
| 
       198 
     | 
    
         
            -
                  #   * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
         
     | 
| 
       199 
     | 
    
         
            -
                  #     must be chosen, canceling the dialog is not possible.
         
     | 
| 
       200 
     | 
    
         
            -
                  #   * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
         
     | 
| 
       201 
     | 
    
         
            -
                  #     important. Sets the section in the config-file, where for example the
         
     | 
| 
       202 
     | 
    
         
            -
                  #     window size and position is stored.
         
     | 
| 
       203 
     | 
    
         
            -
                  # 
         
     | 
| 
       204 
     | 
    
         
            -
                  # *Returns:* (String) Path of the chosen dir;  +nil+, if 'Cancel' was clicked.
         
     | 
| 
       205 
     | 
    
         
            -
                  # 
         
     | 
| 
       206 
     | 
    
         
            -
                  # *Example:*   
         
     | 
| 
       207 
     | 
    
         
            -
                  # 
         
     | 
| 
       208 
     | 
    
         
            -
                  #   help = "Pick a dir."
         
     | 
| 
       209 
     | 
    
         
            -
                  #   ans = choose_dir( 
         
     | 
| 
       210 
     | 
    
         
            -
                  #     'c:\WinDows', 
         
     | 
| 
       211 
     | 
    
         
            -
                  #     help, 
         
     | 
| 
       212 
     | 
    
         
            -
                  #     :validate=>true, 
         
     | 
| 
       213 
     | 
    
         
            -
                  #     :defaultEntry=>'c:/windows/system' 
         
     | 
| 
       214 
     | 
    
         
            -
                  #   )
         
     | 
| 
       215 
     | 
    
         
            -
                  # 
         
     | 
| 
       216 
     | 
    
         
            -
                  # TODO: How to choose multiple dirs or even dirs & files?
         
     | 
| 
       217 
     | 
    
         
            -
                HERE
         
     | 
| 
       218 
     | 
    
         
            -
             
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
       220 
     | 
    
         
            -
                ans = choose_dir( 
         
     | 
| 
       221 
     | 
    
         
            -
                  'c:\WinDows', 
         
     | 
| 
       222 
     | 
    
         
            -
                  help, 
         
     | 
| 
       223 
     | 
    
         
            -
                  :validate=>true, 
         
     | 
| 
       224 
     | 
    
         
            -
                  :defaultEntry=>'c:/windows/system' 
         
     | 
| 
       225 
     | 
    
         
            -
                )
         
     | 
| 
       226 
     | 
    
         
            -
             
     | 
| 
       227 
     | 
    
         
            -
                @outW.puts "choose_dir returned: #{ ans.inspect }"
         
     | 
| 
       228 
     | 
    
         
            -
                puts
         
     | 
| 
       229 
     | 
    
         
            -
                @outW.puts help
         
     | 
| 
       230 
     | 
    
         
            -
              end # explain_choose_dir
         
     | 
| 
       231 
     | 
    
         
            -
              
         
     | 
| 
       232 
     | 
    
         
            -
              def explain_open_files(  )
         
     | 
| 
       233 
     | 
    
         
            -
                @outW.puts_h2 "open_files(initialdir=nil,help=nil,hash=nil)"
         
     | 
| 
       234 
     | 
    
         
            -
             
     | 
| 
       235 
     | 
    
         
            -
                help = <<-HERE.margin
         
     | 
| 
       236 
     | 
    
         
            -
                  # open_files( initialdir=nil,help=nil,hash=nil )
         
     | 
| 
       237 
     | 
    
         
            -
                  # 
         
     | 
| 
       238 
     | 
    
         
            -
                  # To get this dialog explain, run the example and point the mouse
         
     | 
| 
       239 
     | 
    
         
            -
                  # at each button.
         
     | 
| 
       240 
     | 
    
         
            -
                  #
         
     | 
| 
       241 
     | 
    
         
            -
                  # *Params*:
         
     | 
| 
       242 
     | 
    
         
            -
                  # * +initialdir+ - (String, optional) Initial dir; default = +nil+
         
     | 
| 
       243 
     | 
    
         
            -
                  #   -> Working dir at the time of calling this method.
         
     | 
| 
       244 
     | 
    
         
            -
                  # * +help+ - (String, optional) ; Text used in the BalloonHelp;
         
     | 
| 
       245 
     | 
    
         
            -
                  #   default = +nil+ -> No help.
         
     | 
| 
       246 
     | 
    
         
            -
                  # * +hash+ - (Hash, optional) 
         
     | 
| 
       247 
     | 
    
         
            -
                  #   * <tt>:initialdir</tt> - Like above. 
         
     | 
| 
       248 
     | 
    
         
            -
                  #   * <tt>:help</tt> - Like above. 
         
     | 
| 
       249 
     | 
    
         
            -
                  #   * <tt>:mode</tt> - Don't change this!
         
     | 
| 
       250 
     | 
    
         
            -
                  #   * <tt>:multiple</tt> - Don't change this!
         
     | 
| 
       251 
     | 
    
         
            -
                  #   * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
         
     | 
| 
       252 
     | 
    
         
            -
                  #   * <tt>:title</tt> - (String) Title of the dialog window.
         
     | 
| 
       253 
     | 
    
         
            -
                  #   * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field. 
         
     | 
| 
       254 
     | 
    
         
            -
                  #   * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
         
     | 
| 
       255 
     | 
    
         
            -
                  #     must be chosen, canceling the dialog is not possible.
         
     | 
| 
       256 
     | 
    
         
            -
                  #   * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
         
     | 
| 
       257 
     | 
    
         
            -
                  #     important. Sets the section in the config-file, where for example the
         
     | 
| 
       258 
     | 
    
         
            -
                  #     window size and position is stored.
         
     | 
| 
       259 
     | 
    
         
            -
                  #   * <tt>:filetypes</tt> - (Array of Arrays) Filter for the file types
         
     | 
| 
       260 
     | 
    
         
            -
                  #     Format of the (inner) Arrays: 
         
     | 
| 
       261 
     | 
    
         
            -
                  #     * First element: (String) Name of the file type, e.g. 'Ruby files'
         
     | 
| 
       262 
     | 
    
         
            -
                  #     * Second element: (Array) List of extensions for the file type, e.g. ['.rb','.rbw']
         
     | 
| 
       263 
     | 
    
         
            -
                  #     * Third element: (String, optional) Mac file type(s), e.g. 'TEXT'
         
     | 
| 
       264 
     | 
    
         
            -
                  #     * Example:
         
     | 
| 
       265 
     | 
    
         
            -
                  #         filetypes = [
         
     | 
| 
       266 
     | 
    
         
            -
                  #           ['Text files',       ['.txt','.doc']          ],
         
     | 
| 
       267 
     | 
    
         
            -
                  #           ['Text files',       [],                      'TEXT' ],
         
     | 
| 
       268 
     | 
    
         
            -
                  #           ['Ruby Scripts',     ['.rb'],                 'TEXT' ],
         
     | 
| 
       269 
     | 
    
         
            -
                  #           ['Tcl Scripts',      ['.tcl'],                'TEXT' ],
         
     | 
| 
       270 
     | 
    
         
            -
                  #           ['C Source Files',   ['.c','.h']              ],
         
     | 
| 
       271 
     | 
    
         
            -
                  #           ['All Source Files', ['.rb','.tcl','.c','.h'] ],
         
     | 
| 
       272 
     | 
    
         
            -
                  #           ['Image Files',      ['.gif']                 ],
         
     | 
| 
       273 
     | 
    
         
            -
                  #           ['Image Files',      ['.jpeg','.jpg']         ],
         
     | 
| 
       274 
     | 
    
         
            -
                  #           ['Image Files',      [],                      ['GIFF','JPEG']],
         
     | 
| 
       275 
     | 
    
         
            -
                  #           ['All files',        '*'                      ]
         
     | 
| 
       276 
     | 
    
         
            -
                  #         ]
         
     | 
| 
       277 
     | 
    
         
            -
                  # *Returns:* (Array) Paths of the chosen files;  +nil+, if 'Cancel' was clicked.
         
     | 
| 
       278 
     | 
    
         
            -
                  # 
         
     | 
| 
       279 
     | 
    
         
            -
                  # *Example:*   
         
     | 
| 
       280 
     | 
    
         
            -
                  # 
         
     | 
| 
       281 
     | 
    
         
            -
                  #    filetypes = [
         
     | 
| 
       282 
     | 
    
         
            -
                  #        ['Log Files', ['.log']],
         
     | 
| 
       283 
     | 
    
         
            -
                  #        ['All Files', '*']
         
     | 
| 
       284 
     | 
    
         
            -
                  #      ]
         
     | 
| 
       285 
     | 
    
         
            -
                  #   
         
     | 
| 
       286 
     | 
    
         
            -
                  #    ans = open_files('c:\Windows', :filetypes=>filetypes)
         
     | 
| 
       287 
     | 
    
         
            -
                  # 
         
     | 
| 
       288 
     | 
    
         
            -
                  # TODO: When using "Recent"-Button > "Files" or "Favorite"-Button >
         
     | 
| 
       289 
     | 
    
         
            -
                  # "Files" you can choose only one from Recent and none from, for
         
     | 
| 
       290 
     | 
    
         
            -
                  # example "Browse"; should be multiple.
         
     | 
| 
       291 
     | 
    
         
            -
                HERE
         
     | 
| 
       292 
     | 
    
         
            -
             
     | 
| 
       293 
     | 
    
         
            -
                filetypes = [
         
     | 
| 
       294 
     | 
    
         
            -
                    ['Text Files', ['.txt']],
         
     | 
| 
       295 
     | 
    
         
            -
                    ['All Files', '*']
         
     | 
| 
       296 
     | 
    
         
            -
                  ]
         
     | 
| 
       297 
     | 
    
         
            -
             
     | 
| 
       298 
     | 
    
         
            -
                ans = open_files('c:\Windows', help, :filetypes=>filetypes)
         
     | 
| 
       299 
     | 
    
         
            -
             
     | 
| 
       300 
     | 
    
         
            -
                @outW.puts "open_files returned: #{ ans.inspect }"
         
     | 
| 
       301 
     | 
    
         
            -
                puts
         
     | 
| 
       302 
     | 
    
         
            -
                @outW.puts help
         
     | 
| 
       303 
     | 
    
         
            -
              end # explain_open_files
         
     | 
| 
       304 
     | 
    
         
            -
              
         
     | 
| 
       305 
     | 
    
         
            -
              def explain_open_file(  )
         
     | 
| 
       306 
     | 
    
         
            -
                @outW.puts_h2 "open_file(initialdir=nil,help=nil,hash=nil)"
         
     | 
| 
       307 
     | 
    
         
            -
             
     | 
| 
       308 
     | 
    
         
            -
                help = <<-HERE.margin
         
     | 
| 
       309 
     | 
    
         
            -
                  # open_file( initialdir=nil,help=nil,hash=nil )
         
     | 
| 
       310 
     | 
    
         
            -
                  # 
         
     | 
| 
       311 
     | 
    
         
            -
                  # To get this dialog explain, run the example and point the mouse
         
     | 
| 
       312 
     | 
    
         
            -
                  # at each button.
         
     | 
| 
       313 
     | 
    
         
            -
                  #
         
     | 
| 
       314 
     | 
    
         
            -
                  # *Params*:
         
     | 
| 
       315 
     | 
    
         
            -
                  # * +initialdir+ - (String, optional) Initial dir; default = +nil+
         
     | 
| 
       316 
     | 
    
         
            -
                  #   -> Working dir at the time of calling this method.
         
     | 
| 
       317 
     | 
    
         
            -
                  # * +help+ - (String, optional) ; Text used in the BalloonHelp;
         
     | 
| 
       318 
     | 
    
         
            -
                  #   default = +nil+ -> No help.
         
     | 
| 
       319 
     | 
    
         
            -
                  # * +hash+ - (Hash, optional) 
         
     | 
| 
       320 
     | 
    
         
            -
                  #   * <tt>:initialdir</tt> - Like above. 
         
     | 
| 
       321 
     | 
    
         
            -
                  #   * <tt>:help</tt> - Like above. 
         
     | 
| 
       322 
     | 
    
         
            -
                  #   * <tt>:mode</tt> - Don't change this!
         
     | 
| 
       323 
     | 
    
         
            -
                  #   * <tt>:multiple</tt> - Don't change this!
         
     | 
| 
       324 
     | 
    
         
            -
                  #   * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
         
     | 
| 
       325 
     | 
    
         
            -
                  #   * <tt>:title</tt> - (String) Title of the dialog window.
         
     | 
| 
       326 
     | 
    
         
            -
                  #   * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field. 
         
     | 
| 
       327 
     | 
    
         
            -
                  #   * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
         
     | 
| 
       328 
     | 
    
         
            -
                  #     must be chosen, canceling the dialog is not possible.
         
     | 
| 
       329 
     | 
    
         
            -
                  #   * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
         
     | 
| 
       330 
     | 
    
         
            -
                  #     important. Sets the section in the config-file, where for example the
         
     | 
| 
       331 
     | 
    
         
            -
                  #     window size and position is stored.
         
     | 
| 
       332 
     | 
    
         
            -
                  #   * <tt>:filetypes</tt> - (Array of Arrays) Filter for the file types
         
     | 
| 
       333 
     | 
    
         
            -
                  #     Format of the (inner) Arrays: 
         
     | 
| 
       334 
     | 
    
         
            -
                  #     * First element: (String) Name of the file type, e.g. 'Ruby files'
         
     | 
| 
       335 
     | 
    
         
            -
                  #     * Second element: (Array) List of extensions for the file type, e.g. ['.rb','.rbw']
         
     | 
| 
       336 
     | 
    
         
            -
                  #     * Third element: (String, optional) Mac file type(s), e.g. 'TEXT'
         
     | 
| 
       337 
     | 
    
         
            -
                  #     * Example:
         
     | 
| 
       338 
     | 
    
         
            -
                  #         filetypes = [
         
     | 
| 
       339 
     | 
    
         
            -
                  #           ['Text files',       ['.txt','.doc']          ],
         
     | 
| 
       340 
     | 
    
         
            -
                  #           ['Text files',       [],                      'TEXT' ],
         
     | 
| 
       341 
     | 
    
         
            -
                  #           ['Ruby Scripts',     ['.rb'],                 'TEXT' ],
         
     | 
| 
       342 
     | 
    
         
            -
                  #           ['Tcl Scripts',      ['.tcl'],                'TEXT' ],
         
     | 
| 
       343 
     | 
    
         
            -
                  #           ['C Source Files',   ['.c','.h']              ],
         
     | 
| 
       344 
     | 
    
         
            -
                  #           ['All Source Files', ['.rb','.tcl','.c','.h'] ],
         
     | 
| 
       345 
     | 
    
         
            -
                  #           ['Image Files',      ['.gif']                 ],
         
     | 
| 
       346 
     | 
    
         
            -
                  #           ['Image Files',      ['.jpeg','.jpg']         ],
         
     | 
| 
       347 
     | 
    
         
            -
                  #           ['Image Files',      [],                      ['GIFF','JPEG']],
         
     | 
| 
       348 
     | 
    
         
            -
                  #           ['All files',        '*'                      ]
         
     | 
| 
       349 
     | 
    
         
            -
                  #         ]
         
     | 
| 
       350 
     | 
    
         
            -
                  # *Returns:* (Array) Paths of the chosen files;  +nil+, if 'Cancel' was clicked.
         
     | 
| 
       351 
     | 
    
         
            -
                  # 
         
     | 
| 
       352 
     | 
    
         
            -
                  # *Example:*   
         
     | 
| 
       353 
     | 
    
         
            -
                  # 
         
     | 
| 
       354 
     | 
    
         
            -
                  #    filetypes = [
         
     | 
| 
       355 
     | 
    
         
            -
                  #        ['Log Files', ['.log']],
         
     | 
| 
       356 
     | 
    
         
            -
                  #        ['All Files', '*']
         
     | 
| 
       357 
     | 
    
         
            -
                  #      ]
         
     | 
| 
       358 
     | 
    
         
            -
                  #   
         
     | 
| 
       359 
     | 
    
         
            -
                  #    ans = open_file('c:\Windows', :filetypes=>filetypes)
         
     | 
| 
       360 
     | 
    
         
            -
                  # 
         
     | 
| 
       361 
     | 
    
         
            -
                  # TODO: Does initialdir work?
         
     | 
| 
       362 
     | 
    
         
            -
                HERE
         
     | 
| 
       363 
     | 
    
         
            -
             
     | 
| 
       364 
     | 
    
         
            -
                filetypes = [
         
     | 
| 
       365 
     | 
    
         
            -
                    ['Text Files', ['.txt']],
         
     | 
| 
       366 
     | 
    
         
            -
                    ['All Files', '*']
         
     | 
| 
       367 
     | 
    
         
            -
                  ]
         
     | 
| 
       368 
     | 
    
         
            -
             
     | 
| 
       369 
     | 
    
         
            -
                ans = open_file('c:\WinDows', help, :filetypes=>filetypes)
         
     | 
| 
       370 
     | 
    
         
            -
             
     | 
| 
       371 
     | 
    
         
            -
                @outW.puts "open_file returned: #{ ans.inspect }"
         
     | 
| 
       372 
     | 
    
         
            -
                puts
         
     | 
| 
       373 
     | 
    
         
            -
                @outW.puts help
         
     | 
| 
       374 
     | 
    
         
            -
              end # explain_open_file
         
     | 
| 
       375 
     | 
    
         
            -
              
         
     | 
| 
       376 
     | 
    
         
            -
              def explain_save_file(  )
         
     | 
| 
       377 
     | 
    
         
            -
                @outW.puts_h2 "save_file(initialdir=nil,help=nil,hash=nil)"
         
     | 
| 
       378 
     | 
    
         
            -
             
     | 
| 
       379 
     | 
    
         
            -
                help = <<-HERE.margin
         
     | 
| 
       380 
     | 
    
         
            -
                  # save_file( initialdir=nil,help=nil,hash=nil )
         
     | 
| 
       381 
     | 
    
         
            -
                  # 
         
     | 
| 
       382 
     | 
    
         
            -
                  # To get this dialog explain, run the example and point the mouse
         
     | 
| 
       383 
     | 
    
         
            -
                  # at each button.
         
     | 
| 
       384 
     | 
    
         
            -
                  #
         
     | 
| 
       385 
     | 
    
         
            -
                  # *Params*:
         
     | 
| 
       386 
     | 
    
         
            -
                  # * +initialdir+ - (String, optional) Initial dir; default = +nil+
         
     | 
| 
       387 
     | 
    
         
            -
                  #   -> Working dir at the time of calling this method.
         
     | 
| 
       388 
     | 
    
         
            -
                  # * +help+ - (String, optional) ; Text used in the BalloonHelp;
         
     | 
| 
       389 
     | 
    
         
            -
                  #   default = +nil+ -> No help.
         
     | 
| 
       390 
     | 
    
         
            -
                  # * +hash+ - (Hash, optional) 
         
     | 
| 
       391 
     | 
    
         
            -
                  #   * <tt>:initialdir</tt> - Like above. 
         
     | 
| 
       392 
     | 
    
         
            -
                  #   * <tt>:help</tt> - Like above. 
         
     | 
| 
       393 
     | 
    
         
            -
                  #   * <tt>:initialfile</tt> - (String) Default filename, extension
         
     | 
| 
       394 
     | 
    
         
            -
                  #     will be added automatically by filetypes-setting; default =
         
     | 
| 
       395 
     | 
    
         
            -
                  #     'Untitled'
         
     | 
| 
       396 
     | 
    
         
            -
                  #   * <tt>:mode</tt> - Don't change this!
         
     | 
| 
       397 
     | 
    
         
            -
                  #   * <tt>:multiple</tt> - Don't change this!
         
     | 
| 
       398 
     | 
    
         
            -
                  #   * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
         
     | 
| 
       399 
     | 
    
         
            -
                  #   * <tt>:title</tt> - (String) Title of the dialog window.
         
     | 
| 
       400 
     | 
    
         
            -
                  #   * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field. 
         
     | 
| 
       401 
     | 
    
         
            -
                  #   * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
         
     | 
| 
       402 
     | 
    
         
            -
                  #     must be chosen, canceling the dialog is not possible.
         
     | 
| 
       403 
     | 
    
         
            -
                  #   * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
         
     | 
| 
       404 
     | 
    
         
            -
                  #     important. Sets the section in the config-file, where for example the
         
     | 
| 
       405 
     | 
    
         
            -
                  #     window size and position is stored.
         
     | 
| 
       406 
     | 
    
         
            -
                  #   * <tt>:defaultextension</tt> - ??? (Don't change).
         
     | 
| 
       407 
     | 
    
         
            -
                  #   * <tt>:filetypes</tt> - (Array of Arrays) Filter for the file types
         
     | 
| 
       408 
     | 
    
         
            -
                  #     Format of the (inner) Arrays: 
         
     | 
| 
       409 
     | 
    
         
            -
                  #     * First element: (String) Name of the file type, e.g. 'Ruby files'
         
     | 
| 
       410 
     | 
    
         
            -
                  #     * Second element: (Array) List of extensions for the file type, e.g. ['.rb','.rbw']
         
     | 
| 
       411 
     | 
    
         
            -
                  #     * Third element: (String, optional) Mac file type(s), e.g. 'TEXT'
         
     | 
| 
       412 
     | 
    
         
            -
                  #     * Example:
         
     | 
| 
       413 
     | 
    
         
            -
                  #         filetypes = [
         
     | 
| 
       414 
     | 
    
         
            -
                  #           ['Text files',       ['.txt','.doc']          ],
         
     | 
| 
       415 
     | 
    
         
            -
                  #           ['Text files',       [],                      'TEXT' ],
         
     | 
| 
       416 
     | 
    
         
            -
                  #           ['Ruby Scripts',     ['.rb'],                 'TEXT' ],
         
     | 
| 
       417 
     | 
    
         
            -
                  #           ['Tcl Scripts',      ['.tcl'],                'TEXT' ],
         
     | 
| 
       418 
     | 
    
         
            -
                  #           ['C Source Files',   ['.c','.h']              ],
         
     | 
| 
       419 
     | 
    
         
            -
                  #           ['All Source Files', ['.rb','.tcl','.c','.h'] ],
         
     | 
| 
       420 
     | 
    
         
            -
                  #           ['Image Files',      ['.gif']                 ],
         
     | 
| 
       421 
     | 
    
         
            -
                  #           ['Image Files',      ['.jpeg','.jpg']         ],
         
     | 
| 
       422 
     | 
    
         
            -
                  #           ['Image Files',      [],                      ['GIFF','JPEG']],
         
     | 
| 
       423 
     | 
    
         
            -
                  #           ['All files',        '*'                      ]
         
     | 
| 
       424 
     | 
    
         
            -
                  #         ]
         
     | 
| 
       425 
     | 
    
         
            -
                  # 
         
     | 
| 
       426 
     | 
    
         
            -
                  # *Returns:* (String) Paths of the chosen file;  +nil+, if 'Cancel' was clicked.
         
     | 
| 
       427 
     | 
    
         
            -
                  # 
         
     | 
| 
       428 
     | 
    
         
            -
                  # *Example:*   
         
     | 
| 
       429 
     | 
    
         
            -
                  # 
         
     | 
| 
       430 
     | 
    
         
            -
                  #    filetypes = [
         
     | 
| 
       431 
     | 
    
         
            -
                  #        ['Log Files', ['.log']],
         
     | 
| 
       432 
     | 
    
         
            -
                  #        ['All Files', '*']
         
     | 
| 
       433 
     | 
    
         
            -
                  #      ]
         
     | 
| 
       434 
     | 
    
         
            -
                  #   
         
     | 
| 
       435 
     | 
    
         
            -
                  #    ans = save_file('c:\Windows', :filetypes=>filetypes)
         
     | 
| 
       436 
     | 
    
         
            -
                  # 
         
     | 
| 
       437 
     | 
    
         
            -
                  # TODO: Does initialdir work?
         
     | 
| 
       438 
     | 
    
         
            -
                HERE
         
     | 
| 
       439 
     | 
    
         
            -
             
     | 
| 
       440 
     | 
    
         
            -
                filetypes = [
         
     | 
| 
       441 
     | 
    
         
            -
                    ['Text Files', ['.txt']],
         
     | 
| 
       442 
     | 
    
         
            -
                    ['All Files', '*']
         
     | 
| 
       443 
     | 
    
         
            -
                  ]
         
     | 
| 
       444 
     | 
    
         
            -
             
     | 
| 
       445 
     | 
    
         
            -
                ans = save_file('c:\Windows', help, :initialfile=>'my_name', :filetypes=>filetypes)
         
     | 
| 
       446 
     | 
    
         
            -
             
     | 
| 
       447 
     | 
    
         
            -
                @outW.puts "save_file returned: #{ ans.inspect }"
         
     | 
| 
       448 
     | 
    
         
            -
                puts
         
     | 
| 
       449 
     | 
    
         
            -
                @outW.puts help
         
     | 
| 
       450 
     | 
    
         
            -
              end # explain_save_file
         
     | 
| 
       451 
     | 
    
         
            -
             
     | 
| 
       452 
     | 
    
         
            -
              
         
     | 
| 
       453 
     | 
    
         
            -
              def finish(  )
         
     | 
| 
       454 
     | 
    
         
            -
                @outW.puts( "\n\nFINISHED - Close by clicking the close-button ('X') on top of this window.")
         
     | 
| 
       455 
     | 
    
         
            -
              end # finish
         
     | 
| 
       456 
     | 
    
         
            -
              
         
     | 
| 
       457 
     | 
    
         
            -
             
     | 
| 
       458 
     | 
    
         
            -
              
         
     | 
| 
       459 
     | 
    
         
            -
              def run(  )
         
     | 
| 
       460 
     | 
    
         
            -
                explain_puts
         
     | 
| 
       461 
     | 
    
         
            -
                explain_window_size
         
     | 
| 
       462 
     | 
    
         
            -
                explain_ask_single_line
         
     | 
| 
       463 
     | 
    
         
            -
                explain_single_choice
         
     | 
| 
       464 
     | 
    
         
            -
                explain_multi_choice
         
     | 
| 
       465 
     | 
    
         
            -
                explain_choose_dir
         
     | 
| 
       466 
     | 
    
         
            -
                explain_open_files
         
     | 
| 
       467 
     | 
    
         
            -
                explain_open_file
         
     | 
| 
       468 
     | 
    
         
            -
                explain_save_file   
         
     | 
| 
       469 
     | 
    
         
            -
                finish          
         
     | 
| 
       470 
     | 
    
         
            -
             
     | 
| 
       471 
     | 
    
         
            -
             
     | 
| 
       472 
     | 
    
         
            -
                Tk.mainloop  # !!! IMPORTANT !!!
         
     | 
| 
       473 
     | 
    
         
            -
              end # run
         
     | 
| 
       474 
     | 
    
         
            -
             
     | 
| 
       475 
     | 
    
         
            -
            end # class MyTinyUI
         
     | 
| 
       476 
     | 
    
         
            -
             
     | 
| 
       477 
     | 
    
         
            -
            ##########################################################################
         
     | 
| 
       478 
     | 
    
         
            -
            ##########################################################################
         
     | 
| 
       479 
     | 
    
         
            -
            class String
         
     | 
| 
       480 
     | 
    
         
            -
              
         
     | 
| 
       481 
     | 
    
         
            -
              unless String.method_defined?(:margin)
         
     | 
| 
       482 
     | 
    
         
            -
                #################################
         
     | 
| 
       483 
     | 
    
         
            -
                # Provides a margin controlled string. 
         
     | 
| 
       484 
     | 
    
         
            -
                # 
         
     | 
| 
       485 
     | 
    
         
            -
                # From:  
         
     | 
| 
       486 
     | 
    
         
            -
                #   http://facets.rubyforge.org/
         
     | 
| 
       487 
     | 
    
         
            -
                # Example:
         
     | 
| 
       488 
     | 
    
         
            -
                #   x = %Q{
         
     | 
| 
       489 
     | 
    
         
            -
                #         aThis
         
     | 
| 
       490 
     | 
    
         
            -
                #         a     is
         
     | 
| 
       491 
     | 
    
         
            -
                #         a       margin controlled!
         
     | 
| 
       492 
     | 
    
         
            -
                #         }.margin
         
     | 
| 
       493 
     | 
    
         
            -
                # Result:
         
     | 
| 
       494 
     | 
    
         
            -
                #   This
         
     | 
| 
       495 
     | 
    
         
            -
                #        is
         
     | 
| 
       496 
     | 
    
         
            -
                #          margin controlled!
         
     | 
| 
       497 
     | 
    
         
            -
                #
         
     | 
| 
       498 
     | 
    
         
            -
                # Attributes:
         
     | 
| 
       499 
     | 
    
         
            -
                #   n: left margin
         
     | 
| 
       500 
     | 
    
         
            -
                #
         
     | 
| 
       501 
     | 
    
         
            -
                def margin(n=0)
         
     | 
| 
       502 
     | 
    
         
            -
                  d = /\A.*\n\s*(.)/.match( self )[1]
         
     | 
| 
       503 
     | 
    
         
            -
                  d = /\A\s*(.)/.match( self)[1] unless d
         
     | 
| 
       504 
     | 
    
         
            -
                  return '' unless d
         
     | 
| 
       505 
     | 
    
         
            -
                  if n == 0
         
     | 
| 
       506 
     | 
    
         
            -
                    gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, '')
         
     | 
| 
       507 
     | 
    
         
            -
                  else
         
     | 
| 
       508 
     | 
    
         
            -
                    gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, ' ' * n)
         
     | 
| 
       509 
     | 
    
         
            -
                  end
         
     | 
| 
       510 
     | 
    
         
            -
                end
         
     | 
| 
       511 
     | 
    
         
            -
              end # unless
         
     | 
| 
       512 
     | 
    
         
            -
             
     | 
| 
       513 
     | 
    
         
            -
            end # class String
         
     | 
| 
       514 
     | 
    
         
            -
             
     | 
| 
       515 
     | 
    
         
            -
             
     | 
| 
       516 
     | 
    
         
            -
             
     | 
| 
       517 
     | 
    
         
            -
            ##########################################################################
         
     | 
| 
       518 
     | 
    
         
            -
            ##########################################################################
         
     | 
| 
       519 
     | 
    
         
            -
            if $0 == __FILE__
         
     | 
| 
       520 
     | 
    
         
            -
              MyTinyUI.new
         
     | 
| 
       521 
     | 
    
         
            -
            end
         
     | 
| 
      
 1 
     | 
    
         
            +
            # encoding: Windows-1252 :encoding=Windows-1252: 
         
     | 
| 
      
 2 
     | 
    
         
            +
            begin
         
     | 
| 
      
 3 
     | 
    
         
            +
              require 'tkxxs'
         
     | 
| 
      
 4 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 5 
     | 
    
         
            +
              require( File.dirname( File.dirname(__FILE__)) +'/lib/tkxxs')
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
      
 7 
     | 
    
         
            +
            include TKXXS
         
     | 
| 
      
 8 
     | 
    
         
            +
            $VERBOSE = false
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            ##################################################################
         
     | 
| 
      
 11 
     | 
    
         
            +
            ##################################################################
         
     | 
| 
      
 12 
     | 
    
         
            +
            # Example for TKXXS
         
     | 
| 
      
 13 
     | 
    
         
            +
            # 
         
     | 
| 
      
 14 
     | 
    
         
            +
            # Tested on Windows with Ruby 1.9.3-installer.
         
     | 
| 
      
 15 
     | 
    
         
            +
            class MyTinyUI
         
     | 
| 
      
 16 
     | 
    
         
            +
              
         
     | 
| 
      
 17 
     | 
    
         
            +
              def initialize(  )
         
     | 
| 
      
 18 
     | 
    
         
            +
                #< # #  CREATE OUTPUT WINDOW  # # # 
         
     | 
| 
      
 19 
     | 
    
         
            +
                @outW = OutW.new
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                #< # # REDIRECT "puts" to Output Window
         
     | 
| 
      
 22 
     | 
    
         
            +
                # Hence, you can simply write "puts" instead of "@outW.puts" 
         
     | 
| 
      
 23 
     | 
    
         
            +
                $stdout = @outW # BUT: Doesn't work with OCRA!!
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                @outW.puts "Ruby#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
         
     | 
| 
      
 26 
     | 
    
         
            +
                
         
     | 
| 
      
 27 
     | 
    
         
            +
                run
         
     | 
| 
      
 28 
     | 
    
         
            +
              end # initialize
         
     | 
| 
      
 29 
     | 
    
         
            +
              
         
     | 
| 
      
 30 
     | 
    
         
            +
              
         
     | 
| 
      
 31 
     | 
    
         
            +
              def explain_puts(  )
         
     | 
| 
      
 32 
     | 
    
         
            +
                @outW.puts "'puts' writes to the Output Window."
         
     | 
| 
      
 33 
     | 
    
         
            +
                
         
     | 
| 
      
 34 
     | 
    
         
            +
                @outW.puts_h2 "@outW.puts_h2 writes formated text to the Output Window"
         
     | 
| 
      
 35 
     | 
    
         
            +
                
         
     | 
| 
      
 36 
     | 
    
         
            +
                @outW.puts "Other formatings can be implemented."
         
     | 
| 
      
 37 
     | 
    
         
            +
                puts
         
     | 
| 
      
 38 
     | 
    
         
            +
              end # explain_puts
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              def explain_window_size(  )
         
     | 
| 
      
 41 
     | 
    
         
            +
                @outW.puts_h2 "WINDOW SIZE"
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                @outW.puts <<-HERE.margin
         
     | 
| 
      
 44 
     | 
    
         
            +
                  # When using this little app the first time, you should resize
         
     | 
| 
      
 45 
     | 
    
         
            +
                  # and position all popup windows to your desire. This will be
         
     | 
| 
      
 46 
     | 
    
         
            +
                  # saved for the next start of this app.
         
     | 
| 
      
 47 
     | 
    
         
            +
                HERE
         
     | 
| 
      
 48 
     | 
    
         
            +
                
         
     | 
| 
      
 49 
     | 
    
         
            +
              end # explain_window_size
         
     | 
| 
      
 50 
     | 
    
         
            +
              
         
     | 
| 
      
 51 
     | 
    
         
            +
              def explain_ask_single_line(  )
         
     | 
| 
      
 52 
     | 
    
         
            +
                @outW.puts_h2 "ask_single_line( question, help, :defaultEntry=>DefaultAnswer )"
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                help = "This dialog is named 'ask_single_line'"
         
     | 
| 
      
 55 
     | 
    
         
            +
                ans = ask_single_line(
         
     | 
| 
      
 56 
     | 
    
         
            +
                  "Want to know more?\nPoint the mouse at the entry field!",
         
     | 
| 
      
 57 
     | 
    
         
            +
                  help,
         
     | 
| 
      
 58 
     | 
    
         
            +
                  :defaultEntry =>"Of course"
         
     | 
| 
      
 59 
     | 
    
         
            +
                )
         
     | 
| 
      
 60 
     | 
    
         
            +
                
         
     | 
| 
      
 61 
     | 
    
         
            +
                puts
         
     | 
| 
      
 62 
     | 
    
         
            +
                @outW.puts help
         
     | 
| 
      
 63 
     | 
    
         
            +
                @outW.puts 
         
     | 
| 
      
 64 
     | 
    
         
            +
                print "The answer from 'ask_single_line' was: "
         
     | 
| 
      
 65 
     | 
    
         
            +
                @outW.puts ans.inspect
         
     | 
| 
      
 66 
     | 
    
         
            +
                puts
         
     | 
| 
      
 67 
     | 
    
         
            +
                @outW.puts "'Cancel' returns nil."
         
     | 
| 
      
 68 
     | 
    
         
            +
                puts
         
     | 
| 
      
 69 
     | 
    
         
            +
                puts
         
     | 
| 
      
 70 
     | 
    
         
            +
              end # explain_ask_single_line
         
     | 
| 
      
 71 
     | 
    
         
            +
              
         
     | 
| 
      
 72 
     | 
    
         
            +
              def explain_single_choice(  )
         
     | 
| 
      
 73 
     | 
    
         
            +
                @outW.puts_h2 "single_choice( aryWithChoices, help=nil, hash=nil )"
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                help0 = <<-HERE.margin
         
     | 
| 
      
 76 
     | 
    
         
            +
                  # single_choice( aryWithChoices, help=nil, hash=nil )
         
     | 
| 
      
 77 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 78 
     | 
    
         
            +
                  # *Params*:
         
     | 
| 
      
 79 
     | 
    
         
            +
                  # * +aryWithChoices+ - (Array) one of the following formats:
         
     | 
| 
      
 80 
     | 
    
         
            +
                  #   * [ choiceStrA, choiceStrB, ...]
         
     | 
| 
      
 81 
     | 
    
         
            +
                  #   * [ [choiceStrA,objectA], [choiceStrB,objectB], ...  ]
         
     | 
| 
      
 82 
     | 
    
         
            +
                  #   * [ [choiceStrA,objectA,helpStrA], [choiceStrB,objectB,helpStrB], ...]
         
     | 
| 
      
 83 
     | 
    
         
            +
                  #   Quite usefull: a Proc for object.
         
     | 
| 
      
 84 
     | 
    
         
            +
                  # * +help+ - (String, optional) Array, with one help-String for each choice element!;  +nil+ => No help text 
         
     | 
| 
      
 85 
     | 
    
         
            +
                  # * +hash+ - (Hash, optional) 
         
     | 
| 
      
 86 
     | 
    
         
            +
                  #   * <tt>:question</tt> - Like above.
         
     | 
| 
      
 87 
     | 
    
         
            +
                  #   * <tt>:help</tt> - Like above. 
         
     | 
| 
      
 88 
     | 
    
         
            +
                  #   * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
         
     | 
| 
      
 89 
     | 
    
         
            +
                  #     important. Sets the section in the config-file, where for example the
         
     | 
| 
      
 90 
     | 
    
         
            +
                  #     window size and position is stored.
         
     | 
| 
      
 91 
     | 
    
         
            +
                  #   * <tt>:title</tt> - (String) Title of the dialog window
         
     | 
| 
      
 92 
     | 
    
         
            +
                  #   * <tt>:bd</tt> - (Number as String) ?
         
     | 
| 
      
 93 
     | 
    
         
            +
                  #   * <tt>:searchFieldHelp</tt> - (String) Ballon help of the search field,
         
     | 
| 
      
 94 
     | 
    
         
            +
                  #   * <tt>:returnChoiceAndClient</tt> - returns the right side (+false+) or both sides (+true+) of +aryWithChoices+.
         
     | 
| 
      
 95 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 96 
     | 
    
         
            +
                  # *Returns:* 
         
     | 
| 
      
 97 
     | 
    
         
            +
                  # * The right side of +aryWithChoices+ if :returnChoiceAndClient == +false+ (default),
         
     | 
| 
      
 98 
     | 
    
         
            +
                  # * both sides of +aryWithChoices+ if :returnChoiceAndClient == +true+,
         
     | 
| 
      
 99 
     | 
    
         
            +
                  # * +nil+, if 'Cancel' was clicked.
         
     | 
| 
      
 100 
     | 
    
         
            +
                HERE
         
     | 
| 
      
 101 
     | 
    
         
            +
                
         
     | 
| 
      
 102 
     | 
    
         
            +
                
         
     | 
| 
      
 103 
     | 
    
         
            +
                help = ['#1: ' + help0, '#2: ' + help0, '#3: ' + help0]
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                ans = single_choice(
         
     | 
| 
      
 106 
     | 
    
         
            +
                  [
         
     | 
| 
      
 107 
     | 
    
         
            +
                    [ "You want 1?", 1],
         
     | 
| 
      
 108 
     | 
    
         
            +
                    [ "You want 2?", 2],
         
     | 
| 
      
 109 
     | 
    
         
            +
                    [ "You want 3?", 3],
         
     | 
| 
      
 110 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 111 
     | 
    
         
            +
                  help
         
     | 
| 
      
 112 
     | 
    
         
            +
                )
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                @outW.puts "single_choice returned: #{ ans.inspect }"
         
     | 
| 
      
 115 
     | 
    
         
            +
                puts
         
     | 
| 
      
 116 
     | 
    
         
            +
                @outW.puts help0
         
     | 
| 
      
 117 
     | 
    
         
            +
              end # explain_single_choice
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
              def explain_multi_choice(  )
         
     | 
| 
      
 120 
     | 
    
         
            +
                @outW.puts_h2 "multi_choice(aryWithChoices, help=nil, hash=nil)"
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                help0 = <<-HERE.margin
         
     | 
| 
      
 123 
     | 
    
         
            +
              # multi_choice( aryWithChoices, help=nil, hash=nil )
         
     | 
| 
      
 124 
     | 
    
         
            +
              # 
         
     | 
| 
      
 125 
     | 
    
         
            +
              # *Params*:
         
     | 
| 
      
 126 
     | 
    
         
            +
              # * +aryWithChoices+ - (Array) one of the following formats:
         
     | 
| 
      
 127 
     | 
    
         
            +
              #   * [ choiceStrA, choiceStrB, ...]
         
     | 
| 
      
 128 
     | 
    
         
            +
              #   * [ [choiceStrA,objectA], [choiceStrB,objectB], ...  ]
         
     | 
| 
      
 129 
     | 
    
         
            +
              #   * [ [choiceStrA,objectA,helpStrA], [choiceStrB,objectB,helpStrB], ...]
         
     | 
| 
      
 130 
     | 
    
         
            +
              #   Quite usefull: a Proc for object.
         
     | 
| 
      
 131 
     | 
    
         
            +
              # * +help+ - (String, optional) Array, with one help-String for each choice element!;  +nil+ => No help text 
         
     | 
| 
      
 132 
     | 
    
         
            +
              # * +hash+ - (Hash, optional) 
         
     | 
| 
      
 133 
     | 
    
         
            +
              #   * <tt>:question</tt> - Like above.
         
     | 
| 
      
 134 
     | 
    
         
            +
              #   * <tt>:help</tt> - Like above. 
         
     | 
| 
      
 135 
     | 
    
         
            +
              #   * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
         
     | 
| 
      
 136 
     | 
    
         
            +
              #     important. Sets the section in the config-file, where for example the
         
     | 
| 
      
 137 
     | 
    
         
            +
              #     window size and position is stored.
         
     | 
| 
      
 138 
     | 
    
         
            +
              #   * <tt>:title</tt> - (String) Title of the dialog window
         
     | 
| 
      
 139 
     | 
    
         
            +
              #   * <tt>:bd</tt> - (Number as String) ?
         
     | 
| 
      
 140 
     | 
    
         
            +
              #   * <tt>:selectmode => :multiple</tt> - Obsolet?
         
     | 
| 
      
 141 
     | 
    
         
            +
              #   * <tt>:searchFieldHelp</tt> - (String) Ballon help of the search field, searchField not implemented yet
         
     | 
| 
      
 142 
     | 
    
         
            +
              #   * <tt>:returnChoiceAndClient</tt> - returns the right side (+false+) or both sides (+true+) of +aryWithChoices+.
         
     | 
| 
      
 143 
     | 
    
         
            +
              # 
         
     | 
| 
      
 144 
     | 
    
         
            +
              # *Returns:* 
         
     | 
| 
      
 145 
     | 
    
         
            +
              # * An Array of the chosen right sides of +aryWithChoices+ if :returnChoiceAndClient == +false+ (default),
         
     | 
| 
      
 146 
     | 
    
         
            +
              # * An Array of the chosen right and left sides of +aryWithChoices+ if :returnChoiceAndClient == +true+,
         
     | 
| 
      
 147 
     | 
    
         
            +
              # * +nil+, if 'Cancel' was clicked.
         
     | 
| 
      
 148 
     | 
    
         
            +
              # 
         
     | 
| 
      
 149 
     | 
    
         
            +
              # *Example:*   
         
     | 
| 
      
 150 
     | 
    
         
            +
              #    help = ['Help #1', 'Help #2', 'Help #3']
         
     | 
| 
      
 151 
     | 
    
         
            +
              #    ans = single_choice(
         
     | 
| 
      
 152 
     | 
    
         
            +
              #      [
         
     | 
| 
      
 153 
     | 
    
         
            +
              #        [ "You want 1?", 1],
         
     | 
| 
      
 154 
     | 
    
         
            +
              #        [ "You want 2?", 2],
         
     | 
| 
      
 155 
     | 
    
         
            +
              #        [ "You want 3?", 3],
         
     | 
| 
      
 156 
     | 
    
         
            +
              #      ],
         
     | 
| 
      
 157 
     | 
    
         
            +
              #      help
         
     | 
| 
      
 158 
     | 
    
         
            +
              #    )
         
     | 
| 
      
 159 
     | 
    
         
            +
                HERE
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
                help = [help0, help0, help0]
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                ans = multi_choice(
         
     | 
| 
      
 164 
     | 
    
         
            +
                  [
         
     | 
| 
      
 165 
     | 
    
         
            +
                    [ "You want 1?", 1],
         
     | 
| 
      
 166 
     | 
    
         
            +
                    [ "You want 2?", 2],
         
     | 
| 
      
 167 
     | 
    
         
            +
                    [ "You want 3?", 3],
         
     | 
| 
      
 168 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 169 
     | 
    
         
            +
                  help
         
     | 
| 
      
 170 
     | 
    
         
            +
                )
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
                @outW.puts "multi_choice returned: #{ ans.inspect }"
         
     | 
| 
      
 173 
     | 
    
         
            +
                puts
         
     | 
| 
      
 174 
     | 
    
         
            +
                @outW.puts help0
         
     | 
| 
      
 175 
     | 
    
         
            +
              end # explain_multi_choice
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
              def explain_choose_dir(  )
         
     | 
| 
      
 178 
     | 
    
         
            +
                @outW.puts_h2 "choose_dir( initialdir=nil,help=nil,hash=nil)"
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
                help = <<-HERE.margin
         
     | 
| 
      
 181 
     | 
    
         
            +
                  # choose_dir( initialdir=nil,help=nil,hash=nil )
         
     | 
| 
      
 182 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 183 
     | 
    
         
            +
                  # To get this dialog explain, run the example and point the mouse
         
     | 
| 
      
 184 
     | 
    
         
            +
                  # at each button.
         
     | 
| 
      
 185 
     | 
    
         
            +
                  #
         
     | 
| 
      
 186 
     | 
    
         
            +
                  # *Params*:
         
     | 
| 
      
 187 
     | 
    
         
            +
                  # * +initialdir+ - (String, optional) Initial dir; default = +nil+
         
     | 
| 
      
 188 
     | 
    
         
            +
                  #   -> Working dir at the time of calling this method.
         
     | 
| 
      
 189 
     | 
    
         
            +
                  # * +help+ - (String, optional) ; Text used in the BalloonHelp;
         
     | 
| 
      
 190 
     | 
    
         
            +
                  #   default = +nil+ -> No help.
         
     | 
| 
      
 191 
     | 
    
         
            +
                  # * +hash+ - (Hash, optional) 
         
     | 
| 
      
 192 
     | 
    
         
            +
                  #   * <tt>:initialdir</tt> - Like above. 
         
     | 
| 
      
 193 
     | 
    
         
            +
                  #   * <tt>:help</tt> - Like above. 
         
     | 
| 
      
 194 
     | 
    
         
            +
                  #   * <tt>:mode</tt> - Don't modify this!
         
     | 
| 
      
 195 
     | 
    
         
            +
                  #   * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
         
     | 
| 
      
 196 
     | 
    
         
            +
                  #   * <tt>:title</tt> - (String) Title of the dialog window.
         
     | 
| 
      
 197 
     | 
    
         
            +
                  #   * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field. 
         
     | 
| 
      
 198 
     | 
    
         
            +
                  #   * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
         
     | 
| 
      
 199 
     | 
    
         
            +
                  #     must be chosen, canceling the dialog is not possible.
         
     | 
| 
      
 200 
     | 
    
         
            +
                  #   * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
         
     | 
| 
      
 201 
     | 
    
         
            +
                  #     important. Sets the section in the config-file, where for example the
         
     | 
| 
      
 202 
     | 
    
         
            +
                  #     window size and position is stored.
         
     | 
| 
      
 203 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 204 
     | 
    
         
            +
                  # *Returns:* (String) Path of the chosen dir;  +nil+, if 'Cancel' was clicked.
         
     | 
| 
      
 205 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 206 
     | 
    
         
            +
                  # *Example:*   
         
     | 
| 
      
 207 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 208 
     | 
    
         
            +
                  #   help = "Pick a dir."
         
     | 
| 
      
 209 
     | 
    
         
            +
                  #   ans = choose_dir( 
         
     | 
| 
      
 210 
     | 
    
         
            +
                  #     'c:\WinDows', 
         
     | 
| 
      
 211 
     | 
    
         
            +
                  #     help, 
         
     | 
| 
      
 212 
     | 
    
         
            +
                  #     :validate=>true, 
         
     | 
| 
      
 213 
     | 
    
         
            +
                  #     :defaultEntry=>'c:/windows/system' 
         
     | 
| 
      
 214 
     | 
    
         
            +
                  #   )
         
     | 
| 
      
 215 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 216 
     | 
    
         
            +
                  # TODO: How to choose multiple dirs or even dirs & files?
         
     | 
| 
      
 217 
     | 
    
         
            +
                HERE
         
     | 
| 
      
 218 
     | 
    
         
            +
             
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
                ans = choose_dir( 
         
     | 
| 
      
 221 
     | 
    
         
            +
                  'c:\WinDows', 
         
     | 
| 
      
 222 
     | 
    
         
            +
                  help, 
         
     | 
| 
      
 223 
     | 
    
         
            +
                  :validate=>true, 
         
     | 
| 
      
 224 
     | 
    
         
            +
                  :defaultEntry=>'c:/windows/system' 
         
     | 
| 
      
 225 
     | 
    
         
            +
                )
         
     | 
| 
      
 226 
     | 
    
         
            +
             
     | 
| 
      
 227 
     | 
    
         
            +
                @outW.puts "choose_dir returned: #{ ans.inspect }"
         
     | 
| 
      
 228 
     | 
    
         
            +
                puts
         
     | 
| 
      
 229 
     | 
    
         
            +
                @outW.puts help
         
     | 
| 
      
 230 
     | 
    
         
            +
              end # explain_choose_dir
         
     | 
| 
      
 231 
     | 
    
         
            +
              
         
     | 
| 
      
 232 
     | 
    
         
            +
              def explain_open_files(  )
         
     | 
| 
      
 233 
     | 
    
         
            +
                @outW.puts_h2 "open_files(initialdir=nil,help=nil,hash=nil)"
         
     | 
| 
      
 234 
     | 
    
         
            +
             
     | 
| 
      
 235 
     | 
    
         
            +
                help = <<-HERE.margin
         
     | 
| 
      
 236 
     | 
    
         
            +
                  # open_files( initialdir=nil,help=nil,hash=nil )
         
     | 
| 
      
 237 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 238 
     | 
    
         
            +
                  # To get this dialog explain, run the example and point the mouse
         
     | 
| 
      
 239 
     | 
    
         
            +
                  # at each button.
         
     | 
| 
      
 240 
     | 
    
         
            +
                  #
         
     | 
| 
      
 241 
     | 
    
         
            +
                  # *Params*:
         
     | 
| 
      
 242 
     | 
    
         
            +
                  # * +initialdir+ - (String, optional) Initial dir; default = +nil+
         
     | 
| 
      
 243 
     | 
    
         
            +
                  #   -> Working dir at the time of calling this method.
         
     | 
| 
      
 244 
     | 
    
         
            +
                  # * +help+ - (String, optional) ; Text used in the BalloonHelp;
         
     | 
| 
      
 245 
     | 
    
         
            +
                  #   default = +nil+ -> No help.
         
     | 
| 
      
 246 
     | 
    
         
            +
                  # * +hash+ - (Hash, optional) 
         
     | 
| 
      
 247 
     | 
    
         
            +
                  #   * <tt>:initialdir</tt> - Like above. 
         
     | 
| 
      
 248 
     | 
    
         
            +
                  #   * <tt>:help</tt> - Like above. 
         
     | 
| 
      
 249 
     | 
    
         
            +
                  #   * <tt>:mode</tt> - Don't change this!
         
     | 
| 
      
 250 
     | 
    
         
            +
                  #   * <tt>:multiple</tt> - Don't change this!
         
     | 
| 
      
 251 
     | 
    
         
            +
                  #   * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
         
     | 
| 
      
 252 
     | 
    
         
            +
                  #   * <tt>:title</tt> - (String) Title of the dialog window.
         
     | 
| 
      
 253 
     | 
    
         
            +
                  #   * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field. 
         
     | 
| 
      
 254 
     | 
    
         
            +
                  #   * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
         
     | 
| 
      
 255 
     | 
    
         
            +
                  #     must be chosen, canceling the dialog is not possible.
         
     | 
| 
      
 256 
     | 
    
         
            +
                  #   * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
         
     | 
| 
      
 257 
     | 
    
         
            +
                  #     important. Sets the section in the config-file, where for example the
         
     | 
| 
      
 258 
     | 
    
         
            +
                  #     window size and position is stored.
         
     | 
| 
      
 259 
     | 
    
         
            +
                  #   * <tt>:filetypes</tt> - (Array of Arrays) Filter for the file types
         
     | 
| 
      
 260 
     | 
    
         
            +
                  #     Format of the (inner) Arrays: 
         
     | 
| 
      
 261 
     | 
    
         
            +
                  #     * First element: (String) Name of the file type, e.g. 'Ruby files'
         
     | 
| 
      
 262 
     | 
    
         
            +
                  #     * Second element: (Array) List of extensions for the file type, e.g. ['.rb','.rbw']
         
     | 
| 
      
 263 
     | 
    
         
            +
                  #     * Third element: (String, optional) Mac file type(s), e.g. 'TEXT'
         
     | 
| 
      
 264 
     | 
    
         
            +
                  #     * Example:
         
     | 
| 
      
 265 
     | 
    
         
            +
                  #         filetypes = [
         
     | 
| 
      
 266 
     | 
    
         
            +
                  #           ['Text files',       ['.txt','.doc']          ],
         
     | 
| 
      
 267 
     | 
    
         
            +
                  #           ['Text files',       [],                      'TEXT' ],
         
     | 
| 
      
 268 
     | 
    
         
            +
                  #           ['Ruby Scripts',     ['.rb'],                 'TEXT' ],
         
     | 
| 
      
 269 
     | 
    
         
            +
                  #           ['Tcl Scripts',      ['.tcl'],                'TEXT' ],
         
     | 
| 
      
 270 
     | 
    
         
            +
                  #           ['C Source Files',   ['.c','.h']              ],
         
     | 
| 
      
 271 
     | 
    
         
            +
                  #           ['All Source Files', ['.rb','.tcl','.c','.h'] ],
         
     | 
| 
      
 272 
     | 
    
         
            +
                  #           ['Image Files',      ['.gif']                 ],
         
     | 
| 
      
 273 
     | 
    
         
            +
                  #           ['Image Files',      ['.jpeg','.jpg']         ],
         
     | 
| 
      
 274 
     | 
    
         
            +
                  #           ['Image Files',      [],                      ['GIFF','JPEG']],
         
     | 
| 
      
 275 
     | 
    
         
            +
                  #           ['All files',        '*'                      ]
         
     | 
| 
      
 276 
     | 
    
         
            +
                  #         ]
         
     | 
| 
      
 277 
     | 
    
         
            +
                  # *Returns:* (Array) Paths of the chosen files;  +nil+, if 'Cancel' was clicked.
         
     | 
| 
      
 278 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 279 
     | 
    
         
            +
                  # *Example:*   
         
     | 
| 
      
 280 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 281 
     | 
    
         
            +
                  #    filetypes = [
         
     | 
| 
      
 282 
     | 
    
         
            +
                  #        ['Log Files', ['.log']],
         
     | 
| 
      
 283 
     | 
    
         
            +
                  #        ['All Files', '*']
         
     | 
| 
      
 284 
     | 
    
         
            +
                  #      ]
         
     | 
| 
      
 285 
     | 
    
         
            +
                  #   
         
     | 
| 
      
 286 
     | 
    
         
            +
                  #    ans = open_files('c:\Windows', :filetypes=>filetypes)
         
     | 
| 
      
 287 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 288 
     | 
    
         
            +
                  # TODO: When using "Recent"-Button > "Files" or "Favorite"-Button >
         
     | 
| 
      
 289 
     | 
    
         
            +
                  # "Files" you can choose only one from Recent and none from, for
         
     | 
| 
      
 290 
     | 
    
         
            +
                  # example "Browse"; should be multiple.
         
     | 
| 
      
 291 
     | 
    
         
            +
                HERE
         
     | 
| 
      
 292 
     | 
    
         
            +
             
     | 
| 
      
 293 
     | 
    
         
            +
                filetypes = [
         
     | 
| 
      
 294 
     | 
    
         
            +
                    ['Text Files', ['.txt']],
         
     | 
| 
      
 295 
     | 
    
         
            +
                    ['All Files', '*']
         
     | 
| 
      
 296 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 297 
     | 
    
         
            +
             
     | 
| 
      
 298 
     | 
    
         
            +
                ans = open_files('c:\Windows', help, :filetypes=>filetypes)
         
     | 
| 
      
 299 
     | 
    
         
            +
             
     | 
| 
      
 300 
     | 
    
         
            +
                @outW.puts "open_files returned: #{ ans.inspect }"
         
     | 
| 
      
 301 
     | 
    
         
            +
                puts
         
     | 
| 
      
 302 
     | 
    
         
            +
                @outW.puts help
         
     | 
| 
      
 303 
     | 
    
         
            +
              end # explain_open_files
         
     | 
| 
      
 304 
     | 
    
         
            +
              
         
     | 
| 
      
 305 
     | 
    
         
            +
              def explain_open_file(  )
         
     | 
| 
      
 306 
     | 
    
         
            +
                @outW.puts_h2 "open_file(initialdir=nil,help=nil,hash=nil)"
         
     | 
| 
      
 307 
     | 
    
         
            +
             
     | 
| 
      
 308 
     | 
    
         
            +
                help = <<-HERE.margin
         
     | 
| 
      
 309 
     | 
    
         
            +
                  # open_file( initialdir=nil,help=nil,hash=nil )
         
     | 
| 
      
 310 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 311 
     | 
    
         
            +
                  # To get this dialog explain, run the example and point the mouse
         
     | 
| 
      
 312 
     | 
    
         
            +
                  # at each button.
         
     | 
| 
      
 313 
     | 
    
         
            +
                  #
         
     | 
| 
      
 314 
     | 
    
         
            +
                  # *Params*:
         
     | 
| 
      
 315 
     | 
    
         
            +
                  # * +initialdir+ - (String, optional) Initial dir; default = +nil+
         
     | 
| 
      
 316 
     | 
    
         
            +
                  #   -> Working dir at the time of calling this method.
         
     | 
| 
      
 317 
     | 
    
         
            +
                  # * +help+ - (String, optional) ; Text used in the BalloonHelp;
         
     | 
| 
      
 318 
     | 
    
         
            +
                  #   default = +nil+ -> No help.
         
     | 
| 
      
 319 
     | 
    
         
            +
                  # * +hash+ - (Hash, optional) 
         
     | 
| 
      
 320 
     | 
    
         
            +
                  #   * <tt>:initialdir</tt> - Like above. 
         
     | 
| 
      
 321 
     | 
    
         
            +
                  #   * <tt>:help</tt> - Like above. 
         
     | 
| 
      
 322 
     | 
    
         
            +
                  #   * <tt>:mode</tt> - Don't change this!
         
     | 
| 
      
 323 
     | 
    
         
            +
                  #   * <tt>:multiple</tt> - Don't change this!
         
     | 
| 
      
 324 
     | 
    
         
            +
                  #   * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
         
     | 
| 
      
 325 
     | 
    
         
            +
                  #   * <tt>:title</tt> - (String) Title of the dialog window.
         
     | 
| 
      
 326 
     | 
    
         
            +
                  #   * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field. 
         
     | 
| 
      
 327 
     | 
    
         
            +
                  #   * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
         
     | 
| 
      
 328 
     | 
    
         
            +
                  #     must be chosen, canceling the dialog is not possible.
         
     | 
| 
      
 329 
     | 
    
         
            +
                  #   * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
         
     | 
| 
      
 330 
     | 
    
         
            +
                  #     important. Sets the section in the config-file, where for example the
         
     | 
| 
      
 331 
     | 
    
         
            +
                  #     window size and position is stored.
         
     | 
| 
      
 332 
     | 
    
         
            +
                  #   * <tt>:filetypes</tt> - (Array of Arrays) Filter for the file types
         
     | 
| 
      
 333 
     | 
    
         
            +
                  #     Format of the (inner) Arrays: 
         
     | 
| 
      
 334 
     | 
    
         
            +
                  #     * First element: (String) Name of the file type, e.g. 'Ruby files'
         
     | 
| 
      
 335 
     | 
    
         
            +
                  #     * Second element: (Array) List of extensions for the file type, e.g. ['.rb','.rbw']
         
     | 
| 
      
 336 
     | 
    
         
            +
                  #     * Third element: (String, optional) Mac file type(s), e.g. 'TEXT'
         
     | 
| 
      
 337 
     | 
    
         
            +
                  #     * Example:
         
     | 
| 
      
 338 
     | 
    
         
            +
                  #         filetypes = [
         
     | 
| 
      
 339 
     | 
    
         
            +
                  #           ['Text files',       ['.txt','.doc']          ],
         
     | 
| 
      
 340 
     | 
    
         
            +
                  #           ['Text files',       [],                      'TEXT' ],
         
     | 
| 
      
 341 
     | 
    
         
            +
                  #           ['Ruby Scripts',     ['.rb'],                 'TEXT' ],
         
     | 
| 
      
 342 
     | 
    
         
            +
                  #           ['Tcl Scripts',      ['.tcl'],                'TEXT' ],
         
     | 
| 
      
 343 
     | 
    
         
            +
                  #           ['C Source Files',   ['.c','.h']              ],
         
     | 
| 
      
 344 
     | 
    
         
            +
                  #           ['All Source Files', ['.rb','.tcl','.c','.h'] ],
         
     | 
| 
      
 345 
     | 
    
         
            +
                  #           ['Image Files',      ['.gif']                 ],
         
     | 
| 
      
 346 
     | 
    
         
            +
                  #           ['Image Files',      ['.jpeg','.jpg']         ],
         
     | 
| 
      
 347 
     | 
    
         
            +
                  #           ['Image Files',      [],                      ['GIFF','JPEG']],
         
     | 
| 
      
 348 
     | 
    
         
            +
                  #           ['All files',        '*'                      ]
         
     | 
| 
      
 349 
     | 
    
         
            +
                  #         ]
         
     | 
| 
      
 350 
     | 
    
         
            +
                  # *Returns:* (Array) Paths of the chosen files;  +nil+, if 'Cancel' was clicked.
         
     | 
| 
      
 351 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 352 
     | 
    
         
            +
                  # *Example:*   
         
     | 
| 
      
 353 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 354 
     | 
    
         
            +
                  #    filetypes = [
         
     | 
| 
      
 355 
     | 
    
         
            +
                  #        ['Log Files', ['.log']],
         
     | 
| 
      
 356 
     | 
    
         
            +
                  #        ['All Files', '*']
         
     | 
| 
      
 357 
     | 
    
         
            +
                  #      ]
         
     | 
| 
      
 358 
     | 
    
         
            +
                  #   
         
     | 
| 
      
 359 
     | 
    
         
            +
                  #    ans = open_file('c:\Windows', :filetypes=>filetypes)
         
     | 
| 
      
 360 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 361 
     | 
    
         
            +
                  # TODO: Does initialdir work?
         
     | 
| 
      
 362 
     | 
    
         
            +
                HERE
         
     | 
| 
      
 363 
     | 
    
         
            +
             
     | 
| 
      
 364 
     | 
    
         
            +
                filetypes = [
         
     | 
| 
      
 365 
     | 
    
         
            +
                    ['Text Files', ['.txt']],
         
     | 
| 
      
 366 
     | 
    
         
            +
                    ['All Files', '*']
         
     | 
| 
      
 367 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 368 
     | 
    
         
            +
             
     | 
| 
      
 369 
     | 
    
         
            +
                ans = open_file('c:\WinDows', help, :filetypes=>filetypes)
         
     | 
| 
      
 370 
     | 
    
         
            +
             
     | 
| 
      
 371 
     | 
    
         
            +
                @outW.puts "open_file returned: #{ ans.inspect }"
         
     | 
| 
      
 372 
     | 
    
         
            +
                puts
         
     | 
| 
      
 373 
     | 
    
         
            +
                @outW.puts help
         
     | 
| 
      
 374 
     | 
    
         
            +
              end # explain_open_file
         
     | 
| 
      
 375 
     | 
    
         
            +
              
         
     | 
| 
      
 376 
     | 
    
         
            +
              def explain_save_file(  )
         
     | 
| 
      
 377 
     | 
    
         
            +
                @outW.puts_h2 "save_file(initialdir=nil,help=nil,hash=nil)"
         
     | 
| 
      
 378 
     | 
    
         
            +
             
     | 
| 
      
 379 
     | 
    
         
            +
                help = <<-HERE.margin
         
     | 
| 
      
 380 
     | 
    
         
            +
                  # save_file( initialdir=nil,help=nil,hash=nil )
         
     | 
| 
      
 381 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 382 
     | 
    
         
            +
                  # To get this dialog explain, run the example and point the mouse
         
     | 
| 
      
 383 
     | 
    
         
            +
                  # at each button.
         
     | 
| 
      
 384 
     | 
    
         
            +
                  #
         
     | 
| 
      
 385 
     | 
    
         
            +
                  # *Params*:
         
     | 
| 
      
 386 
     | 
    
         
            +
                  # * +initialdir+ - (String, optional) Initial dir; default = +nil+
         
     | 
| 
      
 387 
     | 
    
         
            +
                  #   -> Working dir at the time of calling this method.
         
     | 
| 
      
 388 
     | 
    
         
            +
                  # * +help+ - (String, optional) ; Text used in the BalloonHelp;
         
     | 
| 
      
 389 
     | 
    
         
            +
                  #   default = +nil+ -> No help.
         
     | 
| 
      
 390 
     | 
    
         
            +
                  # * +hash+ - (Hash, optional) 
         
     | 
| 
      
 391 
     | 
    
         
            +
                  #   * <tt>:initialdir</tt> - Like above. 
         
     | 
| 
      
 392 
     | 
    
         
            +
                  #   * <tt>:help</tt> - Like above. 
         
     | 
| 
      
 393 
     | 
    
         
            +
                  #   * <tt>:initialfile</tt> - (String) Default filename, extension
         
     | 
| 
      
 394 
     | 
    
         
            +
                  #     will be added automatically by filetypes-setting; default =
         
     | 
| 
      
 395 
     | 
    
         
            +
                  #     'Untitled'
         
     | 
| 
      
 396 
     | 
    
         
            +
                  #   * <tt>:mode</tt> - Don't change this!
         
     | 
| 
      
 397 
     | 
    
         
            +
                  #   * <tt>:multiple</tt> - Don't change this!
         
     | 
| 
      
 398 
     | 
    
         
            +
                  #   * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
         
     | 
| 
      
 399 
     | 
    
         
            +
                  #   * <tt>:title</tt> - (String) Title of the dialog window.
         
     | 
| 
      
 400 
     | 
    
         
            +
                  #   * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field. 
         
     | 
| 
      
 401 
     | 
    
         
            +
                  #   * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
         
     | 
| 
      
 402 
     | 
    
         
            +
                  #     must be chosen, canceling the dialog is not possible.
         
     | 
| 
      
 403 
     | 
    
         
            +
                  #   * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
         
     | 
| 
      
 404 
     | 
    
         
            +
                  #     important. Sets the section in the config-file, where for example the
         
     | 
| 
      
 405 
     | 
    
         
            +
                  #     window size and position is stored.
         
     | 
| 
      
 406 
     | 
    
         
            +
                  #   * <tt>:defaultextension</tt> - ??? (Don't change).
         
     | 
| 
      
 407 
     | 
    
         
            +
                  #   * <tt>:filetypes</tt> - (Array of Arrays) Filter for the file types
         
     | 
| 
      
 408 
     | 
    
         
            +
                  #     Format of the (inner) Arrays: 
         
     | 
| 
      
 409 
     | 
    
         
            +
                  #     * First element: (String) Name of the file type, e.g. 'Ruby files'
         
     | 
| 
      
 410 
     | 
    
         
            +
                  #     * Second element: (Array) List of extensions for the file type, e.g. ['.rb','.rbw']
         
     | 
| 
      
 411 
     | 
    
         
            +
                  #     * Third element: (String, optional) Mac file type(s), e.g. 'TEXT'
         
     | 
| 
      
 412 
     | 
    
         
            +
                  #     * Example:
         
     | 
| 
      
 413 
     | 
    
         
            +
                  #         filetypes = [
         
     | 
| 
      
 414 
     | 
    
         
            +
                  #           ['Text files',       ['.txt','.doc']          ],
         
     | 
| 
      
 415 
     | 
    
         
            +
                  #           ['Text files',       [],                      'TEXT' ],
         
     | 
| 
      
 416 
     | 
    
         
            +
                  #           ['Ruby Scripts',     ['.rb'],                 'TEXT' ],
         
     | 
| 
      
 417 
     | 
    
         
            +
                  #           ['Tcl Scripts',      ['.tcl'],                'TEXT' ],
         
     | 
| 
      
 418 
     | 
    
         
            +
                  #           ['C Source Files',   ['.c','.h']              ],
         
     | 
| 
      
 419 
     | 
    
         
            +
                  #           ['All Source Files', ['.rb','.tcl','.c','.h'] ],
         
     | 
| 
      
 420 
     | 
    
         
            +
                  #           ['Image Files',      ['.gif']                 ],
         
     | 
| 
      
 421 
     | 
    
         
            +
                  #           ['Image Files',      ['.jpeg','.jpg']         ],
         
     | 
| 
      
 422 
     | 
    
         
            +
                  #           ['Image Files',      [],                      ['GIFF','JPEG']],
         
     | 
| 
      
 423 
     | 
    
         
            +
                  #           ['All files',        '*'                      ]
         
     | 
| 
      
 424 
     | 
    
         
            +
                  #         ]
         
     | 
| 
      
 425 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 426 
     | 
    
         
            +
                  # *Returns:* (String) Paths of the chosen file;  +nil+, if 'Cancel' was clicked.
         
     | 
| 
      
 427 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 428 
     | 
    
         
            +
                  # *Example:*   
         
     | 
| 
      
 429 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 430 
     | 
    
         
            +
                  #    filetypes = [
         
     | 
| 
      
 431 
     | 
    
         
            +
                  #        ['Log Files', ['.log']],
         
     | 
| 
      
 432 
     | 
    
         
            +
                  #        ['All Files', '*']
         
     | 
| 
      
 433 
     | 
    
         
            +
                  #      ]
         
     | 
| 
      
 434 
     | 
    
         
            +
                  #   
         
     | 
| 
      
 435 
     | 
    
         
            +
                  #    ans = save_file('c:\Windows', :filetypes=>filetypes)
         
     | 
| 
      
 436 
     | 
    
         
            +
                  # 
         
     | 
| 
      
 437 
     | 
    
         
            +
                  # TODO: Does initialdir work?
         
     | 
| 
      
 438 
     | 
    
         
            +
                HERE
         
     | 
| 
      
 439 
     | 
    
         
            +
             
     | 
| 
      
 440 
     | 
    
         
            +
                filetypes = [
         
     | 
| 
      
 441 
     | 
    
         
            +
                    ['Text Files', ['.txt']],
         
     | 
| 
      
 442 
     | 
    
         
            +
                    ['All Files', '*']
         
     | 
| 
      
 443 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 444 
     | 
    
         
            +
             
     | 
| 
      
 445 
     | 
    
         
            +
                ans = save_file('c:\Windows', help, :initialfile=>'my_name', :filetypes=>filetypes)
         
     | 
| 
      
 446 
     | 
    
         
            +
             
     | 
| 
      
 447 
     | 
    
         
            +
                @outW.puts "save_file returned: #{ ans.inspect }"
         
     | 
| 
      
 448 
     | 
    
         
            +
                puts
         
     | 
| 
      
 449 
     | 
    
         
            +
                @outW.puts help
         
     | 
| 
      
 450 
     | 
    
         
            +
              end # explain_save_file
         
     | 
| 
      
 451 
     | 
    
         
            +
             
     | 
| 
      
 452 
     | 
    
         
            +
              
         
     | 
| 
      
 453 
     | 
    
         
            +
              def finish(  )
         
     | 
| 
      
 454 
     | 
    
         
            +
                @outW.puts( "\n\nFINISHED - Close by clicking the close-button ('X') on top of this window.")
         
     | 
| 
      
 455 
     | 
    
         
            +
              end # finish
         
     | 
| 
      
 456 
     | 
    
         
            +
              
         
     | 
| 
      
 457 
     | 
    
         
            +
             
     | 
| 
      
 458 
     | 
    
         
            +
              
         
     | 
| 
      
 459 
     | 
    
         
            +
              def run(  )
         
     | 
| 
      
 460 
     | 
    
         
            +
                explain_puts
         
     | 
| 
      
 461 
     | 
    
         
            +
                explain_window_size
         
     | 
| 
      
 462 
     | 
    
         
            +
                explain_ask_single_line
         
     | 
| 
      
 463 
     | 
    
         
            +
                explain_single_choice
         
     | 
| 
      
 464 
     | 
    
         
            +
                explain_multi_choice
         
     | 
| 
      
 465 
     | 
    
         
            +
                explain_choose_dir
         
     | 
| 
      
 466 
     | 
    
         
            +
                explain_open_files
         
     | 
| 
      
 467 
     | 
    
         
            +
                explain_open_file
         
     | 
| 
      
 468 
     | 
    
         
            +
                explain_save_file   
         
     | 
| 
      
 469 
     | 
    
         
            +
                finish          
         
     | 
| 
      
 470 
     | 
    
         
            +
             
     | 
| 
      
 471 
     | 
    
         
            +
             
     | 
| 
      
 472 
     | 
    
         
            +
                Tk.mainloop  # !!! IMPORTANT !!!
         
     | 
| 
      
 473 
     | 
    
         
            +
              end # run
         
     | 
| 
      
 474 
     | 
    
         
            +
             
     | 
| 
      
 475 
     | 
    
         
            +
            end # class MyTinyUI
         
     | 
| 
      
 476 
     | 
    
         
            +
             
     | 
| 
      
 477 
     | 
    
         
            +
            ##########################################################################
         
     | 
| 
      
 478 
     | 
    
         
            +
            ##########################################################################
         
     | 
| 
      
 479 
     | 
    
         
            +
            class String
         
     | 
| 
      
 480 
     | 
    
         
            +
              
         
     | 
| 
      
 481 
     | 
    
         
            +
              unless String.method_defined?(:margin)
         
     | 
| 
      
 482 
     | 
    
         
            +
                #################################
         
     | 
| 
      
 483 
     | 
    
         
            +
                # Provides a margin controlled string. 
         
     | 
| 
      
 484 
     | 
    
         
            +
                # 
         
     | 
| 
      
 485 
     | 
    
         
            +
                # From:  
         
     | 
| 
      
 486 
     | 
    
         
            +
                #   http://facets.rubyforge.org/
         
     | 
| 
      
 487 
     | 
    
         
            +
                # Example:
         
     | 
| 
      
 488 
     | 
    
         
            +
                #   x = %Q{
         
     | 
| 
      
 489 
     | 
    
         
            +
                #         aThis
         
     | 
| 
      
 490 
     | 
    
         
            +
                #         a     is
         
     | 
| 
      
 491 
     | 
    
         
            +
                #         a       margin controlled!
         
     | 
| 
      
 492 
     | 
    
         
            +
                #         }.margin
         
     | 
| 
      
 493 
     | 
    
         
            +
                # Result:
         
     | 
| 
      
 494 
     | 
    
         
            +
                #   This
         
     | 
| 
      
 495 
     | 
    
         
            +
                #        is
         
     | 
| 
      
 496 
     | 
    
         
            +
                #          margin controlled!
         
     | 
| 
      
 497 
     | 
    
         
            +
                #
         
     | 
| 
      
 498 
     | 
    
         
            +
                # Attributes:
         
     | 
| 
      
 499 
     | 
    
         
            +
                #   n: left margin
         
     | 
| 
      
 500 
     | 
    
         
            +
                #
         
     | 
| 
      
 501 
     | 
    
         
            +
                def margin(n=0)
         
     | 
| 
      
 502 
     | 
    
         
            +
                  d = /\A.*\n\s*(.)/.match( self )[1]
         
     | 
| 
      
 503 
     | 
    
         
            +
                  d = /\A\s*(.)/.match( self)[1] unless d
         
     | 
| 
      
 504 
     | 
    
         
            +
                  return '' unless d
         
     | 
| 
      
 505 
     | 
    
         
            +
                  if n == 0
         
     | 
| 
      
 506 
     | 
    
         
            +
                    gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, '')
         
     | 
| 
      
 507 
     | 
    
         
            +
                  else
         
     | 
| 
      
 508 
     | 
    
         
            +
                    gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, ' ' * n)
         
     | 
| 
      
 509 
     | 
    
         
            +
                  end
         
     | 
| 
      
 510 
     | 
    
         
            +
                end
         
     | 
| 
      
 511 
     | 
    
         
            +
              end # unless
         
     | 
| 
      
 512 
     | 
    
         
            +
             
     | 
| 
      
 513 
     | 
    
         
            +
            end # class String
         
     | 
| 
      
 514 
     | 
    
         
            +
             
     | 
| 
      
 515 
     | 
    
         
            +
             
     | 
| 
      
 516 
     | 
    
         
            +
             
     | 
| 
      
 517 
     | 
    
         
            +
            ##########################################################################
         
     | 
| 
      
 518 
     | 
    
         
            +
            ##########################################################################
         
     | 
| 
      
 519 
     | 
    
         
            +
            if $0 == __FILE__
         
     | 
| 
      
 520 
     | 
    
         
            +
              MyTinyUI.new
         
     | 
| 
      
 521 
     | 
    
         
            +
            end
         
     |