diff 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
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/AcceleratorManager.h	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,135 @@
     1.4 +////////////////////////////////////////////////////////////////////////////////
     1.5 +// Copyright (C) 1998 by Thierry Maurel
     1.6 +// All rights reserved
     1.7 +//
     1.8 +// Distribute freely, except: don't remove my name from the source or
     1.9 +// documentation (don't take credit for my work), mark your changes (don't
    1.10 +// get me blamed for your possible bugs), don't alter or remove this
    1.11 +// notice.
    1.12 +// No warrantee of any kind, express or implied, is included with this
    1.13 +// software; use at your own risk, responsibility for damages (if any) to
    1.14 +// anyone resulting from the use of this software rests entirely with the
    1.15 +// user.
    1.16 +//
    1.17 +// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
    1.18 +// I'll try to keep a version up to date.  I can be reached as follows:
    1.19 +//    tmaurel@caramail.com   (or tmaurel@hol.fr)
    1.20 +//
    1.21 +////////////////////////////////////////////////////////////////////////////////
    1.22 +// File    : AcceleratorManager.h
    1.23 +// Project : AccelsEditor
    1.24 +////////////////////////////////////////////////////////////////////////////////
    1.25 +// Version : 1.0                       * Author : T.Maurel
    1.26 +// Date    : 17.08.98
    1.27 +//
    1.28 +// Remarks : interface for the CAcceleratorManager class.
    1.29 +//
    1.30 +////////////////////////////////////////////////////////////////////////////////
    1.31 +#if !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_)
    1.32 +#define AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_
    1.33 +
    1.34 +#if _MSC_VER >= 1000
    1.35 +#pragma once
    1.36 +#endif // _MSC_VER >= 1000
    1.37 +
    1.38 +#include "afxtempl.h"
    1.39 +
    1.40 +class CCmdAccelOb;
    1.41 +
    1.42 +// Helper map
    1.43 +#ifndef CMapStringToWord
    1.44 +typedef CMap< CString, LPCSTR, WORD, WORD & > CMapStringToWord;
    1.45 +#endif
    1.46 +
    1.47 +#ifndef CMapWordToCCmdAccelOb
    1.48 +typedef CMap< WORD, WORD &, CCmdAccelOb *, CCmdAccelOb * & > CMapWordToCCmdAccelOb;
    1.49 +#endif
    1.50 +
    1.51 +////////////////////////////////////////////////////////////////////////////////
    1.52 +// All Registry stuff removed
    1.53 +
    1.54 +class CAcceleratorManager : public CObject
    1.55 +{
    1.56 +	friend class AccelEditor;
    1.57 +public:
    1.58 +	CAcceleratorManager();
    1.59 +	virtual ~CAcceleratorManager();
    1.60 +
    1.61 +	// Operations
    1.62 +public:
    1.63 +	void UpdateMenu(HMENU menu);
    1.64 +	// Connection to the main application wnd
    1.65 +	void Connect(CWnd *pWnd, bool bAutoSave = true);
    1.66 +	// In/Out
    1.67 +	bool Load();
    1.68 +	bool Write();
    1.69 +	// Get the initials accels, not the user's
    1.70 +	bool Default();
    1.71 +	// Save a copy in the 2 maps called xxxSaved, which are used in case
    1.72 +	// of Default(), to reload the defaults accels.
    1.73 +	bool CreateDefaultTable();
    1.74 +	bool IsDefaultTableAvailable() {return m_bDefaultTable;}
    1.75 +	bool IsMapStringCommandsEmpty()
    1.76 +	{
    1.77 +		if (m_mapAccelString.IsEmpty())
    1.78 +			return true;
    1.79 +		else
    1.80 +			return false;
    1.81 +	}
    1.82 +
    1.83 +	bool IsAutoSave() {return m_bAutoSave;}
    1.84 +	void SetAutoSave(bool bAutoSave) {m_bAutoSave = bAutoSave;}
    1.85 +
    1.86 +	// Helper fct, used for new menus strings
    1.87 +	bool GetStringFromACCEL(ACCEL*pACCEL, CString& szAccel);
    1.88 +	bool GetStringFromACCEL(BYTE cVirt, WORD nCode, CString& szAccel);
    1.89 +
    1.90 +	// Update the ACCELS table in the application, from the specified
    1.91 +	// datas in the manager.
    1.92 +	bool UpdateWndTable();
    1.93 +
    1.94 +	// Modification helper fcts
    1.95 +	bool SetAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract,
    1.96 +	              LPCTSTR szCommand, bool bLocked = false);
    1.97 +	bool AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked = true);
    1.98 +	bool CreateEntry(WORD wIDCommand, LPCTSTR szCommand);
    1.99 +
   1.100 +	bool DeleteEntry(LPCTSTR szCommand);
   1.101 +	bool DeleteEntry(WORD wIDCommand);
   1.102 +	bool DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract);
   1.103 +
   1.104 +	// Affectation operator
   1.105 +	CAcceleratorManager & operator=(const CAcceleratorManager& accelmgr);
   1.106 +public:
   1.107 +#ifdef _DEBUG
   1.108 +	virtual void AssertValid() const;
   1.109 +	virtual void Dump(CDumpContext& dc) const;
   1.110 +#endif
   1.111 +protected:
   1.112 +	// Erase all the datas
   1.113 +	void Reset();
   1.114 +	// Internal affect fct.
   1.115 +	bool AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey,
   1.116 +	              LPCTSTR szCommand, bool bLocked);
   1.117 +
   1.118 +	// Attributes
   1.119 +protected:
   1.120 +	CWnd *m_pWndConnected;
   1.121 +
   1.122 +	// User datas
   1.123 +/*TEMP HACK*/
   1.124 +public:
   1.125 +	CMapStringToWord m_mapAccelString;
   1.126 +/*TEMP HACK*/
   1.127 +public:
   1.128 +	CMapWordToCCmdAccelOb m_mapAccelTable;
   1.129 +protected:
   1.130 +	// Default datas
   1.131 +	CMapWordToCCmdAccelOb m_mapAccelTableSaved;
   1.132 +	bool m_bDefaultTable;
   1.133 +
   1.134 +	// if true, there is an auto-save, when the destructor is called
   1.135 +	bool m_bAutoSave;
   1.136 +};
   1.137 +
   1.138 +#endif // !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_)