tkxxs 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,208 +1,208 @@
1
- #
2
- # tkballoonhelp.rb : simple balloon help widget
3
- # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4
- #
5
- # Add a balloon help to a widget.
6
- # This widget has only poor featureas. If you need more useful features,
7
- # please try to use the Tix extension of Tcl/Tk under Ruby/Tk.
8
- #
9
- # The interval time to display a balloon help is defined 'interval' option
10
- # (default is 750ms).
11
- #
12
- require 'tk'
13
-
14
- module Tk
15
- module RbWidget
16
- class BalloonHelp<TkLabel
17
- end
18
- end
19
- end
20
- class Tk::RbWidget::BalloonHelp<TkLabel
21
- DEFAULT_FOREGROUND = 'black'
22
- DEFAULT_BACKGROUND = 'white'
23
- DEFAULT_INTERVAL = 750
24
-
25
- def _balloon_binding(interval)
26
- @timer = TkAfter.new(interval, 1, proc{show})
27
- def @timer.interval(val)
28
- @sleep_time = val
29
- end
30
- @bindtag = TkBindTag.new
31
- @bindtag.bind('Enter', proc{@timer.start})
32
- @bindtag.bind('Motion', proc{@timer.restart; erase})
33
- @bindtag.bind('Any-ButtonPress', proc{@timer.restart; erase})
34
- @bindtag.bind('Leave', proc{@timer.stop; erase})
35
- tags = @parent.bindtags
36
- idx = tags.index(@parent)
37
- unless idx
38
- ppath = TkComm.window(@parent.path)
39
- idx = tags.index(ppath) || 0
40
- end
41
- tags[idx,0] = @bindtag
42
- @parent.bindtags(tags)
43
- end
44
- private :_balloon_binding
45
-
46
- def initialize(parent=nil, keys={})
47
- @parent = parent || Tk.root
48
-
49
- @frame = TkToplevel.new(@parent)
50
- @frame.withdraw
51
- @frame.overrideredirect(true)
52
- @frame.transient(TkWinfo.toplevel(@parent))
53
- @epath = @frame.path
54
-
55
- if keys
56
- keys = _symbolkey2str(keys)
57
- else
58
- keys = {}
59
- end
60
-
61
- @command = keys.delete('command')
62
-
63
- @interval = keys.delete('interval'){DEFAULT_INTERVAL}
64
- _balloon_binding(@interval)
65
-
66
- # @label = TkLabel.new(@frame, 'background'=>'bisque').pack
67
- @label = TkLabel.new(@frame,
68
- 'foreground'=>DEFAULT_FOREGROUND,
69
- 'background'=>DEFAULT_BACKGROUND).pack
70
- @label.configure(_symbolkey2str(keys)) unless keys.empty?
71
- @path = @label
72
- end
73
-
74
- def epath
75
- @epath
76
- end
77
-
78
- def interval(val)
79
- if val
80
- @timer.interval(val)
81
- else
82
- @interval
83
- end
84
- end
85
-
86
- def command(cmd = Proc.new)
87
- @command = cmd
88
- self
89
- end
90
-
91
- def show
92
- x = TkWinfo.pointerx(@parent)
93
- y = TkWinfo.pointery(@parent)
94
- @frame.geometry("+#{x+1}+#{y+1}")
95
-
96
- if @command
97
- case @command.arity
98
- when 0
99
- @command.call
100
- when 2
101
- @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent))
102
- when 3
103
- @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent),
104
- self)
105
- else
106
- @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent),
107
- self, @parent)
108
- end
109
- end
110
-
111
- @frame.deiconify
112
- @frame.raise
113
-
114
- @org_cursor = @parent['cursor']
115
- @parent.cursor('crosshair')
116
- end
117
-
118
- def erase
119
- @parent.cursor(@org_cursor)
120
- @frame.withdraw
121
- end
122
-
123
- def destroy
124
- @frame.destroy
125
- end
126
- end
127
-
128
- ################################################
129
- # test
130
- ################################################
131
- if __FILE__ == $0
132
- TkButton.new('text'=>'This button has a balloon help') {|b|
133
- pack('fill'=>'x')
134
- Tk::RbWidget::BalloonHelp.new(b, 'text'=>' Message ')
135
- }
136
- TkButton.new('text'=>'This button has another balloon help') {|b|
137
- pack('fill'=>'x')
138
- Tk::RbWidget::BalloonHelp.new(b,
139
- 'text'=>"CONFIGURED MESSAGE\nchange colors, and so on",
140
- 'interval'=>200, 'font'=>'courier',
141
- 'background'=>'gray', 'foreground'=>'red')
142
- }
143
-
144
- sb = TkScrollbox.new.pack(:fill=>:x)
145
- sb.insert(:end, *%w(aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm))
146
- =begin
147
- # CASE1 : command takes no arguemnt
148
- bh = Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
149
- :relief=>:ridge, :background=>'white',
150
- :command=>proc{
151
- y = TkWinfo.pointery(sb) - TkWinfo.rooty(sb)
152
- bh.text "current index == #{sb.nearest(y)}"
153
- })
154
- =end
155
- =begin
156
- # CASE2 : command takes 2 arguemnts
157
- bh = Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
158
- :relief=>:ridge, :background=>'white',
159
- :command=>proc{|x, y|
160
- bh.text "current index == #{sb.nearest(y)}"
161
- })
162
- =end
163
- =begin
164
- # CASE3 : command takes 3 arguemnts
165
- Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
166
- :relief=>:ridge, :background=>'white',
167
- :command=>proc{|x, y, bhelp|
168
- bhelp.text "current index == #{sb.nearest(y)}"
169
- })
170
- =end
171
- =begin
172
- # CASE4a : command is a Proc object and takes 4 arguemnts
173
- cmd = proc{|x, y, bhelp, parent|
174
- bhelp.text "current index == #{parent.nearest(y)}"
175
- }
176
-
177
- Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
178
- :relief=>:ridge, :background=>'white',
179
- :command=>cmd)
180
-
181
- sb2 = TkScrollbox.new.pack(:fill=>:x)
182
- sb2.insert(:end, *%w(AAA BBB CCC DDD EEE FFF GGG HHH III JJJ KKK LLL MMM))
183
- Tk::RbWidget::BalloonHelp.new(sb2, :interval=>500,
184
- :padx=>5, :relief=>:raised,
185
- :background=>'gray25', :foreground=>'white',
186
- :command=>cmd)
187
- =end
188
- #=begin
189
- # CASE4b : command is a Method object and takes 4 arguemnts
190
- def set_msg(x, y, bhelp, parent)
191
- bhelp.text "current index == #{parent.nearest(y)}"
192
- end
193
- cmd = self.method(:set_msg)
194
-
195
- Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
196
- :relief=>:ridge, :background=>'white',
197
- :command=>cmd)
198
-
199
- sb2 = TkScrollbox.new.pack(:fill=>:x)
200
- sb2.insert(:end, *%w(AAA BBB CCC DDD EEE FFF GGG HHH III JJJ KKK LLL MMM))
201
- Tk::RbWidget::BalloonHelp.new(sb2, :interval=>500,
202
- :padx=>5, :relief=>:raised,
203
- :background=>'gray25', :foreground=>'white',
204
- :command=>cmd)
205
- #=end
206
-
207
- Tk.mainloop
208
- end
1
+ #
2
+ # tkballoonhelp.rb : simple balloon help widget
3
+ # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4
+ #
5
+ # Add a balloon help to a widget.
6
+ # This widget has only poor featureas. If you need more useful features,
7
+ # please try to use the Tix extension of Tcl/Tk under Ruby/Tk.
8
+ #
9
+ # The interval time to display a balloon help is defined 'interval' option
10
+ # (default is 750ms).
11
+ #
12
+ require 'tk'
13
+
14
+ module Tk
15
+ module RbWidget
16
+ class BalloonHelp<TkLabel
17
+ end
18
+ end
19
+ end
20
+ class Tk::RbWidget::BalloonHelp<TkLabel
21
+ DEFAULT_FOREGROUND = 'black'
22
+ DEFAULT_BACKGROUND = 'white'
23
+ DEFAULT_INTERVAL = 750
24
+
25
+ def _balloon_binding(interval)
26
+ @timer = TkAfter.new(interval, 1, proc{show})
27
+ def @timer.interval(val)
28
+ @sleep_time = val
29
+ end
30
+ @bindtag = TkBindTag.new
31
+ @bindtag.bind('Enter', proc{@timer.start})
32
+ @bindtag.bind('Motion', proc{@timer.restart; erase})
33
+ @bindtag.bind('Any-ButtonPress', proc{@timer.restart; erase})
34
+ @bindtag.bind('Leave', proc{@timer.stop; erase})
35
+ tags = @parent.bindtags
36
+ idx = tags.index(@parent)
37
+ unless idx
38
+ ppath = TkComm.window(@parent.path)
39
+ idx = tags.index(ppath) || 0
40
+ end
41
+ tags[idx,0] = @bindtag
42
+ @parent.bindtags(tags)
43
+ end
44
+ private :_balloon_binding
45
+
46
+ def initialize(parent=nil, keys={})
47
+ @parent = parent || Tk.root
48
+
49
+ @frame = TkToplevel.new(@parent)
50
+ @frame.withdraw
51
+ @frame.overrideredirect(true)
52
+ @frame.transient(TkWinfo.toplevel(@parent))
53
+ @epath = @frame.path
54
+
55
+ if keys
56
+ keys = _symbolkey2str(keys)
57
+ else
58
+ keys = {}
59
+ end
60
+
61
+ @command = keys.delete('command')
62
+
63
+ @interval = keys.delete('interval'){DEFAULT_INTERVAL}
64
+ _balloon_binding(@interval)
65
+
66
+ # @label = TkLabel.new(@frame, 'background'=>'bisque').pack
67
+ @label = TkLabel.new(@frame,
68
+ 'foreground'=>DEFAULT_FOREGROUND,
69
+ 'background'=>DEFAULT_BACKGROUND).pack
70
+ @label.configure(_symbolkey2str(keys)) unless keys.empty?
71
+ @path = @label
72
+ end
73
+
74
+ def epath
75
+ @epath
76
+ end
77
+
78
+ def interval(val)
79
+ if val
80
+ @timer.interval(val)
81
+ else
82
+ @interval
83
+ end
84
+ end
85
+
86
+ def command(cmd = Proc.new)
87
+ @command = cmd
88
+ self
89
+ end
90
+
91
+ def show
92
+ x = TkWinfo.pointerx(@parent)
93
+ y = TkWinfo.pointery(@parent)
94
+ @frame.geometry("+#{x+1}+#{y+1}")
95
+
96
+ if @command
97
+ case @command.arity
98
+ when 0
99
+ @command.call
100
+ when 2
101
+ @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent))
102
+ when 3
103
+ @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent),
104
+ self)
105
+ else
106
+ @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent),
107
+ self, @parent)
108
+ end
109
+ end
110
+
111
+ @frame.deiconify
112
+ @frame.raise
113
+
114
+ @org_cursor = @parent['cursor']
115
+ @parent.cursor('crosshair')
116
+ end
117
+
118
+ def erase
119
+ @parent.cursor(@org_cursor)
120
+ @frame.withdraw
121
+ end
122
+
123
+ def destroy
124
+ @frame.destroy
125
+ end
126
+ end
127
+
128
+ ################################################
129
+ # test
130
+ ################################################
131
+ if __FILE__ == $0
132
+ TkButton.new('text'=>'This button has a balloon help') {|b|
133
+ pack('fill'=>'x')
134
+ Tk::RbWidget::BalloonHelp.new(b, 'text'=>' Message ')
135
+ }
136
+ TkButton.new('text'=>'This button has another balloon help') {|b|
137
+ pack('fill'=>'x')
138
+ Tk::RbWidget::BalloonHelp.new(b,
139
+ 'text'=>"CONFIGURED MESSAGE\nchange colors, and so on",
140
+ 'interval'=>200, 'font'=>'courier',
141
+ 'background'=>'gray', 'foreground'=>'red')
142
+ }
143
+
144
+ sb = TkScrollbox.new.pack(:fill=>:x)
145
+ sb.insert(:end, *%w(aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm))
146
+ =begin
147
+ # CASE1 : command takes no arguemnt
148
+ bh = Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
149
+ :relief=>:ridge, :background=>'white',
150
+ :command=>proc{
151
+ y = TkWinfo.pointery(sb) - TkWinfo.rooty(sb)
152
+ bh.text "current index == #{sb.nearest(y)}"
153
+ })
154
+ =end
155
+ =begin
156
+ # CASE2 : command takes 2 arguemnts
157
+ bh = Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
158
+ :relief=>:ridge, :background=>'white',
159
+ :command=>proc{|x, y|
160
+ bh.text "current index == #{sb.nearest(y)}"
161
+ })
162
+ =end
163
+ =begin
164
+ # CASE3 : command takes 3 arguemnts
165
+ Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
166
+ :relief=>:ridge, :background=>'white',
167
+ :command=>proc{|x, y, bhelp|
168
+ bhelp.text "current index == #{sb.nearest(y)}"
169
+ })
170
+ =end
171
+ =begin
172
+ # CASE4a : command is a Proc object and takes 4 arguemnts
173
+ cmd = proc{|x, y, bhelp, parent|
174
+ bhelp.text "current index == #{parent.nearest(y)}"
175
+ }
176
+
177
+ Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
178
+ :relief=>:ridge, :background=>'white',
179
+ :command=>cmd)
180
+
181
+ sb2 = TkScrollbox.new.pack(:fill=>:x)
182
+ sb2.insert(:end, *%w(AAA BBB CCC DDD EEE FFF GGG HHH III JJJ KKK LLL MMM))
183
+ Tk::RbWidget::BalloonHelp.new(sb2, :interval=>500,
184
+ :padx=>5, :relief=>:raised,
185
+ :background=>'gray25', :foreground=>'white',
186
+ :command=>cmd)
187
+ =end
188
+ #=begin
189
+ # CASE4b : command is a Method object and takes 4 arguemnts
190
+ def set_msg(x, y, bhelp, parent)
191
+ bhelp.text "current index == #{parent.nearest(y)}"
192
+ end
193
+ cmd = self.method(:set_msg)
194
+
195
+ Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
196
+ :relief=>:ridge, :background=>'white',
197
+ :command=>cmd)
198
+
199
+ sb2 = TkScrollbox.new.pack(:fill=>:x)
200
+ sb2.insert(:end, *%w(AAA BBB CCC DDD EEE FFF GGG HHH III JJJ KKK LLL MMM))
201
+ Tk::RbWidget::BalloonHelp.new(sb2, :interval=>500,
202
+ :padx=>5, :relief=>:raised,
203
+ :background=>'gray25', :foreground=>'white',
204
+ :command=>cmd)
205
+ #=end
206
+
207
+ Tk.mainloop
208
+ end
@@ -1,708 +1,710 @@
1
- # encoding: Windows-1252 :encoding=Windows-1252:
2
- # Copyright (c) 2010-2014 Axel Friedrich
3
-
4
- $stdout.sync = true
5
- $stderr.sync = true
6
- STDOUT.sync = true
7
- STDERR.sync = true
8
- DIR_OF_TKXXS = File.dirname( File.expand_path( __FILE__ ) ).gsub('\\', '/')
9
- $: << DIR_OF_TKXXS
10
- $:.uniq!
11
- $FILE_SEP = File::ALT_SEPARATOR || File::SEPARATOR
12
-
13
- require 'tkxxs/conf'
14
- require 'tk'
15
- require 'tkextlib/tile'
16
- require( File.dirname(DIR_OF_TKXXS) + '/ext/tkballoonhelp.rb' )
17
- ##/ ##require 'tkrbwidget/tkballoonhelp/tkballoonhelp.rb'
18
- ##/ ##require 'ext/tkballoonhelp/tkballoonhelp.rb'
19
- ##/ if $0 == __FILE__
20
- ##/ ##/ require 'ext/conf/conf'
21
- ##/ require 'axel/conf'
22
- CONF = Conf.new unless defined?(CONF)
23
- STDOUT.puts "CONFIG-FILENAME is: #{ CONF.filename.gsub('/',$FILE_SEP) }"
24
- ##/ end
25
- require 'Platform' unless defined?(Platform::OS)
26
- require 'tkxxs/version'
27
- require 'tkxxs/tkxxs_classes'
28
-
29
- ##########################################################################
30
- ##########################################################################
31
- module TKXXS
32
- include Tk::RbWidget
33
- include Tk::Tile
34
- $tkxxs_ = Hash.new unless defined?( $tkxxs_ )
35
- CONF[:recentDirsSize] = CONF[:recentDirsSize] || 100
36
- CONF[:recentFilesSize] = CONF[:recentFilesSize] || 100
37
-
38
- ##########################################################################
39
- ##########################################################################
40
- #
41
- class Tk::RbWidget::BalloonHelp # :nodoc:
42
-
43
- alias :orig_initialize :initialize
44
-
45
- ##################################################################
46
- # Setting defaults
47
- def initialize( parent=nil, keys={} )
48
- keys = {
49
- :interval=>300, # ms
50
- :background=>'LightYellow',
51
- :relief=>:ridge, :justify=>:left,
52
- }.merge(keys)
53
- orig_initialize(parent, keys)
54
- end # initialize
55
-
56
- end # class Tk::RbWidget::BalloonHelp
57
-
58
- ##########################################################################
59
- ##########################################################################
60
- # You create an Output Window like this:
61
- # @outW = OutW.new
62
- # You can write to the Output Window like this:
63
- # @outW.puts "Hallo"
64
- # OR, you can redirect stdout to @outW:
65
- # $stdout = @outW
66
- # Then you can simply write:
67
- # puts "Hallo"
68
- # to write to the Output Window.
69
- # This means, if you have an existing application which uses +puts+
70
- # to write to the console, you can easily make it to write to the
71
- # Output Window!
72
- # BUT: Unfortunately, this is not compatible with OCRA (as of 2013-12).
73
- # When you want to use OCRA, you cannot use this redirection of stdout.
74
- class OutW < TKXXS_CLASSES::TextW
75
- CONF = nil unless defined?(CONF)
76
-
77
- def initialize( hash={} )
78
- @alive = true
79
- teardownDone = false
80
- at_exit { self.destroy }
81
-
82
- #---- Root
83
- img = TkPhotoImage.new(:file=>"#{ DIR_OF_TKXXS }/icon.gif")
84
- @root = TkRoot.new(:iconphoto_default=>img )
85
-
86
- userscreen(@root) unless $tkxxs_[:userscreenx]
87
- if CONF
88
- @root.geometry =
89
- CONF.or_default( :outWGeom, '400x300+100+0' )
90
- end
91
- #---- Root-bindings
92
- @root.bind('Destroy') {
93
- unless teardownDone
94
- notify_dying
95
- if CONF
96
- CONF[:outWGeom] = @root.geometry
97
- STDOUT.puts "Saving config to #{ CONF.filename.gsub('/', $FILE_SEP) }"
98
- CONF.save
99
- end
100
- teardownDone = true
101
- end # unless
102
- }
103
-
104
- #---- TopFrame
105
- top = Frame.new.pack(:expand=>true, :fill=>:both)
106
-
107
- #---- outWindow
108
- ##/ @outW = TextW.new(top)
109
- super(top, hash)
110
- @tagH2 = TkTextTag.new(self, :font=>"Courier 14 bold")
111
- @tagSel = TkTextTagSel.new(self)
112
- bind('Control-Key-a') {
113
- # From:
114
- # "Using Control-a to select all text in a text widget : TCL",
115
- # http://objectmix.com/tcl/35276-using-control-select-all-text-text-widget.html
116
- @tagSel.add('0.0', :end)
117
- Kernel.raise TkCallbackBreak
118
- }
119
-
120
- end # initialize
121
-
122
- ##################################################################
123
- # Like Kernel::puts. Write a String to the Output Window.
124
- def puts( *args )
125
- args = args.join("\n") if args.class == Array
126
- str = args.chomp("\n") + "\n"
127
- self.insert(:end, str)
128
- self.see :end
129
- ##/ self.update # N�tig?
130
- end # puts
131
-
132
- ##################################################################
133
- # puts, formated as heading level 2
134
- def puts_h2( str )
135
- self.insert(:end, "\n" + str.chomp("\n") + "\n", @tagH2)
136
- end # puts_h2
137
-
138
- ##################################################################
139
- # Like Kernel::print. Print a String to the Output Window.
140
- def print( *args )
141
- if args.class == Array
142
- args.map! {|a| a.to_s }
143
- args = args.join(" ")
144
- end
145
- str = args.chomp("\n") + "\n"
146
- self.insert('end', str)
147
- self.see :end
148
- ##/ self.update # N�tig?
149
- end # print
150
-
151
- # TODO def p()
152
-
153
- # :nodoc:
154
- def write( str )
155
- ##self.insert(:end, "\n" + str)
156
- self.insert(:end, str)
157
- self.see :end
158
- ##/ self.update # N�tig?
159
- end # write
160
-
161
- ##########################################################################
162
- # :nodoc:
163
- # Does nothing, just for compatibility
164
- def sync=( x )
165
- # nothing to do
166
- end # sync=
167
-
168
- # :nodoc:
169
- def flush
170
- self.update
171
- end #
172
-
173
- # :nodoc:
174
- def tty?( )
175
- false
176
- end # tty?
177
-
178
-
179
- # :nodoc:
180
- def private____________________________( )
181
- end # private____________________________
182
-
183
- ##################################################################
184
- # "private"
185
- def userscreen( root )
186
- if Platform::OS == :win32
187
- root.state('zoomed') # OK on Windows
188
- ##/ root.wm_state('zoomed') # OK on Windows
189
- ##/ root.wm_zoomed # method missing
190
- ##/ root.wm_attributes('zoomed')
191
- ##/ root.wm_maximized # method missing
192
- else
193
- # Linux: works
194
- # Other: not tested
195
- root.height = root.winfo_screenheight
196
- root.width = root.winfo_screenwidth
197
- end
198
- root.update
199
-
200
- root.winfo_geometry =~ /(\d+)x(\d+)\+([+-]?\d+)\+([+-]?\d+)/
201
- xwg = $3.to_i
202
- ywg = $4.to_i
203
- root.geometry =~ /(\d+)x(\d+)\+([+-]?\d+)\+([+-]?\d+)/
204
- gw = $1.to_i
205
- gh = $2.to_i
206
-
207
- ## sw = root.winfo_screenwidth
208
- ## sh = root.winfo_screenheight
209
-
210
- rx = root.winfo_rootx
211
- ry = root.winfo_rooty # maybe, taskbar height
212
-
213
- border = -[xwg,ywg].min
214
- userscreenx = xwg + border
215
- userscreeny= ywg + border
216
- userscreenwidth = gw
217
- userscreenheight = gh + ry - ywg - border
218
-
219
- $tkxxs_[:userscreenx ] = userscreenx
220
- $tkxxs_[:userscreeny ] = userscreeny
221
- $tkxxs_[:userscreenwidth ] = userscreenwidth
222
- $tkxxs_[:userscreenheight] = userscreenheight
223
-
224
- root.state('normal')
225
- nil
226
- end # userscreen
227
-
228
- ##################################################################
229
- # "private"
230
- def notify_dying( )
231
- @alive = false
232
- end # notify_dying
233
-
234
- ##################################################################
235
- # "private"
236
- def alive?( )
237
- @alive
238
- end # alive?
239
- end # class OutW
240
-
241
- ##################################################################
242
- ##################################################################
243
- # Depreciated (replaced by OutW).
244
- class LogW < OutW # :nodoc:
245
- end
246
-
247
- ##########################################################################
248
- ##########################################################################
249
- def messageBoxExamples
250
- # TODO: Is this usefull?
251
- ##################################################################
252
- # :type: :abortretryignore, :ok, :okcancel, :retrycancel, :yesno, :yesnocancel
253
- # :icon: :error, :info, :question or :warning (default: info)
254
- # :detail: Specifies an auxiliary message to the main message given by
255
- # the -message option. Where supported by the underlying OS, the
256
- # message detail will be presented in a less emphasized font than the
257
- # main message.
258
- # Returns: A String describing the pressed button ("ok", "cancel", "retry", "ignore", ...)
259
- # Balloonhelp funktioniert damit nicht (oder?).
260
- #
261
- ans = Tk.messageBox( :type=>:yesno,:icon=>:question,
262
- :title=>"Next",
263
- :message=>"xxx",
264
- :detail=>"xxx"
265
- )
266
- #
267
- # puts sprintf("--DEBUG: button: %1s ", button.inspect) #loe
268
- end # class MessageBoxExamples
269
-
270
- ##########################################################################
271
- # ask_single_line(question=nil, help=nil, hash=nil)
272
- #
273
- # Ask for a single line of text.
274
- #
275
- # *Params*:
276
- # * +question+ - (String, optional) Your question; +nil+ => Default question
277
- # * +help+ - (String, optional) Text used in the BalloonHelp; +nil+ => No help text
278
- # * +hash+ - (Hash, optional)
279
- # * <tt>:question</tt> - Like above.
280
- # * <tt>:help</tt> - Like above.
281
- # * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
282
- # important. Sets the section in the config-file, where for example the
283
- # window size and position is stored.
284
- # * <tt>:defaultEntry</tt> - (String) Default answer.
285
- #
286
- # *Returns*: (String or nil) The answer of the dialog. 'Cancel' returns nil.
287
- #
288
- # *Example:*
289
- # help = "This dialog is named 'ask_single_line'"
290
- # ans = ask_single_line(
291
- # "Want to know more?\nPoint with the mouse to the entry field!",
292
- # help,
293
- # :defaultEntry =>"Of course"
294
- # )
295
- def ask_single_line( *args )
296
- TKXXS_CLASSES::AskSingleLineD.new(*args).answer
297
- end # ask_single_line
298
-
299
- ##################################################################
300
- # single_choice( aryWithChoices, help=nil, hash=nil )
301
- #
302
- # *Params*:
303
- # * +aryWithChoices+ - (Array) one of the following formats:
304
- # * [ choiceStrA, choiceStrB, ...]
305
- # * [ [choiceStrA,objectA], [choiceStrB,objectB], ... ]
306
- # * [ [choiceStrA,objectA,helpStrA], [choiceStrB,objectB,helpStrB], ...]
307
- # Quite usefull: a Proc for object.
308
- # * +help+ - (String, optional) Array, with one help-String for each choice element!; +nil+ => No help text
309
- # * +hash+ - (Hash, optional)
310
- # * <tt>:question</tt> - Like above.
311
- # * <tt>:help</tt> - Like above.
312
- # * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
313
- # important. Sets the section in the config-file, where for example the
314
- # window size and position is stored.
315
- # * <tt>:title</tt> - (String) Title of the dialog window
316
- # * <tt>:bd</tt> - (Number as String) ?
317
- # * <tt>:searchFieldHelp</tt> - (String) Ballon help of the search field,
318
- # * <tt>:returnChoiceAndClient</tt> - returns the right side (+false+) or both sides (+true+) of +aryWithChoices+.
319
- #
320
- # *Returns:*
321
- # * The chosen right sides of +aryWithChoices+ if :returnChoiceAndClient == +false+ (default),
322
- # * An Array of the chosen right and left side of +aryWithChoices+ if :returnChoiceAndClient == +true+,
323
- # * +nil+, if 'Cancel' was clicked.
324
- #
325
- # *Example:*
326
- # help = ['Help #1', 'Help #2', 'Help #3']
327
- # ans = single_choice(
328
- # [
329
- # [ "You want 1?", 1],
330
- # [ "You want 2?", 2],
331
- # [ "You want 3?", 3],
332
- # ],
333
- # help
334
- # )
335
- #
336
- # *TODO:* Choice-search field: � (&auml;) does not work?
337
- def single_choice( *args )
338
- TKXXS_CLASSES::SingleChoiceD.new(*args).answer
339
- end # single_choice
340
-
341
- ##################################################################
342
- # multi_choice( aryWithChoices, help=nil, hash=nil )
343
- #
344
- # *Params*:
345
- # * +aryWithChoices+ - (Array) one of the following formats:
346
- # * [ choiceStrA, choiceStrB, ...]
347
- # * [ [choiceStrA,objectA], [choiceStrB,objectB], ... ]
348
- # * [ [choiceStrA,objectA,helpStrA], [choiceStrB,objectB,helpStrB], ...]
349
- # Quite usefull: a Proc for object.
350
- # * +help+ - (String, optional) Array, with one help-String for each choice element!; +nil+ => No help text
351
- # * +hash+ - (Hash, optional)
352
- # * <tt>:question</tt> - Like above.
353
- # * <tt>:help</tt> - Like above.
354
- # * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
355
- # important. Sets the section in the config-file, where for example the
356
- # window size and position is stored.
357
- # * <tt>:title</tt> - (String) Title of the dialog window
358
- # * <tt>:bd</tt> - (Number as String) ?
359
- # * <tt>:selectmode => :multiple</tt> - Obsolet?
360
- # * <tt>:searchFieldHelp</tt> - (String) Ballon help of the search field, searchField not implemented yet
361
- # * <tt>:returnChoiceAndClient</tt> - returns the right side (+false+) or both sides (+true+) of +aryWithChoices+.
362
- #
363
- # *Returns:*
364
- # * An Array of the chosen right sides of +aryWithChoices+ if :returnChoiceAndClient == +false+ (default),
365
- # * An Array of the chosen right and left sides of +aryWithChoices+ if :returnChoiceAndClient == +true+,
366
- # * +nil+, if 'Cancel' was clicked.
367
- #
368
- # *Example:*
369
- # help = ['Help #1', 'Help #2', 'Help #3']
370
- # ans = single_choice(
371
- # [
372
- # [ "You want 1?", 1],
373
- # [ "You want 2?", 2],
374
- # [ "You want 3?", 3],
375
- # ],
376
- # help
377
- # )
378
- def multi_choice( *args )
379
- TKXXS_CLASSES::MultiChoiceD.new(*args).answer
380
- end # multi_choice
381
-
382
- ##########################################################################
383
- # choose_dir( initialdir=nil,help=nil,hash=nil )
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>:mode</tt> - Don't modify this!
394
- # * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
395
- # * <tt>:title</tt> - (String) Title of the dialog window.
396
- # * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field.
397
- # * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
398
- # must be chosen, canceling the dialog is not possible.
399
- # * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
400
- # important. Sets the section in the config-file, where for example the
401
- # window size and position is stored.
402
- #
403
- # *Returns:* (String) Path of the chosen dir; +nil+, if 'Cancel' was clicked.
404
- #
405
- # *Example:*
406
- #
407
- # help = "Pick a dir."
408
- # ans = choose_dir(
409
- # 'c:\WinDows',
410
- # help,
411
- # :validate=>true,
412
- # :defaultEntry=>'c:/windows/system'
413
- # )
414
- #
415
- # *TODO:* How to choose multiple dirs or even dirs & files?
416
- def choose_dir( *args ) # initialdir
417
- TKXXS_CLASSES::ChooseDirD.new(*args).answer
418
- end # choose_dir
419
-
420
- ##########################################################################
421
- # open_files( initialdir=nil,help=nil,hash=nil )
422
- #
423
- # To get this dialog explain, run the example and point the mouse
424
- # at each button.
425
- #
426
- # *Params*:
427
- # * +initialdir+ - (String, optional) Initial dir; default = +nil+
428
- # -> Working dir at the time of calling this method.
429
- # * +help+ - (String, optional) ; Text used in the BalloonHelp;
430
- # default = +nil+ -> No help.
431
- # * +hash+ - (Hash, optional)
432
- # * <tt>:initialdir</tt> - Like above.
433
- # * <tt>:help</tt> - Like above.
434
- # * <tt>:mode</tt> - Don't change this!
435
- # * <tt>:multiple</tt> - Don't change this!
436
- # * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
437
- # * <tt>:title</tt> - (String) Title of the dialog window.
438
- # * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field.
439
- # * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
440
- # must be chosen, canceling the dialog is not possible.
441
- # * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
442
- # important. Sets the section in the config-file, where for example the
443
- # window size and position is stored.
444
- # * <tt>:filetypes</tt> - (Array of Arrays) Filter for the file types
445
- # Format of the (inner) Arrays:
446
- # * First element: (String) Name of the file type, e.g. 'Ruby files'
447
- # * Second element: (Array) List of extensions for the file type, e.g. ['.rb','.rbw']
448
- # * Third element: (String, optional) Mac file type(s), e.g. 'TEXT'
449
- # * Example:
450
- # filetypes = [
451
- # ['Text files', ['.txt','.doc'] ],
452
- # ['Text files', [], 'TEXT' ],
453
- # ['Ruby Scripts', ['.rb'], 'TEXT' ],
454
- # ['Tcl Scripts', ['.tcl'], 'TEXT' ],
455
- # ['C Source Files', ['.c','.h'] ],
456
- # ['All Source Files', ['.rb','.tcl','.c','.h'] ],
457
- # ['Image Files', ['.gif'] ],
458
- # ['Image Files', ['.jpeg','.jpg'] ],
459
- # ['Image Files', [], ['GIFF','JPEG']],
460
- # ['All files', '*' ]
461
- # ]
462
- # *Returns:* (Array) Paths of the chosen files; +nil+, if 'Cancel' was clicked.
463
- #
464
- # *Example:*
465
- #
466
- # filetypes = [
467
- # ['Log Files', ['.log']],
468
- # ['All Files', '*']
469
- # ]
470
- #
471
- # ans = open_files('c:\Windows', :filetypes=>filetypes)
472
- #
473
- # *TODO:* When using "Recent"-Button > "Files" or "Favorite"-Button >
474
- # "Files" you can choose only one from Recent and none from, for
475
- # example "Browse"; should be multiple.
476
- def open_files( *args )
477
- TKXXS_CLASSES::OpenFilesD.new(*args).answer
478
- end # open_files
479
-
480
- ##################################################################
481
- # open_file( initialdir=nil,help=nil,hash=nil )
482
- #
483
- # To get this dialog explain, run the example and point the mouse
484
- # at each button.
485
- #
486
- # *Params*:
487
- # * +initialdir+ - (String, optional) Initial dir; default = +nil+
488
- # -> Working dir at the time of calling this method.
489
- # * +help+ - (String, optional) ; Text used in the BalloonHelp;
490
- # default = +nil+ -> No help.
491
- # * +hash+ - (Hash, optional)
492
- # * <tt>:initialdir</tt> - Like above.
493
- # * <tt>:help</tt> - Like above.
494
- # * <tt>:mode</tt> - Don't change this!
495
- # * <tt>:multiple</tt> - Don't change this!
496
- # * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
497
- # * <tt>:title</tt> - (String) Title of the dialog window.
498
- # * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field.
499
- # * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
500
- # must be chosen, canceling the dialog is not possible.
501
- # * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
502
- # important. Sets the section in the config-file, where for example the
503
- # window size and position is stored.
504
- # * <tt>:filetypes</tt> - (Array of Arrays) Filter for the file types
505
- # Format of the (inner) Arrays:
506
- # * First element: (String) Name of the file type, e.g. 'Ruby files'
507
- # * Second element: (Array) List of extensions for the file type, e.g. ['.rb','.rbw']
508
- # * Third element: (String, optional) Mac file type(s), e.g. 'TEXT'
509
- # * Example:
510
- # filetypes = [
511
- # ['Text files', ['.txt','.doc'] ],
512
- # ['Text files', [], 'TEXT' ],
513
- # ['Ruby Scripts', ['.rb'], 'TEXT' ],
514
- # ['Tcl Scripts', ['.tcl'], 'TEXT' ],
515
- # ['C Source Files', ['.c','.h'] ],
516
- # ['All Source Files', ['.rb','.tcl','.c','.h'] ],
517
- # ['Image Files', ['.gif'] ],
518
- # ['Image Files', ['.jpeg','.jpg'] ],
519
- # ['Image Files', [], ['GIFF','JPEG']],
520
- # ['All files', '*' ]
521
- # ]
522
- # *Returns:* (Array) Paths of the chosen files; +nil+, if 'Cancel' was clicked.
523
- #
524
- # *Example:*
525
- #
526
- # filetypes = [
527
- # ['Log Files', ['.log']],
528
- # ['All Files', '*']
529
- # ]
530
- #
531
- # ans = open_file('c:\Windows', :filetypes=>filetypes)
532
- #
533
- # *TODO:* Does initialdir work?
534
- def open_file( *args )
535
- TKXXS_CLASSES::OpenFileD.new(*args).answer
536
- end # open_file
537
-
538
- ##################################################################
539
- # save_file( initialdir=nil,help=nil,hash=nil )
540
- #
541
- # To get this dialog explain, run the example and point the mouse
542
- # at each button.
543
- #
544
- # *Params*:
545
- # * +initialdir+ - (String, optional) Initial dir; default = +nil+
546
- # -> Working dir at the time of calling this method.
547
- # * +help+ - (String, optional) ; Text used in the BalloonHelp;
548
- # default = +nil+ -> No help.
549
- # * +hash+ - (Hash, optional)
550
- # * <tt>:initialdir</tt> - Like above.
551
- # * <tt>:help</tt> - Like above.
552
- # * <tt>:initialfile</tt> - (String) Default filename, extension
553
- # will be added automatically by filetypes-setting; default =
554
- # 'Untitled'
555
- # * <tt>:mode</tt> - Don't change this!
556
- # * <tt>:multiple</tt> - Don't change this!
557
- # * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
558
- # * <tt>:title</tt> - (String) Title of the dialog window.
559
- # * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field.
560
- # * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
561
- # must be chosen, canceling the dialog is not possible.
562
- # * <tt>:configSection</tt> - (any String, Integer or Float or nil) Not
563
- # important. Sets the section in the config-file, where for example the
564
- # window size and position is stored.
565
- # * <tt>:defaultextension</tt> - ??? (Don't change).
566
- # * <tt>:filetypes</tt> - (Array of Arrays) Filter for the file types
567
- # Format of the (inner) Arrays:
568
- # * First element: (String) Name of the file type, e.g. 'Ruby files'
569
- # * Second element: (Array) List of extensions for the file type, e.g. ['.rb','.rbw']
570
- # * Third element: (String, optional) Mac file type(s), e.g. 'TEXT'
571
- # * Example:
572
- # filetypes = [
573
- # ['Text files', ['.txt','.doc'] ],
574
- # ['Text files', [], 'TEXT' ],
575
- # ['Ruby Scripts', ['.rb'], 'TEXT' ],
576
- # ['Tcl Scripts', ['.tcl'], 'TEXT' ],
577
- # ['C Source Files', ['.c','.h'] ],
578
- # ['All Source Files', ['.rb','.tcl','.c','.h'] ],
579
- # ['Image Files', ['.gif'] ],
580
- # ['Image Files', ['.jpeg','.jpg'] ],
581
- # ['Image Files', [], ['GIFF','JPEG']],
582
- # ['All files', '*' ]
583
- # ]
584
- #
585
- # *Returns:* (String) Paths of the chosen file; +nil+, if 'Cancel' was clicked.
586
- #
587
- # *Example:*
588
- #
589
- # filetypes = [
590
- # ['Log Files', ['.log']],
591
- # ['All Files', '*']
592
- # ]
593
- #
594
- # ans = save_file('c:\Windows', :filetypes=>filetypes)
595
- #
596
- # *TODO:* Does initialdir work?
597
- def save_file( *args )
598
- TKXXS_CLASSES::SaveFileD.new(*args).answer
599
- end # save_file
600
-
601
- def todo( ) # :nodoc:
602
- # * in all balloon-helps, remove interval, background, justify, relief (not needed) 2010-02-19
603
- # * Build into TK a function for userscreensize, that's for Balloonhelp
604
- # *
605
- # *
606
- # *
607
- # *
608
- end # todo
609
-
610
- end # module TKXXS
611
-
612
- ##########################################################################
613
- ##########################################################################
614
- if $0 == __FILE__
615
- $VERBOSE = false
616
- ##/ require 'axel/conf'
617
- ##/ CONF = Conf.new
618
- include TKXXS
619
-
620
- if !true # OutWindow!
621
- @outW = OutW.new
622
- $stdout = @outW
623
- else
624
- STDOUT.puts "OUTWindow disabled !!!!!!!!!!!!!!!!!!"
625
- end
626
-
627
- if !true # SingleChoiceD
628
- choices = File.open(__FILE__.strip + '_dummydata') {|f| f.read }
629
- choices = choices*100
630
- choices = choices.split("\n")
631
- help = choices.unshift("abc def abc def abc def abc def abc def abc def abc def abcdef abc def abc def abc def abcdef abc def abc def abc def abcdef abc def abc def abc def abcdef abc def abc def abc def abcdef abc def abc def abc def abc \n"*40)
632
- ans = SingleChoiceD.new(choices, help).answer
633
- p(ans)
634
- end
635
-
636
- if !true # SingleChoiceD
637
- choices = File.open(__FILE__.strip + '_dummydata') {|f| f.read }
638
- choices = choices*100
639
- choices = choices.split("\n")
640
- ans = SingleChoiceD.new(choices, :title=>'Dialogs title').answer
641
- p(ans)
642
- end
643
-
644
- if !true # AskSingleLineD
645
- ans = AskSingleLineD.new("Name?", 'help name').answer
646
- p(ans)
647
- end
648
-
649
- if true # MultiChoiceD
650
- ans = multi_choice(['hund', 'katze'], ['help-hund', 'help-katze'])
651
- p(ans)
652
- end
653
-
654
- if !true # AskMultiLineD
655
- ans = AskMultiLineD.new("Name? "*100, 'my help'*30, :title=>"Dialog's Title").answer
656
- p(ans)
657
- end
658
-
659
- if !true # ChooseDirD
660
- ans = ChooseDirD.new().answer
661
- p(ans)
662
- end
663
-
664
- if !true # SaveFileD
665
- ans = SaveFileD.new().answer
666
- p(ans)
667
- end
668
-
669
- if !true # ChooseDirD
670
- ans = ChooseDirD.new().answer
671
- p(ans)
672
- end
673
-
674
- if !true # OpenFilesD
675
- ans = OpenFilesD.new(:help=>'Bitte einen Pfad aussuchen').answer
676
- puts "Returned: #{ ans.inspect }"
677
- end
678
-
679
- if !true # OpenFileD
680
- #ans = OpenFileD.new().path
681
- ans = OpenFileD.new(:validate => true).path
682
- p(ans)
683
- end
684
-
685
- if !true # SaveFileD
686
- ans = SaveFileD.new().answer
687
- p(ans)
688
- end
689
-
690
- # p ask_single_line('frage', 'tja....')
691
-
692
- #p single_choice([ ['choiceStr1',:choice1, :helpStr1], ['choiceStr2',:choice2, :helpStr2]], :returnChoiceAndClient=>false)
693
-
694
- # p multi_choice([ ['choiceStr1',:choice1, :helpStr1], ['choiceStr2',:choice2, :helpStr2]], :returnChoiceAndClient=>true)
695
-
696
- #p choose_dir( 'C:\_Abfall\Thomas' )
697
-
698
- #p open_files( 'C:\_Abfall\Thomas')
699
-
700
- #p open_file( 'C:\_Abfall\Thomas' )
701
-
702
- ##/ p save_file( 'C:\_Abfall\Thomas' )
703
-
704
- Tk.mainloop
705
- end
706
-
707
- # :mode=ruby:
708
-
1
+ # encoding: Windows-1252 :encoding=Windows-1252:
2
+ # Copyright (c) 2010-2014 Axel Friedrich
3
+
4
+ $stdout.sync = true
5
+ $stderr.sync = true
6
+ STDOUT.sync = true
7
+ STDERR.sync = true
8
+ DIR_OF_TKXXS = File.dirname( File.expand_path( __FILE__ ) ).gsub('\\', '/')
9
+ $: << DIR_OF_TKXXS
10
+ $:.uniq!
11
+ $FILE_SEP = File::ALT_SEPARATOR || File::SEPARATOR
12
+
13
+ require 'tkxxs/conf'
14
+ require 'tk'
15
+ require 'tkextlib/tile'
16
+ require( File.dirname(DIR_OF_TKXXS) + '/ext/tkballoonhelp.rb' )
17
+ ##/ ##require 'tkrbwidget/tkballoonhelp/tkballoonhelp.rb'
18
+ ##/ ##require 'ext/tkballoonhelp/tkballoonhelp.rb'
19
+ ##/ if $0 == __FILE__
20
+ ##/ ##/ require 'ext/conf/conf'
21
+ ##/ require 'axel/conf'
22
+ CONF = Conf.new unless defined?(CONF)
23
+ STDOUT.puts "CONFIG-FILENAME is: #{ CONF.filename.gsub('/',$FILE_SEP) }"
24
+ ##/ end
25
+ require 'platform' unless defined?(Platform::OS)
26
+ require 'tkxxs/version'
27
+ require 'tkxxs/tkxxs_classes'
28
+ ##require 'pry'
29
+
30
+ ##########################################################################
31
+ ##########################################################################
32
+ module TKXXS
33
+ include Tk::RbWidget
34
+ include Tk::Tile
35
+ $tkxxs_ = Hash.new unless defined?( $tkxxs_ )
36
+ CONF[:recentDirsSize] = CONF[:recentDirsSize] || 100
37
+ CONF[:recentFilesSize] = CONF[:recentFilesSize] || 100
38
+
39
+ ##########################################################################
40
+ ##########################################################################
41
+ #
42
+ class Tk::RbWidget::BalloonHelp # :nodoc:
43
+
44
+ alias :orig_initialize :initialize
45
+
46
+ ##################################################################
47
+ # Setting defaults
48
+ def initialize( parent=nil, keys={} )
49
+ keys = {
50
+ :interval=>300, # ms
51
+ :background=>'LightYellow',
52
+ :relief=>:ridge, :justify=>:left,
53
+ }.merge(keys)
54
+ orig_initialize(parent, keys)
55
+ end # initialize
56
+
57
+ end # class Tk::RbWidget::BalloonHelp
58
+
59
+ ##########################################################################
60
+ ##########################################################################
61
+ # You create an Output Window like this:
62
+ # @outW = OutW.new
63
+ # You can write to the Output Window like this:
64
+ # @outW.puts "Hallo"
65
+ # OR, you can redirect stdout to @outW:
66
+ # $stdout = @outW
67
+ # Then you can simply write:
68
+ # puts "Hallo"
69
+ # to write to the Output Window.
70
+ # This means, if you have an existing application which uses +puts+
71
+ # to write to the console, you can easily make it to write to the
72
+ # Output Window!
73
+ # BUT: Unfortunately, this is not compatible with OCRA and pry (as
74
+ # of 2013-12). When you want to use OCRA or pry, you cannot use this
75
+ # redirection of stdout.
76
+ class OutW < TKXXS_CLASSES::TextW
77
+ CONF = nil unless defined?(CONF)
78
+
79
+ def initialize( hash={} )
80
+ @alive = true
81
+ teardownDone = false
82
+ at_exit { self.destroy }
83
+
84
+ #---- Root
85
+ img = TkPhotoImage.new(:file=>"#{ DIR_OF_TKXXS }/icon.gif")
86
+ @root = TkRoot.new(:iconphoto_default=>img )
87
+
88
+ userscreen(@root) unless $tkxxs_[:userscreenx]
89
+ if CONF
90
+ @root.geometry =
91
+ CONF.or_default( :outWGeom, '400x300+100+0' )
92
+ end
93
+ #---- Root-bindings
94
+ @root.bind('Destroy') {
95
+ unless teardownDone
96
+ notify_dying
97
+ if CONF
98
+ CONF[:outWGeom] = @root.geometry
99
+ STDOUT.puts "Saving config to #{ CONF.filename.gsub('/', $FILE_SEP) }"
100
+ CONF.save
101
+ end
102
+ teardownDone = true
103
+ end # unless
104
+ }
105
+
106
+ #---- TopFrame
107
+ top = Frame.new.pack(:expand=>true, :fill=>:both)
108
+
109
+ #---- outWindow
110
+ ##/ @outW = TextW.new(top)
111
+ super(top, hash)
112
+ @tagH2 = TkTextTag.new(self, :font=>"Courier 14 bold")
113
+ @tagSel = TkTextTagSel.new(self)
114
+ bind('Control-Key-a') {
115
+ # From:
116
+ # "Using Control-a to select all text in a text widget : TCL",
117
+ # http://objectmix.com/tcl/35276-using-control-select-all-text-text-widget.html
118
+ @tagSel.add('0.0', :end)
119
+ Kernel.raise TkCallbackBreak
120
+ }
121
+
122
+ end # initialize
123
+
124
+ ##################################################################
125
+ # Like Kernel::puts. Write a String to the Output Window.
126
+ def puts( *args )
127
+ args = args.join("\n") if args.class == Array
128
+ str = args.chomp("\n") + "\n"
129
+ self.insert(:end, str)
130
+ self.see :end
131
+ ##/ self.update # N�tig?
132
+ end # puts
133
+
134
+ ##################################################################
135
+ # puts, formated as heading level 2
136
+ def puts_h2( str )
137
+ self.insert(:end, "\n" + str.chomp("\n") + "\n", @tagH2)
138
+ end # puts_h2
139
+
140
+ ##################################################################
141
+ # Like Kernel::print. Print a String to the Output Window.
142
+ def print( *args )
143
+ if args.class == Array
144
+ args.map! {|a| a.to_s }
145
+ args = args.join(" ")
146
+ end
147
+ str = args.chomp("\n") + "\n"
148
+ self.insert('end', str)
149
+ self.see :end
150
+ ##/ self.update # N�tig?
151
+ end # print
152
+
153
+ # TODO def p()
154
+
155
+ # :nodoc:
156
+ def write( str )
157
+ ##self.insert(:end, "\n" + str)
158
+ self.insert(:end, str)
159
+ self.see :end
160
+ ##/ self.update # N�tig?
161
+ end # write
162
+
163
+ ##########################################################################
164
+ # :nodoc:
165
+ # Does nothing, just for compatibility
166
+ def sync=( x )
167
+ # nothing to do
168
+ end # sync=
169
+
170
+ # :nodoc:
171
+ def flush
172
+ self.update
173
+ end #
174
+
175
+ # :nodoc:
176
+ def tty?( )
177
+ false
178
+ end # tty?
179
+
180
+
181
+ # :nodoc:
182
+ def private____________________________( )
183
+ end # private____________________________
184
+
185
+ ##################################################################
186
+ # "private"
187
+ def userscreen( root )
188
+ if Platform::OS == :win32
189
+ root.state('zoomed') # OK on Windows
190
+ ##/ root.wm_state('zoomed') # OK on Windows
191
+ ##/ root.wm_zoomed # method missing
192
+ ##/ root.wm_attributes('zoomed')
193
+ ##/ root.wm_maximized # method missing
194
+ else
195
+ # Linux: works
196
+ # Other: not tested
197
+ root.height = root.winfo_screenheight
198
+ root.width = root.winfo_screenwidth
199
+ end
200
+ root.update
201
+
202
+ root.winfo_geometry =~ /(\d+)x(\d+)\+([+-]?\d+)\+([+-]?\d+)/
203
+ xwg = $3.to_i
204
+ ywg = $4.to_i
205
+ root.geometry =~ /(\d+)x(\d+)\+([+-]?\d+)\+([+-]?\d+)/
206
+ gw = $1.to_i
207
+ gh = $2.to_i
208
+
209
+ ## sw = root.winfo_screenwidth
210
+ ## sh = root.winfo_screenheight
211
+
212
+ rx = root.winfo_rootx
213
+ ry = root.winfo_rooty # maybe, taskbar height
214
+
215
+ border = -[xwg,ywg].min
216
+ userscreenx = xwg + border
217
+ userscreeny= ywg + border
218
+ userscreenwidth = gw
219
+ userscreenheight = gh + ry - ywg - border
220
+
221
+ $tkxxs_[:userscreenx ] = userscreenx
222
+ $tkxxs_[:userscreeny ] = userscreeny
223
+ $tkxxs_[:userscreenwidth ] = userscreenwidth
224
+ $tkxxs_[:userscreenheight] = userscreenheight
225
+
226
+ root.state('normal')
227
+ nil
228
+ end # userscreen
229
+
230
+ ##################################################################
231
+ # "private"
232
+ def notify_dying( )
233
+ @alive = false
234
+ end # notify_dying
235
+
236
+ ##################################################################
237
+ # "private"
238
+ def alive?( )
239
+ @alive
240
+ end # alive?
241
+ end # class OutW
242
+
243
+ ##################################################################
244
+ ##################################################################
245
+ # Depreciated (replaced by OutW).
246
+ class LogW < OutW # :nodoc:
247
+ end
248
+
249
+ ##########################################################################
250
+ ##########################################################################
251
+ def messageBoxExamples
252
+ # TODO: Is this usefull?
253
+ ##################################################################
254
+ # :type: :abortretryignore, :ok, :okcancel, :retrycancel, :yesno, :yesnocancel
255
+ # :icon: :error, :info, :question or :warning (default: info)
256
+ # :detail: Specifies an auxiliary message to the main message given by
257
+ # the -message option. Where supported by the underlying OS, the
258
+ # message detail will be presented in a less emphasized font than the
259
+ # main message.
260
+ # Returns: A String describing the pressed button ("ok", "cancel", "retry", "ignore", ...)
261
+ # Balloonhelp funktioniert damit nicht (oder?).
262
+ #
263
+ ans = Tk.messageBox( :type=>:yesno,:icon=>:question,
264
+ :title=>"Next",
265
+ :message=>"xxx",
266
+ :detail=>"xxx"
267
+ )
268
+ #
269
+ # puts sprintf("--DEBUG: button: %1s ", button.inspect) #loe
270
+ end # class MessageBoxExamples
271
+
272
+ ##########################################################################
273
+ # ask_single_line(question=nil, help=nil, hash=nil)
274
+ #
275
+ # Ask for a single line of text.
276
+ #
277
+ # *Params*:
278
+ # * +question+ - (String, optional) Your question; +nil+ => Default question
279
+ # * +help+ - (String, optional) Text used in the BalloonHelp; +nil+ => No help text
280
+ # * +hash+ - (Hash, optional)
281
+ # * <tt>:question</tt> - Like above.
282
+ # * <tt>:help</tt> - Like above.
283
+ # * <tt>:configSection</tt> - (any String, Integer, Float or nil)
284
+ # Sets the section where to store and read from config settings.
285
+ # Default = nil. If key is not given, section remains unchanged.
286
+ # * <tt>:defaultEntry</tt> - (String) Default answer.
287
+ #
288
+ # *Returns*: (String or nil) The answer of the dialog. 'Cancel' returns nil.
289
+ #
290
+ # *Example:*
291
+ # help = "This dialog is named 'ask_single_line'"
292
+ # ans = ask_single_line(
293
+ # "Want to know more?\nPoint with the mouse to the entry field!",
294
+ # help,
295
+ # :defaultEntry =>"Of course"
296
+ # )
297
+ def ask_single_line( *args )
298
+ TKXXS_CLASSES::AskSingleLineD.new(*args).answer
299
+ end # ask_single_line
300
+
301
+ ##################################################################
302
+ # single_choice( aryWithChoices, help=nil, hash=nil )
303
+ #
304
+ # *Params*:
305
+ # * +aryWithChoices+ - (Array) one of the following formats:
306
+ # * [ choiceStrA, choiceStrB, ...]
307
+ # * [ [choiceStrA,objectA], [choiceStrB,objectB], ... ]
308
+ # * [ [choiceStrA,objectA,helpStrA], [choiceStrB,objectB,helpStrB], ...]
309
+ # Quite usefull: a Proc for object.
310
+ # * +help+ - (String, optional) Array, with one help-String for each choice element!; +nil+ => No help text
311
+ # * +hash+ - (Hash, optional)
312
+ # * <tt>:question</tt> - Like above.
313
+ # * <tt>:help</tt> - Like above.
314
+ # * <tt>:configSection</tt> - (any String, Integer, Float or nil)
315
+ # Sets the section where to store and read from config settings.
316
+ # Default = nil. If key is not given, section remains unchanged.
317
+ # * <tt>:title</tt> - (String) Title of the dialog window
318
+ # * <tt>:bd</tt> - (Number as String) ?
319
+ # * <tt>:searchFieldHelp</tt> - (String) Ballon help of the search field,
320
+ # * <tt>:returnChoiceAndClient</tt> - returns the right side (+false+) or both sides (+true+) of +aryWithChoices+.
321
+ #
322
+ # *Returns:*
323
+ # * The chosen right sides of +aryWithChoices+ if :returnChoiceAndClient == +false+ (default),
324
+ # * An Array of the chosen right and left side of +aryWithChoices+ if :returnChoiceAndClient == +true+,
325
+ # * +nil+, if 'Cancel' was clicked.
326
+ #
327
+ # *Example:*
328
+ # help = ['Help #1', 'Help #2', 'Help #3']
329
+ # ans = single_choice(
330
+ # [
331
+ # [ "You want 1?", 1],
332
+ # [ "You want 2?", 2],
333
+ # [ "You want 3?", 3],
334
+ # ],
335
+ # help
336
+ # )
337
+ #
338
+ # *TODO:* Choice-search field: � (&auml;) does not work?
339
+ def single_choice( *args )
340
+ TKXXS_CLASSES::SingleChoiceD.new(*args).answer
341
+ end # single_choice
342
+
343
+ ##################################################################
344
+ # multi_choice( aryWithChoices, help=nil, hash=nil )
345
+ #
346
+ # *Params*:
347
+ # * +aryWithChoices+ - (Array) one of the following formats:
348
+ # * [ choiceStrA, choiceStrB, ...]
349
+ # * [ [choiceStrA,objectA], [choiceStrB,objectB], ... ]
350
+ # * [ [choiceStrA,objectA,helpStrA], [choiceStrB,objectB,helpStrB], ...]
351
+ # Quite usefull: a Proc for object.
352
+ # * +help+ - (String, optional) Array, with one help-String for each choice element!; +nil+ => No help text
353
+ # * +hash+ - (Hash, optional)
354
+ # * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
355
+ # * <tt>:help</tt> - Like above.
356
+ # * <tt>:configSection</tt> - (any String, Integer, Float or nil)
357
+ # Sets the section where to store and read from config settings.
358
+ # Default = nil. If key is not given, section remains unchanged.
359
+ # * <tt>:title</tt> - (String) Title of the dialog window
360
+ # * <tt>:bd</tt> - (Number as String) ?
361
+ # * <tt>:selectmode => :multiple</tt> - Obsolet?
362
+ # * <tt>:searchFieldHelp</tt> - (String) Ballon help of the search field, searchField not implemented yet
363
+ # * <tt>:returnChoiceAndClient</tt> - returns the right side (+false+) or both sides (+true+) of +aryWithChoices+.
364
+ #
365
+ # *Returns:*
366
+ # * An Array of the chosen right sides of +aryWithChoices+ if :returnChoiceAndClient == +false+ (default),
367
+ # * An Array of the chosen right and left sides of +aryWithChoices+ if :returnChoiceAndClient == +true+,
368
+ # * +nil+, if 'Cancel' was clicked.
369
+ #
370
+ # *Example:*
371
+ # help = ['Help #1', 'Help #2', 'Help #3']
372
+ # ans = single_choice(
373
+ # [
374
+ # [ "You want 1?", 1],
375
+ # [ "You want 2?", 2],
376
+ # [ "You want 3?", 3],
377
+ # ],
378
+ # help
379
+ # )
380
+ def multi_choice( *args )
381
+ TKXXS_CLASSES::MultiChoiceD.new(*args).answer
382
+ end # multi_choice
383
+
384
+ ##########################################################################
385
+ # choose_dir( initialdir=nil,help=nil,hash=nil )
386
+ #
387
+ # *Params*:
388
+ # * +initialdir+ - (String, optional) Initial dir; default = +nil+
389
+ # -> Working dir at the time of calling this method.
390
+ # * +help+ - (String, optional) ; Text used in the BalloonHelp;
391
+ # default = +nil+ -> No help.
392
+ # * +hash+ - (Hash, optional)
393
+ # * <tt>:initialdir</tt> - Like above.
394
+ # * <tt>:help</tt> - Like above.
395
+ # * <tt>:mode</tt> - Don't modify this!
396
+ # * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
397
+ # * <tt>:title</tt> - (String) Title of the dialog window.
398
+ # * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field.
399
+ # * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
400
+ # must be chosen, canceling the dialog is not possible.
401
+ # * <tt>:configSection</tt> - (any String, Integer, Float or nil)
402
+ # Sets the section where to store and read from config settings.
403
+ # Default = nil. If key is not given, section remains unchanged.
404
+ #
405
+ # *Returns:* (String) Path of the chosen dir; +nil+, if 'Cancel' was clicked.
406
+ #
407
+ # *Example:*
408
+ #
409
+ # help = "Pick a dir."
410
+ # ans = choose_dir(
411
+ # 'c:\WinDows',
412
+ # help,
413
+ # :validate=>true,
414
+ # :defaultEntry=>'c:/windows/system'
415
+ # )
416
+ #
417
+ # *TODO:* How to choose multiple dirs or even dirs & files?
418
+ def choose_dir( *args ) # initialdir
419
+ TKXXS_CLASSES::ChooseDirD.new(*args).answer
420
+ end # choose_dir
421
+
422
+ ##########################################################################
423
+ # open_files( initialdir=nil,help=nil,hash=nil )
424
+ #
425
+ # To get this dialog explain, run the example and point the mouse
426
+ # at each button.
427
+ #
428
+ # *Params*:
429
+ # * +initialdir+ - (String, optional) Initial dir; default = +nil+
430
+ # -> Working dir at the time of calling this method.
431
+ # * +help+ - (String, optional) ; Text used in the BalloonHelp;
432
+ # default = +nil+ -> No help.
433
+ # * +hash+ - (Hash, optional)
434
+ # * <tt>:initialdir</tt> - Like above.
435
+ # * <tt>:help</tt> - Like above.
436
+ # * <tt>:mode</tt> - Don't change this!
437
+ # * <tt>:multiple</tt> - Don't change this!
438
+ # * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
439
+ # * <tt>:title</tt> - (String) Title of the dialog window.
440
+ # * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field.
441
+ # * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
442
+ # must be chosen, canceling the dialog is not possible.
443
+ # * <tt>:configSection</tt> - (any String, Integer, Float or nil)
444
+ # Sets the section where to store and read from config settings.
445
+ # Default = nil. If key is not given, section remains unchanged.
446
+ # * <tt>:filetypes</tt> - (Array of Arrays) Filter for the file types
447
+ # Format of the (inner) Arrays:
448
+ # * First element: (String) Name of the file type, e.g. 'Ruby files'
449
+ # * Second element: (Array) List of extensions for the file type, e.g. ['.rb','.rbw']
450
+ # * Third element: (String, optional) Mac file type(s), e.g. 'TEXT'
451
+ # * Example:
452
+ # filetypes = [
453
+ # ['Text files', ['.txt','.doc'] ],
454
+ # ['Text files', [], 'TEXT' ],
455
+ # ['Ruby Scripts', ['.rb'], 'TEXT' ],
456
+ # ['Tcl Scripts', ['.tcl'], 'TEXT' ],
457
+ # ['C Source Files', ['.c','.h'] ],
458
+ # ['All Source Files', ['.rb','.tcl','.c','.h'] ],
459
+ # ['Image Files', ['.gif'] ],
460
+ # ['Image Files', ['.jpeg','.jpg'] ],
461
+ # ['Image Files', [], ['GIFF','JPEG']],
462
+ # ['All files', '*' ]
463
+ # ]
464
+ # *Returns:* (Array) Paths of the chosen files; +nil+, if 'Cancel' was clicked.
465
+ #
466
+ # *Example:*
467
+ #
468
+ # filetypes = [
469
+ # ['Log Files', ['.log']],
470
+ # ['All Files', '*']
471
+ # ]
472
+ #
473
+ # ans = open_files('c:\Windows', :filetypes=>filetypes)
474
+ #
475
+ # *TODO:* When using "Recent"-Button > "Files" or "Favorite"-Button >
476
+ # "Files" you can choose only one from Recent and none from, for
477
+ # example "Browse"; should be multiple.
478
+ def open_files( *args )
479
+ TKXXS_CLASSES::OpenFilesD.new(*args).answer
480
+ end # open_files
481
+
482
+ ##################################################################
483
+ # open_file( initialdir=nil,help=nil,hash=nil )
484
+ #
485
+ # To get this dialog explain, run the example and point the mouse
486
+ # at each button.
487
+ #
488
+ # *Params*:
489
+ # * +initialdir+ - (String, optional) Initial dir; default = +nil+
490
+ # -> Working dir at the time of calling this method.
491
+ # * +help+ - (String, optional) ; Text used in the BalloonHelp;
492
+ # default = +nil+ -> No help.
493
+ # * +hash+ - (Hash, optional)
494
+ # * <tt>:initialdir</tt> - Like above.
495
+ # * <tt>:help</tt> - Like above.
496
+ # * <tt>:mode</tt> - Don't change this!
497
+ # * <tt>:multiple</tt> - Don't change this!
498
+ # * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
499
+ # * <tt>:title</tt> - (String) Title of the dialog window.
500
+ # * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field.
501
+ # * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
502
+ # must be chosen, canceling the dialog is not possible.
503
+ # * <tt>:configSection</tt> - (any String, Integer, Float or nil)
504
+ # Sets the section where to store and read from config settings.
505
+ # Default = nil. If key is not given, section remains unchanged.
506
+ # * <tt>:filetypes</tt> - (Array of Arrays) Filter for the file types
507
+ # Format of the (inner) Arrays:
508
+ # * First element: (String) Name of the file type, e.g. 'Ruby files'
509
+ # * Second element: (Array) List of extensions for the file type, e.g. ['.rb','.rbw']
510
+ # * Third element: (String, optional) Mac file type(s), e.g. 'TEXT'
511
+ # * Example:
512
+ # filetypes = [
513
+ # ['Text files', ['.txt','.doc'] ],
514
+ # ['Text files', [], 'TEXT' ],
515
+ # ['Ruby Scripts', ['.rb'], 'TEXT' ],
516
+ # ['Tcl Scripts', ['.tcl'], 'TEXT' ],
517
+ # ['C Source Files', ['.c','.h'] ],
518
+ # ['All Source Files', ['.rb','.tcl','.c','.h'] ],
519
+ # ['Image Files', ['.gif'] ],
520
+ # ['Image Files', ['.jpeg','.jpg'] ],
521
+ # ['Image Files', [], ['GIFF','JPEG']],
522
+ # ['All files', '*' ]
523
+ # ]
524
+ # *Returns:* (Array) Paths of the chosen files; +nil+, if 'Cancel' was clicked.
525
+ #
526
+ # *Example:*
527
+ #
528
+ # filetypes = [
529
+ # ['Log Files', ['.log']],
530
+ # ['All Files', '*']
531
+ # ]
532
+ #
533
+ # ans = open_file('c:\Windows', :filetypes=>filetypes)
534
+ #
535
+ # *TODO:* Does initialdir work?
536
+ def open_file( *args )
537
+ TKXXS_CLASSES::OpenFileD.new(*args).answer
538
+ end # open_file
539
+
540
+ ##################################################################
541
+ # save_file( initialdir=nil,help=nil,hash=nil )
542
+ #
543
+ # To get this dialog explain, run the example and point the mouse
544
+ # at each button.
545
+ #
546
+ # *Params*:
547
+ # * +initialdir+ - (String, optional) Initial dir; default = +nil+
548
+ # -> Working dir at the time of calling this method.
549
+ # * +help+ - (String, optional) ; Text used in the BalloonHelp;
550
+ # default = +nil+ -> No help.
551
+ # * +hash+ - (Hash, optional)
552
+ # * <tt>:initialdir</tt> - Like above.
553
+ # * <tt>:help</tt> - Like above.
554
+ # * <tt>:initialfile</tt> - (String) Default filename, extension
555
+ # will be added automatically by filetypes-setting; default =
556
+ # 'Untitled'
557
+ # * <tt>:mode</tt> - Don't change this!
558
+ # * <tt>:multiple</tt> - Don't change this!
559
+ # * <tt>:question</tt> - (String) Your question; +nil+ -> no question.
560
+ # * <tt>:title</tt> - (String) Title of the dialog window.
561
+ # * <tt>:defaultEntry</tt> - (String) Path, shown in the entry field.
562
+ # * <tt>:validate</tt> - +true+ or +false+; if true, a valid path
563
+ # must be chosen, canceling the dialog is not possible.
564
+ # * <tt>:configSection</tt> - (any String, Integer, Float or nil)
565
+ # Sets the section where to store and read from config settings.
566
+ # Default = nil. If key is not given, section remains unchanged.
567
+ # * <tt>:defaultextension</tt> - ??? (Don't change).
568
+ # * <tt>:filetypes</tt> - (Array of Arrays) Filter for the file types
569
+ # Format of the (inner) Arrays:
570
+ # * First element: (String) Name of the file type, e.g. 'Ruby files'
571
+ # * Second element: (Array) List of extensions for the file type, e.g. ['.rb','.rbw']
572
+ # * Third element: (String, optional) Mac file type(s), e.g. 'TEXT'
573
+ # * Example:
574
+ # filetypes = [
575
+ # ['Text files', ['.txt','.doc'] ],
576
+ # ['Text files', [], 'TEXT' ],
577
+ # ['Ruby Scripts', ['.rb'], 'TEXT' ],
578
+ # ['Tcl Scripts', ['.tcl'], 'TEXT' ],
579
+ # ['C Source Files', ['.c','.h'] ],
580
+ # ['All Source Files', ['.rb','.tcl','.c','.h'] ],
581
+ # ['Image Files', ['.gif'] ],
582
+ # ['Image Files', ['.jpeg','.jpg'] ],
583
+ # ['Image Files', [], ['GIFF','JPEG']],
584
+ # ['All files', '*' ]
585
+ # ]
586
+ #
587
+ # *Returns:* (String) Paths of the chosen file; +nil+, if 'Cancel' was clicked.
588
+ #
589
+ # *Example:*
590
+ #
591
+ # filetypes = [
592
+ # ['Log Files', ['.log']],
593
+ # ['All Files', '*']
594
+ # ]
595
+ #
596
+ # ans = save_file('c:\Windows', :filetypes=>filetypes)
597
+ #
598
+ # *TODO:* Does initialdir work?
599
+ def save_file( *args )
600
+ TKXXS_CLASSES::SaveFileD.new(*args).answer
601
+ end # save_file
602
+
603
+ def todo( ) # :nodoc:
604
+ # * in all balloon-helps, remove interval, background, justify, relief (not needed) 2010-02-19
605
+ # * Build into TK a function for userscreensize, that's for Balloonhelp
606
+ # *
607
+ # *
608
+ # *
609
+ # *
610
+ end # todo
611
+
612
+ end # module TKXXS
613
+
614
+ ##########################################################################
615
+ ##########################################################################
616
+ if $0 == __FILE__
617
+ $VERBOSE = false
618
+ ##/ require 'axel/conf'
619
+ ##/ CONF = Conf.new
620
+ include TKXXS
621
+
622
+ if !true # OutWindow!
623
+ @outW = OutW.new
624
+ $stdout = @outW
625
+ else
626
+ STDOUT.puts "OUTWindow disabled !!!!!!!!!!!!!!!!!!"
627
+ end
628
+
629
+ if !true # SingleChoiceD
630
+ choices = File.open(__FILE__.strip + '_dummydata') {|f| f.read }
631
+ choices = choices*100
632
+ choices = choices.split("\n")
633
+ help = choices.unshift("abc def abc def abc def abc def abc def abc def abc def abcdef abc def abc def abc def abcdef abc def abc def abc def abcdef abc def abc def abc def abcdef abc def abc def abc def abcdef abc def abc def abc def abc \n"*40)
634
+ ans = SingleChoiceD.new(choices, help).answer
635
+ p(ans)
636
+ end
637
+
638
+ if !true # SingleChoiceD
639
+ choices = File.open(__FILE__.strip + '_dummydata') {|f| f.read }
640
+ choices = choices*100
641
+ choices = choices.split("\n")
642
+ ans = SingleChoiceD.new(choices, :title=>'Dialogs title').answer
643
+ p(ans)
644
+ end
645
+
646
+ if !true # AskSingleLineD
647
+ ans = AskSingleLineD.new("Name?", 'help name').answer
648
+ p(ans)
649
+ end
650
+
651
+ if true # MultiChoiceD
652
+ ans = multi_choice(['hund', 'katze'], ['help-hund', 'help-katze'])
653
+ p(ans)
654
+ end
655
+
656
+ if !true # AskMultiLineD
657
+ ans = AskMultiLineD.new("Name? "*100, 'my help'*30, :title=>"Dialog's Title").answer
658
+ p(ans)
659
+ end
660
+
661
+ if !true # ChooseDirD
662
+ ans = ChooseDirD.new().answer
663
+ p(ans)
664
+ end
665
+
666
+ if !true # SaveFileD
667
+ ans = SaveFileD.new().answer
668
+ p(ans)
669
+ end
670
+
671
+ if !true # ChooseDirD
672
+ ans = ChooseDirD.new().answer
673
+ p(ans)
674
+ end
675
+
676
+ if !true # OpenFilesD
677
+ ans = OpenFilesD.new(:help=>'Bitte einen Pfad aussuchen').answer
678
+ puts "Returned: #{ ans.inspect }"
679
+ end
680
+
681
+ if !true # OpenFileD
682
+ #ans = OpenFileD.new().path
683
+ ans = OpenFileD.new(:validate => true).path
684
+ p(ans)
685
+ end
686
+
687
+ if !true # SaveFileD
688
+ ans = SaveFileD.new().answer
689
+ p(ans)
690
+ end
691
+
692
+ # p ask_single_line('frage', 'tja....')
693
+
694
+ #p single_choice([ ['choiceStr1',:choice1, :helpStr1], ['choiceStr2',:choice2, :helpStr2]], :returnChoiceAndClient=>false)
695
+
696
+ # p multi_choice([ ['choiceStr1',:choice1, :helpStr1], ['choiceStr2',:choice2, :helpStr2]], :returnChoiceAndClient=>true)
697
+
698
+ #p choose_dir( 'C:\_Abfall\Thomas' )
699
+
700
+ #p open_files( 'C:\_Abfall\Thomas')
701
+
702
+ #p open_file( 'C:\_Abfall\Thomas' )
703
+
704
+ ##/ p save_file( 'C:\_Abfall\Thomas' )
705
+
706
+ Tk.mainloop
707
+ end
708
+
709
+ # :mode=ruby:
710
+