source: advance-wars/src/com/medievaltech/gui/Button.java@ abe7b3d

Last change on this file since abe7b3d was abe7b3d, checked in by dportnoy <devnull@…>, 14 years ago

Changed the package names from com.example.* to com.medievaltech.*

  • Property mode set to 100644
File size: 683 bytes
Line 
1package com.medievaltech.gui;
2
3import android.graphics.Canvas;
4import android.graphics.Paint;
5
6public class Button extends GUIObject {
7 private String text;
8 private Paint textPaint;
9 private float vOffset;
10
11 public Button(String newText, int newX, int newY, int newWidth, int newHeight, Paint linePaint, Paint textPaint) {
12 super(newX, newY, newWidth, newHeight, linePaint);
13
14 this.textPaint = textPaint;
15 text = newText;
16 vOffset = -(textPaint.getFontMetrics().ascent+textPaint.getFontMetrics().descent)/2;
17 }
18
19 public void draw(Canvas c) {
20 c.drawRect(x, y, x+width, y+height, p);
21 c.drawText(text, x+width/2, y+height/2+vOffset, textPaint);
22 }
23}
Note: See TracBrowser for help on using the repository browser.