ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / Examples / Android / ardrone / project / src / com / parrot / ARDrone / RotatedButton.java
diff --git a/mardrone/ARDrone_SDK_Version_1_8_20110726/Examples/Android/ardrone/project/src/com/parrot/ARDrone/RotatedButton.java b/mardrone/ARDrone_SDK_Version_1_8_20110726/Examples/Android/ardrone/project/src/com/parrot/ARDrone/RotatedButton.java
new file mode 100644 (file)
index 0000000..b74fba7
--- /dev/null
@@ -0,0 +1,42 @@
+package com.parrot.ARDrone;\r
+\r
+import android.content.Context;\r
+import android.graphics.Canvas;\r
+import android.util.AttributeSet;\r
+import android.widget.Button;\r
+\r
+public class RotatedButton extends Button {\r
+    public RotatedButton(Context context) {\r
+        super(context, null);\r
+    }\r
+\r
+    public RotatedButton(Context context, AttributeSet attrs) {\r
+        super(context, attrs );\r
+    }\r
+\r
+    public RotatedButton(Context context, AttributeSet attrs, int defStyle) {\r
+        super(context, attrs, defStyle);\r
+    }\r
+       \r
+       @Override\r
+       protected void onDraw( Canvas canvas ) {\r
+            canvas.save();\r
+            int bottom = this.getBottom();\r
+            int top = this.getTop();\r
+            int right = this.getRight();\r
+            int left = this.getLeft();\r
+            \r
+            // int rotX = left + (right - left)/2;\r
+            // int rotY =  top + (bottom-top)/2; \r
+\r
+            /*int rotX = (right - left)/2;\r
+            int rotY = (bottom-top)/2; */ \r
+            int rotX = this.getWidth()/2;\r
+            int rotY = this.getHeight()/2; \r
+            \r
+            canvas.rotate(180, rotX, rotY); \r
+            super.onDraw(canvas);\r
+            canvas.restore();\r
+       }\r
+       \r
+}\r