Files
Work/common/PUREICON.HPP
2024-08-07 09:09:36 -04:00

124 lines
2.2 KiB
C++

#ifndef _COMMON_PUREICON_HPP_
#define _COMMON_PUREICON_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _COMMON_PUREDEVICE_HPP_
#include <common/purehdc.hpp>
#endif
#ifndef _COMMON_POINT_HPP_
#include <common/point.hpp>
#endif
#ifndef _COMMON_ICONINFO_HPP_
#include <common/iconinfo.hpp>
#endif
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
class PureIcon : public IconInfo
{
public:
PureIcon(void);
PureIcon(HICON hIcon);
PureIcon(HINSTANCE hProcessInstance,const String &iconName);
PureIcon(const PureIcon &somePureIcon);
virtual ~PureIcon();
PureIcon &operator=(const PureIcon &somePureIcon);
WORD operator==(const PureIcon &somePureIcon)const;
WORD drawIcon(PureDevice &somePureDevice,const Point &xyPoint);
operator HICON(void)const;
WORD isOkay(void)const;
private:
void getIconInfo(void);
void destroyIconInfo(void);
HICON mhIcon;
};
inline
PureIcon::PureIcon(void)
: mhIcon(0)
{
}
inline
PureIcon::PureIcon(HICON hIcon)
: mhIcon(hIcon)
{
getIconInfo();
}
inline
PureIcon::PureIcon(HINSTANCE hProcessInstance,const String &iconName)
: mhIcon(0)
{
if(iconName.isNull())return;
mhIcon=::LoadIcon(hProcessInstance,iconName);
getIconInfo();
return;
}
inline
PureIcon::PureIcon(const PureIcon &somePureIcon)
{
*this=somePureIcon;
}
inline
PureIcon::~PureIcon()
{
destroyIconInfo();
}
inline
PureIcon &PureIcon::operator=(const PureIcon &somePureIcon)
{
if(somePureIcon.isOkay())
{
mhIcon=(HICON)somePureIcon;
getIconInfo();
}
return *this;
}
inline
WORD PureIcon::operator==(const PureIcon &somePureIcon)const
{
return (HICON)*this==(HICON)somePureIcon;
}
inline
PureIcon::operator HICON(void)const
{
return mhIcon;
}
inline
WORD PureIcon::drawIcon(PureDevice &somePureDevice,const Point &xyPoint)
{
if(!isOkay())return FALSE;
return ::DrawIcon(somePureDevice,xyPoint.x(),xyPoint.y(),mhIcon);
}
inline
void PureIcon::getIconInfo(void)
{
if(!isOkay())return;
destroyIconInfo();
::GetIconInfo(mhIcon,&((_ICONINFO&)((IconInfo&)*this)));
}
inline
void PureIcon::destroyIconInfo(void)
{
if(maskBitmap()){::DeleteObject(maskBitmap());maskBitmap(0);}
if(colorBitmap()){::DeleteObject(colorBitmap());colorBitmap(0);}
}
inline
WORD PureIcon::isOkay(void)const
{
return (mhIcon?TRUE:FALSE);
}
#endif