#pragma once
#include "skinnableframe.h"
#include "textbox.h"
#include "resizingbutton.h"
#include "StringMap.h"

class ChatWindow :
	public SkinnableFrame
{
public:
	ChatWindow(int id, const TCHAR * recipient);
	~ChatWindow(void);
	int Create(HWND parent = 0);
	void OnCarriageReturn(HWND h);

	virtual void OnSize(int cx, int cy);
	virtual void OnClose();
	virtual void OnCustomNotify(int id, Notification& n);

	// placing messages in the history box comes in 3 flavors:
	void FriendMessage(const TCHAR * username, const TCHAR * msg);
	void MyMessage(const TCHAR * msg);
	void SystemMessage(const TCHAR * msg);

	// Data
	TextBox history; // the chat history is contained in here
	TextBox msg; // the user types messages here
	HWND hBrowser;

	int recipientId;
	std::wstring recipient; // of the chat messages

	int padding;

	// Text formatting
	static void LoadTranslator(const char * b);
	static const TCHAR * TranslateMessage(const TCHAR * msg);
	std::wstring MyFormat, FriendFormat, SystemFormat;
	static StringMap tmap; // the mapping of substrings to pieces of html
};
