76 lines
1.7 KiB
C++
76 lines
1.7 KiB
C++
#ifndef _LEDDISPLAY_HPP_
|
|
#define _LEDDISPLAY_HPP_
|
|
#include <common/windows.hpp>
|
|
#include <common/string.hpp>
|
|
#include <common/point.hpp>
|
|
|
|
class LedDisplay
|
|
{
|
|
public:
|
|
enum SpecialChar{BlankChar,DashChar};
|
|
LedDisplay(HWND hDisplayWindow,Point windowPoint);
|
|
virtual ~LedDisplay();
|
|
void setNumber(short someNumber);
|
|
void setNumber(SpecialChar specialChar);
|
|
short getNumber(void)const;
|
|
void paint(void);
|
|
private:
|
|
enum {Width=13,Height=23,Frames=12};
|
|
enum {OffsetDashChar,OffsetBlankChar};
|
|
WORD charPosition(char someDisplayChar)const;
|
|
void positions(WORD &firstOffset,WORD &secondOffset,WORD &thirdOffset,WORD &fourthOffset)const;
|
|
HBITMAP mhFilm;
|
|
short mCurrentNumber;
|
|
SpecialChar mCurrentSpecialChar;
|
|
WORD mHasSpecialChar;
|
|
Point mWindowPoint;
|
|
HWND mhDisplayWindow;
|
|
};
|
|
|
|
inline
|
|
LedDisplay::LedDisplay(HWND hDisplayWindow,Point windowPoint)
|
|
: mWindowPoint(windowPoint), mhDisplayWindow(hDisplayWindow), mCurrentNumber(-1),
|
|
mHasSpecialChar(TRUE), mCurrentSpecialChar(DashChar),
|
|
#if defined(__FLAT__)
|
|
mhFilm(::LoadBitmap((HINSTANCE)::GetWindowWord(hDisplayWindow,GWL_HINSTANCE),"LED"))
|
|
#else
|
|
mhFilm(::LoadBitmap((HINSTANCE)::GetWindowWord(hDisplayWindow,GWW_HINSTANCE),"LED"))
|
|
#endif
|
|
{
|
|
}
|
|
|
|
inline
|
|
LedDisplay::~LedDisplay()
|
|
{
|
|
if(mhFilm){::DeleteObject(mhFilm);mhFilm=0;}
|
|
}
|
|
|
|
inline
|
|
WORD LedDisplay::charPosition(char someChar)const
|
|
{
|
|
return ((Frames-1)-((int)someChar-'0'));
|
|
}
|
|
|
|
inline
|
|
short LedDisplay::getNumber(void)const
|
|
{
|
|
return mCurrentNumber;
|
|
}
|
|
|
|
inline
|
|
void LedDisplay::setNumber(SpecialChar specialChar)
|
|
{
|
|
mHasSpecialChar=TRUE;
|
|
mCurrentSpecialChar=specialChar;
|
|
paint();
|
|
}
|
|
|
|
inline
|
|
void LedDisplay::setNumber(short someNumber)
|
|
{
|
|
mHasSpecialChar=FALSE;
|
|
mCurrentNumber=someNumber;
|
|
paint();
|
|
}
|
|
#endif
|