]> git.saurik.com Git - wxWidgets.git/commitdiff
Rename wxCharCode{MSWToWX,WXToMSW}() and move them to a separate header.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 11 Sep 2010 10:18:53 +0000 (10:18 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 11 Sep 2010 10:18:53 +0000 (10:18 +0000)
These functions were confusingly named as they work with MSW (virtual) key
codes and not character codes, rename them to better indicate what they do.
They also don't need to be in wx/msw/window.h included by all wx code when
they are only really needed in a couple of files, so move them to a private
header.

No changes in behaviour.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65523 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/private/keyboard.h [new file with mode: 0644]
include/wx/msw/window.h
src/msw/accel.cpp
src/msw/listctrl.cpp
src/msw/uiaction.cpp
src/msw/window.cpp

diff --git a/include/wx/msw/private/keyboard.h b/include/wx/msw/private/keyboard.h
new file mode 100644 (file)
index 0000000..5bc8cc7
--- /dev/null
@@ -0,0 +1,37 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        wx/msw/private/keyboard.h
+// Purpose:     Helper keyboard-related functions.
+// Author:      Vadim Zeitlin
+// Created:     2010-09-09
+// RCS-ID:      $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
+// Copyright:   (c) 2010 Vadim Zeitlin <vadim@wxwidgets.org>
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_MSW_PRIVATE_KEYBOARD_H_
+#define _WX_MSW_PRIVATE_KEYBOARD_H_
+
+#include "wx/defs.h"
+
+namespace wxMSWKeyboard
+{
+
+// ----------------------------------------------------------------------------
+// Functions for translating between MSW virtual keys codes and wx key codes
+//
+// These functions are currently implemented in src/msw/window.cpp.
+// ----------------------------------------------------------------------------
+
+// Translate MSW virtual key code to wx key code. lParam is used to distinguish
+// between numpad and extended version of the keys, extended is assumed by
+// default if lParam == 0.
+WXDLLIMPEXP_CORE int VKToWX(WXWORD vk, WXLPARAM lParam = 0);
+
+// Translate wxKeyCode enum element (passed as int for compatibility reasons)
+// to MSW virtual key code. isExtended is set to true if the key corresponds to
+// a non-numpad version of a key that exists both on numpad and outside it.
+WXDLLIMPEXP_CORE WXWORD WXToVK(int id, bool *isExtended = NULL);
+
+} // namespace wxMSWKeyboard
+
+#endif // _WX_MSW_PRIVATE_KEYBOARD_H_
index fe5dc28d9e4c7e069847946be5f274f77f303169..64b95f9cd521252fcd760dccd3159f81cb12a3b4 100644 (file)
@@ -648,26 +648,6 @@ private:
     DECLARE_EVENT_TABLE()
 };
 
-// ----------------------------------------------------------------------------
-// inline functions
-// ----------------------------------------------------------------------------
-
-// ---------------------------------------------------------------------------
-// global functions
-// ---------------------------------------------------------------------------
-
-// key codes translation between wx and MSW
-
-// Translate MSW virtual key code to wx key code. lParam is used to distinguish
-// between numpad and extended version of the keys, extended is assumed by
-// default if lParam == 0.
-WXDLLIMPEXP_CORE int wxCharCodeMSWToWX(WXWORD vk, WXLPARAM lParam = 0);
-
-// Translate wxKeyCode enum element (passed as int for compatibility reasons)
-// to MSW virtual key code. isExtended is set to true if the key corresponds to
-// a non-numpad version of a key that exists both on numpad and outside it.
-WXDLLIMPEXP_CORE WXWORD wxCharCodeWXToMSW(int id, bool *isExtended = NULL);
-
 // window creation helper class: before creating a new HWND, instantiate an
 // object of this class on stack - this allows to process the messages sent to
 // the window even before CreateWindow() returns
index f3e2f10c7f797d9ed66b4fadb74a370a7bcead36..cce31919c22f798770e20476d4d54c94b46754cb 100644 (file)
@@ -33,6 +33,7 @@
 #include "wx/accel.h"
 
 #include "wx/msw/private.h"
+#include "wx/msw/private/keyboard.h"
 
 IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject)
 
@@ -111,7 +112,7 @@ wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]
         if ( flags & wxACCEL_CTRL )
             fVirt |= FCONTROL;
 
-        WORD key = wxCharCodeWXToMSW(entries[i].GetKeyCode());
+        WORD key = wxMSWKeyboard::WXToVK(entries[i].GetKeyCode());
 
         arr[i].fVirt = fVirt;
         arr[i].key = key;
index f5a7a6a75f514849c33bb65e2d93cfb93964ecd5..6e526f3784a82b91785db0acc47755b4924454d7 100644 (file)
@@ -42,6 +42,7 @@
 #include "wx/vector.h"
 
 #include "wx/msw/private.h"
+#include "wx/msw/private/keyboard.h"
 
 #if defined(__WXWINCE__) && !defined(__HANDHELDPC__)
   #include <ole2.h>
@@ -2340,7 +2341,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                     {
                         eventType = wxEVT_COMMAND_LIST_KEY_DOWN;
 
-                        event.m_code = wxCharCodeMSWToWX(wVKey);
+                        event.m_code = wxMSWKeyboard::VKToWX(wVKey);
                     }
 
                     event.m_itemIndex =
index ee59fd0603174501a5f6f440f2716a93c27d7bc2..eb5bfd1e34567522b04efbf19496fce891cdd85b 100644 (file)
 #if wxUSE_UIACTIONSIMULATOR
 
 #include "wx/uiaction.h"
-#include "wx/window.h" //for wxCharCodeWXToMSW
 #include "wx/msw/wrapwin.h"
 
+#include "wx/msw/private/keyboard.h"
+
 namespace
 {
 
@@ -75,7 +76,7 @@ bool
 wxUIActionSimulator::DoKey(int keycode, int WXUNUSED(modifiers), bool isDown)
 {
     bool isExtended;
-    DWORD vkkeycode = wxCharCodeWXToMSW(keycode, &isExtended);
+    DWORD vkkeycode = wxMSWKeyboard::WXToVK(keycode, &isExtended);
 
     DWORD flags = 0;
     if ( isExtended )
index 4bcb4b22a64f9465e331f4fdc36a7e33235edc8c..d389407b7007bf7e171d622d38bd26a093ca7c80 100644 (file)
@@ -79,6 +79,7 @@
 #endif
 
 #include "wx/msw/private.h"
+#include "wx/msw/private/keyboard.h"
 #include "wx/msw/dcclient.h"
 
 #if wxUSE_TOOLTIPS
@@ -3223,7 +3224,7 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
                         // generate CHAR events with WXK_HOME and not
                         // WXK_NUMPAD_HOME even if the "Home" key on numpad was
                         // pressed.
-                        event.m_keyCode = wxCharCodeMSWToWX
+                        event.m_keyCode = wxMSWKeyboard::VKToWX
                                           (
                                             wParam,
                                             lParam | (KF_EXTENDED << 16)
@@ -5664,7 +5665,7 @@ wxWindowMSW::CreateKeyEvent(wxEventType evType,
     wxKeyEvent event(evType);
     InitAnyKeyEvent(event, wParam, lParam);
 
-    event.m_keyCode = wxCharCodeMSWToWX(wParam, lParam);
+    event.m_keyCode = wxMSWKeyboard::VKToWX(wParam, lParam);
 #if wxUSE_UNICODE
     if ( event.m_keyCode < WXK_START )
     {
@@ -6054,6 +6055,13 @@ void wxGetCharSize(WXHWND wnd, int *x, int *y, const wxFont& the_font)
     //   the_font.ReleaseResource();
 }
 
+// ----------------------------------------------------------------------------
+// keyboard codes
+// ----------------------------------------------------------------------------
+
+namespace wxMSWKeyboard
+{
+
 namespace
 {
 
@@ -6070,7 +6078,7 @@ int ChooseNormalOrExtended(int lParam, int keyNormal, int keyExtended)
 }
 
 // this array contains the Windows virtual key codes which map one to one to
-// WXK_xxx constants and is used in wxCharCodeMSWToWX/WXToMSW() below
+// WXK_xxx constants and is used in wxMSWKeyboard::VKToWX/WXToVK() below
 //
 // note that keys having a normal and numpad version (e.g. WXK_HOME and
 // WXK_NUMPAD_HOME) are not included in this table as the mapping is not 1-to-1
@@ -6150,7 +6158,7 @@ const struct wxKeyMapping
 
 } // anonymous namespace
 
-int wxCharCodeMSWToWX(WXWORD vk, WXLPARAM lParam)
+int VKToWX(WXWORD vk, WXLPARAM lParam)
 {
     // check the table first
     for ( size_t n = 0; n < WXSIZEOF(gs_specialKeys); n++ )
@@ -6233,7 +6241,7 @@ int wxCharCodeMSWToWX(WXWORD vk, WXLPARAM lParam)
     return wxk;
 }
 
-WXWORD wxCharCodeWXToMSW(int wxk, bool *isExtended)
+WXWORD WXToVK(int wxk, bool *isExtended)
 {
     // check the table first
     for ( size_t n = 0; n < WXSIZEOF(gs_specialKeys); n++ )
@@ -6338,6 +6346,8 @@ WXWORD wxCharCodeWXToMSW(int wxk, bool *isExtended)
     return vk;
 }
 
+} // namespace wxMSWKeyboard
+
 // small helper for wxGetKeyState() and wxGetMouseState()
 static inline bool wxIsKeyDown(WXWORD vk)
 {
@@ -6370,7 +6380,7 @@ bool wxGetKeyState(wxKeyCode key)
                         key != VK_MBUTTON,
                     wxT("can't use wxGetKeyState() for mouse buttons") );
 
-    const WXWORD vk = wxCharCodeWXToMSW(key);
+    const WXWORD vk = wxMSWKeyboard::WXToVK(key);
 
     // if the requested key is a LED key, return true if the led is pressed
     if ( key == WXK_NUMLOCK || key == WXK_CAPITAL || key == WXK_SCROLL )
@@ -6495,7 +6505,7 @@ wxKeyboardHook(int nCode, WORD wParam, DWORD lParam)
     DWORD hiWord = HIWORD(lParam);
     if ( nCode != HC_NOREMOVE && ((hiWord & KF_UP) == 0) )
     {
-        int id = wxCharCodeMSWToWX(wParam, lParam);
+        int id = wxMSWKeyboard::VKToWX(wParam, lParam);
         if ( id >= WXK_START )
         {
             wxKeyEvent event(wxEVT_CHAR_HOOK);