/*****************************************************************************
Open Source MIT License

Copyright (c) 2017 Matthew Ahmed

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*****************************************************************************/

// ParentDlg.h: interface for the CParentDlg class.
//
//////////////////////////////////////////////////////////////////////

#pragma once

#include "ZWinDlg.h"
//#include "MinDlg.h"
//#include "CopyDlg.h"
class CCopyDlg;
class CMinDlg;

#define IX_MINDLG   0
#define IX_COPYDLG  1

#define WMU_CLOSEALL  WMU0 + 1
#define WMU_HELP_MENU_OFF WMU0 + 2
#define WMU_PREF_MENU_OFF WMU0 + 3

//#define U_TIMER_NO_POSTPAINT    12344

class CParentDlg : public ZDlg  
{
public:
	CParentDlg(HINSTANCE hInst, CSettings * pSet, LPCTSTR sCapt1,
						LPCTSTR sCapt2 = NULL, ZWin * pOwner = NULL, ZWinAppData * pzwd = NULL);
	~CParentDlg();
//	BOOL OwnProc(HWND hDlg, UINT uMsg, WPARAM wP, LPARAM lp_XloYhi);
	INT_PTR CALLBACK OwnProc(HWND hDlg, UINT uMsg, WPARAM wP, LPARAM lp_XloYhi);

  // Override ZDlg, so can set Proc as INT_PTR CALLBACK
  INT Run(); // Usual modal dialog


  CCopyDlg * m_pCopyDlg;
  CMinDlg * m_pMinDlg;

  void CloseAll();
  void ShowHelp(LPCTSTR sHelpPage); // Public so dialog classes can call parent's function

  //// Public for CMinDlg to tell ParentDlg don't repaint just painted stars
  //void ValidateStarsRect();

protected:
  // For helping CMinDlg figure out when its bitmap needs repaint
  BOOL m_bMinIsActive;
  //BOOL m_bMinPaintPending;
  //RECT m_rcStarsFrame;
  ////void OnWmPaint();
  ////HANDLE m_hnMinImgStars;
  BOOL m_bIsStartUp;

  void CloseAllReally();
  //RECT m_rect;
  RECT m_rcTab;
  HWND m_hActiveChild;

  HWND m_hTxtHelp;
  HWND m_hTxtPref;
  RECT m_rectPref;
  RECT m_rectHelp;
  HWND m_hFrHelp;
  HWND m_hFrPref;
  RECT m_rFrPref;
  RECT m_rFrHelp;

  HWND m_hTab;
  void ShowTab(INT nTab);
  void OnShowWindow(); // WM_SHOWWINDOW to this dialog
  void OnTcnSelChange(NMHDR* pnmh);
  //BOOL OnTcnSelChanging(NMHDR* pnmh);

  void OnLButtonDown(WPARAM, LPARAM lp);
  //void ShowMenu(BOOL bMenuIsPref);
  void ShowHelpMenu();
  void ShowPrefMenu();

  BOOL m_bHelpMenuOn;
  BOOL m_bPrefMenuOn;

  void OnWmMouseMove(WPARAM, LPARAM lp_XloYhi);
  BOOL m_bMouseInPref;
  BOOL m_bMouseInHelp;
  void SetMouseInPref(BOOL bIn, BOOL bSetTrack = TRUE);
  void SetMouseInHelp(BOOL bIn, BOOL bSetTrack = TRUE);
//  void HiLiteControl(HWND hCtl, RECT rc, LPCTSTR sTxt, BOOL bHiLite);
//  void OnWmTimer(WPARAM wp, LPARAM);
//  UINT m_uTimerIdCheckMenus;
  TRACKMOUSEEVENT m_tme_StartTrackMouse;
  TRACKMOUSEEVENT m_tme_StopTrackMouse;
//  TRACKMOUSEEVENT m_tme_QueryTrackMouse;
  void OnWmMouseLeave();

  void RunShufflePref();
  TCHAR m_sOwnDirSlash[MAX_PATH];
  TCHAR m_sHelpPath[MAX_PATH];

  void RunOptCopy();
  void RunAbout();
  void RunOptLog();

  LRESULT OnWmCtlColorStatic(WPARAM wp_hDC, LPARAM lp_hCtl);

	CSettings * ini;
	BOOL OnInitDialog();
	void OnOk();
	void OnCancel();
  void OnClose();
};

