////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004 Sergey Solozhentsev
// Author: 	Sergey Solozhentsev e-mail: salos@mail.ru
// Product:	WTL Helper
// File:      	WtlHelperDlg.h
// Created:	12.01.2005 13:54
// 
//   Using this software in commercial applications requires an author
// permission. The permission will be granted to everyone excluding the cases
// when someone simply tries to resell the code.
//   This file 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.
//
////////////////////////////////////////////////////////////////////////////////

// This file was generated by WTL Dialog wizard 
// WtlHelperDlg.h : Declaration of the CWtlHelperDlg

#pragma once
#pragma warning (disable: 4267)
#include "../atlgdix.h"
#include "../CustomTabCtrl.h"
#include "../DotNetTabCtrl.h"
#include <atlframe.h>
#include "../TabbedFrame.h"
#pragma warning (default: 4267)

#include "VariablePage.h"
#include "FunctionPage.h"

struct WtlDlgWindowSettings : public CSettings<WtlDlgWindowSettings>
{
	CRect m_WindowRect;
	int m_ActiveTab;

	BEGIN_SETTINGS_MAP()
		SETTINGS_VARIABLE_OPT(m_ActiveTab)
		SETTINGS_BINARY_OPT(&m_WindowRect, sizeof(CRect))
	END_SETTINGS_MAP()
	WtlDlgWindowSettings() : m_ActiveTab(0), m_WindowRect(0, 0, 450, 300)
	{
	}
};

// CWtlHelperDlg
#define IDC_PAGESTAB	1023

class CWtlHelperDlg : 
	public CDialogImpl<CWtlHelperDlg>,
	public CDialogResize<CWtlHelperDlg>,
	public CSettings<CWtlHelperDlg>
{
	CToolBarCtrl m_ToolBar;
	CTabbedChildWindow< CDotNetTabCtrl<CTabViewTabItem> > m_tabbedChildWindow;
	CFunctionPage m_FunctionPage;
	CVariablePage m_VariablePage;
	WtlDlgWindowSettings m_DlgSettings;
	bool m_bSavePreviousPane;

	void SetCommonPointers();

	void LoadSettings();
	void SaveSettings();
public:
	CWtlHelperDlg();
	~CWtlHelperDlg();
	enum { IDD = IDD_WTLHELPERDLG };

	int* m_piCurrentClass;
	ClassVector* m_pClassVector;
	CSmartAtlArray<InsDelPoints>* m_pModifications;
	CResourceManager* m_pResManager;
	int m_iActivePage;

    BEGIN_MSG_MAP(CWtlHelperDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
		MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo)

        COMMAND_HANDLER(IDOK, BN_CLICKED, OnClickedOK)
        COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnClickedCancel)
		COMMAND_HANDLER(IDC_BUTTON_APPLY, BN_CLICKED, OnApply)

		NOTIFY_CODE_HANDLER(CTCN_SELCHANGE, OnTabSelectChange)

		MESSAGE_HANDLER(WTLH_SETMODIFIED, OnSetModified)
		NOTIFY_CODE_HANDLER(TTN_GETDISPINFO, OnTtnGetDispInfo)
		if (uMsg == WM_COMMAND)
		{
			if (lParam == (LPARAM)m_ToolBar.m_hWnd)
			{
				::SendMessage(m_tabbedChildWindow.GetActiveView(), uMsg, wParam, lParam);
			}
		}
		if (uMsg == WM_NOTIFY)
		{
			if (((LPNMHDR)lParam)->hwndFrom == m_ToolBar.m_hWnd)
			{
				::SendMessage(m_tabbedChildWindow.GetActiveView(), uMsg, wParam, lParam);
			}
		}
		CHAIN_MSG_MAP(CDialogResize<CWtlHelperDlg>)
    END_MSG_MAP()

	BEGIN_DLGRESIZE_MAP(CWtlHelperDlg)
		DLGRESIZE_CONTROL(IDOK, DLSZ_MOVE_X | DLSZ_MOVE_Y)
		DLGRESIZE_CONTROL(IDCANCEL, DLSZ_MOVE_X | DLSZ_MOVE_Y)
		DLGRESIZE_CONTROL(IDC_BUTTON_APPLY, DLSZ_MOVE_X | DLSZ_MOVE_Y)

		DLGRESIZE_CONTROL(IDC_PAGESTAB, DLSZ_SIZE_X | DLSZ_SIZE_Y)
	END_DLGRESIZE_MAP()

	BEGIN_SETTINGS_MAP()
		SETTINGS_VARIABLE_OPT_RO(m_bSavePreviousPane)
		SETTINGS_CHILD_OPT_USE_PARENT(m_DlgSettings)
	END_SETTINGS_MAP()

    // Handler prototypes:
    //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
    //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
    //  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

	LRESULT OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnClickedCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnApply(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

	LRESULT OnTabSelectChange(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
	LRESULT OnTtnGetDispInfo(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

	LRESULT OnSetModified(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
};


