#include "StdAfx.h"
#include "titlebar.h"

TitleBar::TitleBar(void)
{
}

TitleBar::~TitleBar(void)
{
}

void TitleBar::OnMouseMove(){
	// Moving the parent window
	if(env.mouse.LeftButton){
		SkinnableWindow * wnd = (SkinnableWindow*)GetWindowLongPtr(hWndParent,GWLP_USERDATA);
		wnd->OnMouseMove();
	} else if(state==AppearanceState::normal) 
		SetState(AppearanceState::mouseover);
}

void TitleBar::OnButton(HWND h){
	SafeSendMessage(hWndParent,WM_COMMAND,MAKEWPARAM(0,ID_LEFTBUTTON),(LPARAM)h);
}

void TitleBar::OnLButtonDown()
{
	//SetState(AppearanceState::pressed);
	SkinnableWindow * wnd = (SkinnableWindow*)GetWindowLongPtr(hWndParent,GWLP_USERDATA);
	wnd->OnLButtonDown();
}
	
void TitleBar::OnRButtonDown()
{
	//SetState(AppearanceState::pressed);
	SkinnableWindow * wnd = (SkinnableWindow*)GetWindowLongPtr(hWndParent,GWLP_USERDATA);
	wnd->OnRButtonDown();
}
