// Start =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// General information section.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// $Author:yongkiang$ User who last changed the file
// $Date:1/2/2013 12:16:34 PM$ Date and time of last check in
// $Revision:1.0$ Visual SourceSafe version number
// $Workfile::   mainfrm.h                                             $ Filename
// End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
// {{AFX_INCLUDES()
#include "MainSheet.h"
#include "OOExToolBar.h"
#include "SplashScreenEx.h"
// }}AFX_INCLUDES

#if !defined(AFX_MAINFRM_H__2250FB38_F9DF_11D0_B9B3_0080489188C9__INCLUDED_)
#define AFX_MAINFRM_H__2250FB38_F9DF_11D0_B9B3_0080489188C9__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#ifdef  BUILD_GUIDLL
#define     DLLCLASS    __declspec(dllexport)
#else
#define     DLLCLASS    __declspec(dllimport)
#endif

class CMainDoc;

class DLLCLASS CMainFrame : public CFrameWnd
{
friend class CRunView;
protected: // create from serialization only
    CMainFrame();
    DECLARE_DYNCREATE(CMainFrame)

// Attributes
public:

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
// {{AFX_VIRTUAL(CMainFrame)
public:
    virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
    virtual BOOL PreTranslateMessage(MSG* pMsg);
// }}AFX_VIRTUAL

// Implementation
public:
// Gary 2Aug11, V1.24.05
// method to close all menu pages and go to main page
    void ShotcutToMainPage();

// Gary 2Aug11, V1.24.05
// method to check if any menu pages are in focus
    bool IsMenuPagesFocus();

    LRESULT DisableMenuButtons(WPARAM wNo, LPARAM lp);
    LRESULT ReleaseMenuButtons(WPARAM wNo, LPARAM lp);
    void    RefreshLotReportPage(void);
    bool    CheckChildIsVisible();
    void    ShortcutToRunReset();
    void    ShortcutToRunStop();
    void    ShortcutToRunStart();
    void    ShortcutToHelpPage(LPARAM lpDisplayPage = 0);
    void    ShortcutToAlarmPage(LPARAM lpDisplayPage = 0);
    void    ShortcutToDatalogLotSpcPage(LPARAM lpDisplayPage = 0);
    void    ShortcutToSetupModulePage(LPARAM lpDisplayPage = 0);
    void    ShortcutToRecipePage(LPARAM lpDisplayPage = 0);
    void    ShortcutToMaintenancePage(LPARAM lpDisplayPage = 0);
    void    ShortcutToJobLoadPage(LPARAM lpDisplayPage = 0);
    void    OnWndClose();
    void    DisplayIn2ndLang();

//  reset warn count
    void ResetWarnCnt();

//  enable all menu buttons
    void EnableAllMenuButtons();

//  disable all menu buttons
    void DisableAllMenuButtons();

    virtual ~CMainFrame();

#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
#endif

protected: // control bar embedded members
    COOBmpToolBar m_mainToolBar;

// to switch between different views

// Generated message map functions
protected:
    void OnCustomizedSwitch(int nSwitchNo, int nState);
// {{AFX_MSG(CMainFrame)
    afx_msg int  OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg void OnRunPurge();
    afx_msg void OnRunReset();
    afx_msg void OnRunRestart();
    afx_msg void OnRunStart();
    afx_msg void OnRunStop();
    afx_msg void OnUpdateRunPurge(CCmdUI* pCmdUI);
    afx_msg void OnUpdateRunReset(CCmdUI* pCmdUI);
    afx_msg void OnUpdateRunRestart(CCmdUI* pCmdUI);
    afx_msg void OnUpdateRunStart(CCmdUI* pCmdUI);
    afx_msg void OnUpdateRunStop(CCmdUI* pCmdUI);
    afx_msg void OnClose();
    afx_msg void OnMove(int x, int y);
    afx_msg void OnTimer(UINT nIDEvent);
// }}AFX_MSG
    afx_msg void OnDeleteButton();

#if _MSC_VER > 1200 // Version Higher than VC6
    afx_msg void OnMainMenu(UINT nID);
#else // VC 6 Version
    afx_msg void OnMainMenu(UINT nID, LPARAM lpDisplayPage = 0);
#endif

    afx_msg LRESULT OnSwitchDown(WPARAM wNo, LPARAM lp);
    afx_msg LRESULT OnJam(WPARAM wpID, LPARAM lpCount);
    afx_msg LRESULT OnJamReset(WPARAM wpID, LPARAM lpCount); // wm_jam_reset post by CRunCtrl
    afx_msg LRESULT OnWarning(WPARAM wpID, LPARAM lpClear);
    afx_msg LRESULT OnPowerUpComplete(WPARAM wp, LPARAM lp); // WM_ON_POWER_UP_COMPLETE post by CRunCtrl
    afx_msg LRESULT OnCloseLotComplete(WPARAM wp, LPARAM lp);
    afx_msg LRESULT OnShortCut(WPARAM wNo, LPARAM lp);
    afx_msg LRESULT OnMaintMessage(WPARAM wNo, LPARAM lp);
//  general message for modules to inform GUI of an event not handle by GUI dll
    afx_msg LRESULT OnGeneralMessage(WPARAM wNo, LPARAM lp);

    afx_msg LRESULT OnCloseSplash(WPARAM wNo, LPARAM lp);
    afx_msg LRESULT OnMachineStopping(WPARAM wNo, LPARAM lp);
    afx_msg LRESULT OnMachineEOL(WPARAM wNo, LPARAM lp);
    afx_msg LRESULT OnMachineInitialising(WPARAM wNo, LPARAM lp);

//  message handler from sequence to send to secgem event thread via gui
// TISGREMOVE    afx_msg void OnSendSecGemEvt(WPARAM wNo, LPARAM lp);

// TISGREMOVE    afx_msg LRESULT OnSecsGemRemoteCommandReceived(WPARAM wParam, LPARAM lParam); //SECSGEM
    afx_msg LRESULT OnMainMsgReceivedFromSecsGem(WPARAM wParam, LPARAM lParam); // TISGADD
    afx_msg LRESULT OnEMSStatus(WPARAM wNo, LPARAM lp);

// method to receive external applications broadcast message using registered message;
    afx_msg LRESULT OnThirdPartyMessage(WPARAM wp, LPARAM lp);

    afx_msg LRESULT OnPostMessageToMainMenu(WPARAM wp, LPARAM lp);

    DECLARE_MESSAGE_MAP()

//  void ReloadCurrPack();
//  bool IsInDiagnose();
private:
    bool CheckGUIState();
    void OnEngineering(BOOL bState);
    void OnSystemWarning(BOOL bState);
    void OnCurtain(BOOL bState);
    void OnAir(BOOL bState);
    void OnVacuum(BOOL bState);
    void OnEStop(BOOL bState);
    void OnDoor(BOOL bState);
// Operations
    void OnMainDatalog();
    void OnMainHelp();
    void OnMainAlarm();
    void OnMainSetup();
    void OnMainRecipe();
    void OnMainJob();
    void OnMainMaintenance();
    void OnMainButtonClick(int id);
    void LoadRecipeFromHost(CString name);

// Attributes
    CMainSheet* m_pSheet[MainMaxButton];
    UINT        nPreviousMainToolBarButton;
// CPrjDoc* pDoc;
    CMainDoc* pDoc;
    CFont     m_fontLogo;

    int m_nWarningCount; // module warning counter

    CSplashScreenEx *m_pSplash;

#if _MSC_VER > 1200      // Version Higher than VC6
    LPARAM m_lpDisplayPage;
#endif
};

/////////////////////////////////////////////////////////////////////////////

// {{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MAINFRM_H__2250FB38_F9DF_11D0_B9B3_0080489188C9__INCLUDED_)
