Class: TK::BaseDialog
- Inherits:
-
Object
show all
- Defined in:
- lib/wiki_lyrics/gui/gui-tk.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(values, close_on_escape = true) ⇒ BaseDialog
Returns a new instance of BaseDialog.
350
351
352
353
354
355
356
357
358
359
360
361
|
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 350
def initialize( values, close_on_escape=true )
@root = TkRoot.new()
@root.withdraw()
@shell = TkToplevel.new( @root )
@shell.protocol( "WM_DELETE_WINDOW", proc { destroy() } )
@shell.bind( "Escape", proc { destroy() } ) if close_on_escape
@shell.withdraw()
@values = values
@x, @y, @width, @height = nil, nil, nil, nil
end
|
Instance Attribute Details
#accepted ⇒ Object
Returns the value of attribute accepted.
347
348
349
|
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 347
def accepted
@accepted
end
|
#values ⇒ Object
Returns the value of attribute values.
348
349
350
|
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 348
def values
@values
end
|
Class Method Details
.get_screen_size ⇒ Object
415
416
417
418
|
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 415
def BaseDialog.get_screen_size()
maxsize = Tk.root.maxsize()
return maxsize[0], maxsize[1]
end
|
Instance Method Details
#accept ⇒ Object
386
387
388
389
|
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 386
def accept()
@accepted = true
destroy()
end
|
#destroy ⇒ Object
382
383
384
|
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 382
def destroy()
@root.destroy()
end
|
#exec ⇒ Object
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
|
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 363
def exec()
@accepted = false
if ! @x && ! @y
set_size( @width, @height ) if @width
width, height = get_size()
s_width, s_height = BaseDialog.get_screen_size()
@x, @y = (s_width - width) / 2, (s_height - height) / 2
end
set_position( @x, @y )
@shell.deiconify()
Tk.mainloop()
Tk.restart()
end
|
#get_position ⇒ Object
411
412
413
|
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 411
def get_position()
return @x.to_i(), @y.to_i()
end
|
#get_size ⇒ Object
401
402
403
404
405
406
407
408
409
|
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 401
def get_size()
return @width.to_i(), @height.to_i() if @width
width, height = nil, nil
if @shell
md = /([0-9]+)x([0-9]+)[-\+][0-9]+[-\+][0-9]+/.match( @shell.geometry() )
width, height = md[1].to_i(), md[2].to_i()
end
return width, height
end
|
#set_position(x, y) ⇒ Object
396
397
398
399
|
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 396
def set_position( x, y )
@x, @y = x.to_i(), y.to_i()
@shell.geometry( "#{@x > 0 ? "+" : "-"}#{@x}#{@y > 0 ? "+" : "-"}#{@y}" ) if @shell
end
|
#set_size(width, height) ⇒ Object
391
392
393
394
|
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 391
def set_size( width, height )
@width, @height = width.to_i(), height.to_i()
@shell.geometry( "#{@width}x#{@height}" ) if @shell
end
|