OSDN Git Service

Remove the copyright notice and code to handle it. Modify the layout
[xkeymacs/xkeymacs.git] / xkeymacs / 109keyboard.cpp
1 // 109Keyboard.cpp : implementation file\r
2 //\r
3 \r
4 #include "stdafx.h"\r
5 #include <Lmcons.h>\r
6 #include "xkeymacs.h"\r
7 #include "109Keyboard.h"\r
8 \r
9 #ifdef _DEBUG\r
10 #define new DEBUG_NEW\r
11 #undef THIS_FILE\r
12 static char THIS_FILE[] = __FILE__;\r
13 #endif\r
14 \r
15 /////////////////////////////////////////////////////////////////////////////\r
16 // C109Keyboard dialog\r
17 \r
18 \r
19 C109Keyboard::C109Keyboard(const HKEY_TYPE hkey_type, CWnd *const pParent /*=NULL*/)\r
20         : CKeyboardLayout(hkey_type, C109Keyboard::IDD, pParent)\r
21 {\r
22         //{{AFX_DATA_INIT(C109Keyboard)\r
23                 // NOTE: the ClassWizard will add member initialization here\r
24         //}}AFX_DATA_INIT\r
25 }\r
26 \r
27 void C109Keyboard::DoDataExchange(CDataExchange *const pDX)\r
28 {\r
29         CDialog::DoDataExchange(pDX);\r
30         //{{AFX_DATA_MAP(C109Keyboard)\r
31                 // NOTE: the ClassWizard will add DDX and DDV calls here\r
32         //}}AFX_DATA_MAP\r
33 }\r
34 \r
35 \r
36 BEGIN_MESSAGE_MAP(C109Keyboard, CDialog)\r
37         //{{AFX_MSG_MAP(C109Keyboard)\r
38         ON_WM_DESTROY()\r
39         //}}AFX_MSG_MAP\r
40 END_MESSAGE_MAP()\r
41 \r
42 /////////////////////////////////////////////////////////////////////////////\r
43 // C109Keyboard message handlers\r
44 \r
45 BOOL C109Keyboard::OnInitDialog() \r
46 {\r
47         CDialog::OnInitDialog();\r
48         \r
49         CString szWindowText;\r
50         CString szFor;\r
51         switch (m_HkeyType) {\r
52         case CURRENT_USER:\r
53                 {\r
54                         TCHAR szUserName[UNLEN + 1] = {'0'};\r
55                         DWORD nSize = UNLEN + 1;\r
56                         if (GetUserName(szUserName, &nSize)) {\r
57                                 szFor.Format(IDS_FOR, szUserName);\r
58                         } else {\r
59                                 szFor.LoadString(IDS_FOR_LOGGED_ON_USER);\r
60                         }\r
61                 }\r
62                 break;\r
63         case LOCAL_MACHINE:\r
64                 szFor.LoadString(IDS_FOR_ANY_USER);\r
65                 break;\r
66         default:\r
67                 break;\r
68         }\r
69         this->GetWindowText(szWindowText);\r
70         this->SetWindowText(szWindowText + szFor);\r
71 \r
72         m_ToolTip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX);\r
73         m_ToolTip.SetMaxTipWidth(0x100);        // Enable multiline\r
74 \r
75         InitKeyboardLayout();\r
76 \r
77         return TRUE;  // return TRUE unless you set the focus to a control\r
78                       // EXCEPTION: OCX Property Pages should return FALSE\r
79 }\r
80 \r
81 void C109Keyboard::OnOK() \r
82 {\r
83         if (LostKeyWarning(m_HkeyType) != IDCANCEL) {\r
84                 SaveScanCodeMap(m_HkeyType);\r
85 \r
86                 CDialog::OnOK();\r
87         }\r
88 }\r
89 \r
90 void C109Keyboard::OnDestroy() \r
91 {\r
92         CDialog::OnDestroy();\r
93 \r
94         DestroyKeyboardLayout();\r
95 }\r
96 \r
97 BOOL C109Keyboard::PreTranslateMessage(MSG *const pMsg) \r
98 {\r
99         switch (pMsg->message) {\r
100         case WM_LBUTTONDOWN:\r
101         case WM_LBUTTONUP:\r
102         case WM_MOUSEMOVE:\r
103                 m_ToolTip.RelayEvent(pMsg);\r
104                 break;\r
105         }\r
106 \r
107         return CDialog::PreTranslateMessage(pMsg);\r
108 }\r
109 \r
110 int C109Keyboard::GetToolTipID(int nToolTipID)\r
111 {\r
112         switch (nToolTipID) {\r
113         case IDS_EQUAL:                 // ^\r
114                 nToolTipID = IDS_CARET;\r
115                 break;\r
116         case IDS_SQUARE_BRA:    // @\r
117                 nToolTipID = IDS_AT_MARK;\r
118                 break;\r
119         case IDS_SQUARE_CKET:   // [\r
120                 nToolTipID = IDS_SQUARE_BRA;\r
121                 break;\r
122         case IDS_QUOTE:                 // :\r
123                 nToolTipID = IDS_COLON;\r
124                 break;\r
125         case IDS_BACK_QUOTE:    // Hankaku/Zenkaku\r
126                 nToolTipID = IDS_HANKAKU;\r
127                 break;\r
128         case IDS_BACKSLASH:             // ]\r
129                 nToolTipID = IDS_SQUARE_CKET;\r
130                 break;\r
131         }\r
132         return nToolTipID;\r
133 }\r