--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// 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_
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
#include "wx/accel.h"
#include "wx/msw/private.h"
+#include "wx/msw/private/keyboard.h"
IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject)
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;
#include "wx/vector.h"
#include "wx/msw/private.h"
+#include "wx/msw/private/keyboard.h"
#if defined(__WXWINCE__) && !defined(__HANDHELDPC__)
#include <ole2.h>
{
eventType = wxEVT_COMMAND_LIST_KEY_DOWN;
- event.m_code = wxCharCodeMSWToWX(wVKey);
+ event.m_code = wxMSWKeyboard::VKToWX(wVKey);
}
event.m_itemIndex =
#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
{
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 )
#endif
#include "wx/msw/private.h"
+#include "wx/msw/private/keyboard.h"
#include "wx/msw/dcclient.h"
#if wxUSE_TOOLTIPS
// 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)
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 )
{
// the_font.ReleaseResource();
}
+// ----------------------------------------------------------------------------
+// keyboard codes
+// ----------------------------------------------------------------------------
+
+namespace wxMSWKeyboard
+{
+
namespace
{
}
// 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
} // 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++ )
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++ )
return vk;
}
+} // namespace wxMSWKeyboard
+
// small helper for wxGetKeyState() and wxGetMouseState()
static inline bool wxIsKeyDown(WXWORD vk)
{
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 )
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);