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

class ChatRoom :
	public SkinnableFrame
{
public:
	ChatRoom(int id, const TCHAR * recipient);
	~ChatRoom(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);

	// the interaction states
	enum InteractionState {sendinvite, rsvp, accepted};
	InteractionState mode;
	void SendInvitation(); // the user is expected to enter an invitation message
	void RespondToInvitation(); // the user is expected to respond to the invitation message
	void AcceptInvitation(); // if accepted then a discussion starts

	// 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
	Vector<int> members;
	Vector<int> active;

	int padding;
	std::wstring MyFormat, FriendFormat, SystemFormat;

};
