/*
- Copyright 2004-2005 Chris Tallon
+ Copyright 2004-2020 Chris Tallon
This file is part of VOMP.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
-#include "wbutton.h"
-
#include "colour.h"
+#include "wbutton.h"
+
WButton::WButton()
{
-
setSize(70, 21/*fontHeight*/);
-
- mytext = NULL;
- active = 0;
- tag = 0;
- dimmed = false;
-}
-
-WButton::~WButton()
-{
- if (mytext) delete[] mytext;
}
void WButton::setText(const char* takeText)
{
- int length = strlen(takeText);
- mytext = new char[length + 1];
- strcpy(mytext, takeText);
+ mytext = takeText;
}
void WButton::setActive(UCHAR tactive)
if (dimmed)
{
fillColour(DrawStyle::BLACK);
- drawTextCentre(mytext, area.w / 2, 0, DrawStyle::SELECTHIGHLIGHT);
+ drawTextCentre(mytext.c_str(), area.w / 2, 0, DrawStyle::SELECTHIGHLIGHT);
}
else if (active)
{
fillColour(DrawStyle::SELECTHIGHLIGHT);
- drawTextCentre(mytext, area.w / 2, 0, DrawStyle::DARKTEXT);
+ drawTextCentre(mytext.c_str(), area.w / 2, 0, DrawStyle::DARKTEXT);
}
else
{
fillColour(DrawStyle::BUTTONBACKGROUND);
- drawTextCentre(mytext, area.w / 2, 0, DrawStyle::LIGHTTEXT);
+ drawTextCentre(mytext.c_str(), area.w / 2, 0, DrawStyle::LIGHTTEXT);
}
}
return tag;
}
-// Sorry, I've broken these in the boxx upgrade - chris
+// Sorry, I've broken these in the boxx upgrade - chris // FIXME so fix it
bool WButton::mouseMove(int x, int y)
{
- if ((x-getRootBoxOffsetX())>=0 && (y-getRootBoxOffsetY())>=0
- && (x-getRootBoxOffsetX())<=(int)area.w && (y-getRootBoxOffsetY())<=(int)area.h && !active)
+ if ( (x - getRootBoxOffsetX()) >= 0
+ && (y - getRootBoxOffsetY()) >= 0
+ && (x - getRootBoxOffsetX()) <= static_cast<int>(area.w)
+ && (y - getRootBoxOffsetY()) <= static_cast<int>(area.h)
+ && !active
+ )
{
setActive(1);
return true;
bool WButton::mouseLBDOWN(int x, int y)
{
- if ((x-getRootBoxOffsetX())>=0 && (y-getRootBoxOffsetY())>=0
- && (x-getRootBoxOffsetX())<=(int)area.w && (y-getRootBoxOffsetY())<=(int)area.h && active)
+ if ( (x - getRootBoxOffsetX()) >= 0
+ && (y - getRootBoxOffsetY()) >= 0
+ && (x - getRootBoxOffsetX()) <= static_cast<int>(area.w)
+ && (y - getRootBoxOffsetY()) <= static_cast<int>(area.h)
+ && active
+ )
{
return true;
}
/*
- Copyright 2004-2005 Chris Tallon
+ Copyright 2004-2020 Chris Tallon
This file is part of VOMP.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef WBUTTON_H
#define WBUTTON_H
-#include <stdio.h>
-#include <string.h>
+#include <string>
#include "defines.h"
#include "boxx.h"
{
public:
WButton();
- virtual ~WButton();
void setText(const char* text);
void setActive(UCHAR tactive);
void dim();
virtual bool mouseLBDOWN(int x, int y);
private:
- UCHAR active;
- bool dimmed;
-
- char* mytext;
- int tag;
+ std::string mytext;
+ UCHAR active{};
+ bool dimmed{};
+ int tag{};
};
#endif