text: //
  //
  // DirectUI - UI Library
  //
  // Written by Bjarke Viksoe (bjarke@viksoe.dk)
  // Copyright (c) 2006-2007 Bjarke Viksoe.
  //
  // This code may be used in compiled form in any way you desire. These
  // source files may be redistributed by any means PROVIDING it is 
  // not sold for profit without the authors written consent, and 
  // providing that this notice and the authors name is included. 
  //
  // This file is provided "as is" with no expressed or implied warranty.
  // The author accepts no liability if it causes any damage to you or your
  // computer whatsoever. It's free, so don't hassle me about it.
  //
  ////
  // Acknowledgements :
  // Bjarke Viksoe (http://www.viksoe.dk/code/windowless1.htm)
  //
  //
  //
  // Beware of bugs.
  //
  //
  //
  ////////////////////////////////////////////////////////
  
  #ifndef __UISKWINDOW_WIN_H__
  #define __UISKWINDOW_WIN_H__
  
  #ifdef UI_BUILD_FOR_SKIA
  
  #include "SkWindow.h"
  #include "SkCanvas.h"
  #include "SkBitmap.h"
  #include "UIDlgBuilder.h"
  /////////////////////////////////////////////////////////////////////////////////////
  //
  class SkWindow;
  class SkCanvas;
  
  struct SkWinWindow {
  	SkCanvas	rasterCanvas;
  	HWND		hWnd;
  	HDC			hDC;
  };
  
  class UILIB_API CSkUIWindow : public SkWindow
  {
  public:
  	CSkUIWindow();
  	virtual ~CSkUIWindow();
  
  	HWND GetHWND() const;
  	operator HWND() const;
  
  	bool RegisterWindowClass();
  	bool RegisterSuperclass();
  
  	bool UnRegisterWindowClass();
  	bool UnRegisterSuperclass();
  
  	HWND Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle, const RECT rc, HMENU hMenu = NULL);
  	HWND Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle, int x = CW_USEDEFAULT, int y = CW_USEDEFAULT, int cx = CW_USEDEFAULT, int cy = CW_USEDEFAULT, HMENU hMenu = NULL);
  	HWND Subclass(HWND hWnd);
  	void Unsubclass();
  	void ShowWindow(bool bShow = true, bool bTakeFocus = true);
  	bool ShowModal();
  	void Close();
  	void CenterWindow();
  	void SetIcon(UINT nRes);
  
  	LRESULT SendMessage(UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0L);
  	LRESULT PostMessage(UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0L);
  	void ResizeClient(int cx = -1, int cy = -1);
  
  protected:
  	virtual LPCTSTR GetWindowClassName() const = 0;
  	virtual LPCTSTR GetSuperClassName() const;
  	virtual UINT GetClassStyle() const;
  
  	virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) = 0;
  
  	virtual LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  #if defined(UI_BUILD_FOR_WIN32) && !defined(UI_BUILD_FOR_WINCE)
  	virtual LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  #endif
  
  	virtual LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnMouseWheel(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  	virtual LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam);
  
  	virtual void OnFinalMessage(HWND hWnd);
  
  	// do not override this routine
  	LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);	
  
  private:
  	static LRESULT CALLBACK __WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  	static LRESULT CALLBACK __ControlProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  
  	LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  
  #if defined(UI_BUILD_FOR_WIN32) && !defined(UI_BUILD_FOR_WINCE)
  	LRESULT OnPrintClient(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  #endif
  	virtual void onHandleInval(const SkIRect&);
  
  protected:
  	HWND m_hWnd;
  	WNDPROC m_OldWndProc;
  	bool m_bSubclassed;
  	CPaintManagerUI	m_paintManager;
  	SkWinWindow		fWinWindow;
  	SkBitmap		m_backBitmap;
  };
  
  #endif
  
  #endif // __UISKWINDOW_WIN_H__
  