mirror of
https://github.com/leozide/leocad.git
synced 2026-07-28 04:07:11 +00:00
Added support for custom user shortcut keys.
This commit is contained in:
+4
-1
@@ -7,10 +7,13 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// System specific
|
||||
|
||||
#if ! ( defined( LC_WINDOWS ) || defined( LC_LINUX ) || defined( LC_MACINTOSH ))
|
||||
#if !(defined(LC_WINDOWS) || defined(LC_LINUX))
|
||||
#error YOU NEED TO DEFINE YOUR OS
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
// Old defines (mostly deprecated).
|
||||
|
||||
#ifdef LC_WINDOWS
|
||||
#define LC_MAXPATH 260 //_MAX_PATH
|
||||
#define KEY_SHIFT VK_SHIFT
|
||||
|
||||
@@ -400,6 +400,9 @@ int FileDisk::PutChar(int c)
|
||||
|
||||
bool FileDisk::Open(const char *filename, const char *mode)
|
||||
{
|
||||
if (*filename == 0)
|
||||
return false;
|
||||
|
||||
strcpy(FileName, filename);
|
||||
|
||||
m_hFile = fopen(filename, mode);
|
||||
|
||||
+47
-61
@@ -1,7 +1,3 @@
|
||||
//
|
||||
// file.h
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _FILE_H_
|
||||
#define _FILE_H_
|
||||
|
||||
@@ -12,46 +8,46 @@
|
||||
class File
|
||||
{
|
||||
public:
|
||||
// Constructors
|
||||
File();
|
||||
virtual ~File();
|
||||
// Constructors
|
||||
File();
|
||||
virtual ~File();
|
||||
|
||||
// Implementation
|
||||
// Implementation
|
||||
public:
|
||||
virtual unsigned long GetPosition() const = 0;
|
||||
virtual unsigned long Seek(long lOff, int nFrom) = 0;
|
||||
virtual void SetLength(unsigned long nNewLen) = 0;
|
||||
virtual unsigned long GetLength() const = 0;
|
||||
virtual unsigned long GetPosition() const = 0;
|
||||
virtual unsigned long Seek(long lOff, int nFrom) = 0;
|
||||
virtual void SetLength(unsigned long nNewLen) = 0;
|
||||
virtual unsigned long GetLength() const = 0;
|
||||
|
||||
virtual char* ReadString(char* pBuf, unsigned long nMax)=0;
|
||||
virtual unsigned long Read(void* pBuf, unsigned long nCount)=0;
|
||||
virtual unsigned long Write(const void* pBuf, unsigned long nCount)=0;
|
||||
virtual int GetChar()=0;
|
||||
virtual int PutChar(int c)=0;
|
||||
virtual char* ReadString(char* pBuf, unsigned long nMax)=0;
|
||||
virtual unsigned long Read(void* pBuf, unsigned long nCount)=0;
|
||||
virtual unsigned long Write(const void* pBuf, unsigned long nCount)=0;
|
||||
virtual int GetChar()=0;
|
||||
virtual int PutChar(int c)=0;
|
||||
|
||||
unsigned long ReadByte (void* pBuf, unsigned long nCount);
|
||||
unsigned long ReadShort (void* pBuf, unsigned long nCount);
|
||||
unsigned long ReadLong (void* pBuf, unsigned long nCount);
|
||||
unsigned long ReadFloat (void* pBuf, unsigned long nCount);
|
||||
unsigned long ReadDouble (void* pBuf, unsigned long nCount);
|
||||
unsigned long WriteByte (const void* pBuf, unsigned long nCount);
|
||||
unsigned long WriteShort (const void* pBuf, unsigned long nCount);
|
||||
unsigned long WriteLong (const void* pBuf, unsigned long nCount);
|
||||
unsigned long WriteFloat (const void* pBuf, unsigned long nCount);
|
||||
unsigned long WriteDouble (const void* pBuf, unsigned long nCount);
|
||||
unsigned long ReadByte(void* pBuf, unsigned long nCount);
|
||||
unsigned long ReadShort(void* pBuf, unsigned long nCount);
|
||||
unsigned long ReadLong(void* pBuf, unsigned long nCount);
|
||||
unsigned long ReadFloat(void* pBuf, unsigned long nCount);
|
||||
unsigned long ReadDouble(void* pBuf, unsigned long nCount);
|
||||
unsigned long WriteByte(const void* pBuf, unsigned long nCount);
|
||||
unsigned long WriteShort(const void* pBuf, unsigned long nCount);
|
||||
unsigned long WriteLong(const void* pBuf, unsigned long nCount);
|
||||
unsigned long WriteFloat(const void* pBuf, unsigned long nCount);
|
||||
unsigned long WriteDouble(const void* pBuf, unsigned long nCount);
|
||||
|
||||
virtual void Abort()=0;
|
||||
virtual void Flush()=0;
|
||||
virtual void Close()=0;
|
||||
virtual void Abort()=0;
|
||||
virtual void Flush()=0;
|
||||
virtual void Close()=0;
|
||||
|
||||
const char* GetFileName() const
|
||||
{ return FileName; }
|
||||
|
||||
void SetFileName(const char* Name)
|
||||
{ strncpy(FileName, Name, LC_MAXPATH); }
|
||||
const char* GetFileName() const
|
||||
{ return FileName; }
|
||||
|
||||
void SetFileName(const char* Name)
|
||||
{ strncpy(FileName, Name, LC_MAXPATH); }
|
||||
|
||||
protected:
|
||||
char FileName[LC_MAXPATH];
|
||||
char FileName[LC_MAXPATH];
|
||||
};
|
||||
|
||||
class FileMem : public File
|
||||
@@ -62,16 +58,6 @@ public:
|
||||
~FileMem();
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
// MemFile specific:
|
||||
unsigned long m_nGrowBytes;
|
||||
unsigned long m_nPosition;
|
||||
unsigned long m_nBufferSize;
|
||||
unsigned long m_nFileSize;
|
||||
unsigned char* m_pBuffer;
|
||||
bool m_bAutoDelete;
|
||||
void GrowFile(unsigned long nNewLen);
|
||||
|
||||
public:
|
||||
unsigned long GetPosition() const;
|
||||
unsigned long Seek(long lOff, int nFrom);
|
||||
@@ -88,6 +74,16 @@ public:
|
||||
void Flush();
|
||||
void Close();
|
||||
bool Open(const char *filename, const char *mode);
|
||||
|
||||
protected:
|
||||
// MemFile specific:
|
||||
unsigned long m_nGrowBytes;
|
||||
unsigned long m_nPosition;
|
||||
unsigned long m_nBufferSize;
|
||||
unsigned long m_nFileSize;
|
||||
unsigned char* m_pBuffer;
|
||||
bool m_bAutoDelete;
|
||||
void GrowFile(unsigned long nNewLen);
|
||||
};
|
||||
|
||||
class FileDisk : public File
|
||||
@@ -98,11 +94,6 @@ public:
|
||||
~FileDisk();
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
// DiscFile specific:
|
||||
FILE* m_hFile;
|
||||
bool m_bCloseOnDelete;
|
||||
|
||||
public:
|
||||
unsigned long GetPosition() const;
|
||||
unsigned long Seek(long lOff, int nFrom);
|
||||
@@ -119,16 +110,11 @@ public:
|
||||
void Flush();
|
||||
void Close();
|
||||
bool Open(const char *filename, const char *mode);
|
||||
|
||||
protected:
|
||||
// DiscFile specific:
|
||||
FILE* m_hFile;
|
||||
bool m_bCloseOnDelete;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _FILE_H_
|
||||
|
||||
@@ -0,0 +1,382 @@
|
||||
//
|
||||
// Code to handle user-defined keyboard shortcuts.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include "system.h"
|
||||
#include "keyboard.h"
|
||||
#include "file.h"
|
||||
#include "str.h"
|
||||
|
||||
// ============================================================================
|
||||
// Globals.
|
||||
|
||||
LC_KEYBOARD_COMMAND DefaultKeyboardShortcuts[] =
|
||||
{
|
||||
{ LC_FILE_NEW, "New Project", LC_KEYMOD1_CONTROL, LC_KEY_N, 0 },
|
||||
{ LC_FILE_OPEN, "Open Project", LC_KEYMOD1_CONTROL, LC_KEY_O, 0 },
|
||||
{ LC_FILE_MERGE, "Merge Project", 0, 0, 0 },
|
||||
{ LC_FILE_SAVE, "Save Project", LC_KEYMOD1_CONTROL, LC_KEY_S, 0 },
|
||||
{ LC_FILE_SAVEAS, "Save Project As", 0, 0, 0 },
|
||||
{ LC_FILE_PICTURE, "Save Picture", 0, 0, 0 },
|
||||
{ LC_FILE_3DS, "Export 3D Studio", 0, 0, 0 },
|
||||
{ LC_FILE_HTML, "Export HTML", 0, 0, 0 },
|
||||
{ LC_FILE_POVRAY, "Export POV-Ray", 0, 0, 0 },
|
||||
{ LC_FILE_WAVEFRONT, "Export Wavefront", 0, 0, 0 },
|
||||
{ LC_FILE_PROPERTIES, "Project Properties", 0, 0, 0 },
|
||||
// { LC_FILE_TERRAIN, "Terrain Editor", 0, 0, 0 },
|
||||
{ LC_FILE_LIBRARY, "Piece Library Manager", 0, 0, 0 },
|
||||
// { LC_FILE_RECENT, "Open Recent File", 0, 0, 0 },
|
||||
{ LC_EDIT_UNDO, "Undo", LC_KEYMOD1_CONTROL, LC_KEY_Z, 0 },
|
||||
{ LC_EDIT_REDO, "Redo", LC_KEYMOD1_CONTROL, LC_KEY_Y, 0 },
|
||||
{ LC_EDIT_CUT, "Cut", LC_KEYMOD1_CONTROL, LC_KEY_X, 0 },
|
||||
{ LC_EDIT_COPY, "Copy", LC_KEYMOD1_CONTROL, LC_KEY_C, 0 },
|
||||
{ LC_EDIT_PASTE, "Paste", LC_KEYMOD1_CONTROL, LC_KEY_V, 0 },
|
||||
{ LC_EDIT_SELECT_ALL, "Select All", LC_KEYMOD1_CONTROL, LC_KEY_A, 0 },
|
||||
{ LC_EDIT_SELECT_NONE, "Select None", 0, 0, 0 },
|
||||
{ LC_EDIT_SELECT_INVERT, "Select Invert", 0, 0, 0 },
|
||||
{ LC_EDIT_SELECT_BYNAME, "Select By Name", 0, 0, 0 },
|
||||
{ LC_PIECE_INSERT, "Piece Insert", 0, LC_KEY_INSERT, 0 },
|
||||
{ LC_PIECE_DELETE, "Piece Delete", 0, LC_KEY_DELETE, 0 },
|
||||
// { LC_PIECE_MINIFIG, "Minifig Wizard", 0, 0, 0 },
|
||||
{ LC_PIECE_ARRAY, "Piece Array", 0, 0, 0 },
|
||||
// { LC_PIECE_COPYKEYS, "", 0, 0, 0 },
|
||||
{ LC_PIECE_GROUP, "Piece Group", LC_KEYMOD1_CONTROL, LC_KEY_G, 0 },
|
||||
{ LC_PIECE_UNGROUP, "Piece Ungroup", LC_KEYMOD1_CONTROL, LC_KEY_U, 0 },
|
||||
{ LC_PIECE_GROUP_ADD, "Group Add Piece", 0, 0, 0 },
|
||||
{ LC_PIECE_GROUP_REMOVE, "Group Remove Piece", 0, 0, 0 },
|
||||
{ LC_PIECE_GROUP_EDIT, "Group Edit", 0, 0, 0 },
|
||||
{ LC_PIECE_HIDE_SELECTED, "Hide Selection", LC_KEYMOD1_CONTROL, LC_KEY_H, 0 },
|
||||
{ LC_PIECE_HIDE_UNSELECTED, "Unhide Selection", 0, 0, 0 },
|
||||
{ LC_PIECE_UNHIDE_ALL, "Unhide All", 0, 0, 0 },
|
||||
{ LC_PIECE_PREVIOUS, "Piece Previous Step", 0, 0, 0 },
|
||||
{ LC_PIECE_NEXT, "Piece Next Step", 0, 0, 0 },
|
||||
{ LC_VIEW_PREFERENCES, "Preferences", 0, 0, 0 },
|
||||
// { LC_VIEW_ZOOM, "", 0, 0, 0 },
|
||||
{ LC_VIEW_ZOOMIN, "Zoom In", 0, 0, 0 },
|
||||
{ LC_VIEW_ZOOMOUT, "Zoom Out", 0, 0, 0 },
|
||||
{ LC_VIEW_ZOOMEXTENTS, "Zoom Extents", 0, 0, 0 },
|
||||
// { LC_VIEW_VIEWPORTS, "", 0, 0, 0 },
|
||||
{ LC_VIEW_STEP_NEXT, "Step Next", 0, 0, 0 },
|
||||
{ LC_VIEW_STEP_PREVIOUS, "Step Previous", 0, 0, 0 },
|
||||
{ LC_VIEW_STEP_FIRST, "Step First", 0, 0, 0 },
|
||||
{ LC_VIEW_STEP_LAST, "Step Last", 0, 0, 0 },
|
||||
// { LC_VIEW_STEP_CHOOSE, "", 0, 0, 0 },
|
||||
// { LC_VIEW_STEP_SET, "", 0, 0, 0 },
|
||||
{ LC_VIEW_STEP_INSERT, "Step Insert", 0, 0, 0 },
|
||||
{ LC_VIEW_STEP_DELETE, "Step Delete", 0, 0, 0 },
|
||||
// { LC_VIEW_STOP, "", 0, 0, 0 },
|
||||
// { LC_VIEW_PLAY, "", 0, 0, 0 },
|
||||
// { LC_VIEW_CAMERA_MENU, "", 0, 0, 0 },
|
||||
// { LC_VIEW_CAMERA_RESET, "", 0, 0, 0 },
|
||||
// { LC_VIEW_AUTOPAN, "", 0, 0, 0 },
|
||||
// { LC_HELP_ABOUT, "", 0, 0, 0 },
|
||||
// { LC_TOOLBAR_ANIMATION, "", 0, 0, 0 },
|
||||
// { LC_TOOLBAR_ADDKEYS, "", 0, 0, 0 },
|
||||
// { LC_TOOLBAR_SNAPMENU, "", 0, 0, 0 },
|
||||
// { LC_TOOLBAR_LOCKMENU, "", 0, 0, 0 },
|
||||
// { LC_TOOLBAR_SNAPMOVEMENU, "", 0, 0, 0 },
|
||||
// { LC_TOOLBAR_FASTRENDER, "", 0, 0, 0 },
|
||||
// { LC_TOOLBAR_BACKGROUND, "", 0, 0, 0 },
|
||||
};
|
||||
|
||||
const int KeyboardShortcutsCount = sizeof(DefaultKeyboardShortcuts)/sizeof(KeyboardShortcuts[0]);
|
||||
|
||||
LC_KEYBOARD_COMMAND KeyboardShortcuts[KeyboardShortcutsCount];
|
||||
|
||||
// ============================================================================
|
||||
// Functions
|
||||
|
||||
bool SaveKeyboardShortcuts(const char* FileName)
|
||||
{
|
||||
FileDisk f;
|
||||
|
||||
if (!f.Open(FileName, "wt"))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < KeyboardShortcutsCount; i++)
|
||||
{
|
||||
LC_KEYBOARD_COMMAND& Cmd = KeyboardShortcuts[i];
|
||||
String str;
|
||||
|
||||
str = Cmd.Description;
|
||||
str += "=";
|
||||
|
||||
if (Cmd.Key1)
|
||||
{
|
||||
if (Cmd.Modifiers & LC_KEYMOD1_SHIFT)
|
||||
str += "Shift+";
|
||||
|
||||
if (Cmd.Modifiers & LC_KEYMOD1_CONTROL)
|
||||
str += "Ctrl+";
|
||||
|
||||
str += "\"";
|
||||
str += GetKeyName(Cmd.Key1);
|
||||
str += "\"";
|
||||
}
|
||||
|
||||
if (Cmd.Key2)
|
||||
{
|
||||
str += ",";
|
||||
|
||||
if (Cmd.Modifiers & LC_KEYMOD2_SHIFT)
|
||||
str += "Shift+";
|
||||
|
||||
if (Cmd.Modifiers & LC_KEYMOD2_CONTROL)
|
||||
str += "Ctrl+";
|
||||
|
||||
str += "\"";
|
||||
str += GetKeyName(Cmd.Key2);
|
||||
str += "\"";
|
||||
}
|
||||
|
||||
str += "\n";
|
||||
|
||||
f.Write((const char*)str, str.GetLength());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoadKeyboardShortcuts(const char* FileName)
|
||||
{
|
||||
FileDisk f;
|
||||
int i;
|
||||
|
||||
if (!f.Open(FileName, "rt"))
|
||||
return false;
|
||||
|
||||
// Remove all existing shortcuts
|
||||
for (i = 0; i < KeyboardShortcutsCount; i++)
|
||||
{
|
||||
LC_KEYBOARD_COMMAND& Cmd = KeyboardShortcuts[i];
|
||||
|
||||
Cmd.Key1 = 0;
|
||||
Cmd.Key2 = 0;
|
||||
Cmd.Modifiers = 0;
|
||||
}
|
||||
|
||||
char Line[1024];
|
||||
while (f.ReadString(Line, 1024))
|
||||
{
|
||||
char* ptr = strchr(Line, '=');
|
||||
|
||||
if (ptr == NULL)
|
||||
continue;
|
||||
|
||||
*ptr = 0;
|
||||
ptr++;
|
||||
|
||||
|
||||
for (i = 0; i < KeyboardShortcutsCount; i++)
|
||||
{
|
||||
LC_KEYBOARD_COMMAND& Cmd = KeyboardShortcuts[i];
|
||||
|
||||
if (strcmp(Line, Cmd.Description))
|
||||
continue;
|
||||
|
||||
if (!strncmp(ptr, "Shift+", 6))
|
||||
{
|
||||
Cmd.Modifiers |= LC_KEYMOD1_SHIFT;
|
||||
ptr += 6;
|
||||
}
|
||||
|
||||
if (!strncmp(ptr, "Ctrl+", 5))
|
||||
{
|
||||
Cmd.Modifiers |= LC_KEYMOD1_CONTROL;
|
||||
ptr += 5;
|
||||
}
|
||||
|
||||
ptr++;
|
||||
char* ptr2 = strchr(ptr, '\"');
|
||||
|
||||
if (ptr2 == NULL)
|
||||
{
|
||||
Cmd.Modifiers = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
*ptr2 = 0;
|
||||
Cmd.Key1 = GetKeyFromName(ptr);
|
||||
|
||||
ptr = ptr2 + 1;
|
||||
|
||||
if (*ptr != ',')
|
||||
continue;
|
||||
ptr++;
|
||||
|
||||
if (!strncmp(ptr, "Shift+", 6))
|
||||
{
|
||||
Cmd.Modifiers |= LC_KEYMOD2_SHIFT;
|
||||
ptr += 6;
|
||||
}
|
||||
|
||||
if (!strncmp(ptr, "Ctrl+", 5))
|
||||
{
|
||||
Cmd.Modifiers |= LC_KEYMOD2_CONTROL;
|
||||
ptr += 5;
|
||||
}
|
||||
|
||||
ptr++;
|
||||
ptr2 = strchr(ptr, '\"');
|
||||
|
||||
if (ptr2 == NULL)
|
||||
{
|
||||
Cmd.Modifiers &= ~(LC_KEYMOD2_SHIFT | LC_KEYMOD2_CONTROL);
|
||||
continue;
|
||||
}
|
||||
|
||||
*ptr2 = 0;
|
||||
Cmd.Key2 = GetKeyFromName(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ResetKeyboardShortcuts()
|
||||
{
|
||||
memcpy(KeyboardShortcuts, DefaultKeyboardShortcuts, sizeof(KeyboardShortcuts));
|
||||
}
|
||||
|
||||
void InitKeyboardShortcuts()
|
||||
{
|
||||
const char* FileName = Sys_ProfileLoadString("Settings", "Keyboard", "");
|
||||
|
||||
ResetKeyboardShortcuts();
|
||||
LoadKeyboardShortcuts(FileName);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int Key;
|
||||
const char* Name;
|
||||
|
||||
} LC_KEYNAME_ENTRY;
|
||||
|
||||
static LC_KEYNAME_ENTRY KeyNames[] =
|
||||
{
|
||||
{ LC_KEY_BACK, "Backspace" },
|
||||
{ LC_KEY_TAB, "Tab" },
|
||||
{ LC_KEY_RETURN, "Return" },
|
||||
{ LC_KEY_PAUSE, "Pause" },
|
||||
{ LC_KEY_CAPITAL, "Caps" },
|
||||
{ LC_KEY_ESCAPE, "Escape" },
|
||||
{ LC_KEY_SPACE, "Space" },
|
||||
{ LC_KEY_PRIOR, "Page Up" },
|
||||
{ LC_KEY_NEXT, "Page Down" },
|
||||
{ LC_KEY_END, "End" },
|
||||
{ LC_KEY_HOME, "Home" },
|
||||
{ LC_KEY_LEFT, "Left" },
|
||||
{ LC_KEY_UP, "Up" },
|
||||
{ LC_KEY_RIGHT, "Right" },
|
||||
{ LC_KEY_DOWN, "Down" },
|
||||
{ LC_KEY_SELECT, "Select" },
|
||||
{ LC_KEY_PRINT, "Print" },
|
||||
{ LC_KEY_INSERT, "Insert" },
|
||||
{ LC_KEY_DELETE, "Delete" },
|
||||
{ LC_KEY_0, "0" },
|
||||
{ LC_KEY_1, "1" },
|
||||
{ LC_KEY_2, "2" },
|
||||
{ LC_KEY_3, "3" },
|
||||
{ LC_KEY_4, "4" },
|
||||
{ LC_KEY_5, "5" },
|
||||
{ LC_KEY_6, "6" },
|
||||
{ LC_KEY_7, "7" },
|
||||
{ LC_KEY_8, "8" },
|
||||
{ LC_KEY_9, "9" },
|
||||
{ LC_KEY_A, "A" },
|
||||
{ LC_KEY_B, "B" },
|
||||
{ LC_KEY_C, "C" },
|
||||
{ LC_KEY_D, "D" },
|
||||
{ LC_KEY_E, "E" },
|
||||
{ LC_KEY_F, "F" },
|
||||
{ LC_KEY_G, "G" },
|
||||
{ LC_KEY_H, "H" },
|
||||
{ LC_KEY_I, "I" },
|
||||
{ LC_KEY_J, "J" },
|
||||
{ LC_KEY_K, "K" },
|
||||
{ LC_KEY_L, "L" },
|
||||
{ LC_KEY_M, "M" },
|
||||
{ LC_KEY_N, "N" },
|
||||
{ LC_KEY_O, "O" },
|
||||
{ LC_KEY_P, "P" },
|
||||
{ LC_KEY_Q, "Q" },
|
||||
{ LC_KEY_R, "R" },
|
||||
{ LC_KEY_S, "S" },
|
||||
{ LC_KEY_T, "T" },
|
||||
{ LC_KEY_U, "U" },
|
||||
{ LC_KEY_V, "V" },
|
||||
{ LC_KEY_W, "W" },
|
||||
{ LC_KEY_X, "X" },
|
||||
{ LC_KEY_Y, "Y" },
|
||||
{ LC_KEY_Z, "Z" },
|
||||
{ LC_KEY_NUMPAD0, "Numpad 0" },
|
||||
{ LC_KEY_NUMPAD1, "Numpad 1" },
|
||||
{ LC_KEY_NUMPAD2, "Numpad 2" },
|
||||
{ LC_KEY_NUMPAD3, "Numpad 3" },
|
||||
{ LC_KEY_NUMPAD4, "Numpad 4" },
|
||||
{ LC_KEY_NUMPAD5, "Numpad 5" },
|
||||
{ LC_KEY_NUMPAD6, "Numpad 6" },
|
||||
{ LC_KEY_NUMPAD7, "Numpad 7" },
|
||||
{ LC_KEY_NUMPAD8, "Numpad 8" },
|
||||
{ LC_KEY_NUMPAD9, "Numpad 9" },
|
||||
{ LC_KEY_MULTIPLY, "Numpad *" },
|
||||
{ LC_KEY_ADD, "Numpad +" },
|
||||
{ LC_KEY_SUBTRACT, "Numpad -" },
|
||||
{ LC_KEY_DECIMAL, "Numpad ." },
|
||||
{ LC_KEY_DIVIDE, "Numpad /" },
|
||||
{ LC_KEY_F1, "F1" },
|
||||
{ LC_KEY_F2, "F2" },
|
||||
{ LC_KEY_F3, "F3" },
|
||||
{ LC_KEY_F4, "F4" },
|
||||
{ LC_KEY_F5, "F5" },
|
||||
{ LC_KEY_F6, "F6" },
|
||||
{ LC_KEY_F7, "F7" },
|
||||
{ LC_KEY_F8, "F8" },
|
||||
{ LC_KEY_F9, "F9" },
|
||||
{ LC_KEY_F10, "F10" },
|
||||
{ LC_KEY_F11, "F11" },
|
||||
{ LC_KEY_F12, "F12" },
|
||||
{ LC_KEY_F13, "F13" },
|
||||
{ LC_KEY_F14, "F14" },
|
||||
{ LC_KEY_F15, "F15" },
|
||||
{ LC_KEY_F16, "F16" },
|
||||
{ LC_KEY_F17, "F17" },
|
||||
{ LC_KEY_F18, "F18" },
|
||||
{ LC_KEY_F19, "F19" },
|
||||
{ LC_KEY_F20, "F20" },
|
||||
{ LC_KEY_F21, "F21" },
|
||||
{ LC_KEY_F22, "F22" },
|
||||
{ LC_KEY_F23, "F23" },
|
||||
{ LC_KEY_F24, "F24" },
|
||||
{ LC_KEY_NUMLOCK, "Num Lock" },
|
||||
{ LC_KEY_SCROLL, "Scroll" }
|
||||
};
|
||||
|
||||
// Returns a string with the name of the key.
|
||||
const char* GetKeyName(char Key)
|
||||
{
|
||||
int Count = sizeof(KeyNames)/sizeof(KeyNames[0]);
|
||||
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
if (Key == KeyNames[i].Key)
|
||||
return KeyNames[i].Name;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char GetKeyFromName(const char* Name)
|
||||
{
|
||||
int Count = sizeof(KeyNames)/sizeof(KeyNames[0]);
|
||||
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
if (!strcmp(Name, KeyNames[i].Name))
|
||||
return KeyNames[i].Key;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
#ifndef _KEYBOARD_H_
|
||||
#define _KEYBOARD_H_
|
||||
|
||||
#include "typedefs.h"
|
||||
|
||||
// ============================================================================
|
||||
// Keyboard keys.
|
||||
|
||||
#define LC_KEY_BACK 0x08
|
||||
#define LC_KEY_TAB 0x09
|
||||
|
||||
#define LC_KEY_RETURN 0x0D
|
||||
|
||||
#define LC_KEY_PAUSE 0x13
|
||||
#define LC_KEY_CAPITAL 0x14
|
||||
|
||||
#define LC_KEY_ESCAPE 0x1B
|
||||
|
||||
#define LC_KEY_SPACE 0x20
|
||||
#define LC_KEY_PRIOR 0x21
|
||||
#define LC_KEY_NEXT 0x22
|
||||
#define LC_KEY_END 0x23
|
||||
#define LC_KEY_HOME 0x24
|
||||
#define LC_KEY_LEFT 0x25
|
||||
#define LC_KEY_UP 0x26
|
||||
#define LC_KEY_RIGHT 0x27
|
||||
#define LC_KEY_DOWN 0x28
|
||||
#define LC_KEY_SELECT 0x29
|
||||
#define LC_KEY_PRINT 0x2A
|
||||
#define LC_KEY_INSERT 0x2D
|
||||
#define LC_KEY_DELETE 0x2E
|
||||
|
||||
#define LC_KEY_0 0x30
|
||||
#define LC_KEY_1 0x31
|
||||
#define LC_KEY_2 0x32
|
||||
#define LC_KEY_3 0x33
|
||||
#define LC_KEY_4 0x34
|
||||
#define LC_KEY_5 0x35
|
||||
#define LC_KEY_6 0x36
|
||||
#define LC_KEY_7 0x37
|
||||
#define LC_KEY_8 0x38
|
||||
#define LC_KEY_9 0x39
|
||||
|
||||
#define LC_KEY_A 0x41
|
||||
#define LC_KEY_B 0x42
|
||||
#define LC_KEY_C 0x43
|
||||
#define LC_KEY_D 0x44
|
||||
#define LC_KEY_E 0x45
|
||||
#define LC_KEY_F 0x46
|
||||
#define LC_KEY_G 0x47
|
||||
#define LC_KEY_H 0x48
|
||||
#define LC_KEY_I 0x49
|
||||
#define LC_KEY_J 0x4A
|
||||
#define LC_KEY_K 0x4B
|
||||
#define LC_KEY_L 0x4C
|
||||
#define LC_KEY_M 0x4D
|
||||
#define LC_KEY_N 0x4E
|
||||
#define LC_KEY_O 0x4F
|
||||
#define LC_KEY_P 0x50
|
||||
#define LC_KEY_Q 0x51
|
||||
#define LC_KEY_R 0x52
|
||||
#define LC_KEY_S 0x53
|
||||
#define LC_KEY_T 0x54
|
||||
#define LC_KEY_U 0x55
|
||||
#define LC_KEY_V 0x56
|
||||
#define LC_KEY_W 0x57
|
||||
#define LC_KEY_X 0x58
|
||||
#define LC_KEY_Y 0x59
|
||||
#define LC_KEY_Z 0x5A
|
||||
|
||||
#define LC_KEY_NUMPAD0 0x60
|
||||
#define LC_KEY_NUMPAD1 0x61
|
||||
#define LC_KEY_NUMPAD2 0x62
|
||||
#define LC_KEY_NUMPAD3 0x63
|
||||
#define LC_KEY_NUMPAD4 0x64
|
||||
#define LC_KEY_NUMPAD5 0x65
|
||||
#define LC_KEY_NUMPAD6 0x66
|
||||
#define LC_KEY_NUMPAD7 0x67
|
||||
#define LC_KEY_NUMPAD8 0x68
|
||||
#define LC_KEY_NUMPAD9 0x69
|
||||
#define LC_KEY_MULTIPLY 0x6A
|
||||
#define LC_KEY_ADD 0x6B
|
||||
//#define LC_KEY_SEPARATOR 0x6C
|
||||
#define LC_KEY_SUBTRACT 0x6D
|
||||
#define LC_KEY_DECIMAL 0x6E
|
||||
#define LC_KEY_DIVIDE 0x6F
|
||||
#define LC_KEY_F1 0x70
|
||||
#define LC_KEY_F2 0x71
|
||||
#define LC_KEY_F3 0x72
|
||||
#define LC_KEY_F4 0x73
|
||||
#define LC_KEY_F5 0x74
|
||||
#define LC_KEY_F6 0x75
|
||||
#define LC_KEY_F7 0x76
|
||||
#define LC_KEY_F8 0x77
|
||||
#define LC_KEY_F9 0x78
|
||||
#define LC_KEY_F10 0x79
|
||||
#define LC_KEY_F11 0x7A
|
||||
#define LC_KEY_F12 0x7B
|
||||
#define LC_KEY_F13 0x7C
|
||||
#define LC_KEY_F14 0x7D
|
||||
#define LC_KEY_F15 0x7E
|
||||
#define LC_KEY_F16 0x7F
|
||||
#define LC_KEY_F17 0x80
|
||||
#define LC_KEY_F18 0x81
|
||||
#define LC_KEY_F19 0x82
|
||||
#define LC_KEY_F20 0x83
|
||||
#define LC_KEY_F21 0x84
|
||||
#define LC_KEY_F22 0x85
|
||||
#define LC_KEY_F23 0x86
|
||||
#define LC_KEY_F24 0x87
|
||||
|
||||
#define LC_KEY_NUMLOCK 0x90
|
||||
#define LC_KEY_SCROLL 0x91
|
||||
|
||||
// ============================================================================
|
||||
// Functions.
|
||||
|
||||
#define LC_KEYMOD1_SHIFT 0x01
|
||||
#define LC_KEYMOD1_CONTROL 0x02
|
||||
#define LC_KEYMOD2_SHIFT 0x10
|
||||
#define LC_KEYMOD2_CONTROL 0x20
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LC_COMMANDS ID;
|
||||
const char* Description;
|
||||
unsigned char Modifiers;
|
||||
unsigned char Key1;
|
||||
unsigned char Key2;
|
||||
} LC_KEYBOARD_COMMAND;
|
||||
|
||||
extern LC_KEYBOARD_COMMAND KeyboardShortcuts[];
|
||||
extern const int KeyboardShortcutsCount;
|
||||
|
||||
const char* GetKeyName(char Key);
|
||||
char GetKeyFromName(const char* Name);
|
||||
|
||||
void InitKeyboardShortcuts();
|
||||
void ResetKeyboardShortcuts();
|
||||
bool SaveKeyboardShortcuts(const char* FileName);
|
||||
bool LoadKeyboardShortcuts(const char* FileName);
|
||||
|
||||
#endif // _KEYBOARD_H_
|
||||
@@ -1375,3 +1375,38 @@ HBITMAP CBMPMenu::LoadSysColorBitmap(int nResourceId)
|
||||
return NULL;
|
||||
return AfxLoadSysColorBitmap(hInst, hRsrc, FALSE);
|
||||
}
|
||||
|
||||
BOOL CBMPMenu::ChangeMenuItemShortcut(const char *Shortcut, UINT nID)
|
||||
{
|
||||
int nLoc;
|
||||
CBMPMenuData *mdata;
|
||||
|
||||
// Find the old CBMPMenuData structure:
|
||||
CBMPMenu *psubmenu = FindMenuOption(nID,nLoc);
|
||||
if (psubmenu && nLoc >= 0)
|
||||
mdata = psubmenu->m_MenuList[nLoc];
|
||||
else
|
||||
return false;
|
||||
ASSERT(mdata);
|
||||
|
||||
CString OldText = mdata->GetString();
|
||||
nLoc = OldText.Find('\t');
|
||||
|
||||
// Remove old shortcut text
|
||||
if (nLoc > 0)
|
||||
OldText = OldText.Left(nLoc);
|
||||
|
||||
if (Shortcut)
|
||||
{
|
||||
OldText += '\t';
|
||||
OldText += Shortcut;
|
||||
}
|
||||
#ifdef UNICODE
|
||||
mdata->SetWideString((LPCTSTR)OldText);//SK: modified for dynamic allocation
|
||||
#else
|
||||
mdata->SetAnsiString(OldText);
|
||||
#endif
|
||||
|
||||
return (CMenu::ModifyMenu(nID,mdata->nFlags,nID,(LPCTSTR)mdata));
|
||||
}
|
||||
|
||||
|
||||
+80
-90
@@ -57,101 +57,91 @@ typedef enum {Normal,TextOnly} HIGHLIGHTSTYLE;
|
||||
|
||||
class CBMPMenu : public CMenu // Derived from CMenu
|
||||
{
|
||||
// Construction
|
||||
// Construction
|
||||
public:
|
||||
CBMPMenu();
|
||||
// Attributes
|
||||
CBMPMenu();
|
||||
// Attributes
|
||||
protected:
|
||||
CTypedPtrArray<CPtrArray, CBMPMenuData*> m_MenuList; // Stores list of menu items
|
||||
// When loading an owner-drawn menu using a Resource, CBMPMenu must keep track of
|
||||
// the popup menu's that it creates. Warning, this list *MUST* be destroyed
|
||||
// last item first :)
|
||||
CImageList m_List;
|
||||
|
||||
CTypedPtrArray<CPtrArray, CBMPMenu*> m_SubMenus; // Stores list of sub-menus
|
||||
// Operations
|
||||
CTypedPtrArray<CPtrArray, CBMPMenuData*> m_MenuList; // Stores list of menu items
|
||||
// When loading an owner-drawn menu using a Resource, CBMPMenu must keep track of
|
||||
// the popup menu's that it creates. Warning, this list *MUST* be destroyed
|
||||
// last item first :)
|
||||
CImageList m_List;
|
||||
|
||||
CTypedPtrArray<CPtrArray, CBMPMenu*> m_SubMenus; // Stores list of sub-menus
|
||||
// Operations
|
||||
public:
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CCustomMenu)
|
||||
//}}AFX_VIRTUAL
|
||||
// Implementation
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CCustomMenu)
|
||||
//}}AFX_VIRTUAL
|
||||
// Implementation
|
||||
public:
|
||||
static BOOL IsNewShell(void);
|
||||
void SetBitmapBackground(COLORREF color);
|
||||
void SetDisableOldStyle(void);
|
||||
void UnSetDisableOldStyle(void);
|
||||
BOOL GetDisableOldStyle(void);
|
||||
void UnSetBitmapBackground(void);
|
||||
int AddBitmapToImageList(CImageList *list,UINT nResourceID);
|
||||
BOOL LoadFromToolBar(UINT nID,UINT nToolBar,int& xoffset);
|
||||
void InsertSpaces(void);
|
||||
static LRESULT FindKeyboardShortcut(UINT nChar,UINT nFlags,CMenu *pMenu);
|
||||
static void UpdateMenu(CMenu *pmenu);
|
||||
BOOL IsMenu(CMenu *submenu);
|
||||
void DrawCheckMark(CDC *pDC,int x,int y,COLORREF color);
|
||||
void DrawRadioDot(CDC *pDC,int x,int y,COLORREF color);
|
||||
CBMPMenu *FindMenuOption(int nId,int& nLoc);
|
||||
CBMPMenuData *FindMenuOption(wchar_t *lpstrText);
|
||||
BOOL GetMenuText(UINT id,CString &string);
|
||||
CImageList *checkmaps;
|
||||
BOOL checkmapsshare;
|
||||
int m_selectcheck;
|
||||
int m_unselectcheck;
|
||||
void LoadCheckmarkBitmap(int unselect,int select);
|
||||
void DitherBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth,
|
||||
int nHeight, HBITMAP hbm, int nXSrc, int nYSrc);
|
||||
void DitherBlt2(CDC *drawdc, int nXDest, int nYDest, int nWidth,
|
||||
int nHeight, CBitmap &bmp, int nXSrc, int nYSrc);
|
||||
HBITMAP LoadSysColorBitmap(int nResourceId);
|
||||
|
||||
virtual ~CBMPMenu(); // Virtual Destructor
|
||||
// Drawing:
|
||||
virtual void DrawItem( LPDRAWITEMSTRUCT); // Draw an item
|
||||
virtual void MeasureItem( LPMEASUREITEMSTRUCT ); // Measure an item
|
||||
|
||||
// Customizing:
|
||||
|
||||
void SetIconSize (int, int); // Set icon size
|
||||
|
||||
BOOL AppendODMenuA(LPCSTR lpstrText,
|
||||
UINT nFlags = MF_OWNERDRAW,
|
||||
UINT nID = 0,
|
||||
int nIconNormal = -1); // Owner-Drawn Append
|
||||
|
||||
BOOL AppendODMenuW(wchar_t *lpstrText,
|
||||
UINT nFlags = MF_OWNERDRAW,
|
||||
UINT nID = 0,
|
||||
int nIconNormal = -1); // Owner-Drawn Append
|
||||
|
||||
|
||||
BOOL ModifyODMenuA(const char *lpstrText,UINT nID=0,int nIconNormal=-1);
|
||||
BOOL ModifyODMenuA(const char *lpstrText,const char *OptionText,int nIconNormal);
|
||||
BOOL ModifyODMenuW(wchar_t *lpstrText,UINT nID=0,int nIconNormal=-1);
|
||||
BOOL ModifyODMenuW(wchar_t *lpstrText,wchar_t *OptionText,int nIconNormal);
|
||||
CBMPMenuData *NewODMenu(UINT pos,UINT nFlags,UINT nID,CString string);
|
||||
void SynchronizeMenu(void);
|
||||
void CBMPMenu::InitializeMenuList(int value);
|
||||
void CBMPMenu::DeleteMenuList(void);
|
||||
CBMPMenuData *CBMPMenu::FindMenuList(UINT nID);
|
||||
virtual BOOL LoadMenu(LPCTSTR lpszResourceName); // Load a menu
|
||||
virtual BOOL LoadMenu(int nResource); // ...
|
||||
void AddFromToolBar(CToolBar* pToolBar, int nResourceID);
|
||||
BOOL Draw3DCheckmark(CDC *dc, const CRect& rc,BOOL bSelected,
|
||||
HBITMAP hbmCheck);
|
||||
BOOL LoadToolbar(UINT nToolBar);
|
||||
BOOL LoadToolbars(const UINT *arID,int n);
|
||||
|
||||
// Destoying:
|
||||
|
||||
virtual BOOL DestroyMenu();
|
||||
|
||||
// Generated message map functions
|
||||
static BOOL IsNewShell(void);
|
||||
void SetBitmapBackground(COLORREF color);
|
||||
void SetDisableOldStyle(void);
|
||||
void UnSetDisableOldStyle(void);
|
||||
BOOL GetDisableOldStyle(void);
|
||||
void UnSetBitmapBackground(void);
|
||||
int AddBitmapToImageList(CImageList *list,UINT nResourceID);
|
||||
BOOL LoadFromToolBar(UINT nID,UINT nToolBar,int& xoffset);
|
||||
void InsertSpaces(void);
|
||||
static LRESULT FindKeyboardShortcut(UINT nChar,UINT nFlags,CMenu *pMenu);
|
||||
static void UpdateMenu(CMenu *pmenu);
|
||||
BOOL IsMenu(CMenu *submenu);
|
||||
void DrawCheckMark(CDC *pDC,int x,int y,COLORREF color);
|
||||
void DrawRadioDot(CDC *pDC,int x,int y,COLORREF color);
|
||||
CBMPMenu *FindMenuOption(int nId,int& nLoc);
|
||||
CBMPMenuData *FindMenuOption(wchar_t *lpstrText);
|
||||
BOOL GetMenuText(UINT id,CString &string);
|
||||
CImageList *checkmaps;
|
||||
BOOL checkmapsshare;
|
||||
int m_selectcheck;
|
||||
int m_unselectcheck;
|
||||
void LoadCheckmarkBitmap(int unselect,int select);
|
||||
void DitherBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HBITMAP hbm, int nXSrc, int nYSrc);
|
||||
void DitherBlt2(CDC *drawdc, int nXDest, int nYDest, int nWidth, int nHeight, CBitmap &bmp, int nXSrc, int nYSrc);
|
||||
HBITMAP LoadSysColorBitmap(int nResourceId);
|
||||
|
||||
virtual ~CBMPMenu(); // Virtual Destructor
|
||||
// Drawing:
|
||||
virtual void DrawItem( LPDRAWITEMSTRUCT); // Draw an item
|
||||
virtual void MeasureItem( LPMEASUREITEMSTRUCT ); // Measure an item
|
||||
|
||||
// Customizing:
|
||||
|
||||
void SetIconSize (int, int); // Set icon size
|
||||
|
||||
BOOL AppendODMenuA(LPCSTR lpstrText, UINT nFlags = MF_OWNERDRAW, UINT nID = 0, int nIconNormal = -1); // Owner-Drawn Append
|
||||
BOOL AppendODMenuW(wchar_t *lpstrText, UINT nFlags = MF_OWNERDRAW, UINT nID = 0, int nIconNormal = -1); // Owner-Drawn Append
|
||||
|
||||
BOOL ChangeMenuItemShortcut(const char *Shortcut, UINT nID);
|
||||
BOOL ModifyODMenuA(const char *lpstrText,UINT nID=0,int nIconNormal=-1);
|
||||
BOOL ModifyODMenuA(const char *lpstrText,const char *OptionText,int nIconNormal);
|
||||
BOOL ModifyODMenuW(wchar_t *lpstrText,UINT nID=0,int nIconNormal=-1);
|
||||
BOOL ModifyODMenuW(wchar_t *lpstrText,wchar_t *OptionText,int nIconNormal);
|
||||
CBMPMenuData *NewODMenu(UINT pos,UINT nFlags,UINT nID,CString string);
|
||||
void SynchronizeMenu(void);
|
||||
void CBMPMenu::InitializeMenuList(int value);
|
||||
void CBMPMenu::DeleteMenuList(void);
|
||||
CBMPMenuData *CBMPMenu::FindMenuList(UINT nID);
|
||||
virtual BOOL LoadMenu(LPCTSTR lpszResourceName); // Load a menu
|
||||
virtual BOOL LoadMenu(int nResource); // ...
|
||||
void AddFromToolBar(CToolBar* pToolBar, int nResourceID);
|
||||
BOOL Draw3DCheckmark(CDC *dc, const CRect& rc,BOOL bSelected, HBITMAP hbmCheck);
|
||||
BOOL LoadToolbar(UINT nToolBar);
|
||||
BOOL LoadToolbars(const UINT *arID,int n);
|
||||
|
||||
// Destoying:
|
||||
|
||||
virtual BOOL DestroyMenu();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
int m_iconX,m_iconY;
|
||||
COLORREF m_bitmapBackground;
|
||||
BOOL m_bitmapBackgroundFlag;
|
||||
BOOL disable_old_style;
|
||||
int m_iconX,m_iconY;
|
||||
COLORREF m_bitmapBackground;
|
||||
BOOL m_bitmapBackgroundFlag;
|
||||
BOOL disable_old_style;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -182,6 +182,10 @@ SOURCE=.\Ipedit.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\keyedit.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Leocad.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -432,6 +436,10 @@ SOURCE=.\Ipedit.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\keyedit.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LeoCAD.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -1020,6 +1028,10 @@ SOURCE=..\Common\image.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\common\keyboard.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\common\libman.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -1171,6 +1183,11 @@ SOURCE=..\Common\image.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\common\keyboard.cpp
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\common\libman.cpp
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
|
||||
+41
-27
@@ -232,11 +232,11 @@ IDR_MAINFRAME MENU PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&New\tCtrl+N", ID_FILE_NEW
|
||||
MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN
|
||||
MENUITEM "&Merge...\tCtrl+M", ID_FILE_MERGE
|
||||
MENUITEM "&New", ID_FILE_NEW
|
||||
MENUITEM "&Open...", ID_FILE_OPEN
|
||||
MENUITEM "&Merge...", ID_FILE_MERGE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE
|
||||
MENUITEM "&Save", ID_FILE_SAVE
|
||||
MENUITEM "Save &As...", ID_FILE_SAVE_AS
|
||||
MENUITEM "Save Picture...", ID_FILE_SAVEPICTURE
|
||||
MENUITEM "Sen&d...", ID_FILE_SEND_MAIL
|
||||
@@ -263,12 +263,12 @@ BEGIN
|
||||
END
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO
|
||||
MENUITEM "Redo\tCtrl+Y", ID_EDIT_REDO
|
||||
MENUITEM "&Undo", ID_EDIT_UNDO
|
||||
MENUITEM "Redo", ID_EDIT_REDO
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT
|
||||
MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY
|
||||
MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE
|
||||
MENUITEM "Cu&t", ID_EDIT_CUT
|
||||
MENUITEM "&Copy", ID_EDIT_COPY
|
||||
MENUITEM "&Paste", ID_EDIT_PASTE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Select All", ID_EDIT_SELECTALL
|
||||
MENUITEM "Select None", ID_EDIT_SELECTNONE
|
||||
@@ -284,13 +284,13 @@ BEGIN
|
||||
MENUITEM "Mirror...", ID_PIECE_MIRROR
|
||||
MENUITEM "Copy Keys", ID_PIECE_COPYKEYS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Group...\tCtrl+G", ID_PIECE_GROUP
|
||||
MENUITEM "Ungroup\tCtrl+U", ID_PIECE_UNGROUP
|
||||
MENUITEM "Group...", ID_PIECE_GROUP
|
||||
MENUITEM "Ungroup", ID_PIECE_UNGROUP
|
||||
MENUITEM "Remove From Group", ID_PIECE_DETACH
|
||||
MENUITEM "Add To Group", ID_PIECE_ATTACH
|
||||
MENUITEM "Edit Groups...", ID_PIECE_EDITGROUPS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Hide Selected\tCtrl+H", ID_PIECE_HIDESELECTED
|
||||
MENUITEM "Hide Selected", ID_PIECE_HIDESELECTED
|
||||
MENUITEM "Hide Unselected", ID_PIECE_HIDEUNSELECTED
|
||||
MENUITEM "Unhide All", ID_PIECE_UNHIDEALL
|
||||
END
|
||||
@@ -580,27 +580,12 @@ END
|
||||
|
||||
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
|
||||
BEGIN
|
||||
"C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
|
||||
"F", ID_VIEW_FULLSCREEN, VIRTKEY, CONTROL, NOINVERT
|
||||
"G", ID_PIECE_GROUP, VIRTKEY, CONTROL, NOINVERT
|
||||
"H", ID_PIECE_HIDESELECTED, VIRTKEY, CONTROL, NOINVERT
|
||||
"M", ID_FILE_MERGE, VIRTKEY, CONTROL, NOINVERT
|
||||
"N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT
|
||||
"O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
|
||||
"P", ID_FILE_PRINT, VIRTKEY, CONTROL, NOINVERT
|
||||
"S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT
|
||||
"U", ID_PIECE_UNGROUP, VIRTKEY, CONTROL, NOINVERT
|
||||
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT
|
||||
VK_DELETE, ID_PIECE_DELETE, VIRTKEY, NOINVERT
|
||||
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT
|
||||
VK_F1, ID_HELP, VIRTKEY, NOINVERT
|
||||
VK_F1, ID_CONTEXT_HELP, VIRTKEY, SHIFT, NOINVERT
|
||||
VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT
|
||||
"X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT
|
||||
"Y", ID_EDIT_REDO, VIRTKEY, CONTROL, NOINVERT
|
||||
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT
|
||||
END
|
||||
|
||||
|
||||
@@ -1399,6 +1384,27 @@ BEGIN
|
||||
PUSHBUTTON "Remove",ID_LIBTEX_REMOVE,169,41,50,14
|
||||
END
|
||||
|
||||
IDD_PREFKEYBOARD DIALOG DISCARDABLE 0, 0, 246, 132
|
||||
STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
|
||||
CAPTION "Keyboard"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LISTBOX IDC_KEYDLG_CMDLIST,7,7,85,113,LBS_NOINTEGRALHEIGHT |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Current shortcuts:",IDC_STATIC,100,7,82,8
|
||||
COMBOBOX IDC_KEYDLG_COMBO,100,19,90,40,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Remove",IDC_KEYDLG_REMOVE,197,18,42,14,WS_DISABLED
|
||||
LTEXT "Press new shortcut:",IDC_STATIC,100,35,59,9
|
||||
EDITTEXT IDC_KEYDLG_KEYEDIT,100,47,90,12,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "Assign",IDC_KEYDLG_ASSIGN,197,46,42,14,WS_DISABLED
|
||||
EDITTEXT IDC_KEYDLG_FILENAME,100,88,139,12,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "Save...",IDC_KEYDLG_SAVE,100,106,42,14
|
||||
PUSHBUTTON "Load...",IDC_KEYDLG_LOAD,148,106,42,14
|
||||
PUSHBUTTON "Reset",IDC_KEYDLG_RESET,197,106,42,14
|
||||
LTEXT "Shortcuts File:",IDC_STATIC,100,76,139,8
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1653,6 +1659,14 @@ BEGIN
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 194
|
||||
END
|
||||
|
||||
IDD_PREFKEYBOARD, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 239
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 124
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "config.h"
|
||||
#include "mainwnd.h"
|
||||
#include "library.h"
|
||||
#include "keyboard.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
@@ -94,6 +95,8 @@ BOOL CCADApp::InitInstance()
|
||||
SetRegistryKey(_T("BT Software"));
|
||||
// LoadStdProfileSettings(); // Load standard INI file options (including MRU)
|
||||
|
||||
InitKeyboardShortcuts();
|
||||
|
||||
if (!GL_Initialize (NULL))
|
||||
return FALSE;
|
||||
|
||||
|
||||
+154
@@ -13,6 +13,7 @@
|
||||
#include "mainwnd.h"
|
||||
#include "cadview.h"
|
||||
#include "console.h"
|
||||
#include "keyboard.h"
|
||||
|
||||
#include "Print.h"
|
||||
|
||||
@@ -247,6 +248,8 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
SetMenu (pMenu);
|
||||
m_hMenuDefault = hMenu;
|
||||
|
||||
UpdateMenuAccelerators();
|
||||
|
||||
messenger->Listen (&mainframe_listener, this);
|
||||
|
||||
main_window->SetXID (this);
|
||||
@@ -1094,3 +1097,154 @@ BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
// Check if the user pressed any accelerator.
|
||||
if (pMsg->message == WM_KEYDOWN)
|
||||
{
|
||||
if ((HIWORD(pMsg->lParam) & KF_REPEAT) == 0)
|
||||
{
|
||||
bool Control = GetKeyState(VK_CONTROL) < 0;
|
||||
bool Shift = GetKeyState(VK_SHIFT) < 0;
|
||||
|
||||
for (int i = 0; i < KeyboardShortcutsCount; i++)
|
||||
{
|
||||
LC_KEYBOARD_COMMAND& Cmd = KeyboardShortcuts[i];
|
||||
|
||||
if (pMsg->wParam == Cmd.Key1)
|
||||
{
|
||||
if ((Shift == ((Cmd.Modifiers & LC_KEYMOD1_SHIFT) != 0)) &&
|
||||
(Control == ((Cmd.Modifiers & LC_KEYMOD1_CONTROL) != 0)))
|
||||
{
|
||||
project->HandleCommand(Cmd.ID, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (pMsg->wParam == Cmd.Key2)
|
||||
{
|
||||
if ((Shift == ((Cmd.Modifiers & LC_KEYMOD2_SHIFT) != 0)) &&
|
||||
(Control == ((Cmd.Modifiers & LC_KEYMOD2_CONTROL) != 0)))
|
||||
{
|
||||
project->HandleCommand(Cmd.ID, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CFrameWnd::PreTranslateMessage(pMsg);
|
||||
}
|
||||
|
||||
void CMainFrame::UpdateMenuAccelerators()
|
||||
{
|
||||
DWORD CmdToID[] =
|
||||
{
|
||||
ID_FILE_NEW, // LC_FILE_NEW
|
||||
ID_FILE_OPEN, // LC_FILE_OPEN
|
||||
ID_FILE_MERGE, // LC_FILE_MERGE
|
||||
ID_FILE_SAVE, // LC_FILE_SAVE
|
||||
ID_FILE_SAVE_AS, // LC_FILE_SAVEAS
|
||||
ID_FILE_SAVEPICTURE, // LC_FILE_PICTURE
|
||||
ID_FILE_EXPORT_3DSTUDIO, // LC_FILE_3DS
|
||||
ID_FILE_EXPORT_HTML, // LC_FILE_HTML
|
||||
ID_FILE_EXPORT_POVRAY, // LC_FILE_POVRAY
|
||||
ID_FILE_EXPORT_WAVEFRONT, // LC_FILE_WAVEFRONT
|
||||
ID_FILE_PROPERTIES, // LC_FILE_PROPERTIES
|
||||
ID_FILE_TERRAINEDITOR, // LC_FILE_TERRAIN
|
||||
ID_FILE_EDITPIECELIBRARY, // LC_FILE_LIBRARY
|
||||
0, // LC_FILE_RECENT
|
||||
ID_EDIT_UNDO, // LC_EDIT_UNDO
|
||||
ID_EDIT_REDO, // LC_EDIT_REDO
|
||||
ID_EDIT_CUT, // LC_EDIT_CUT
|
||||
ID_EDIT_COPY, // LC_EDIT_COPY
|
||||
ID_EDIT_PASTE, // LC_EDIT_PASTE
|
||||
ID_EDIT_SELECTALL, // LC_EDIT_SELECT_ALL
|
||||
ID_EDIT_SELECTNONE, // LC_EDIT_SELECT_NONE
|
||||
ID_EDIT_SELECTINVERT, // LC_EDIT_SELECT_INVERT
|
||||
ID_EDIT_SELECTBYNAME, // LC_EDIT_SELECT_BYNAME
|
||||
ID_PIECE_INSERT, // LC_PIECE_INSERT
|
||||
ID_PIECE_DELETE, // LC_PIECE_DELETE
|
||||
ID_PIECE_MINIFIGWIZARD, // LC_PIECE_MINIFIG
|
||||
ID_PIECE_ARRAY, // LC_PIECE_ARRAY
|
||||
ID_PIECE_COPYKEYS, // LC_PIECE_COPYKEYS
|
||||
ID_PIECE_GROUP, // LC_PIECE_GROUP
|
||||
ID_PIECE_UNGROUP, // LC_PIECE_UNGROUP
|
||||
ID_PIECE_ATTACH, // LC_PIECE_GROUP_ADD
|
||||
ID_PIECE_DETACH, // LC_PIECE_GROUP_REMOVE
|
||||
ID_PIECE_EDITGROUPS, // LC_PIECE_GROUP_EDIT
|
||||
ID_PIECE_HIDESELECTED, // LC_PIECE_HIDE_SELECTED
|
||||
ID_PIECE_HIDEUNSELECTED, // LC_PIECE_HIDE_UNSELECTED
|
||||
ID_PIECE_UNHIDEALL, // LC_PIECE_UNHIDE_ALL
|
||||
ID_PIECE_PREVIOUS, // LC_PIECE_PREVIOUS
|
||||
ID_PIECE_NEXT, // LC_PIECE_NEXT
|
||||
ID_VIEW_PREFERENCES, // LC_VIEW_PREFERENCES
|
||||
0, // LC_VIEW_ZOOM
|
||||
ID_VIEW_ZOOMIN, // LC_VIEW_ZOOMIN
|
||||
ID_VIEW_ZOOMOUT, // LC_VIEW_ZOOMOUT
|
||||
ID_ZOOM_EXTENTS, // LC_VIEW_ZOOMEXTENTS
|
||||
0, // LC_VIEW_VIEWPORTS
|
||||
ID_VIEW_STEP_NEXT, // LC_VIEW_STEP_NEXT
|
||||
ID_VIEW_STEP_PREVIOUS, // LC_VIEW_STEP_PREVIOUS
|
||||
ID_VIEW_STEP_FIRST, // LC_VIEW_STEP_FIRST
|
||||
ID_VIEW_STEP_LAST, // LC_VIEW_STEP_LAST
|
||||
ID_VIEW_STEP_CHOOSE, // LC_VIEW_STEP_CHOOSE
|
||||
0, // LC_VIEW_STEP_SET
|
||||
ID_VIEW_STEP_INSERT, // LC_VIEW_STEP_INSERT
|
||||
ID_VIEW_STEP_DELETE, // LC_VIEW_STEP_DELETE
|
||||
ID_ANIMATOR_STOP, // LC_VIEW_STOP
|
||||
ID_ANIMATOR_PLAY, // LC_VIEW_PLAY
|
||||
0, // LC_VIEW_CAMERA_MENU
|
||||
ID_VIEW_CAMERAS_RESET, // LC_VIEW_CAMERA_RESET
|
||||
0, // LC_VIEW_AUTOPAN
|
||||
ID_APP_ABOUT, // LC_HELP_ABOUT
|
||||
0, // LC_TOOLBAR_ANIMATION
|
||||
0, // LC_TOOLBAR_ADDKEYS
|
||||
0, // LC_TOOLBAR_SNAPMENU
|
||||
0, // LC_TOOLBAR_LOCKMENU
|
||||
0, // LC_TOOLBAR_SNAPMOVEMENU
|
||||
0, // LC_TOOLBAR_FASTRENDER
|
||||
0, // LC_TOOLBAR_BACKGROUND
|
||||
};
|
||||
|
||||
m_bmpMenu.Attach(m_hMenuDefault);
|
||||
|
||||
for (int i = 0; i < KeyboardShortcutsCount; i++)
|
||||
{
|
||||
LC_KEYBOARD_COMMAND& Cmd = KeyboardShortcuts[i];
|
||||
DWORD ID = CmdToID[Cmd.ID];
|
||||
String str;
|
||||
|
||||
if (ID == 0)
|
||||
continue;
|
||||
|
||||
if (Cmd.Key1)
|
||||
{
|
||||
if (Cmd.Modifiers & LC_KEYMOD1_SHIFT)
|
||||
str += "Shift+";
|
||||
|
||||
if (Cmd.Modifiers & LC_KEYMOD1_CONTROL)
|
||||
str += "Ctrl+";
|
||||
|
||||
str += GetKeyName(Cmd.Key1);
|
||||
|
||||
if (Cmd.Key2)
|
||||
{
|
||||
str += ",";
|
||||
if (Cmd.Modifiers & LC_KEYMOD2_SHIFT)
|
||||
str += "Shift+";
|
||||
|
||||
if (Cmd.Modifiers & LC_KEYMOD2_CONTROL)
|
||||
str += "Ctrl+";
|
||||
|
||||
str += GetKeyName(Cmd.Key2);
|
||||
}
|
||||
}
|
||||
|
||||
m_bmpMenu.ChangeMenuItemShortcut(str, ID);
|
||||
}
|
||||
|
||||
m_bmpMenu.Detach();
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
//{{AFX_VIRTUAL(CMainFrame)
|
||||
public:
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||
protected:
|
||||
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
|
||||
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
|
||||
@@ -56,6 +57,7 @@ public:
|
||||
CPiecesBar m_wndPiecesBar;
|
||||
CSplitterWnd m_wndSplitter;
|
||||
|
||||
void UpdateMenuAccelerators();
|
||||
void SetStatusBarMessage(const char* Message)
|
||||
{ m_strStatusBar = Message; }
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
#include "resource.h"
|
||||
#include "PrefPage.h"
|
||||
#include "Tools.h"
|
||||
#include "MainFrm.h"
|
||||
#include "defines.h"
|
||||
#include "keyboard.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
@@ -17,6 +19,7 @@ IMPLEMENT_DYNCREATE(CPreferencesDetail, CPropertyPage)
|
||||
IMPLEMENT_DYNCREATE(CPreferencesDrawing, CPropertyPage)
|
||||
IMPLEMENT_DYNCREATE(CPreferencesScene, CPropertyPage)
|
||||
IMPLEMENT_DYNCREATE(CPreferencesPrint, CPropertyPage)
|
||||
IMPLEMENT_DYNCREATE(CPreferencesKeyboard, CPropertyPage)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPreferencesGeneral property page
|
||||
@@ -687,3 +690,318 @@ void CPreferencesPrint::GetOptions(char* strHeader, char* strFooter)
|
||||
AfxGetApp()->WriteProfileInt("Default","Catalog Rows", m_nCatRows);
|
||||
AfxGetApp()->WriteProfileInt("Default","Catalog Columns", m_nCatCols);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPreferencesKeyboard property page
|
||||
|
||||
CPreferencesKeyboard::CPreferencesKeyboard() : CPropertyPage(CPreferencesKeyboard::IDD)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CPreferencesKeyboard)
|
||||
m_strFileName = _T("");
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
CPreferencesKeyboard::~CPreferencesKeyboard()
|
||||
{
|
||||
}
|
||||
|
||||
void CPreferencesKeyboard::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CPropertyPage::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CPreferencesKeyboard)
|
||||
DDX_Control(pDX, IDC_KEYDLG_KEYEDIT, m_Edit);
|
||||
DDX_Control(pDX, IDC_KEYDLG_ASSIGN, m_Assign);
|
||||
DDX_Control(pDX, IDC_KEYDLG_REMOVE, m_Remove);
|
||||
DDX_Control(pDX, IDC_KEYDLG_CMDLIST, m_List);
|
||||
DDX_Control(pDX, IDC_KEYDLG_COMBO, m_Combo);
|
||||
DDX_Text(pDX, IDC_KEYDLG_FILENAME, m_strFileName);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CPreferencesKeyboard, CPropertyPage)
|
||||
//{{AFX_MSG_MAP(CPreferencesKeyboard)
|
||||
ON_BN_CLICKED(IDC_KEYDLG_REMOVE, OnKeydlgRemove)
|
||||
ON_BN_CLICKED(IDC_KEYDLG_ASSIGN, OnKeydlgAssign)
|
||||
ON_BN_CLICKED(IDC_KEYDLG_RESET, OnKeydlgReset)
|
||||
ON_LBN_SELCHANGE(IDC_KEYDLG_CMDLIST, OnSelchangeKeydlgCmdlist)
|
||||
ON_EN_CHANGE(IDC_KEYDLG_KEYEDIT, OnChangeKeydlgKeyedit)
|
||||
ON_BN_CLICKED(IDC_KEYDLG_SAVE, OnKeydlgSave)
|
||||
ON_BN_CLICKED(IDC_KEYDLG_LOAD, OnKeydlgLoad)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
void CPreferencesKeyboard::SetOptions()
|
||||
{
|
||||
m_strFileName = AfxGetApp()->GetProfileString("Settings", "Keyboard", "");
|
||||
}
|
||||
|
||||
void CPreferencesKeyboard::GetOptions()
|
||||
{
|
||||
if (SaveKeyboardShortcuts(m_strFileName))
|
||||
{
|
||||
AfxGetApp()->WriteProfileString("Settings", "Keyboard", m_strFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
AfxMessageBox("Error saving Keyboard Shortcuts file.", MB_OK | MB_ICONEXCLAMATION);
|
||||
}
|
||||
|
||||
((CMainFrame*)AfxGetMainWnd())->UpdateMenuAccelerators();
|
||||
}
|
||||
|
||||
BOOL CPreferencesKeyboard::OnInitDialog()
|
||||
{
|
||||
CPropertyPage::OnInitDialog();
|
||||
|
||||
// Fill the list with all commands available.
|
||||
for (int i = 0; i < KeyboardShortcutsCount; i++)
|
||||
{
|
||||
int Index = m_List.AddString(KeyboardShortcuts[i].Description);
|
||||
m_List.SetItemData(Index, i);
|
||||
}
|
||||
|
||||
m_List.SetCurSel(0);
|
||||
OnSelchangeKeydlgCmdlist();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CPreferencesKeyboard::OnKeydlgRemove()
|
||||
{
|
||||
int Sel = m_List.GetCurSel();
|
||||
|
||||
if (Sel == LB_ERR)
|
||||
return;
|
||||
|
||||
LC_KEYBOARD_COMMAND& Cmd = KeyboardShortcuts[m_List.GetItemData(Sel)];
|
||||
|
||||
Sel = m_Combo.GetCurSel();
|
||||
|
||||
if (Sel == CB_ERR)
|
||||
return;
|
||||
|
||||
if (Sel == 0)
|
||||
{
|
||||
Cmd.Modifiers >>= 4;
|
||||
Cmd.Key1 = Cmd.Key2;
|
||||
Cmd.Key2 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cmd.Key2 = 0;
|
||||
Cmd.Modifiers |= 0x0f;
|
||||
}
|
||||
|
||||
OnSelchangeKeydlgCmdlist();
|
||||
}
|
||||
|
||||
void CPreferencesKeyboard::OnKeydlgAssign()
|
||||
{
|
||||
int Sel = m_List.GetCurSel();
|
||||
|
||||
if (Sel == LB_ERR)
|
||||
return;
|
||||
|
||||
// Check if this shortcut is not already assigned to someone else.
|
||||
for (int i = 0; i < KeyboardShortcutsCount; i++)
|
||||
{
|
||||
LC_KEYBOARD_COMMAND& Cmd = KeyboardShortcuts[i];
|
||||
int Match = 0;
|
||||
|
||||
if (Cmd.Key1 == m_Edit.m_Key)
|
||||
{
|
||||
if ((((Cmd.Modifiers & LC_KEYMOD1_SHIFT) != 0) == m_Edit.m_Shift) &&
|
||||
(((Cmd.Modifiers & LC_KEYMOD1_CONTROL) != 0) == m_Edit.m_Control))
|
||||
{
|
||||
Match = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (Cmd.Key2 == m_Edit.m_Key)
|
||||
{
|
||||
if ((((Cmd.Modifiers & LC_KEYMOD2_SHIFT) != 0) == m_Edit.m_Shift) &&
|
||||
(((Cmd.Modifiers & LC_KEYMOD2_CONTROL) != 0) == m_Edit.m_Control))
|
||||
{
|
||||
Match = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (Match)
|
||||
{
|
||||
CString Msg;
|
||||
|
||||
Msg.Format("This shortcut is currently assigned to \"%s\", do you want to reassign it?",
|
||||
Cmd.Description);
|
||||
|
||||
if (AfxMessageBox(Msg, MB_YESNO | MB_ICONQUESTION) == IDNO)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove old shortcut.
|
||||
if (Match == 1)
|
||||
{
|
||||
Cmd.Modifiers >>= 4;
|
||||
Cmd.Key1 = Cmd.Key2;
|
||||
Cmd.Key2 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cmd.Key2 = 0;
|
||||
Cmd.Modifiers |= 0x0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LC_KEYBOARD_COMMAND& Cmd = KeyboardShortcuts[m_List.GetItemData(Sel)];
|
||||
|
||||
// Assign new shortcut.
|
||||
if (Cmd.Key1 == 0)
|
||||
{
|
||||
Cmd.Key1 = m_Edit.m_Key;
|
||||
|
||||
if (m_Edit.m_Shift)
|
||||
Cmd.Modifiers |= LC_KEYMOD1_SHIFT;
|
||||
|
||||
if (m_Edit.m_Control)
|
||||
Cmd.Modifiers |= LC_KEYMOD1_CONTROL;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cmd.Key2 = m_Edit.m_Key;
|
||||
|
||||
if (m_Edit.m_Shift)
|
||||
Cmd.Modifiers |= LC_KEYMOD2_SHIFT;
|
||||
|
||||
if (m_Edit.m_Control)
|
||||
Cmd.Modifiers |= LC_KEYMOD2_CONTROL;
|
||||
}
|
||||
|
||||
m_Edit.ResetKey();
|
||||
OnSelchangeKeydlgCmdlist();
|
||||
}
|
||||
|
||||
void CPreferencesKeyboard::OnSelchangeKeydlgCmdlist()
|
||||
{
|
||||
m_Combo.ResetContent();
|
||||
m_Remove.EnableWindow(false);
|
||||
m_Edit.SetWindowText("");
|
||||
|
||||
int Sel = m_List.GetCurSel();
|
||||
|
||||
if (Sel == LB_ERR)
|
||||
return;
|
||||
|
||||
LC_KEYBOARD_COMMAND& Cmd = KeyboardShortcuts[m_List.GetItemData(Sel)];
|
||||
|
||||
// Update the combo box with the shortcuts for the current selection.
|
||||
if (Cmd.Key1)
|
||||
{
|
||||
CString str;
|
||||
|
||||
if (Cmd.Modifiers & LC_KEYMOD1_SHIFT)
|
||||
str = "Shift+";
|
||||
|
||||
if (Cmd.Modifiers & LC_KEYMOD1_CONTROL)
|
||||
str += "Ctrl+";
|
||||
|
||||
str += GetKeyName(Cmd.Key1);
|
||||
|
||||
m_Combo.AddString(str);
|
||||
m_Combo.SetCurSel(0);
|
||||
m_Remove.EnableWindow(true);
|
||||
|
||||
if (Cmd.Key2)
|
||||
{
|
||||
str = "";
|
||||
|
||||
if (Cmd.Modifiers & LC_KEYMOD2_SHIFT)
|
||||
str = "Shift+";
|
||||
|
||||
if (Cmd.Modifiers & LC_KEYMOD2_CONTROL)
|
||||
str += "Ctrl+";
|
||||
|
||||
str += GetKeyName(Cmd.Key2);
|
||||
|
||||
m_Combo.AddString(str);
|
||||
}
|
||||
}
|
||||
|
||||
m_Assign.EnableWindow((Cmd.Key2 == 0) && m_Edit.m_Key);
|
||||
}
|
||||
|
||||
void CPreferencesKeyboard::OnChangeKeydlgKeyedit()
|
||||
{
|
||||
if (m_Edit.m_Key == 0)
|
||||
{
|
||||
m_Assign.EnableWindow(false);
|
||||
return;
|
||||
}
|
||||
|
||||
int Sel = m_List.GetCurSel();
|
||||
|
||||
if (Sel == LB_ERR)
|
||||
return;
|
||||
|
||||
LC_KEYBOARD_COMMAND& Cmd = KeyboardShortcuts[m_List.GetItemData(Sel)];
|
||||
|
||||
if (Cmd.Key2 != 0)
|
||||
{
|
||||
m_Assign.EnableWindow(false);
|
||||
return;
|
||||
}
|
||||
|
||||
m_Assign.EnableWindow(true);
|
||||
}
|
||||
|
||||
void CPreferencesKeyboard::OnKeydlgReset()
|
||||
{
|
||||
if (AfxMessageBox("Are you sure you want to reset the Keyboard Shortcuts to the default settings?", MB_YESNO | MB_ICONQUESTION) == IDYES)
|
||||
{
|
||||
ResetKeyboardShortcuts();
|
||||
OnSelchangeKeydlgCmdlist();
|
||||
}
|
||||
}
|
||||
|
||||
void CPreferencesKeyboard::OnKeydlgSave()
|
||||
{
|
||||
UpdateData(TRUE);
|
||||
|
||||
CFileDialog dlg(FALSE, "*.lkb", m_strFileName, OFN_OVERWRITEPROMPT, "LeoCAD Keyboard Layout Files (*.lkb)|*.lkb||", this);
|
||||
|
||||
if (dlg.DoModal() == IDOK)
|
||||
{
|
||||
if (SaveKeyboardShortcuts(dlg.GetPathName()))
|
||||
{
|
||||
m_strFileName = dlg.GetPathName();
|
||||
UpdateData(FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
AfxMessageBox("Error saving file.", MB_OK | MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPreferencesKeyboard::OnKeydlgLoad()
|
||||
{
|
||||
CFileDialog dlg(TRUE, "*.lkb", m_strFileName, 0, "LeoCAD Keyboard Layout Files (*.lkb)|*.lkb||", this);
|
||||
|
||||
if (dlg.DoModal() == IDOK)
|
||||
{
|
||||
if (LoadKeyboardShortcuts(dlg.GetPathName()))
|
||||
{
|
||||
UpdateData(TRUE);
|
||||
m_strFileName = dlg.GetPathName();
|
||||
UpdateData(FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
AfxMessageBox("Error loading file.", MB_OK | MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#ifndef __PREFPAGE_H__
|
||||
#define __PREFPAGE_H__
|
||||
|
||||
#include "keyedit.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPreferencesGeneral dialog
|
||||
|
||||
@@ -276,4 +278,54 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPreferencesKeyboard dialog
|
||||
|
||||
class CPreferencesKeyboard : public CPropertyPage
|
||||
{
|
||||
DECLARE_DYNCREATE(CPreferencesKeyboard)
|
||||
|
||||
// Construction
|
||||
public:
|
||||
void SetOptions();
|
||||
void GetOptions();
|
||||
CPreferencesKeyboard();
|
||||
~CPreferencesKeyboard();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CPreferencesKeyboard)
|
||||
enum { IDD = IDD_PREFKEYBOARD };
|
||||
CKeyEdit m_Edit;
|
||||
CButton m_Assign;
|
||||
CButton m_Remove;
|
||||
CListBox m_List;
|
||||
CComboBox m_Combo;
|
||||
CString m_strFileName;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generate virtual function overrides
|
||||
//{{AFX_VIRTUAL(CPreferencesKeyboard)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CPreferencesKeyboard)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnKeydlgRemove();
|
||||
afx_msg void OnKeydlgAssign();
|
||||
afx_msg void OnKeydlgReset();
|
||||
afx_msg void OnSelchangeKeydlgCmdlist();
|
||||
afx_msg void OnChangeKeydlgKeyedit();
|
||||
afx_msg void OnKeydlgSave();
|
||||
afx_msg void OnKeydlgLoad();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
};
|
||||
|
||||
#endif // __PREFPAGE_H__
|
||||
|
||||
@@ -26,6 +26,7 @@ CPreferencesSheet::CPreferencesSheet(CWnd* pWndParent)
|
||||
AddPage(&m_PageDrawing);
|
||||
AddPage(&m_PageScene);
|
||||
AddPage(&m_PagePrint);
|
||||
AddPage(&m_PageKeyboard);
|
||||
SetActivePage(AfxGetApp()->GetProfileInt("Settings", "Page", 0));
|
||||
}
|
||||
|
||||
@@ -88,6 +89,8 @@ void CPreferencesSheet::OnDefault()
|
||||
m_PageScene.UpdateData();
|
||||
if (m_PagePrint.m_hWnd)
|
||||
m_PagePrint.UpdateData();
|
||||
if (m_PageKeyboard.m_hWnd)
|
||||
m_PageKeyboard.UpdateData();
|
||||
|
||||
char str[LC_MAXPATH], st1[256], st2[256];
|
||||
int i, j;
|
||||
|
||||
@@ -1382,6 +1382,7 @@ bool SystemDoDialog(int nMode, void* param)
|
||||
ps.m_PageDrawing.SetOptions(opts->nSnap, opts->nAngleSnap, opts->nGridSize);
|
||||
ps.m_PageScene.SetOptions(opts->nScene, opts->fDensity, opts->strBackground, opts->fBackground, opts->fFog, opts->fAmbient, opts->fGrad1, opts->fGrad2);
|
||||
ps.m_PagePrint.SetOptions(opts->strHeader, opts->strFooter);
|
||||
ps.m_PageKeyboard.SetOptions();
|
||||
|
||||
if (ps.DoModal() == IDOK)
|
||||
{
|
||||
@@ -1390,6 +1391,7 @@ bool SystemDoDialog(int nMode, void* param)
|
||||
ps.m_PageDrawing.GetOptions(&opts->nSnap, &opts->nAngleSnap, &opts->nGridSize);
|
||||
ps.m_PageScene.GetOptions(&opts->nScene, &opts->fDensity, opts->strBackground, opts->fBackground, opts->fFog, opts->fAmbient, opts->fGrad1, opts->fGrad2);
|
||||
ps.m_PagePrint.GetOptions(opts->strHeader, opts->strFooter);
|
||||
ps.m_PageKeyboard.GetOptions();
|
||||
AfxGetMainWnd()->PostMessage(WM_LC_UPDATE_SETTINGS);
|
||||
AfxGetApp()->WriteProfileInt("Settings", "Autosave", opts->nSaveInterval);
|
||||
AfxGetApp()->WriteProfileInt("Default", "Mouse", opts->nMouse);
|
||||
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
// keyedit.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "leocad.h"
|
||||
#include "keyedit.h"
|
||||
#include "keyboard.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CKeyEdit
|
||||
|
||||
CKeyEdit::CKeyEdit()
|
||||
{
|
||||
m_Key = 0;
|
||||
m_Control = false;
|
||||
m_Shift = false;
|
||||
}
|
||||
|
||||
CKeyEdit::~CKeyEdit()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CKeyEdit, CEdit)
|
||||
//{{AFX_MSG_MAP(CKeyEdit)
|
||||
ON_WM_KEYDOWN()
|
||||
ON_WM_KEYUP()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CKeyEdit message handlers
|
||||
|
||||
void CKeyEdit::ResetKey()
|
||||
{
|
||||
m_Key = 0;
|
||||
m_Control = false;
|
||||
m_Shift = false;
|
||||
|
||||
SetWindowText("");
|
||||
}
|
||||
|
||||
void CKeyEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
|
||||
{
|
||||
|
||||
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
|
||||
}
|
||||
|
||||
void CKeyEdit::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
|
||||
{
|
||||
|
||||
CEdit::OnKeyUp(nChar, nRepCnt, nFlags);
|
||||
}
|
||||
|
||||
BOOL CKeyEdit::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
if (pMsg->message == WM_KEYDOWN)
|
||||
{
|
||||
// If the keys are for the dialog box or Windows, pass them.
|
||||
if ((pMsg->wParam == VK_TAB) || (pMsg->wParam == VK_ESCAPE))
|
||||
{
|
||||
// DoErasingStuff (hHotKeyEdit);
|
||||
// return CEdit::PreTranslateMessage(pMsg);
|
||||
}
|
||||
/*
|
||||
else if (pMsg->wParam == VK_BACK && !Control && !Shift)
|
||||
{
|
||||
// If backspace, then erase the edit control and disable the Assign button.
|
||||
// DoErasingStuff (hHotKeyEdit);
|
||||
// EnableWindow (GetDlgItem (GetParent (hHotKeyEdit), IDD_INSTALL), FALSE);
|
||||
SetWindowText("");
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
else
|
||||
{
|
||||
CString Text;
|
||||
|
||||
m_Control = (GetKeyState(VK_CONTROL) < 0);
|
||||
m_Shift = (GetKeyState(VK_SHIFT) < 0);
|
||||
|
||||
if (m_Control)
|
||||
Text += "Ctrl+";
|
||||
|
||||
if (m_Shift)
|
||||
Text += "Shift+";
|
||||
|
||||
const char* KeyName = GetKeyName(pMsg->wParam);
|
||||
|
||||
if (KeyName)
|
||||
{
|
||||
Text += KeyName;
|
||||
m_Key = pMsg->wParam;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Key = 0;
|
||||
}
|
||||
|
||||
SetWindowText(Text);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return CEdit::PreTranslateMessage(pMsg);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#if !defined(AFX_KEYEDIT_H__E567D1C8_2DC3_4E8F_BA7D_CF628525F55C__INCLUDED_)
|
||||
#define AFX_KEYEDIT_H__E567D1C8_2DC3_4E8F_BA7D_CF628525F55C__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// keyedit.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CKeyEdit window
|
||||
|
||||
class CKeyEdit : public CEdit
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CKeyEdit();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
char m_Key;
|
||||
bool m_Control;
|
||||
bool m_Shift;
|
||||
|
||||
void ResetKey();
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CKeyEdit)
|
||||
public:
|
||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CKeyEdit();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CKeyEdit)
|
||||
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
|
||||
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_KEYEDIT_H__E567D1C8_2DC3_4E8F_BA7D_CF628525F55C__INCLUDED_)
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
CPreferencesDrawing m_PageDrawing;
|
||||
CPreferencesScene m_PageScene;
|
||||
CPreferencesPrint m_PagePrint;
|
||||
CPreferencesKeyboard m_PageKeyboard;
|
||||
|
||||
CTabCtrlWithDisable m_tabCtrl;
|
||||
|
||||
|
||||
+11
-1
@@ -134,6 +134,7 @@
|
||||
#define IDR_PREVIEW 221
|
||||
#define IDD_EDIT_GROUPS 231
|
||||
#define IDD_LIBRARY_TEXTURES 234
|
||||
#define IDD_PREFKEYBOARD 235
|
||||
#define IDC_SELDLG_LIST 1000
|
||||
#define IDC_SELDLG_ALL 1001
|
||||
#define IDC_SELDLG_NONE 1002
|
||||
@@ -409,18 +410,27 @@
|
||||
#define IDC_MF_LEGLANGLE 1229
|
||||
#define IDC_ABTDLG_HOMEPAGE 1229
|
||||
#define IDC_MF_LEGRANGLE 1230
|
||||
#define IDC_KEYDLG_CMDLIST 1230
|
||||
#define IDC_MF_SHOELANGLE 1231
|
||||
#define IDC_MF_SHOERANGLE 1232
|
||||
#define IDC_MF_HATSPIN 1233
|
||||
#define IDC_KEYDLG_REMOVE 1233
|
||||
#define IDC_MF_HEADSPIN 1234
|
||||
#define IDC_MF_NECKSPIN 1235
|
||||
#define IDC_MF_ARMLSPIN 1236
|
||||
#define IDC_KEYDLG_RESET 1236
|
||||
#define IDC_MF_ARMRSPIN 1237
|
||||
#define IDC_KEYDLG_KEYEDIT 1237
|
||||
#define IDC_MF_HANDLSPIN 1238
|
||||
#define IDC_KEYDLG_ASSIGN 1238
|
||||
#define IDC_MF_HANDRSPIN 1239
|
||||
#define IDC_KEYDLG_COMBO 1239
|
||||
#define IDC_MF_TOOLLSPIN 1240
|
||||
#define IDC_KEYDLG_SAVE 1240
|
||||
#define IDC_MF_TOOLRSPIN 1241
|
||||
#define IDC_KEYDLG_LOAD 1241
|
||||
#define IDC_MF_LEGLSPIN 1242
|
||||
#define IDC_KEYDLG_FILENAME 1242
|
||||
#define IDC_MF_LEGRSPIN 1243
|
||||
#define IDC_MF_SHOELSPIN 1244
|
||||
#define IDC_MF_SHOERSPIN 1245
|
||||
@@ -659,7 +669,7 @@
|
||||
#define _APS_3D_CONTROLS 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 235
|
||||
#define _APS_NEXT_COMMAND_VALUE 33158
|
||||
#define _APS_NEXT_CONTROL_VALUE 1230
|
||||
#define _APS_NEXT_CONTROL_VALUE 1243
|
||||
#define _APS_NEXT_SYMED_VALUE 121
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user