/*
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
 */

#ifndef _BASEWND_INCLUDED_
#define _BASEWND_INCLUDED_

#include <windows.h>

class GlassView;

class BaseWnd {
public:
    BaseWnd(HWND ancestor = NULL);
    virtual ~BaseWnd();
    
    //XXX: might eliminate hParent and use m_ancestor instead
    HWND Create(HWND hParent, int x, int y, int width, int height,
                LPCTSTR lpWindowName, DWORD dwExStyle, DWORD dwStyle, HBRUSH hbrBackground);

    // Creates an overlapped window with default x, y, width and height and
    // returns its bounds. This method is used to find the default window
    // size/location when CW_USEDEFAULT can't be used (e.g. for WS_POPUP windows).
    static BOOL GetDefaultWindowBounds(LPRECT r);
    
    HWND GetHWND() { return m_hWnd; }

    static BaseWnd* FromHandle(HWND hWnd);

    inline virtual bool IsGlassWindow() { return false; }

    virtual BOOL EnterFullScreenMode(GlassView * view, BOOL animate, BOOL keepRatio) { return FALSE; }
    virtual void ExitFullScreenMode(BOOL animate) {}

    HWND GetAncestor() const { return m_ancestor; }
    void SetAncestor(HWND ancestor) { m_ancestor = ancestor; }

private:
    HWND m_hWnd;
    static LRESULT CALLBACK StaticWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

    static unsigned int sm_classNameCounter;
    
    HWND m_ancestor;  // either owner or parent. a window can't have both at once anyway
protected:
    virtual LRESULT WindowProc(UINT msg, WPARAM wParam, LPARAM lParam) = 0;
    
    virtual LPCTSTR GetWindowClassNameSuffix() = 0;
};
   
#endif  // _BASEWND_INCLUDED_
