#ifndef _COMMON_LINKEDBUTTON_HPP_
#define _COMMON_LINKEDBUTTON_HPP_
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
#ifndef _COMMON_PUREBITMAP_HPP_
#include <common/purebmp.hpp>
#endif

class LinkedButton 
{
public:
	enum FocusItem{Focus,NoFocus};
	LinkedButton(void);
	LinkedButton(int ctlID,String &focusUp,String &noFocusUp,String &focusDown,HINSTANCE hLibrary,FocusItem focusItem=Focus);
	LinkedButton(int ctlID,String &focusUp,String &noFocusUp,String &focusDown,String &noFocusDisabled,HINSTANCE hLibrary,FocusItem focusItem=Focus);
	LinkedButton(const LinkedButton &someLinkedButton);
	virtual ~LinkedButton();
	WORD drawButton(LPDRAWITEMSTRUCT lpControlData);
	int referenceCount(void)const;
	void referenceCount(int newCount);
	WORD operator==(const LinkedButton &someLinkedButton)const;
	WORD operator==(int ctlID)const;
	HINSTANCE instance(void)const;
private:
  void instance(HINSTANCE hInstance);
	void setBitmapDefault(void);
	void loadButtons(void);
  void drawBitmap(const LPDRAWITEMSTRUCT lpControlData,PureBitmap &pureBitmap);

	int mCtlID;
	PureBitmap mBitmapFocusUp;
	PureBitmap mBitmapNoFocusUp;
	PureBitmap mBitmapFocusDown;
	PureBitmap mBitmapDisabled;
	PureBitmap *mlpBitmapDefault;
	String mFocusUpString;
	String mNoFocusUpString;
	String mFocusDownString;
	String mNoFocusDisabledString;
	int mReferenceCount;
	FocusItem mFocus;
	HINSTANCE mhInstance;
};

inline
int LinkedButton::referenceCount(void)const
{
	return mReferenceCount;
}

inline
void LinkedButton::referenceCount(int newCount)
{
	mReferenceCount=newCount;
}

inline
WORD LinkedButton::operator==(const LinkedButton &someLinkedButton)const
{
	return (mCtlID==someLinkedButton.mCtlID);
}

inline
WORD LinkedButton::operator==(int ctlID)const
{
	return mCtlID==ctlID;
} 

inline
HINSTANCE LinkedButton::instance(void)const
{
  return mhInstance;
}

inline
void LinkedButton::instance(HINSTANCE hInstance)
{
  mhInstance=hInstance;
}

inline
void LinkedButton::setBitmapDefault(void)
{
  if(Focus==mFocus)mlpBitmapDefault=&mBitmapFocusUp;
	else mlpBitmapDefault=&mBitmapNoFocusUp;
}
#endif

