173 lines
5.7 KiB
C++
173 lines
5.7 KiB
C++
/*=========================================================================*/
|
|
/* CPAKACnf.hpp : CPA_KeyActionConfiguration Class for editors.*/
|
|
/**/
|
|
/* Version 1.0*/
|
|
/* Creation date 21/10/96*/
|
|
/* Author: Philippe Touillaud*/
|
|
/**/
|
|
/* The aim of this class is to provide tools for configurating the keyboard:*/
|
|
/* Init and configuration of the actions ran by a defined keypress.*/
|
|
/* Revision date*/
|
|
/* Author: CB : To isolate from CPA project*/
|
|
/**/
|
|
/* (c) Ubi Studios 1996*/
|
|
/**/
|
|
/*=========================================================================*/
|
|
|
|
#ifndef __CPAKeyActionConfiguration_HPP__
|
|
#define __CPAKeyActionConfiguration_HPP__
|
|
|
|
#ifdef ACTIVE_EDITOR
|
|
|
|
#include <afxtempl.h>
|
|
|
|
/****************************************/
|
|
#ifndef CPA_EXPORT
|
|
#if defined(CPA_WANTS_IMPORT)
|
|
#define CPA_EXPORT __declspec(dllimport)
|
|
#elif defined(CPA_WANTS_EXPORT)
|
|
#define CPA_EXPORT __declspec(dllexport)
|
|
#else
|
|
#define CPA_EXPORT
|
|
#endif
|
|
#endif
|
|
/****************************************/
|
|
|
|
/*///////////////////////////////////////////////////////////////////////////*/
|
|
/* Some constants*/
|
|
#define C_KeybSHIFT 1
|
|
#define C_KeybCTRL 2
|
|
/*CPA2 Corneliu Babiuc (ALT key) 14-05-98*/
|
|
#define C_KeybALT 4
|
|
/*END CPA2 Corneliu Babiuc (ALT key) 14-05-98*/
|
|
|
|
/*###########################################################################*/
|
|
/* To define a key*/
|
|
class CPA_EXPORT CPA_KeyDefinition : public CObject
|
|
{
|
|
public:
|
|
CPA_KeyDefinition(char cKey, char cFlags, unsigned short uwAction)
|
|
{
|
|
m_cKey = cKey;
|
|
m_cFlags = cFlags;
|
|
m_uwAction = uwAction;
|
|
}
|
|
public:
|
|
char m_cKey; /* Value of key stroke*/
|
|
char m_cFlags; /* Value of flags*/
|
|
unsigned short m_uwAction; /* Associated action*/
|
|
};
|
|
|
|
/*///////////////////////////////////////////////////////////////////////////*/
|
|
/* Structure used for the definition of the link table KAction-IniNames*/
|
|
|
|
typedef struct tdstKeyboardActionDef_
|
|
{
|
|
char *p_szIniName; /* Name of section in .INI file*/
|
|
unsigned short uwAction; /* Associated action*/
|
|
} tdstKeyboardActionDef;
|
|
|
|
/*///////////////////////////////////////////////////////////////////////////*/
|
|
class CPA_EXPORT CPA_KeyActionConfiguration : public CObject
|
|
{
|
|
|
|
/* Construction, Destruction*/
|
|
public:
|
|
CPA_KeyActionConfiguration(CString, tdstKeyboardActionDef *p_a_stKeybrdDef);
|
|
~CPA_KeyActionConfiguration();
|
|
|
|
private:
|
|
typedef enum {VALID, INVALID, UNKNOWN} tdeNameValid;
|
|
|
|
CString m_szObjectName;
|
|
CString m_szFileIniName;
|
|
tdeNameValid m_eFileIniNameValid;
|
|
tdstKeyboardActionDef *m_p_a_stKeybrdDef;
|
|
CList<CPA_KeyDefinition *, CPA_KeyDefinition *> m_lstKeyDefinition;
|
|
|
|
/*///////////////////////////////////////////////////////////////////////////*/
|
|
public:
|
|
/**/
|
|
/* Get/Set*/
|
|
/**/
|
|
void mfn_vSetObjectName(CString szName) { m_szObjectName = szName; }
|
|
CString mfn_szGetObjectName(void) { return m_szObjectName; }
|
|
|
|
/**/
|
|
/* Flags tools*/
|
|
/**/
|
|
BOOL mfn_bIsShiftSet(char cFlags) { return (cFlags == C_KeybSHIFT); }
|
|
BOOL mfn_bIsCtrlSet (char cFlags) { return (cFlags == C_KeybCTRL); }
|
|
void mfn_vSetShift (char *cFlags) { *cFlags = C_KeybSHIFT; }
|
|
void mfn_vSetCtrl (char *cFlags) { *cFlags = C_KeybCTRL; }
|
|
void mfn_vSetFlag (char cVKCode, char *cFlags);
|
|
/*CPA2 Corneliu Babiuc (ALT key) 14-05-98*/
|
|
BOOL mfn_bIsAltSet (char cFlags) {return (cFlags == C_KeybALT); }
|
|
void mfn_vSetAlt (char *cFlags) { *cFlags = C_KeybALT; }
|
|
/*END CPA2 Corneliu Babiuc (ALT key) 14-05-98*/
|
|
/**/
|
|
/* Key status acces*/
|
|
/**/
|
|
BOOL mfn_bIsReserved(char cKey);
|
|
BOOL mfn_bIsCombined(char cKey);
|
|
BOOL mfn_bKeyIsUsed(char cKey, char cFlags);
|
|
BOOL mfn_bKeyIsUsedOutside(char cKey, char cFlags);
|
|
|
|
/**/
|
|
/* List inits*/
|
|
/**/
|
|
void mfn_vUpdateIniFileFromKeyDefList(void);
|
|
|
|
BOOL IsInitFileValid() { return (m_eFileIniNameValid == VALID); }
|
|
|
|
/**/
|
|
/* Finding associations*/
|
|
/**/
|
|
unsigned short mfn_uwKeyToAction(char cKey);
|
|
unsigned short mfn_uwKeyToAction(char cKey, char cFlags);
|
|
char mfn_cActionToKey(unsigned short uwAction, char *p_cFlags);
|
|
|
|
/**/
|
|
/* For the keyboard configuration interface*/
|
|
/**/
|
|
void mfn_vBuildStringList(CList<CString, CString> *);
|
|
void mfn_vUpdateKeyDefListFromStringList(CList<CString, CString> *);
|
|
CString mfn_oConvertKeyDefInString(char, char, unsigned short);
|
|
char mfn_cConvertStringInKeyDef(const CString *, char *, unsigned short *);
|
|
char mfn_cIniStringToKey(LPCTSTR, char *);
|
|
CString mfn_oKeyToIniString(char, char);
|
|
CString mfn_oKeyToKeyString(char, char);
|
|
void CPA_KeyActionConfiguration::mfn_vDialog(CWnd *, CString);
|
|
CString mfn_oConvertIniStringToKeyString(const CString *p_oIniString);
|
|
|
|
/*///////////////////////////////////////////////////////////////////////////*/
|
|
private:
|
|
/**/
|
|
/* Load list from INI file*/
|
|
/**/
|
|
void mfn_vUpdateKeyDefListFromIniFile(void);
|
|
void mfn_vAddKeyDefFromIniFile(LPCTSTR p_szDes, unsigned short uwAction);
|
|
|
|
/**/
|
|
/* Conversions*/
|
|
/**/
|
|
unsigned short mfn_uwIniStringToAction(const CString *);
|
|
CString mfn_oActionToIniString(unsigned short);
|
|
|
|
/**/
|
|
/* INI file access*/
|
|
/**/
|
|
CString mfn_oGetProfileString(LPCTSTR p_szDes);
|
|
BOOL mfn_bWriteProfileString(LPCTSTR p_szDes, LPCTSTR p_oValue);
|
|
|
|
/**/
|
|
/* Other useful tools*/
|
|
/**/
|
|
void mfn_vRemoveEditorKeyDefList(void);
|
|
};
|
|
/*///////////////////////////////////////////////////////////////////////////*/
|
|
|
|
#endif /* ACTIVE_EDITOR*/
|
|
|
|
#endif /*__CPAKeyActionConfiguration_HPP__*/
|