dofile( XLCurPath().."Message.lua" )

function OnMsgWndPaint( obj, wParm, lParam )
	XLDrawPicture( obj, 0, 0, 287, 193, XLCurPath().."Msg_Skin.bmp" );
	XLDrawPicture( obj, 5, 0, 59, 25, XLCurPath().."Msg_title.bmp" );
end

function OnDecratedWindowSize( obj, wParam, lParam )
	windowleft = XLGetWindowLeft( lParam );
	windowtop = XLGetWindowTop( lParam );
	windowWidth = XLGetWindowWidth( lParam );
	windowHeight = XLGetWindowHeight( lParam );
	
	left = windowleft - 6;
	top = windowtop - 25;
	Width = windowWidth + 12;
	Height = windowHeight + 31;
	
	XLSetRect( obj, left, top, Width, Height );
	XLMoveWindow( lParam, 6, 25, windowWidth, windowHeight );
	
	id = XLGetWindowElement( obj, "close" );
	XLSetRect( id, 247, 0, 34, 18 );
end
function OnInitSkin( obj, wParam, lParam )
	XLSetCanDrag( obj );
	MainHwnd = XLGetHwnd( obj );
	XLSetWindowToBitmapRegionByColor( MainHwnd, XLCurPath().."Msg_Skin.bmp", 12632256 );	
end

MainWndID = XLRegisterWindow( "XLMsgMainWnd" );
XLRegisterMessage( MainWndID, WM_PAINT, "OnMsgWndPaint" );
XLRegisterMessage( MainWndID, WM_DECORATEDWINDOWSIZE, "OnDecratedWindowSize" );
XLRegisterMessage( MainWndID, WM_INITSKIN, "OnInitSkin" );


function OnClosePaint( obj, wParam, lParam )
	XLDrawPicture( obj, 0, 0, 34, 18, XLCurPath().."Msg_close_nor.bmp" );
end
function OnCloseMouseMove( obj, wParam, lParam )
	if XLIsCapture( obj) == 1 then
		if XLIsMouseInRect( obj ) == 1 then
			XLDrawPicture( obj, 0, 0, 34, 18, XLCurPath().."Msg_close_down.bmp" );
		else
			XLDrawPicture( obj, 0, 0, 34, 18, XLCurPath().."Msg_close_over.bmp" );
		end
	else
		XLDrawPicture( obj, 0, 0, 34, 18, XLCurPath().."Msg_close_over.bmp" );
	end
end
function OnCloseLButtonDown( obj, wParam, lParam )
	XLSetCapture( obj );	
	XLDrawPicture( obj, 0, 0, 34, 18, XLCurPath().."Msg_close_down.bmp" );
end
function OnCloseLButtonUp( obj, wParam, lParam )
	if XLIsMouseInRect( obj ) == 1 then
		XLDrawPicture( obj, 0, 0, 34, 18, XLCurPath().."Msg_close_over.bmp" );
	else
		XLDrawPicture( obj, 0, 0, 34, 18, XLCurPath().."Msg_close_nor.bmp" );
	end
end

CloseID = XLRegisterWindowElement( MainWndID, "close", 247, 0, 34, 18, 61536 )
XLRegisterElementMessage( CloseID, WM_PAINT, "OnClosePaint" );
XLRegisterElementMessage( CloseID, WM_MOUSEMOVE, "OnCloseMouseMove" );
XLRegisterElementMessage( CloseID, WM_LBUTTONDOWN, "OnCloseLButtonDown" );
XLRegisterElementMessage( CloseID, WM_LBUTTONUP, "OnCloseLButtonUp" );



function OnButtonCloseInit( obj, wPaarm, lParam )
	ButtonCloseHwnd = XLGetHwnd( obj );
	XLSetWindowToBitmapRegionByColor( ButtonCloseHwnd, XLCurPath().."button_close_nor.bmp", 12632256 );	
	XLSetWindowToBitmapRegionByColor( ButtonCloseHwnd, XLCurPath().."button_close_over.bmp", 12632256 );
	XLSetWindowToBitmapRegionByColor( ButtonCloseHwnd, XLCurPath().."button_close_down.bmp", 12632256 );	
end

function OnButtonClosePaint( obj, wParam, lParam )
	XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_close_nor.bmp" );
end

function OnButtonCloseMouseMove( obj, wPaarm, lParam )
	if XLIsCapture( obj ) == 1 then
		if XLIsMouseInRect( obj ) == 1 then
			XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_close_down.bmp" );
		else
			XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_close_over.bmp" );
		end
	else
		XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_close_over.bmp" );
	end
end

function OnButtonCloseMouseLeave( obj, wPaarm, lParam )
	XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_close_nor.bmp" );
end

function OnButtonCloseLButtonDown( obj, wPaarm, lParam )
	XLSetCapture( obj );
	XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_close_down.bmp" );
end

function OnButtonCloseLButtonUp( obj, wParam, lParam )
	if XLIsCapture( obj ) == 1 then
		XLDrawPicture( obj, 0, 0, 34, 18, XLCurPath().."button_close_over.bmp" );
	else
		XLDrawPicture( obj, 0, 0, 34, 18, XLCurPath().."button_close_nor.bmp" );
	end
end

ButtonCloseID = XLRegisterWindow( "ButtonClose" );
XLRegisterMessage( ButtonCloseID, WM_PAINT, "OnButtonClosePaint");
XLRegisterMessage( ButtonCloseID, WM_INITSKIN, "OnButtonCloseInit" );
XLRegisterMessage( ButtonCloseID, WM_MOUSEMOVE, "OnButtonCloseMouseMove" );
XLRegisterMessage( ButtonCloseID, WM_MOUSELEAVE, "OnButtonCloseMouseLeave" );
XLRegisterMessage( ButtonCloseID, WM_LBUTTONDOWN, "OnButtonCloseLButtonDown" );
XLRegisterMessage( ButtonCloseID, WM_LBUTTONUP, "OnButtonCloseLButtonUp" );

function OnButtonViewInit( obj, wParm, lParam )
	ButtonViewHwnd = XLGetHwnd( obj );
	XLSetWindowToBitmapRegionByColor( ButtonViewHwnd, XLCurPath().."button_view_nor.bmp", 12632256 );	
	XLSetWindowToBitmapRegionByColor( ButtonViewHwnd, XLCurPath().."button_view_over.bmp", 12632256 );	
	XLSetWindowToBitmapRegionByColor( ButtonViewHwnd, XLCurPath().."button_view_down.bmp", 12632256 );	
end
function OnButtonViewPaint( obj, wParm, lParam )
	XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_view_nor.bmp" );
end
function OnButtonViewMouseMove( obj, wPaarm, lParam )
	if XLIsCapture( obj ) == 1 then
		if XLIsMouseInRect( obj ) == 1 then
			XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_view_down.bmp" );
		else
			XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_view_over.bmp" );
		end
	else
		XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_view_over.bmp" );
	end
end
function OnButtonViewMouseLeave( obj, wPaarm, lParam )
	XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_view_nor.bmp" );
end
function OnButtonViewLButtonDown( obj, wPaarm, lParam )
	XLSetCapture( obj );
	XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_view_down.bmp" );
end
function OnButtonViewLButtonUp( obj, wPaarm, lParam )
	if XLIsCapture( obj ) == 1 then
		XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_view_over.bmp" );
	else
		XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_view_nor.bmp" );
	end
end

ButtonViewID = XLRegisterWindow( "ButtonView" );
XLRegisterMessage( ButtonViewID, WM_PAINT, "OnButtonViewPaint");
XLRegisterMessage( ButtonViewID, WM_INITSKIN, "OnButtonViewInit" );
XLRegisterMessage( ButtonViewID, WM_MOUSEMOVE, "OnButtonViewMouseMove" );
XLRegisterMessage( ButtonViewID, WM_MOUSELEAVE, "OnButtonViewMouseLeave" );
XLRegisterMessage( ButtonViewID, WM_LBUTTONDOWN, "OnButtonViewLButtonDown" );
XLRegisterMessage( ButtonViewID, WM_LBUTTONUP, "OnButtonViewLButtonUp" );


function OnButtonNextInit( obj, wParm, lParam )
	ButtonNextHwnd = XLGetHwnd( obj );
	XLSetWindowToBitmapRegionByColor( ButtonNextHwnd, XLCurPath().."button_next_nor.bmp", 12632256 );	
	XLSetWindowToBitmapRegionByColor( ButtonNextHwnd, XLCurPath().."button_next_over.bmp", 12632256 );	
	XLSetWindowToBitmapRegionByColor( ButtonNextHwnd, XLCurPath().."button_next_down.bmp", 12632256 );	
end
function OnButtonNextPaint( obj, wParm, lParam )
	XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_next_nor.bmp" );
end
function OnButtonNextMouseMove( obj, wPaarm, lParam )
	if XLIsCapture( obj ) == 1 then
		if XLIsMouseInRect( obj ) == 1 then
			XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_next_down.bmp" );
		else
			XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_next_over.bmp" );
		end
	else
		XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_next_over.bmp" );
	end
end
function OnButtonNextMouseLeave( obj, wPaarm, lParam )
	XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_next_nor.bmp" );
end
function OnButtonNextLButtonDown( obj, wPaarm, lParam )
	XLSetCapture( obj );
	XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_next_down.bmp" );
end
function OnButtonNextLButtonUp( obj, wPaarm, lParam )
	if XLIsCapture( obj ) == 1 then
		XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_next_over.bmp" );
	else
		XLDrawPicture( obj, 0, 0, 62, 22, XLCurPath().."button_next_nor.bmp" );
	end
end

ButtonNextID = XLRegisterWindow( "ButtonNext" );
XLRegisterMessage( ButtonNextID, WM_PAINT, "OnButtonNextPaint");
XLRegisterMessage( ButtonNextID, WM_INITSKIN, "OnButtonNextInit" );
XLRegisterMessage( ButtonNextID, WM_MOUSEMOVE, "OnButtonNextMouseMove" );
XLRegisterMessage( ButtonNextID, WM_MOUSELEAVE, "OnButtonNextMouseLeave" );
XLRegisterMessage( ButtonNextID, WM_LBUTTONDOWN, "OnButtonNextLButtonDown");
XLRegisterMessage( ButtonNextID, WM_LBUTTONUP, "OnButtonNextLButtonUp"); 


XLSkinDecorateWindow( "XLMsgMainWnd", "XLMsgWnd" );
XLSkinEffectWindow( "ButtonClose", "BClose" );
XLSkinEffectWindow( "ButtonView", "BView" );
XLSkinEffectWindow( "ButtonNext", "BNext" );

