rlm@1: //////////////////////////////////////////////////////////////////////////////// rlm@1: // Copyright (C) 1998 by Thierry Maurel rlm@1: // All rights reserved rlm@1: // rlm@1: // Distribute freely, except: don't remove my name from the source or rlm@1: // documentation (don't take credit for my work), mark your changes (don't rlm@1: // get me blamed for your possible bugs), don't alter or remove this rlm@1: // notice. rlm@1: // No warrantee of any kind, express or implied, is included with this rlm@1: // software; use at your own risk, responsibility for damages (if any) to rlm@1: // anyone resulting from the use of this software rests entirely with the rlm@1: // user. rlm@1: // rlm@1: // Send bug reports, bug fixes, enhancements, requests, flames, etc., and rlm@1: // I'll try to keep a version up to date. I can be reached as follows: rlm@1: // tmaurel@caramail.com (or tmaurel@hol.fr) rlm@1: // rlm@1: //////////////////////////////////////////////////////////////////////////////// rlm@1: // File : AcceleratorManager.h rlm@1: // Project : AccelsEditor rlm@1: //////////////////////////////////////////////////////////////////////////////// rlm@1: // Version : 1.0 * Author : T.Maurel rlm@1: // Date : 17.08.98 rlm@1: // rlm@1: // Remarks : interface for the CAcceleratorManager class. rlm@1: // rlm@1: //////////////////////////////////////////////////////////////////////////////// rlm@1: #if !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_) rlm@1: #define AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_ rlm@1: rlm@1: #if _MSC_VER >= 1000 rlm@1: #pragma once rlm@1: #endif // _MSC_VER >= 1000 rlm@1: rlm@1: #include "afxtempl.h" rlm@1: rlm@1: class CCmdAccelOb; rlm@1: rlm@1: // Helper map rlm@1: #ifndef CMapStringToWord rlm@1: typedef CMap< CString, LPCSTR, WORD, WORD & > CMapStringToWord; rlm@1: #endif rlm@1: rlm@1: #ifndef CMapWordToCCmdAccelOb rlm@1: typedef CMap< WORD, WORD &, CCmdAccelOb *, CCmdAccelOb * & > CMapWordToCCmdAccelOb; rlm@1: #endif rlm@1: rlm@1: //////////////////////////////////////////////////////////////////////////////// rlm@1: // All Registry stuff removed rlm@1: rlm@1: class CAcceleratorManager : public CObject rlm@1: { rlm@1: friend class AccelEditor; rlm@1: public: rlm@1: CAcceleratorManager(); rlm@1: virtual ~CAcceleratorManager(); rlm@1: rlm@1: // Operations rlm@1: public: rlm@1: void UpdateMenu(HMENU menu); rlm@1: // Connection to the main application wnd rlm@1: void Connect(CWnd *pWnd, bool bAutoSave = true); rlm@1: // In/Out rlm@1: bool Load(); rlm@1: bool Write(); rlm@1: // Get the initials accels, not the user's rlm@1: bool Default(); rlm@1: // Save a copy in the 2 maps called xxxSaved, which are used in case rlm@1: // of Default(), to reload the defaults accels. rlm@1: bool CreateDefaultTable(); rlm@1: bool IsDefaultTableAvailable() {return m_bDefaultTable;} rlm@1: bool IsMapStringCommandsEmpty() rlm@1: { rlm@1: if (m_mapAccelString.IsEmpty()) rlm@1: return true; rlm@1: else rlm@1: return false; rlm@1: } rlm@1: rlm@1: bool IsAutoSave() {return m_bAutoSave;} rlm@1: void SetAutoSave(bool bAutoSave) {m_bAutoSave = bAutoSave;} rlm@1: rlm@1: // Helper fct, used for new menus strings rlm@1: bool GetStringFromACCEL(ACCEL*pACCEL, CString& szAccel); rlm@1: bool GetStringFromACCEL(BYTE cVirt, WORD nCode, CString& szAccel); rlm@1: rlm@1: // Update the ACCELS table in the application, from the specified rlm@1: // datas in the manager. rlm@1: bool UpdateWndTable(); rlm@1: rlm@1: // Modification helper fcts rlm@1: bool SetAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract, rlm@1: LPCTSTR szCommand, bool bLocked = false); rlm@1: bool AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked = true); rlm@1: bool CreateEntry(WORD wIDCommand, LPCTSTR szCommand); rlm@1: rlm@1: bool DeleteEntry(LPCTSTR szCommand); rlm@1: bool DeleteEntry(WORD wIDCommand); rlm@1: bool DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract); rlm@1: rlm@1: // Affectation operator rlm@1: CAcceleratorManager & operator=(const CAcceleratorManager& accelmgr); rlm@1: public: rlm@1: #ifdef _DEBUG rlm@1: virtual void AssertValid() const; rlm@1: virtual void Dump(CDumpContext& dc) const; rlm@1: #endif rlm@1: protected: rlm@1: // Erase all the datas rlm@1: void Reset(); rlm@1: // Internal affect fct. rlm@1: bool AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, rlm@1: LPCTSTR szCommand, bool bLocked); rlm@1: rlm@1: // Attributes rlm@1: protected: rlm@1: CWnd *m_pWndConnected; rlm@1: rlm@1: // User datas rlm@1: /*TEMP HACK*/ rlm@1: public: rlm@1: CMapStringToWord m_mapAccelString; rlm@1: /*TEMP HACK*/ rlm@1: public: rlm@1: CMapWordToCCmdAccelOb m_mapAccelTable; rlm@1: protected: rlm@1: // Default datas rlm@1: CMapWordToCCmdAccelOb m_mapAccelTableSaved; rlm@1: bool m_bDefaultTable; rlm@1: rlm@1: // if true, there is an auto-save, when the destructor is called rlm@1: bool m_bAutoSave; rlm@1: }; rlm@1: rlm@1: #endif // !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_)