Class: GGLib::Button
Constant Summary collapse
- TextColor =
0xff000000
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
Attributes inherited from Widget
#buttonId, #defimage, #id, #name, #sleeping, #theme, #window, #zfocus
Attributes inherited from Tile
#id, #inclusive, #x1, #x2, #y1, #y2
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(name, text, x, y, onClickPrc = Proc.new{}, theme = Themes::blank) ⇒ Button
constructor
A new instance of Button.
- #onClick ⇒ Object
- #onMouseOut ⇒ Object
- #onMouseOver ⇒ Object
- #x1= ⇒ Object
- #y1= ⇒ Object
Methods inherited from Widget
#blur, #button, #clicked?, #del, #event, #feedText, #focus, #hasFocus?, #hasStickyFocus?, #intDraw, #onDelete, #onDrag, #onInitialize, #onKeyPress, #onRightClick, #onRightDrag, #onStickyBlur, #onStickyFocus, #over?, #sleep, #sleeping?, #stickFocus, #unstickFocus, #wakeUp
Methods inherited from Tile
#centerOn, #del, deleteAllInstances, deleteById, #each, #eachBorder, getAllInstances, getById, #height, #iTile, #intersect?, intersect?, #isInTile?, #move, setAllInstances, #setCoordinates, #setTile, #width, #xTile
Constructor Details
#initialize(name, text, x, y, onClickPrc = Proc.new{}, theme = Themes::blank) ⇒ Button
Returns a new instance of Button.
309 310 311 312 313 314 315 |
# File 'lib/ext/widgets.rb', line 309 def initialize(name, text, x, y, onClickPrc=Proc.new{}, theme = Themes::blank) super(name, x, y, x+100, y+30, theme) @text=text @onClickPrc=onClickPrc @drawx=x+((100-@theme.font.default.text_width(@text))/2).floor @drawy=y+((30-@theme.font.default.height)/2).floor end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
308 309 310 |
# File 'lib/ext/widgets.rb', line 308 def text @text end |
Instance Method Details
#draw ⇒ Object
333 334 335 |
# File 'lib/ext/widgets.rb', line 333 def draw @theme.font.default.draw(@text, @drawx, @drawy, ZOrder::Text, 1, 1, @theme.font.color) end |
#onClick ⇒ Object
324 325 326 |
# File 'lib/ext/widgets.rb', line 324 def onClick @onClickPrc.call(self) end |
#onMouseOut ⇒ Object
330 331 332 |
# File 'lib/ext/widgets.rb', line 330 def onMouseOut @theme.setDefaultState end |
#onMouseOver ⇒ Object
327 328 329 |
# File 'lib/ext/widgets.rb', line 327 def onMouseOver @theme.setOverState end |
#x1= ⇒ Object
316 317 318 319 |
# File 'lib/ext/widgets.rb', line 316 def x1= super @drawx=x+((100-@theme.font.default.text_width(@text))/2).floor end |
#y1= ⇒ Object
320 321 322 323 |
# File 'lib/ext/widgets.rb', line 320 def y1= super @drawy=y+((30-@theme.font.default.height)/2).floor end |