// win32mineView.h : Cwin32mineView 類別的介面
//


#pragma once
#include "atltypes.h"


class Cwin32mineView : public CView
{
protected: // 僅從序列化建立
	Cwin32mineView();
	DECLARE_DYNCREATE(Cwin32mineView)

// 屬性
public:
	Cwin32mineDoc* GetDocument() const;

// 作業
public:

// 覆寫
public:
	virtual void OnDraw(CDC* pDC);  // 覆寫以描繪此檢視
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);

// 程式碼實作
public:
	virtual ~Cwin32mineView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// 產生的訊息對應函式
protected:
	DECLARE_MESSAGE_MAP()
public:
    virtual void OnInitialUpdate();
public:
    // calcualte the width and height in pixel of the window based on the width and the height of the game board
    void calculateWindowSize(int * windowWidth, int * windowHeight);
private:
    // cell[0][0]'s left, top
    CPoint m_cellOrg;
    CPoint m_mineCountOrg;
    CPoint m_clockOrg;
    CPoint m_resetBtnOrg;
    CSize m_cellSize;
    CSize m_resetBtnSize;
    // digit size of mine count and clock 
    CSize m_digitSize;
private:
    void DrawCells(CDC* pDC, int cells[][MAXBOARDSIZE]);
    void DrawClock(CDC* pDC, int value);
    void DrawMineCount(CDC* pDC, int count);
    void DrawResetButton(CDC* pDC, int status);
    int DrawBitmap(CDC *pdc, int x, int y, int id);
    afx_msg BOOL OnEraseBkgnd(CDC* pDC);
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
    int hitTest(CPoint pt, int * cell_irow, int * cell_icol) const;
    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
    afx_msg BOOL OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT *pResult);
protected:
    virtual void OnUpdate(CView* /*pSender*/, LPARAM /*lHint*/, CObject* /*pHint*/);
public:
    virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
    void startTimer(void);
    void stopTimer(void);
private:
    UINT_PTR m_timer;
public:
    afx_msg void OnTimer(UINT_PTR nIDEvent);
    void windowLayout(void);
};

#ifndef _DEBUG  // win32mineView.cpp 中的偵錯版本
inline Cwin32mineDoc* Cwin32mineView::GetDocument() const
   { return reinterpret_cast<Cwin32mineDoc*>(m_pDocument); }
#endif

