summaryrefslogtreecommitdiff
path: root/src/interface
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-04-17 14:56:57 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-04-17 14:56:57 (GMT)
commitc261030cef6f63110fecf00aa2d2a22bbb953690 (patch)
treefd5669cef51195df75fca7d90b834af66fe4a9de /src/interface
parentc3c31b20b07d1971091cf225311a86c51b64e2ca (diff)
downloadpowder-c261030cef6f63110fecf00aa2d2a22bbb953690.zip
powder-c261030cef6f63110fecf00aa2d2a22bbb953690.tar.gz
Started on dropdown control
Diffstat (limited to 'src/interface')
-rw-r--r--src/interface/DropDown.cpp75
-rw-r--r--src/interface/DropDown.h29
2 files changed, 104 insertions, 0 deletions
diff --git a/src/interface/DropDown.cpp b/src/interface/DropDown.cpp
new file mode 100644
index 0000000..6944e6f
--- /dev/null
+++ b/src/interface/DropDown.cpp
@@ -0,0 +1,75 @@
+/*
+ * DropDown.cpp
+ *
+ * Created on: Apr 16, 2012
+ * Author: Simon
+ */
+
+#include "DropDown.h"
+
+namespace ui {
+
+class DropDownWindow: public ui::Window {
+ Colour background, activeBackground;
+ Colour border, activeBorder;
+ Colour text, activeText;
+ bool isMouseInside;
+public:
+ DropDownWindow(Point position, Point size, Colour background, Colour activeBackground, Colour border, Colour activeBorder, Colour text, Colour activeText):
+ Window(position, size),
+ background(background),
+ activeBackground(activeBackground),
+ border(border),
+ activeBorder(activeBorder),
+ text(text),
+ activeText(activeText)
+ {
+
+ }
+ virtual void OnDraw()
+ {
+ Graphics * g = ui::Engine::Ref().g;
+ g->fillrect(Position.X, Position.Y, Size.X, Size.Y, background.Red, background.Green, background.Blue, 255);
+ g->drawrect(Position.X, Position.Y, Size.X, Size.Y, border.Red, border.Green, border.Blue, 255);
+ }
+ virtual ~DropDownWindow() {}
+};
+
+DropDown::DropDown(Point position, Point size):
+ Component(position, size),
+ isMouseInside(false)
+{
+ activeText = background = Colour(0, 0, 0);
+ text = activeBackground = border = activeBorder = Colour(255, 255, 255);
+}
+
+void DropDown::OnMouseClick(int x, int y, unsigned int button)
+{
+ ui::Engine().Ref().ShowWindow(new DropDownWindow(ui::Point(50, 50), ui::Point(50, 50), background, activeBackground, border, activeBorder, text, activeText));
+}
+
+void DropDown::Draw(const Point& screenPos)
+{
+ Graphics * g = ui::Engine::Ref().g;
+ Point Position = screenPos;
+ if(isMouseInside)
+ {
+ g->fillrect(Position.X-1, Position.Y-1, Size.X+2, Size.Y+2, activeBackground.Red, activeBackground.Green, activeBackground.Blue, 255);
+ g->drawrect(Position.X, Position.Y, Size.X, Size.Y, activeBorder.Red, activeBorder.Green, activeBorder.Blue, 255);
+ //g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, displayText, activeText.Red, activeText.Green, activeText.Blue, 255);
+ }
+ else
+ {
+ g->fillrect(Position.X, Position.Y, Size.X, Size.Y, background.Red, background.Green, background.Blue, 255);
+ g->drawrect(Position.X, Position.Y, Size.X, Size.Y, border.Red, border.Green, border.Blue, 255);
+ //g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, displayText, text.Red, text.Green, text.Blue, 255);
+ }
+
+}
+
+
+DropDown::~DropDown() {
+ // TODO Auto-generated destructor stub
+}
+
+} /* namespace ui */
diff --git a/src/interface/DropDown.h b/src/interface/DropDown.h
new file mode 100644
index 0000000..619ec5a
--- /dev/null
+++ b/src/interface/DropDown.h
@@ -0,0 +1,29 @@
+/*
+ * DropDown.h
+ *
+ * Created on: Apr 16, 2012
+ * Author: Simon
+ */
+
+#ifndef DROPDOWN_H_
+#define DROPDOWN_H_
+
+#include "Component.h"
+#include "Colour.h"
+
+namespace ui {
+
+class DropDown: public ui::Component {
+ Colour background, activeBackground;
+ Colour border, activeBorder;
+ Colour text, activeText;
+ bool isMouseInside;
+public:
+ DropDown(Point position, Point size);
+ virtual void Draw(const Point& screenPos);
+ virtual void OnMouseClick(int x, int y, unsigned int button);
+ virtual ~DropDown();
+};
+
+} /* namespace ui */
+#endif /* DROPDOWN_H_ */