;+
;sensitive
;+
PRO sesDrawbutton::Sensitive , type

	COMPILE_OPT IDL2
	IF type EQ 0 THEN BEGIN
		Widget_Control,self.widgetID,Sensitive = 0
	ENDIF
	IF type EQ 1 THEN BEGIN
		Widget_Control,self.widgetID,Sensitive = 1
	END

END
;+
;mouse down
;+
PRO sesDrawbutton::ButtonDown

	COMPILE_OPT IDL2

	Tvlct, Reform(self.foreColor,1,3), 0
	WSet, self.drawID
	Erase, Color = 0

	orgTable = BIndgen(256,3)
	Tvlct, orgTable

	TV, Reform(self.bmpArr[2,*,*,*], [3,20,20]), /True
	self.clicked = 1

END
;+
;state resume
;+
PRO sesDrawbutton::Recover

	COMPILE_OPT IDL2

	Tvlct, Reform(self.foreColor,1,3), 0
	WSet, self.drawID
	Erase, Color = 0

	orgTable = BIndgen(256,3)
	Tvlct, orgTable

	TV, Reform(self.bmpArr[0,*,*,*], [3,20,20]), /True
	self.clicked = 0

END
;+
;mouse enter
;+
PRO sesDrawbutton::Enter

	COMPILE_OPT IDL2

	Tvlct, Reform(self.foreColor,1,3), 0
	WSet, self.drawID
	Erase, Color = 0

	orgTable = BIndgen(256,3)
	Tvlct, orgTable

	TV, Reform(self.bmpArr[1,*,*,*], [3,20,20]), /True

END
;+
;mouse handel event
;+
PRO sesDrawbutton::HandleEvent, event

	COMPILE_OPT IDL2

	tagName = Tag_Names(event, /Structure_Name)

	IF self.clicked EQ 0 THEN BEGIN
		IF tagName EQ 'WIDGET_TRACKING' THEN BEGIN
			IF event.enter EQ 1 THEN BEGIN
				self->Enter
			ENDIF ELSE BEGIN
				self->Recover
			ENDELSE
		ENDIF
		IF tagName EQ 'WIDGET_DRAW' THEN BEGIN
			IF event.press EQ 1 THEN BEGIN
				self->ButtonDown
				self.clicked = 1
				GOTO, ENDEVENT
			ENDIF
		ENDIF
	ENDIF

	IF self.clicked EQ 1 THEN BEGIN
		IF tagName EQ 'WIDGET_TRACKING' THEN BEGIN
			IF event.enter EQ 1 THEN BEGIN
				Tvlct, Reform(self.foreColor,1,3), 0
				WSet, self.drawID
				Erase, Color = 0

				orgTable = BIndgen(256,3)
				Tvlct, orgTable
				TV, Reform(self.bmpArr[2,*,*,*], [3,20,20]), /True
			ENDIF ELSE BEGIN
				Tvlct, Reform(self.foreColor,1,3), 0
				WSet, self.drawID
				Erase, Color = 0

				orgTable = BIndgen(256,3)
				Tvlct, orgTable
				TV, Reform(self.bmpArr[2,*,*,*], [3,20,20]), /True
			ENDELSE
		ENDIF
	ENDIF

	ENDEVENT:

END
;+
;create widget
;+
PRO sesDrawbutton::Create

	COMPILE_OPT IDL2

	self.widgetID = Widget_Draw(self.parent				, $
								Retain = 2				, $
								UName = self.uname		, $
								UValue = self			, $
								Tooltip = self.tooltip	, $
								/Button_Events      	, $
								/Tracking_Events    	, $
								Scr_XSize = 20			, $
								Scr_YSize = 20			)

	Widget_Control, self.widgetID, Get_Value = drawID

	self.drawID = drawID

	Tvlct, Reform(self.foreColor,1,3), 0
	WSet, self.drawID
	Erase, Color = 0

	orgTable = BIndgen(256,3)
	Tvlct, orgTable
;	 212 208 200
	TV, Reform(self.bmpArr[0,*,*,*], [3,20,20]), /True

END
;+
;create ico list
;+
PRO sesDrawbutton::CreateBmpArr, bmpFile, Type = type

	COMPILE_OPT IDL2

	FOR i=0,2 DO BEGIN
		bmp = Read_Image(bmpFile[i])
		self.bmpArr[i,*,*,*] = AdjustBmp(bmp, self.signColor, self.foreColor)

	ENDFOR


END
;+
;;;;;;clean up
;+
PRO sesDrawbutton::Cleanup

	COMPILE_OPT IDL2


END
;+
;initialize
;+
FUNCTION sesDrawbutton::Init, parent				, $
							  BmpFile = bmpFile	    , $
							  UName	= uname		    , $
							  Annotate = annotate	, $
							  LabelType = labelType	, $
							  Type = type 		    , $
							  Color = color		    , $
							  Tooltip = tooltip	    , $
							  ForeColor = foreColor	, $
							  SignColor = signColor


	COMPILE_OPT IDL2

	self.parent = parent

	IF ~Keyword_Set(annotate) THEN annotate = ''
	IF ~Keyword_Set(labelType) THEN labelType = ''
	IF ~Keyword_Set(color) THEN color = IntArr(3)

	self.annotate = annotate

	self.labelType = labelType

	self.type = type

	self.color = color

	self.uname = uname

	self.tooltip = tooltip

	self.foreColor = foreColor

	self.signColor = signColor

	self->CreateBmpArr, bmpFile, Type = type

	self->Create

	Return, 1
END
;+
;menu bar class name
;+
PRO sesDrawbutton__Define

	COMPILE_OPT IDL2

   	void = {sesDrawbutton							, $
           	;system parameter
           	parent			:	0					, $
           	uname			:	''					, $
           	tooltip			:	''					, $
           	annotate		:	''					, $
           	labelType		:	''					, $
           	type 			:	''					, $
			bmpArr 			:	BytArr(4,3,20,20)	, $
			foreColor		:	IntArr(3)			, $
			signColor		:	IntArr(3)			, $
			color			:	IntArr(3)			, $
			widgetID		:	0					, $
			drawID			:	0					, $
			clicked			:	0					$

       		}

END