00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <GLW/GLWTextButton.h>
00022 #include <GLW/GLWFont.h>
00023
00024 REGISTER_CLASS_SOURCE(GLWTextButton);
00025
00026 GLWTextButton::GLWTextButton(const LangString &buttonText,
00027 float x, float y, float w, GLWButtonI *handler,
00028 unsigned flags, float size) :
00029 GLWButton(x, y, w, size + 8.0f, handler, flags),
00030 label_(x, y -2, buttonText, size),
00031 color_(GLWFont::widgetFontColor)
00032 {
00033 }
00034
00035 GLWTextButton::~GLWTextButton()
00036 {
00037 }
00038
00039 void GLWTextButton::draw()
00040 {
00041 GLWButton::draw();
00042
00043 float x = x_;
00044 if (!pressed_)
00045 {
00046 label_.setY(y_ - 2);
00047 }
00048 else
00049 {
00050 x = x_ + 1;
00051 label_.setY(y_ - 3);
00052 }
00053 if (flags_ & ButtonFlagCenterX)
00054 {
00055 label_.calcWidth();
00056 x += (w_ / 2.0f) - (label_.getW() / 2.0f);
00057 }
00058
00059 if (enabled_) label_.setColor(color_);
00060 else label_.setColor(GLWFont::disabledWidgetFontColor);
00061
00062 label_.setX(x);
00063 label_.draw();
00064 }