Class: Tk::RbWidget::BalloonHelp
- Defined in:
- sample/tkballoonhelp.rb,
sample/tkballoonhelp.rb
Constant Summary collapse
- DEFAULT_FOREGROUND =
'black'
- DEFAULT_BACKGROUND =
'white'
- DEFAULT_INTERVAL =
750
Class Method Summary collapse
Instance Method Summary collapse
- #command(cmd = Proc.new) ⇒ Object
- #destroy ⇒ Object
- #epath ⇒ Object
- #erase ⇒ Object
-
#initialize(parent = nil, keys = {}) ⇒ BalloonHelp
constructor
A new instance of BalloonHelp.
- #interval(val) ⇒ Object
- #show ⇒ Object
Constructor Details
#initialize(parent = nil, keys = {}) ⇒ BalloonHelp
Returns a new instance of BalloonHelp.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'sample/tkballoonhelp.rb', line 47 def initialize(parent=nil, keys={}) @parent = parent || Tk.root @frame = TkToplevel.new(@parent) @frame.withdraw @frame.overrideredirect(true) @frame.transient(TkWinfo.toplevel(@parent)) @epath = @frame.path if keys keys = _symbolkey2str(keys) else keys = {} end @command = keys.delete('command') @interval = keys.delete('interval'){DEFAULT_INTERVAL} _balloon_binding(@interval) # @label = TkLabel.new(@frame, 'background'=>'bisque').pack @label = TkLabel.new(@frame, 'foreground'=>DEFAULT_FOREGROUND, 'background'=>DEFAULT_BACKGROUND).pack @label.configure(_symbolkey2str(keys)) unless keys.empty? @path = @label end |
Class Method Details
.interval(val) ⇒ Object
28 29 30 |
# File 'sample/tkballoonhelp.rb', line 28 def @timer.interval(val) @sleep_time = val end |
Instance Method Details
#command(cmd = Proc.new) ⇒ Object
87 88 89 90 |
# File 'sample/tkballoonhelp.rb', line 87 def command(cmd = Proc.new) @command = cmd self end |
#destroy ⇒ Object
136 137 138 |
# File 'sample/tkballoonhelp.rb', line 136 def destroy @frame.destroy end |
#epath ⇒ Object
75 76 77 |
# File 'sample/tkballoonhelp.rb', line 75 def epath @epath end |
#erase ⇒ Object
127 128 129 130 131 132 133 134 |
# File 'sample/tkballoonhelp.rb', line 127 def erase begin @parent.configure('cursor', @org_cursor) rescue @parent.cursor(@org_cursor) end @frame.withdraw end |
#interval(val) ⇒ Object
79 80 81 82 83 84 85 |
# File 'sample/tkballoonhelp.rb', line 79 def interval(val) if val @timer.interval(val) else @interval end end |
#show ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'sample/tkballoonhelp.rb', line 92 def show x = TkWinfo.pointerx(@parent) y = TkWinfo.pointery(@parent) @frame.geometry("+#{x+1}+#{y+1}") if @command case @command.arity when 0 @command.call when 2 @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent)) when 3 @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent), self) else @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent), self, @parent) end end @frame.deiconify @frame.raise begin @org_cursor = @parent.cget('cursor') rescue @org_cursor = @parent['cursor'] end begin @parent.configure('cursor', 'crosshair') rescue @parent.cursor('crosshair') end end |