annotate src/win32/AcceleratorManager.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
rev   line source
rlm@1 1 ////////////////////////////////////////////////////////////////////////////////
rlm@1 2 // Copyright (C) 1998 by Thierry Maurel
rlm@1 3 // All rights reserved
rlm@1 4 //
rlm@1 5 // Distribute freely, except: don't remove my name from the source or
rlm@1 6 // documentation (don't take credit for my work), mark your changes (don't
rlm@1 7 // get me blamed for your possible bugs), don't alter or remove this
rlm@1 8 // notice.
rlm@1 9 // No warrantee of any kind, express or implied, is included with this
rlm@1 10 // software; use at your own risk, responsibility for damages (if any) to
rlm@1 11 // anyone resulting from the use of this software rests entirely with the
rlm@1 12 // user.
rlm@1 13 //
rlm@1 14 // Send bug reports, bug fixes, enhancements, requests, flames, etc., and
rlm@1 15 // I'll try to keep a version up to date. I can be reached as follows:
rlm@1 16 // tmaurel@caramail.com (or tmaurel@hol.fr)
rlm@1 17 //
rlm@1 18 ////////////////////////////////////////////////////////////////////////////////
rlm@1 19 // File : AcceleratorManager.h
rlm@1 20 // Project : AccelsEditor
rlm@1 21 ////////////////////////////////////////////////////////////////////////////////
rlm@1 22 // Version : 1.0 * Author : T.Maurel
rlm@1 23 // Date : 17.08.98
rlm@1 24 //
rlm@1 25 // Remarks : interface for the CAcceleratorManager class.
rlm@1 26 //
rlm@1 27 ////////////////////////////////////////////////////////////////////////////////
rlm@1 28 #if !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_)
rlm@1 29 #define AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_
rlm@1 30
rlm@1 31 #if _MSC_VER >= 1000
rlm@1 32 #pragma once
rlm@1 33 #endif // _MSC_VER >= 1000
rlm@1 34
rlm@1 35 #include "afxtempl.h"
rlm@1 36
rlm@1 37 class CCmdAccelOb;
rlm@1 38
rlm@1 39 // Helper map
rlm@1 40 #ifndef CMapStringToWord
rlm@1 41 typedef CMap< CString, LPCSTR, WORD, WORD & > CMapStringToWord;
rlm@1 42 #endif
rlm@1 43
rlm@1 44 #ifndef CMapWordToCCmdAccelOb
rlm@1 45 typedef CMap< WORD, WORD &, CCmdAccelOb *, CCmdAccelOb * & > CMapWordToCCmdAccelOb;
rlm@1 46 #endif
rlm@1 47
rlm@1 48 ////////////////////////////////////////////////////////////////////////////////
rlm@1 49 // All Registry stuff removed
rlm@1 50
rlm@1 51 class CAcceleratorManager : public CObject
rlm@1 52 {
rlm@1 53 friend class AccelEditor;
rlm@1 54 public:
rlm@1 55 CAcceleratorManager();
rlm@1 56 virtual ~CAcceleratorManager();
rlm@1 57
rlm@1 58 // Operations
rlm@1 59 public:
rlm@1 60 void UpdateMenu(HMENU menu);
rlm@1 61 // Connection to the main application wnd
rlm@1 62 void Connect(CWnd *pWnd, bool bAutoSave = true);
rlm@1 63 // In/Out
rlm@1 64 bool Load();
rlm@1 65 bool Write();
rlm@1 66 // Get the initials accels, not the user's
rlm@1 67 bool Default();
rlm@1 68 // Save a copy in the 2 maps called xxxSaved, which are used in case
rlm@1 69 // of Default(), to reload the defaults accels.
rlm@1 70 bool CreateDefaultTable();
rlm@1 71 bool IsDefaultTableAvailable() {return m_bDefaultTable;}
rlm@1 72 bool IsMapStringCommandsEmpty()
rlm@1 73 {
rlm@1 74 if (m_mapAccelString.IsEmpty())
rlm@1 75 return true;
rlm@1 76 else
rlm@1 77 return false;
rlm@1 78 }
rlm@1 79
rlm@1 80 bool IsAutoSave() {return m_bAutoSave;}
rlm@1 81 void SetAutoSave(bool bAutoSave) {m_bAutoSave = bAutoSave;}
rlm@1 82
rlm@1 83 // Helper fct, used for new menus strings
rlm@1 84 bool GetStringFromACCEL(ACCEL*pACCEL, CString& szAccel);
rlm@1 85 bool GetStringFromACCEL(BYTE cVirt, WORD nCode, CString& szAccel);
rlm@1 86
rlm@1 87 // Update the ACCELS table in the application, from the specified
rlm@1 88 // datas in the manager.
rlm@1 89 bool UpdateWndTable();
rlm@1 90
rlm@1 91 // Modification helper fcts
rlm@1 92 bool SetAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract,
rlm@1 93 LPCTSTR szCommand, bool bLocked = false);
rlm@1 94 bool AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked = true);
rlm@1 95 bool CreateEntry(WORD wIDCommand, LPCTSTR szCommand);
rlm@1 96
rlm@1 97 bool DeleteEntry(LPCTSTR szCommand);
rlm@1 98 bool DeleteEntry(WORD wIDCommand);
rlm@1 99 bool DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract);
rlm@1 100
rlm@1 101 // Affectation operator
rlm@1 102 CAcceleratorManager & operator=(const CAcceleratorManager& accelmgr);
rlm@1 103 public:
rlm@1 104 #ifdef _DEBUG
rlm@1 105 virtual void AssertValid() const;
rlm@1 106 virtual void Dump(CDumpContext& dc) const;
rlm@1 107 #endif
rlm@1 108 protected:
rlm@1 109 // Erase all the datas
rlm@1 110 void Reset();
rlm@1 111 // Internal affect fct.
rlm@1 112 bool AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey,
rlm@1 113 LPCTSTR szCommand, bool bLocked);
rlm@1 114
rlm@1 115 // Attributes
rlm@1 116 protected:
rlm@1 117 CWnd *m_pWndConnected;
rlm@1 118
rlm@1 119 // User datas
rlm@1 120 /*TEMP HACK*/
rlm@1 121 public:
rlm@1 122 CMapStringToWord m_mapAccelString;
rlm@1 123 /*TEMP HACK*/
rlm@1 124 public:
rlm@1 125 CMapWordToCCmdAccelOb m_mapAccelTable;
rlm@1 126 protected:
rlm@1 127 // Default datas
rlm@1 128 CMapWordToCCmdAccelOb m_mapAccelTableSaved;
rlm@1 129 bool m_bDefaultTable;
rlm@1 130
rlm@1 131 // if true, there is an auto-save, when the destructor is called
rlm@1 132 bool m_bAutoSave;
rlm@1 133 };
rlm@1 134
rlm@1 135 #endif // !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_)