tagging release
[dasher.git] / trunk / Src / DasherCore / ActionButton.cpp
blobaa77b72ada95a8e51883932a197b6774d8fce981
1 #include "ActionButton.h"
2 #include "DasherInterfaceBase.h"
3 #include "DasherTypes.h"
5 #include <iostream>
7 CActionButton::CActionButton(Dasher::CDasherInterfaceBase *pInterface, const std::string &strCommand, bool bAlwaysVisible)
8 : m_strCommand(strCommand) {
9 m_pInterface = pInterface;
10 m_bAlwaysVisible = bAlwaysVisible;
13 void CActionButton::SetPosition(int iX, int iY, int iWidth, int iHeight) {
14 m_iX = iX;
15 m_iY = iY;
16 m_iWidth = iWidth;
17 m_iHeight = iHeight;
20 void CActionButton::Draw(Dasher::CDasherScreen *pScreen, bool bVisible) {
21 if(bVisible || m_bAlwaysVisible)
22 pScreen->DrawRectangle(m_iX, m_iY, m_iX + m_iWidth, m_iY + m_iHeight, 1, 2, Dasher::Opts::Nodes1, true, true, 1);
25 bool CActionButton::HandleClickDown(int iTime, int iX, int iY, bool bVisible) {
26 if(!bVisible && !m_bAlwaysVisible)
27 return false;
29 if((iX > m_iX) && (iX < (m_iX + m_iWidth)) && (iY > m_iY) && (iY < (m_iY + m_iHeight))) {
30 Execute(iTime);
31 return true;
33 else
34 return false;
37 bool CActionButton::HandleClickUp(int iTime, int iX, int iY, bool bVisible) {
38 if(!bVisible && !m_bAlwaysVisible)
39 return false;
41 if((iX > m_iX) && (iX < (m_iX + m_iWidth)) && (iY > m_iY) && (iY < (m_iY + m_iHeight)))
42 return true;
43 else
44 return false;
47 void CActionButton::Execute(int iTime) {
48 m_pInterface->ExecuteCommand(m_strCommand);