ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / Examples / Android / ardrone / project / src / com / parrot / ARDrone / RotatedButton.java
1 package com.parrot.ARDrone;\r
2 \r
3 import android.content.Context;\r
4 import android.graphics.Canvas;\r
5 import android.util.AttributeSet;\r
6 import android.widget.Button;\r
7 \r
8 public class RotatedButton extends Button {\r
9     public RotatedButton(Context context) {\r
10         super(context, null);\r
11     }\r
12 \r
13     public RotatedButton(Context context, AttributeSet attrs) {\r
14         super(context, attrs );\r
15     }\r
16 \r
17     public RotatedButton(Context context, AttributeSet attrs, int defStyle) {\r
18         super(context, attrs, defStyle);\r
19     }\r
20         \r
21         @Override\r
22         protected void onDraw( Canvas canvas ) {\r
23              canvas.save();\r
24              int bottom = this.getBottom();\r
25              int top = this.getTop();\r
26              int right = this.getRight();\r
27              int left = this.getLeft();\r
28              \r
29              // int rotX = left + (right - left)/2;\r
30              // int rotY =  top + (bottom-top)/2; \r
31 \r
32              /*int rotX = (right - left)/2;\r
33              int rotY = (bottom-top)/2; */ \r
34              int rotX = this.getWidth()/2;\r
35              int rotY = this.getHeight()/2; \r
36              \r
37              canvas.rotate(180, rotX, rotY); \r
38              super.onDraw(canvas);\r
39              canvas.restore();\r
40         }\r
41         \r
42 }\r