Class: GGLib::Button
Constant Summary
collapse
- TextColor =
0xff000000
Instance Attribute Summary collapse
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
Methods inherited from Widget
#blur, #button, #clicked?, #del, #downevent, #event, #feedText, #focus, #hasFocus?, #hasStickyFocus?, #intDraw, #onDelete, #onDrag, #onInitialize, #onKeyPress, #onRightClick, #onRightDrag, #onRightMouseDown, #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
341
342
343
|
# File 'lib/ext/widgets.rb', line 341
def draw
@theme.font.default.draw(@text, @drawx, @drawy, ZOrder::Text, 1, 1, @theme.font.color)
end
|
#onClick ⇒ Object
327
328
329
330
331
332
333
334
|
# File 'lib/ext/widgets.rb', line 327
def onClick
@onClickPrc.call(self)
if self.hasFocus?
@theme.setOverState
else
@theme.setDefaultState
end
end
|
#onMouseDown ⇒ Object
324
325
326
|
# File 'lib/ext/widgets.rb', line 324
def onMouseDown
@theme.setDownState
end
|
#onMouseOut ⇒ Object
338
339
340
|
# File 'lib/ext/widgets.rb', line 338
def onMouseOut
@theme.setDefaultState
end
|
#onMouseOver ⇒ Object
335
336
337
|
# File 'lib/ext/widgets.rb', line 335
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
|