diff options
| author | Simon 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) |
| commit | c261030cef6f63110fecf00aa2d2a22bbb953690 (patch) | |
| tree | fd5669cef51195df75fca7d90b834af66fe4a9de /src/interface/DropDown.cpp | |
| parent | c3c31b20b07d1971091cf225311a86c51b64e2ca (diff) | |
| download | powder-c261030cef6f63110fecf00aa2d2a22bbb953690.zip powder-c261030cef6f63110fecf00aa2d2a22bbb953690.tar.gz | |
Started on dropdown control
Diffstat (limited to 'src/interface/DropDown.cpp')
| -rw-r--r-- | src/interface/DropDown.cpp | 75 |
1 files changed, 75 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 */ |
