Foundation classes for a basic GUI implementing simple widgets and events. (Fork for custom changes.)

Fork of SimpleGUI by Duncan McIntyre

Revision:
13:6714534e7974
Parent:
12:63db16fea709
Child:
17:5184762fda6c
--- a/Widgets/SpinnerWidget.cpp	Sun May 08 14:42:08 2016 +0000
+++ b/Widgets/SpinnerWidget.cpp	Sat May 21 14:40:09 2016 +0000
@@ -1,7 +1,7 @@
 #include "SpinnerWidget.h"
 
-#include"resources/up_arrow_32x19_bmp.h"
-#include"resources/down_arrow_32x19_bmp.h"
+#include"resources/BlueButtonLeft_50x64_bmp.h"
+#include"resources/BlueButtonRight_50x64_bmp.h"
 
 SpinnerWidget::SpinnerWidget(GraphicsContext *context)
     : ContainerWidget(context),
@@ -10,20 +10,39 @@
       _format(""), _buf("")
 {
 
-    setLayout(VERTICAL_CENTER);
-
-    _upArrow.setBitmap(up_arrow_32x19_bmp, 32, 19);
-    _upArrow.setForeground(White);
-    _upArrow.setBackground(Black);
-    _upArrow.setMonochrome(true);
+    setLayout(FIXED);
+    setBorder(1, White);
+    setPadding(1);
+    _upArrow.setBitmap(BlueButtonLeft_50x64_bmp, 50, 64);
+    _downArrow.setBitmap(BlueButtonRight_50x64_bmp, 50, 64);
+    
+    // Calculate these here to take account of border and margin settings
+    // since BitmapWidgets resize themselves rather than clip (!)
+    setSize(
+        context->display()->width(), 
+        _upArrow.height() + 2*(_borderWidth+_padding)
+    );
+    
+    _upArrow.setLocation(
+        _borderWidth + _padding,
+        _borderWidth + _padding
+    );
+    
+    _downArrow.setLocation(
+        width() - _downArrow.width() - (_borderWidth + _padding), 
+        _borderWidth + _padding
+    );
+    
 
-    _downArrow.setBitmap(down_arrow_32x19_bmp, 32, 19);
-    _downArrow.setForeground(White);
-    _downArrow.setBackground(Black);
-    _downArrow.setMonochrome(true);
+    int textWidth = width() 
+        - _upArrow.width()  - 2*(_borderWidth + _padding)
+        - _downArrow.width() - 2*(_borderWidth + _padding)
+    ;
+    
+    int textHeight = height() - 2*(_borderWidth + _padding +1);
 
-    _text.setSize(32,32);
-    _text.setBorder(1,Green);
+    _text.setSize(textWidth, textHeight);
+    _text.setLocation(_downArrow.width() + _borderWidth + _padding, _borderWidth + _padding);
     _text.setForeground(White);
     _text.setBackground(Black);
 
@@ -110,7 +129,6 @@
 
 void SpinnerWidget::setSize(int width, int height)
 {
-    _text.setSize(width, _text.height());
     ContainerWidget::setSize(width, height);
 }