libZRColaUI extended to use wxWidgets and ZRColaApp::GetKeySequenceAsText() moved back to ZRCola::keyseq_db::GetSequenceAsText() for general accessibility

This commit is contained in:
Simon Rozman 2016-05-09 11:05:21 +02:00
parent 92bbc9a8bf
commit 349bc34fa8
17 changed files with 468 additions and 110 deletions

View File

@ -130,6 +130,7 @@ featZRCola comp00_ZRCola_Re.ttf
!IF "$(LANG)" == "Sl"
featZRCola compZRCola.mo.sl_SI
featZRCola compZRCola.zrcdb.mo.sl_SI
featZRCola complibZRColaUI.mo.sl_SI
featZRCola compwxExtend.mo.sl_SI
featZRCola compwxstd.mo.sl_SI
!ENDIF

View File

@ -61,6 +61,7 @@ bool ZRColaApp::OnInit()
m_locale.AddCatalogLookupPathPrefix(sPath);
wxVERIFY(m_locale.Init(language));
wxVERIFY(m_locale.AddCatalog(wxT("wxExtend")));
wxVERIFY(m_locale.AddCatalog(wxT("libZRColaUI")));
wxVERIFY(m_locale.AddCatalog(wxT("ZRCola")));
wxVERIFY(m_locale.AddCatalog(wxT("ZRCola-zrcdb")));
}
@ -128,81 +129,3 @@ bool ZRColaApp::OnInit()
return true;
}
bool ZRColaApp::GetKeySequenceAsText(_In_count_(seq_len) const ZRCola::keyseq_db::keyseq::key_t *seq, _In_ size_t seq_len, _Out_ wxString& str)
{
assert(seq || !seq_len);
str.Clear();
for (size_t i = 0; i < seq_len; i++) {
if (i) str += L", ";
if (seq[i].modifiers & ZRCola::keyseq_db::keyseq::CTRL ) str += L"Ctrl+";
if (seq[i].modifiers & ZRCola::keyseq_db::keyseq::ALT ) str += L"Alt+";
if (seq[i].modifiers & ZRCola::keyseq_db::keyseq::SHIFT) str += L"Shift+";
wchar_t k = seq[i].key;
#if defined(__WXMSW__)
// Translate from U.S. Keyboard to scan code.
static const HKL s_hkl = ::LoadKeyboardLayout(_T("00000409"), 0);
k = ::MapVirtualKeyEx(k, MAPVK_VK_TO_VSC, s_hkl);
// Translate from scan code to local keyboard.
k = ::MapVirtualKey(k, MAPVK_VSC_TO_VK);
#endif
switch (k) {
case 0 : return false;
case WXK_ESCAPE : str += _("Esc" ); break;
case WXK_F1 : str += _("F1" ); break;
case WXK_F2 : str += _("F2" ); break;
case WXK_F3 : str += _("F3" ); break;
case WXK_F4 : str += _("F4" ); break;
case WXK_F5 : str += _("F5" ); break;
case WXK_F6 : str += _("F6" ); break;
case WXK_F7 : str += _("F7" ); break;
case WXK_F8 : str += _("F8" ); break;
case WXK_F9 : str += _("F9" ); break;
case WXK_F10 : str += _("F10" ); break;
case WXK_F11 : str += _("F11" ); break;
case WXK_F12 : str += _("F12" ); break;
case WXK_PRINT : str += _("Print Screen"); break;
case WXK_SCROLL : str += _("Scroll Lock" ); break;
case WXK_PAUSE : str += _("Pause" ); break;
case WXK_BACK : str += _("Backspace" ); break;
case WXK_TAB : str += _("Tab" ); break;
case WXK_CAPITAL : str += _("Caps Lock" ); break;
case WXK_RETURN : str += _("Return" ); break;
case WXK_SPACE : str += _("Space" ); break;
case WXK_SHIFT : str += _("Shift" ); break;
case WXK_ALT : str += _("Alt" ); break;
case WXK_CONTROL : str += _("Ctrl" ); break;
case WXK_MENU : str += _("Menu" ); break;
case WXK_INSERT : str += _("Insert" ); break;
case WXK_DELETE : str += _("Delete" ); break;
case WXK_PAGEUP : str += _("Page Up" ); break;
case WXK_PAGEDOWN : str += _("Page Down" ); break;
case WXK_HOME : str += _("Home" ); break;
case WXK_END : str += _("End" ); break;
case WXK_LEFT : str += _("Left" ); break;
case WXK_UP : str += _("Up" ); break;
case WXK_RIGHT : str += _("Right" ); break;
case WXK_DOWN : str += _("Down" ); break;
case WXK_NUMLOCK : str += _("Num Lock" ); break;
default:
#if defined(__WXMSW__)
k = ::MapVirtualKey(k, MAPVK_VK_TO_CHAR);
#endif
str += k;
}
}
return true;
}

View File

@ -57,34 +57,6 @@ public:
///
inline wxString GetDatabasePath() const;
///
/// Get text representation of a given key sequence
///
/// \param[in] seq Key sequence
/// \param[in] seq_len Number of elements in \p seq
/// \param[out] str Text representation of a \p seq key sequence
///
/// \returns
/// - \c true if conversion succeeded
/// - \c false otherwise
///
static bool GetKeySequenceAsText(_In_count_(seq_len) const ZRCola::keyseq_db::keyseq::key_t *seq, _In_ size_t seq_len, _Out_ wxString& str);
///
/// Get text representation of a given key sequence
///
/// \param[in] seq Key sequence
/// \param[in] seq_len Number of elements in \p seq
///
/// \returns Text representation of a \p seq key sequence
///
static inline wxString GetKeySequenceAsText(_In_count_(seq_len) const ZRCola::keyseq_db::keyseq::key_t *seq, _In_ size_t seq_len)
{
wxString str;
return GetKeySequenceAsText(seq, seq_len, str) ? str : wxEmptyString;
}
public:
ZRCola::translation_db m_t_db; ///< Translation database
ZRCola::langchar_db m_lc_db; ///< Language character database

View File

@ -103,7 +103,7 @@ wxString wxZRColaCharGrid::GetToolTipText(int idx)
if (found) {
ZRCola::keyseq_db::keyseq &seq = app->m_ks_db.idxChr[start];
wxString ks_str;
if (ZRColaApp::GetKeySequenceAsText(seq.seq, seq.seq_len, ks_str))
if (ZRCola::keyseq_db::GetSequenceAsText(seq.seq, seq.seq_len, ks_str))
return wxString::Format(wxT("U+%04X (%s)"), (int)m_chars[idx], ks_str.c_str());
}

View File

@ -117,7 +117,7 @@ bool wxZRColaKeyHandler::ProcessEvent(wxEvent& event)
{
// The sequence is a partial match. Continue watching.
if (pFrame && pFrame->GetStatusBar())
pFrame->SetStatusText(ZRColaApp::GetKeySequenceAsText(m_seq.data(), m_seq.size()));
pFrame->SetStatusText(ZRCola::keyseq_db::GetSequenceAsText(m_seq.data(), m_seq.size()));
event.StopPropagation();
return true;

View File

@ -478,7 +478,7 @@ int _tmain(int argc, _TCHAR *argv[])
&ks2 = db.idxKey[i ];
if (ZRCola::keyseq_db::keyseq::CompareSequence(ks1.seq, ks1.seq_len, ks2.seq, ks2.seq_len) == 0) {
std::wstring seq_str;
wxString seq_str;
ZRCola::keyseq_db::GetSequenceAsText(ks1.seq, ks1.seq_len, seq_str);
_ftprintf(stderr, wxT("%s: warning ZCC0007: Duplicate key sequence (%ls => %04X or %04X). The keyboard behaviour will be unpredictable.\n"), (LPCTSTR)filenameIn.c_str(), seq_str.c_str(), ks1.chr, ks2.chr);
}

View File

@ -72,6 +72,9 @@ complibZRColaUI.dll.Win32 {D9A5BF44-DDFE-4A22-89F4-14D291581829} ZRCOLABINDIR 0
!IF "$(PLAT)" == "x64"
complibZRColaUI.dll.x64 {360E78E5-9560-4C52-B806-45EDC682BB17} ZRCOLABINDIR 256 filelibZRColaUI.dll.x64
!ENDIF
!IF "$(LANG)" == "Sl"
complibZRColaUI.mo.sl_SI {EAE1C699-8415-4FC6-9EC7-FE74AFC432A9} ZRCOLALOCSLSIDIR $(MSIBUILD_COMPONENT_ATTRIB_FILE) filelibZRColaUI.mo.sl_SI
!ENDIF
<<NOKEEP
@ -102,6 +105,9 @@ filelibZRColaUI.dll.x64 complibZRColaUI.dll.x64 LIBZRC~6.DLL|libZRColaUI10u_vc10
filelibZRColaUI.dll.x64 complibZRColaUI.dll.x64 LIBZRC~8.DLL|libZRColaUI10ud_vc100_x64.dll 0 0 1536 1
!ENDIF
!ENDIF
!IF "$(LANG)" == "Sl"
filelibZRColaUI.mo.sl_SI complibZRColaUI.mo.sl_SI LIBZRC~1.MO|libZRColaUI.mo 0 1060 0 1
!ENDIF
<<NOKEEP

View File

@ -36,6 +36,12 @@
<ItemGroup>
<ResourceCompile Include="..\res\libZRColaUI.rc" />
</ItemGroup>
<ItemGroup>
<POCompile Include="..\locale\sl_SI.po" />
</ItemGroup>
<ItemGroup>
<None Include="..\locale\libZRColaUI.pot" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C0A84BD2-3870-4CD6-B281-0AB322E3C579}</ProjectGuid>
<RootNamespace>libZRColaUI</RootNamespace>
@ -105,5 +111,6 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\include\xgettext.targets" />
</ImportGroup>
</Project>

View File

@ -13,6 +13,9 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Resource Files\Localization">
<UniqueIdentifier>{21f03e61-c62a-427a-bcb2-80c08dcff0bd}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\stdafx.cpp">
@ -41,4 +44,14 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\locale\libZRColaUI.pot">
<Filter>Resource Files\Localization</Filter>
</None>
</ItemGroup>
<ItemGroup>
<POCompile Include="..\locale\sl_SI.po">
<Filter>Resource Files\Localization</Filter>
</POCompile>
</ItemGroup>
</Project>

View File

@ -23,6 +23,9 @@
#include <zrcola/common.h>
#include <stdex/idrec.h>
#include <wx/string.h>
#include <istream>
#include <vector>
@ -204,6 +207,33 @@ namespace ZRCola {
/// Constructs the database
///
inline keyseq_db() : idxChr(data), idxKey(data) {}
///
/// Get text representation of a given key sequence
///
/// \param[in] seq Key sequence
/// \param[in] seq_len Number of elements in \p seq
/// \param[out] str Text representation of a \p seq key sequence
///
/// \returns
/// - \c true if conversion succeeded
/// - \c false otherwise
///
static bool GetSequenceAsText(_In_count_(seq_len) const keyseq::key_t *seq, _In_ size_t seq_len, _Out_ wxString& str);
///
/// Get text representation of a given key sequence
///
/// \param[in] seq Key sequence
/// \param[in] seq_len Number of elements in \p seq
///
/// \returns Text representation of a \p seq key sequence
///
static inline wxString GetSequenceAsText(_In_count_(seq_len) const keyseq_db::keyseq::key_t *seq, _In_ size_t seq_len)
{
wxString str;
return GetSequenceAsText(seq, seq_len, str) ? str : wxEmptyString;
}
};

1
lib/libZRColaUI/locale/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/*.mo

View File

@ -0,0 +1,163 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: libZRColaUI\n"
"POT-Creation-Date: 2016-05-09 10:38+0200\n"
"PO-Revision-Date: 2016-02-06 09:04+0100\n"
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n"
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.7\n"
"X-Poedit-Basepath: ..\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: _\n"
"X-Poedit-SearchPath-0: src\n"
"X-Poedit-SearchPath-1: include\n"
#: src/keyboard.cpp:30 src/keyboard.cpp:72
msgid "Ctrl"
msgstr ""
#: src/keyboard.cpp:31 src/keyboard.cpp:71
msgid "Alt"
msgstr ""
#: src/keyboard.cpp:32 src/keyboard.cpp:70
msgid "Shift"
msgstr ""
#: src/keyboard.cpp:45
msgid "Esc"
msgstr ""
#: src/keyboard.cpp:47
msgid "F1"
msgstr ""
#: src/keyboard.cpp:48
msgid "F2"
msgstr ""
#: src/keyboard.cpp:49
msgid "F3"
msgstr ""
#: src/keyboard.cpp:50
msgid "F4"
msgstr ""
#: src/keyboard.cpp:51
msgid "F5"
msgstr ""
#: src/keyboard.cpp:52
msgid "F6"
msgstr ""
#: src/keyboard.cpp:53
msgid "F7"
msgstr ""
#: src/keyboard.cpp:54
msgid "F8"
msgstr ""
#: src/keyboard.cpp:55
msgid "F9"
msgstr ""
#: src/keyboard.cpp:56
msgid "F10"
msgstr ""
#: src/keyboard.cpp:57
msgid "F11"
msgstr ""
#: src/keyboard.cpp:58
msgid "F12"
msgstr ""
#: src/keyboard.cpp:60
msgid "Print Screen"
msgstr ""
#: src/keyboard.cpp:61
msgid "Scroll Lock"
msgstr ""
#: src/keyboard.cpp:62
msgid "Pause"
msgstr ""
#: src/keyboard.cpp:64
msgid "Backspace"
msgstr ""
#: src/keyboard.cpp:65
msgid "Tab"
msgstr ""
#: src/keyboard.cpp:66
msgid "Caps Lock"
msgstr ""
#: src/keyboard.cpp:67
msgid "Return"
msgstr ""
#: src/keyboard.cpp:68
msgid "Space"
msgstr ""
#: src/keyboard.cpp:73
msgid "Menu"
msgstr ""
#: src/keyboard.cpp:75
msgid "Insert"
msgstr ""
#: src/keyboard.cpp:76
msgid "Delete"
msgstr ""
#: src/keyboard.cpp:77
msgid "Page Up"
msgstr ""
#: src/keyboard.cpp:78
msgid "Page Down"
msgstr ""
#: src/keyboard.cpp:79
msgid "Home"
msgstr ""
#: src/keyboard.cpp:80
msgid "End"
msgstr ""
#: src/keyboard.cpp:82
msgid "Left"
msgstr ""
#: src/keyboard.cpp:83
msgid "Up"
msgstr ""
#: src/keyboard.cpp:84
msgid "Right"
msgstr ""
#: src/keyboard.cpp:85
msgid "Down"
msgstr ""
#: src/keyboard.cpp:87
msgid "Num Lock"
msgstr ""

View File

@ -0,0 +1,161 @@
msgid ""
msgstr ""
"Project-Id-Version: libZRColaUI\n"
"POT-Creation-Date: 2016-05-09 10:40+0200\n"
"PO-Revision-Date: 2016-05-09 10:40+0200\n"
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n"
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n"
"Language: sl_SI\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.7\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n"
"%100==4 ? 2 : 3);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: _\n"
#: src/keyboard.cpp:30 src/keyboard.cpp:72
msgid "Ctrl"
msgstr "Ctrl"
#: src/keyboard.cpp:31 src/keyboard.cpp:71
msgid "Alt"
msgstr "Alt"
#: src/keyboard.cpp:32 src/keyboard.cpp:70
msgid "Shift"
msgstr "Shift"
#: src/keyboard.cpp:45
msgid "Esc"
msgstr "Esc"
#: src/keyboard.cpp:47
msgid "F1"
msgstr "F1"
#: src/keyboard.cpp:48
msgid "F2"
msgstr "F2"
#: src/keyboard.cpp:49
msgid "F3"
msgstr "F3"
#: src/keyboard.cpp:50
msgid "F4"
msgstr "F4"
#: src/keyboard.cpp:51
msgid "F5"
msgstr "F5"
#: src/keyboard.cpp:52
msgid "F6"
msgstr "F6"
#: src/keyboard.cpp:53
msgid "F7"
msgstr "F7"
#: src/keyboard.cpp:54
msgid "F8"
msgstr "F8"
#: src/keyboard.cpp:55
msgid "F9"
msgstr "F9"
#: src/keyboard.cpp:56
msgid "F10"
msgstr "F10"
#: src/keyboard.cpp:57
msgid "F11"
msgstr "F11"
#: src/keyboard.cpp:58
msgid "F12"
msgstr "F12"
#: src/keyboard.cpp:60
msgid "Print Screen"
msgstr "Print Screen"
#: src/keyboard.cpp:61
msgid "Scroll Lock"
msgstr "Scroll Lock"
#: src/keyboard.cpp:62
msgid "Pause"
msgstr "Pause"
#: src/keyboard.cpp:64
msgid "Backspace"
msgstr "Backspace"
#: src/keyboard.cpp:65
msgid "Tab"
msgstr "Tab"
#: src/keyboard.cpp:66
msgid "Caps Lock"
msgstr "Caps Lock"
#: src/keyboard.cpp:67
msgid "Return"
msgstr "Return"
#: src/keyboard.cpp:68
msgid "Space"
msgstr "preslednica"
#: src/keyboard.cpp:73
msgid "Menu"
msgstr "Menu"
#: src/keyboard.cpp:75
msgid "Insert"
msgstr "Insert"
#: src/keyboard.cpp:76
msgid "Delete"
msgstr "Delete"
#: src/keyboard.cpp:77
msgid "Page Up"
msgstr "Page Up"
#: src/keyboard.cpp:78
msgid "Page Down"
msgstr "Page Down"
#: src/keyboard.cpp:79
msgid "Home"
msgstr "Home"
#: src/keyboard.cpp:80
msgid "End"
msgstr "End"
#: src/keyboard.cpp:82
msgid "Left"
msgstr "Left"
#: src/keyboard.cpp:83
msgid "Up"
msgstr "Up"
#: src/keyboard.cpp:84
msgid "Right"
msgstr "Right"
#: src/keyboard.cpp:85
msgid "Down"
msgstr "Down"
#: src/keyboard.cpp:87
msgid "Num Lock"
msgstr "Num Lock"

View File

@ -18,3 +18,81 @@
*/
#include "stdafx.h"
bool ZRCola::keyseq_db::GetSequenceAsText(_In_count_(seq_len) const keyseq::key_t *seq, _In_ size_t seq_len, _Out_ wxString& str)
{
assert(seq || !seq_len);
str.Clear();
for (size_t i = 0; i < seq_len; i++) {
if (i) str += wxT(", ");
if (seq[i].modifiers & ZRCola::keyseq_db::keyseq::CTRL ) { str += _("Ctrl" ); str += wxT('+'); }
if (seq[i].modifiers & ZRCola::keyseq_db::keyseq::ALT ) { str += _("Alt" ); str += wxT('+'); }
if (seq[i].modifiers & ZRCola::keyseq_db::keyseq::SHIFT) { str += _("Shift"); str += wxT('+'); }
wchar_t k = seq[i].key;
#if defined(__WXMSW__)
// Translate from U.S. Keyboard to scan code.
static const HKL s_hkl = ::LoadKeyboardLayout(_T("00000409"), 0);
k = ::MapVirtualKeyEx(k, MAPVK_VK_TO_VSC, s_hkl);
// Translate from scan code to local keyboard.
k = ::MapVirtualKey(k, MAPVK_VSC_TO_VK);
#endif
switch (k) {
case 0 : return false;
case WXK_ESCAPE : str += _("Esc" ); break;
case WXK_F1 : str += _("F1" ); break;
case WXK_F2 : str += _("F2" ); break;
case WXK_F3 : str += _("F3" ); break;
case WXK_F4 : str += _("F4" ); break;
case WXK_F5 : str += _("F5" ); break;
case WXK_F6 : str += _("F6" ); break;
case WXK_F7 : str += _("F7" ); break;
case WXK_F8 : str += _("F8" ); break;
case WXK_F9 : str += _("F9" ); break;
case WXK_F10 : str += _("F10" ); break;
case WXK_F11 : str += _("F11" ); break;
case WXK_F12 : str += _("F12" ); break;
case WXK_PRINT : str += _("Print Screen"); break;
case WXK_SCROLL : str += _("Scroll Lock" ); break;
case WXK_PAUSE : str += _("Pause" ); break;
case WXK_BACK : str += _("Backspace" ); break;
case WXK_TAB : str += _("Tab" ); break;
case WXK_CAPITAL : str += _("Caps Lock" ); break;
case WXK_RETURN : str += _("Return" ); break;
case WXK_SPACE : str += _("Space" ); break;
case WXK_SHIFT : str += _("Shift" ); break;
case WXK_ALT : str += _("Alt" ); break;
case WXK_CONTROL : str += _("Ctrl" ); break;
case WXK_MENU : str += _("Menu" ); break;
case WXK_INSERT : str += _("Insert" ); break;
case WXK_DELETE : str += _("Delete" ); break;
case WXK_PAGEUP : str += _("Page Up" ); break;
case WXK_PAGEDOWN : str += _("Page Down" ); break;
case WXK_HOME : str += _("Home" ); break;
case WXK_END : str += _("End" ); break;
case WXK_LEFT : str += _("Left" ); break;
case WXK_UP : str += _("Up" ); break;
case WXK_RIGHT : str += _("Right" ); break;
case WXK_DOWN : str += _("Down" ); break;
case WXK_NUMLOCK : str += _("Num Lock" ); break;
default:
#if defined(__WXMSW__)
k = ::MapVirtualKey(k, MAPVK_VK_TO_CHAR);
#endif
str += k;
}
}
return true;
}

View File

@ -23,4 +23,6 @@
#include "../include/zrcolaui/chargroup.h"
#include "../include/zrcolaui/keyboard.h"
#include <wx/translation.h>
#include <assert.h>

@ -1 +1 @@
Subproject commit 63e206a7ab38f38daecd2747f3b82fa71dbd2f61
Subproject commit 981cdc370be4569ef51c45a53d5cdf110eee9299

View File

@ -1,3 +1,4 @@
*/libZRColaUI.mo
*/wxExtend.mo
*/ZRCola.mo
*/ZRColaCompile.mo