diff options
| author | jacob1 <jfu614@gmail.com> | 2012-09-20 23:33:16 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-09-25 19:09:24 (GMT) |
| commit | 187a5189d597786e51a89221b16393e4ccc37256 (patch) | |
| tree | ccd7af7fb8b6c3928364a5b361d037f1a00c2573 /src/interface/Checkbox.cpp | |
| parent | 5ee1c7ff801b475b4447c5ee6db4a77d0f75f532 (diff) | |
| download | powder-187a5189d597786e51a89221b16393e4ccc37256.zip powder-187a5189d597786e51a89221b16393e4ccc37256.tar.gz | |
some improvements to the render options interface and checkboxes (icons and tooltips coming next)
Diffstat (limited to 'src/interface/Checkbox.cpp')
| -rw-r--r-- | src/interface/Checkbox.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/interface/Checkbox.cpp b/src/interface/Checkbox.cpp index c0dd47b..d7be324 100644 --- a/src/interface/Checkbox.cpp +++ b/src/interface/Checkbox.cpp @@ -9,9 +9,10 @@ using namespace ui; -Checkbox::Checkbox(ui::Point position, ui::Point size, std::string text): +Checkbox::Checkbox(ui::Point position, ui::Point size, std::string text, std::string toolTip): Component(position, size), text(text), + toolTip(toolTip), isMouseOver(false), checked(false), actionCallback(NULL) @@ -30,6 +31,13 @@ std::string Checkbox::GetText() return text; } +void Checkbox::SetIcon(Icon icon) +{ + Appearance.icon = icon; + iconPosition.X = 19; + iconPosition.Y = 3; +} + void Checkbox::OnMouseClick(int x, int y, unsigned int button) { if(checked) @@ -53,6 +61,10 @@ void Checkbox::OnMouseUp(int x, int y, unsigned int button) void Checkbox::OnMouseEnter(int x, int y) { isMouseOver = true; + if(toolTip.length()>0 && GetParentWindow()) + { + GetParentWindow()->ToolTip(this, ui::Point(x, y), toolTip); + } } void Checkbox::OnMouseLeave(int x, int y) @@ -71,12 +83,18 @@ void Checkbox::Draw(const Point& screenPos) { g->drawrect(screenPos.X+2, screenPos.Y+2, 12, 12, 255, 255, 255, 255); g->fillrect(screenPos.X+5, screenPos.Y+5, 6, 6, 255, 255, 255, 170); - g->drawtext(screenPos.X+18, screenPos.Y+4, text, 255, 255, 255, 255); + if (!Appearance.icon) + g->drawtext(screenPos.X+18, screenPos.Y+4, text, 255, 255, 255, 255); + else + g->draw_icon(screenPos.X+15, screenPos.Y+iconPosition.Y, Appearance.icon); } else { g->drawrect(screenPos.X+2, screenPos.Y+2, 12, 12, 255, 255, 255, 200); - g->drawtext(screenPos.X+18, screenPos.Y+4, text, 255, 255, 255, 200); + if (!Appearance.icon) + g->drawtext(screenPos.X+18, screenPos.Y+4, text, 255, 255, 255, 200); + else + g->draw_icon(screenPos.X+15, screenPos.Y+iconPosition.Y, Appearance.icon); } } |
