/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef NATIVEVIEW_H
#define NATIVEVIEW_H

#include <boost/utility.hpp>
#include "NativeWindow.h"

namespace winBe {

	
	class NativeView : public boost::noncopyable
	{
	public:
		NativeView (BView* view, NativeWindow* window);
		virtual ~NativeView ();

		void createWindow (const char* name, int left, int top, int right, int bottom, HWND hWndParent);
		void destroy ();
		void setBgColor (COLORREF color);
		void setPen (int width, COLORREF color);
		void captureKeyboard ();
		void captureMouse ();

		inline NativeWindow* getWindow () { return window; };
		inline BView* getBView () { return view; };
		inline HWND getHWND () { return hWnd; };
		inline HDC getDC () { return hDC; };
		inline COLORREF getColor () { return viewColor; };
		inline HPEN getPen () { return hPen; };

		void onPaint (RECT&, HDC hDC);
		void onMouseUp (int button, int x, int y, int modifiers);
		void onMouseDown (int button, int x, int y, int modifiers);
		void onMouseMove (int x, int y, int modifiers);
		void onEraseBackground (HDC hDC);

	private:
		static NativeView* getNativeView (HWND hWnd);
		friend LRESULT CALLBACK NativeViewWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

		BView* view;
		NativeWindow* window;
		COLORREF viewColor;
		HWND hWnd;
		HDC hDC;
		HPEN hPen;
	};

}

#endif // NATIVEVIEW_H
