Class: Othello::BoardView::Square
Instance Attribute Summary collapse
-
#col ⇒ Object
readonly
Returns the value of attribute col.
-
#oval ⇒ Object
readonly
Returns the value of attribute oval.
-
#row ⇒ Object
readonly
Returns the value of attribute row.
Instance Method Summary collapse
- #blink(color) ⇒ Object
-
#initialize(view, row, col) ⇒ Square
constructor
A new instance of Square.
Constructor Details
#initialize(view, row, col) ⇒ Square
Returns a new instance of Square.
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'sample/tcltklib/sample2.rb', line 197 def initialize(view, row, col) @view = view @id = @view.e("create rectangle", *(view.tk_rect(view.left + col, view.top + row, view.left + col + 1, view.top + row + 1) \ << "-fill #{BACK_GROUND_COLOR}") ) @row = row @col = col @view.e("itemconfigure", @id, "-width 0.5m -outline #{BORDER_COLOR}") @view.e("bind", @id, "<Any-Enter>", TclTkCallback.new($ip, proc{ if @oval == nil view.e("itemconfigure", @id, "-fill #{HILIT_BG_COLOR}") end })) @view.e("bind", @id, "<Any-Leave>", TclTkCallback.new($ip, proc{ view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}") })) @view.e("bind", @id, "<ButtonRelease-1>", TclTkCallback.new($ip, proc{ view.click_square(self) })) end |
Instance Attribute Details
#col ⇒ Object (readonly)
Returns the value of attribute col
195 196 197 |
# File 'sample/tcltklib/sample2.rb', line 195 def col @col end |
#oval ⇒ Object (readonly)
Returns the value of attribute oval
193 194 195 |
# File 'sample/tcltklib/sample2.rb', line 193 def oval @oval end |
#row ⇒ Object (readonly)
Returns the value of attribute row
194 195 196 |
# File 'sample/tcltklib/sample2.rb', line 194 def row @row end |
Instance Method Details
#blink(color) ⇒ Object
223 224 225 226 227 228 |
# File 'sample/tcltklib/sample2.rb', line 223 def blink(color) @view.e("itemconfigure", @id, "-fill #{color}") $update.e() sleep(0.1) @view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}") end |