[unikeyspell] r6 committed - original code

29 views
Skip to first unread message

unike...@googlecode.com

unread,
Oct 10, 2011, 7:26:02 PM10/10/11
to unike...@googlegroups.com
Revision: 6
Author: trung...@gmail.com
Date: Mon Oct 10 16:21:04 2011
Log: original code
http://code.google.com/p/unikeyspell/source/detail?r=6

Added:
/trunk/ unikeyspell --username trung...@gmail.com/byteio
/trunk/ unikeyspell --username trung...@gmail.com/byteio/Readme.txt
/trunk/ unikeyspell --username trung...@gmail.com/byteio/byteio.cpp
/trunk/ unikeyspell --username trung...@gmail.com/byteio/byteio.h
/trunk/ unikeyspell --username trung...@gmail.com/byteio/byteio.plg
/trunk/ unikeyspell --username trung...@gmail.com/byteio/byteio.vcproj
/trunk/ unikeyspell --username
trung...@gmail.com/byteio/byteio.vcproj.old
/trunk/ unikeyspell --username trung...@gmail.com/byteio/prehdr.cpp
/trunk/ unikeyspell --username trung...@gmail.com/byteio/prehdr.h
/trunk/ unikeyspell --username trung...@gmail.com/gpl.txt
/trunk/ unikeyspell --username trung...@gmail.com/keyhook
/trunk/ unikeyspell --username trung...@gmail.com/keyhook/Keyhook.dsp
/trunk/ unikeyspell --username trung...@gmail.com/keyhook/Keyhook.plg
/trunk/ unikeyspell --username trung...@gmail.com/keyhook/Keyhook.vcproj
/trunk/ unikeyspell --username
trung...@gmail.com/keyhook/Keyhook.vcproj.old
/trunk/ unikeyspell --username trung...@gmail.com/keyhook/keycons.h
/trunk/ unikeyspell --username
trung...@gmail.com/keyhook/keyhook-stable.cpp
/trunk/ unikeyspell --username trung...@gmail.com/keyhook/keyhook.cpp
/trunk/ unikeyspell --username trung...@gmail.com/keyhook/keyhook.def
/trunk/ unikeyspell --username trung...@gmail.com/keyhook/keyhook.h
/trunk/ unikeyspell --username trung...@gmail.com/keyhook/preHdr.h
/trunk/ unikeyspell --username trung...@gmail.com/keyhook/prehdr.cpp
/trunk/ unikeyspell --username trung...@gmail.com/keyhook/vietkey.cpp
/trunk/ unikeyspell --username trung...@gmail.com/keyhook/vietkey.h
/trunk/ unikeyspell --username trung...@gmail.com/license.txt
/trunk/ unikeyspell --username trung...@gmail.com/newkey
/trunk/ unikeyspell --username trung...@gmail.com/newkey/NewKey.rc
/trunk/ unikeyspell --username trung...@gmail.com/newkey/NewKey.vcproj
/trunk/ unikeyspell --username
trung...@gmail.com/newkey/NewKey.vcproj.old
/trunk/ unikeyspell --username trung...@gmail.com/newkey/about.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/about.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/button.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/button.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/encode.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/encode.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/expdlg.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/expdlg.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/font.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/font.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/keydlg.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/keydlg.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/label.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/label.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/macro.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/macrodlg.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/macrodlg.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/mactab.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/mactab.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/mainwnd.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/mainwnd.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/newkey.ncb
/trunk/ unikeyspell --username trung...@gmail.com/newkey/newkey.sln
/trunk/ unikeyspell --username trung...@gmail.com/newkey/newkey.sln.old
/trunk/ unikeyspell --username trung...@gmail.com/newkey/newkey.suo
/trunk/ unikeyspell --username trung...@gmail.com/newkey/odmenu.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/odmenu.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/prehdr.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/prehdr.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/2arrow.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/Add.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/CVS
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/CVS/Entries
/trunk/ unikeyspell --username
trung...@gmail.com/newkey/res/CVS/Repository
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/CVS/Root
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/Delete.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/Openfold.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/Pen.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/arw06dn.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/arw06up.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/cancel.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/convert.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/h_point.cur
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/help.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/info.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/ok.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/viet-off.ico
/trunk/ unikeyspell --username
trung...@gmail.com/newkey/res/viet-off2.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/viet-on.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/res/viet-on2.ico
/trunk/ unikeyspell --username trung...@gmail.com/newkey/resource.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/smedit.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/smedit.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/tooldlg-temp.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/tooldlg.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/tooldlg.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/ukmenu.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/ukmenu.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/userpref.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/userpref.h
/trunk/ unikeyspell --username trung...@gmail.com/newkey/util.cpp
/trunk/ unikeyspell --username trung...@gmail.com/newkey/util.h
/trunk/ unikeyspell --username trung...@gmail.com/readme.txt
/trunk/ unikeyspell --username trung...@gmail.com/release
/trunk/ unikeyspell --username trung...@gmail.com/release/rtfio.dll
/trunk/ unikeyspell --username trung...@gmail.com/rtfio
/trunk/ unikeyspell --username trung...@gmail.com/rtfio/intrtfio.h
/trunk/ unikeyspell --username trung...@gmail.com/rtfio/rtfio.dll
/trunk/ unikeyspell --username trung...@gmail.com/rtfio/rtfio.lib
/trunk/ unikeyspell --username trung...@gmail.com/urelease
/trunk/ unikeyspell --username trung...@gmail.com/urelease/rtfio.dll
/trunk/ unikeyspell --username trung...@gmail.com/uvconvert
/trunk/ unikeyspell --username trung...@gmail.com/uvconvert/Makefile
/trunk/ unikeyspell --username trung...@gmail.com/uvconvert/changes.txt
/trunk/ unikeyspell --username trung...@gmail.com/uvconvert/prehdr.cpp
/trunk/ unikeyspell --username trung...@gmail.com/uvconvert/prehdr.h
/trunk/ unikeyspell --username trung...@gmail.com/uvconvert/readme.txt
/trunk/ unikeyspell --username trung...@gmail.com/uvconvert/uvconvert.cpp
/trunk/ unikeyspell --username trung...@gmail.com/uvconvert/uvconvert.plg
/trunk/ unikeyspell --username
trung...@gmail.com/uvconvert/uvconvert.vcproj
/trunk/ unikeyspell --username
trung...@gmail.com/uvconvert/uvconvert.vcproj.old
/trunk/ unikeyspell --username trung...@gmail.com/vnconv
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/Makefile
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/charset.cpp
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/charset.h
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/convert.cpp
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/data.cpp
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/data.h
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/error.cpp
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/out.txt
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/pattern.cpp
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/pattern.h
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/readme.txt
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/stdafx.cpp
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/stdafx.h
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/vnconv.h
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/vnconv.plg
/trunk/ unikeyspell --username trung...@gmail.com/vnconv/vnconv.vcproj

=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/byteio/Readme.txt
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,24 @@
+========================================================================
+ STATIC LIBRARY : byteio
+========================================================================
+
+
+AppWizard has created this byteio library for you.
+
+This file contains a summary of what you will find in each of the files
that
+make up your byteio application.
+
+/////////////////////////////////////////////////////////////////////////////
+
+StdAfx.h, StdAfx.cpp
+ These files are used to build a precompiled header (PCH) file
+ named byteio.pch and a precompiled types file named StdAfx.obj.
+
+/////////////////////////////////////////////////////////////////////////////
+Other notes:
+
+AppWizard uses "TODO:" to indicate parts of the source code you
+should add to or customize.
+
+
+/////////////////////////////////////////////////////////////////////////////
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/byteio/byteio.cpp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,433 @@
+#include "prehdr.h"
+#include "byteio.h"
+
+//------------------------------------------------
+StringBIStream::StringBIStream(BYTE *data, int len)
+{
+ m_data = m_current = data;
+ m_len = m_left = len;
+ if (len == -1)
+ m_eos = (*data == 0);
+ else
+ m_eos = (len <= 0);
+ m_didBookmark = 0;
+}
+
+//------------------------------------------------
+int StringBIStream::eos()
+{
+ return m_eos;
+}
+
+//------------------------------------------------
+int StringBIStream::getNext(BYTE & b)
+{
+ if (m_eos)
+ return 0;
+ b = *m_current++;
+ if (m_len == -1) {
+ m_eos = (b == 0);
+ }
+ else {
+ m_left--;
+ m_eos = (m_left <= 0);
+ }
+ return 1;
+}
+
+//------------------------------------------------
+int StringBIStream::unget(BYTE b)
+{
+ if (m_current != m_data) {
+ *--m_current = b;
+ m_eos = 0;
+ if (m_len != -1)
+ m_left++;
+/*
+ if (m_left > m_len) {
+ int err;
+ err = 1;
+ }
+*/
+ }
+ return 1;
+}
+
+//------------------------------------------------
+int StringBIStream::getNextW(WORD & w)
+{
+ if (m_eos) return 0;
+ w = *((WORD *)m_current);
+ m_current += 2;
+ if (m_len == -1)
+ m_eos = (w == 0);
+ else {
+ m_left -= 2;
+ m_eos = (m_left <= 0);
+ }
+ return 1;
+}
+
+
+//------------------------------------------------
+int StringBIStream::peekNext(BYTE & b)
+{
+ if (m_eos)
+ return 0;
+ b = *m_current;
+ return 1;
+}
+
+//------------------------------------------------
+int StringBIStream::peekNextW(WORD & w)
+{
+ if (m_eos)
+ return 0;
+ w = *((WORD *)m_current);
+ return 1;
+}
+
+//------------------------------------------------
+void StringBIStream::reopen()
+{
+ m_current = m_data;
+ m_left = m_len;
+ if (m_len == -1)
+ m_eos = (m_data == 0);
+ else
+ m_eos = (m_len <= 0);
+ m_didBookmark = 0;
+}
+
+//------------------------------------------------
+int StringBIStream::bookmark()
+{
+ m_didBookmark = 1;
+ m_bookmark.current = m_current;
+ m_bookmark.data = m_data;
+ m_bookmark.eos = m_eos;
+ m_bookmark.left = m_left;
+ m_bookmark.len = m_len;
+ return 1;
+}
+
+//------------------------------------------------
+int StringBIStream::gotoBookmark()
+{
+ if (!m_didBookmark)
+ return 0;
+ m_current = m_bookmark.current;
+ m_data = m_bookmark.data;
+ m_eos = m_bookmark.eos;
+ m_left = m_bookmark.left;
+ m_len = m_bookmark.len;
+ return 1;
+}
+
+//------------------------------------------------
+int StringBIStream::close()
+{
+ return 1;
+};
+
+//////////////////////////////////////////////////
+// Class StringBOStream
+//////////////////////////////////////////////////
+
+//------------------------------------------------
+StringBOStream::StringBOStream(BYTE *buf, int len)
+{
+ m_current = m_buf = buf;
+ m_len = len;
+ m_out = 0;
+ m_bad = 0;
+}
+
+//------------------------------------------------
+int StringBOStream::putB(BYTE b)
+{
+ m_out++;
+/*
+ if (m_out >= 2147483647) {
+ int err;
+ err = 1;
+ }
+*/
+ if (m_bad)
+ return 0;
+/*
+ if (m_out < 0) {
+ int i;
+ i = 1;
+ }
+*/
+ if (m_out <= m_len) {
+ *m_current++ = b;
+ return 1;
+ }
+ m_bad = 1;
+ return 0;
+}
+
+//------------------------------------------------
+int StringBOStream::putW(WORD w)
+{
+ m_out += 2;
+ if (m_bad)
+ return 0;
+ if (m_out <= m_len) {
+ *((WORD *)m_current) = w;
+ m_current += 2;
+ return 1;
+ }
+ m_bad = 1;
+ return 0;
+}
+
+//------------------------------------------------
+int StringBOStream::puts(const char *s, int size)
+{
+ if (size == -1) {
+ while (*s) {
+ m_out++;
+ if (m_out <= m_len)
+ *m_current++ = *s;
+ s++;
+ }
+ if (!m_bad && m_out > m_len)
+ m_bad = 1;
+ return (!m_bad);
+ }
+
+ int n;
+ if (!m_bad && m_out <= m_len) {
+ n = m_len - m_out;
+ if (n>size)
+ n = size;
+ memcpy(m_current, s, n);
+ m_current += n;
+ }
+
+ m_out += size;
+ if (!m_bad && m_out > m_len)
+ m_bad = 1;
+ return (!m_bad);
+}
+
+//------------------------------------------------
+void StringBOStream::reopen()
+{
+ m_current = m_buf;
+ m_out = 0;
+ m_bad = 0;
+}
+
+
+//------------------------------------------------
+int StringBOStream::isOK()
+{
+ return !m_bad;
+}
+
+
+////////////////////////////////////////////////////
+// Class FileBIStream //
+////////////////////////////////////////////////////
+
+//----------------------------------------------------
+FileBIStream::FileBIStream(int bufSize, char *buf)
+{
+ m_file = NULL;
+ m_buf = buf;
+ m_bufSize = bufSize;
+ m_own = 1;
+ m_didBookmark = 0;
+}
+
+//----------------------------------------------------
+FileBIStream::~FileBIStream()
+{
+ if (m_own)
+ close();
+}
+
+//----------------------------------------------------
+int FileBIStream::open(const char *fileName)
+{
+ m_file = fopen(fileName, "rb");
+ if (m_file == NULL)
+ return 0;
+ setvbuf(m_file, m_buf, _IOFBF, m_bufSize);
+ m_own = 0;
+ return 1;
+}
+
+//----------------------------------------------------
+int FileBIStream::close()
+{
+ if (m_file != NULL) {
+ fclose(m_file);
+ m_file = NULL;
+ }
+ return 1;
+}
+
+//----------------------------------------------------
+void FileBIStream::attach(FILE * f)
+{
+ m_file = f;
+ m_own = 0;
+}
+
+//----------------------------------------------------
+int FileBIStream::eos()
+{
+ return feof(m_file);
+}
+
+//----------------------------------------------------
+int FileBIStream::getNext(BYTE &b)
+{
+ b = fgetc(m_file);
+ return (!feof(m_file));
+}
+
+//----------------------------------------------------
+int FileBIStream::peekNext(BYTE &b)
+{
+ b = fgetc(m_file);
+ if (feof(m_file))
+ return 0;
+ ungetc(b, m_file);
+ return 1;
+}
+
+//----------------------------------------------------
+int FileBIStream::unget(BYTE b)
+{
+ ungetc(b, m_file);
+ return 1;
+}
+
+//----------------------------------------------------
+int FileBIStream::getNextW(WORD &w)
+{
+ w = fgetwc(m_file);
+ return (!feof(m_file));
+}
+
+//----------------------------------------------------
+int FileBIStream::peekNextW(WORD &w)
+{
+ w = fgetwc(m_file);
+ if (feof(m_file))
+ return 0;
+ ungetwc(w, m_file);
+ return 1;
+}
+
+//----------------------------------------------------
+int FileBIStream::bookmark()
+{
+ m_didBookmark = 1;
+ m_bookmark.pos = ftell(m_file);
+ return 1;
+}
+
+
+//----------------------------------------------------
+int FileBIStream::gotoBookmark()
+{
+ if (!m_didBookmark)
+ return 0;
+ fseek(m_file, m_bookmark.pos, SEEK_SET);
+ return 1;
+}
+
+////////////////////////////////////////////////////
+// Class FileBOStream //
+////////////////////////////////////////////////////
+//----------------------------------------------------
+FileBOStream::FileBOStream(int bufSize, char *buf)
+{
+ m_file = NULL;
+ m_buf = buf;
+ m_bufSize = bufSize;
+ m_own = 1;
+ m_bad = 1;
+}
+
+//----------------------------------------------------
+FileBOStream::~FileBOStream()
+{
+ if (m_own)
+ close();
+}
+
+//----------------------------------------------------
+int FileBOStream::open(const char *fileName)
+{
+ m_file = fopen(fileName, "wb");
+ if (m_file == NULL)
+ return 0;
+ m_bad = 0;
+ setvbuf(m_file, m_buf, _IOFBF, m_bufSize);
+ m_own = 1;
+ return 1;
+}
+
+//----------------------------------------------------
+void FileBOStream::attach(FILE * f)
+{
+ m_file = f;
+ m_own = 0;
+ m_bad = 0;
+}
+
+//----------------------------------------------------
+int FileBOStream::close()
+{
+ if (m_file != NULL) {
+ fclose(m_file);
+ m_file = NULL;
+ }
+ return 1;
+}
+
+//----------------------------------------------------
+int FileBOStream::putB(BYTE b)
+{
+ if (m_bad)
+ return 0;
+ m_bad = (fputc(b, m_file) == EOF);
+ return (!m_bad);
+}
+
+//----------------------------------------------------
+int FileBOStream::putW(WORD w)
+{
+ if (m_bad)
+ return 0;
+ m_bad = (fputwc(w, m_file) == WEOF);
+ return (!m_bad);
+}
+
+//----------------------------------------------------
+int FileBOStream::puts(const char *s, int size)
+{
+ if (m_bad)
+ return 0;
+ if (size == -1) {
+ m_bad = (fputs(s, m_file) == EOF);
+ return (!m_bad);
+ }
+ int out = fwrite(s, 1, size, m_file);
+ m_bad = (out != size);
+ return (!m_bad);
+}
+
+//----------------------------------------------------
+int FileBOStream::isOK()
+{
+ return !m_bad;
+}
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/byteio/byteio.h Mon
Oct 10 16:21:04 2011
@@ -0,0 +1,175 @@
+#ifndef BYTE_IO_STREAM_H
+#define BYTE_IO_STREAM_H
+
+
+//#include "vnconv.h"
+typedef unsigned char BYTE;
+typedef unsigned short WORD;
+
+//----------------------------------------------------
+class ByteStream {
+
+};
+
+//----------------------------------------------------
+class ByteInStream: public ByteStream
+{
+public:
+ virtual int getNext(BYTE &b) = 0;
+ virtual int peekNext(BYTE &b) = 0;
+ virtual int unget(BYTE b) = 0;
+
+ virtual int getNextW(WORD &w) = 0;
+ virtual int peekNextW(WORD &w) = 0;
+
+ virtual int bookmark() //no support for bookmark by default
+ {
+ return 0;
+ }
+
+ virtual int gotoBookmark()
+ {
+ return 0;
+ }
+
+ virtual int eos() = 0; //end of stream
+ virtual int close() = 0;
+};
+
+//----------------------------------------------------
+class ByteOutStream: public ByteStream
+{
+public:
+ virtual int putB(BYTE b) = 0;
+ virtual int putW(WORD w) = 0;
+ virtual int puts(const char *s, int size = -1) = 0; // write an 8-bit
string
+ virtual int isOK() = 0;// get current stream state
+};
+
+//----------------------------------------------------
+class StringBIStream : public ByteInStream
+{
+protected:
+ int m_eos;
+ BYTE *m_data, *m_current;
+ int m_len, m_left;
+
+ struct {
+ int eos;
+ BYTE *data, *current;
+ int len, left;
+ } m_bookmark;
+
+ int m_didBookmark;
+
+public:
+ StringBIStream(BYTE *data, int len);
+ virtual int getNext(BYTE &b);
+ virtual int peekNext(BYTE &b);
+ virtual int unget(BYTE b);
+
+ virtual int getNextW(WORD &w);
+ virtual int peekNextW(WORD &w);
+ virtual int eos(); //end of stream
+ virtual int close();
+
+ virtual int bookmark();
+ virtual int gotoBookmark();
+
+ void reopen();
+ int left() {
+ return m_left;
+ }
+};
+
+//----------------------------------------------------
+class FileBIStream : public ByteInStream
+{
+protected:
+ FILE *m_file;
+ int m_bufSize;
+ char *m_buf;
+ int m_own;
+ int m_didBookmark;
+
+ struct {
+ long pos;
+ } m_bookmark;
+
+public:
+
+ FileBIStream(int bufsize = 8192, char *buf = NULL);
+// FileBIStream(char *fileName, int bufsize = 8192, void *buf = NULL);
+
+ int open(const char *fileName);
+ void attach(FILE *f);
+ virtual int close();
+
+ virtual int getNext(BYTE &b);
+ virtual int peekNext(BYTE &b);
+ virtual int unget(BYTE b);
+
+ virtual int getNextW(WORD &w);
+ virtual int peekNextW(WORD &w);
+ virtual int eos(); //end of stream
+
+ virtual int bookmark();
+ virtual int gotoBookmark();
+
+ ~FileBIStream();
+};
+
+
+//----------------------------------------------------
+class StringBOStream : public ByteOutStream
+{
+protected:
+ BYTE *m_buf, *m_current;
+ int m_out;
+ int m_len;
+ int m_bad;
+public:
+ StringBOStream(BYTE *buf, int len);
+ virtual int putB(BYTE b);
+ virtual int putW(WORD w);
+ virtual int puts(const char *s, int size = -1);
+ virtual int isOK(); // get current stream state
+
+ virtual int close()
+ {
+ return 1;
+ };
+
+ void reopen();
+ int getOutBytes() {
+ return m_out;
+ }
+};
+
+//----------------------------------------------------
+class FileBOStream : public ByteOutStream
+{
+protected:
+ FILE *m_file;
+ int m_bufSize;
+ char *m_buf;
+ int m_own;
+ int m_bad;
+
+public:
+ FileBOStream(int bufsize = 8192, char *buf = NULL);
+// FileBOStream(char *fileName, int bufsize = 8192, void *buf = NULL);
+
+ int open(const char *fileName);
+ void attach(FILE *);
+ virtual int close();
+
+ virtual int putB(BYTE b);
+ virtual int putW(WORD w);
+ virtual int puts(const char *s, int size = -1);
+ virtual int isOK(); // get current stream state
+ ~FileBOStream();
+};
+
+
+#endif
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/byteio/byteio.plg
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,27 @@
+<html>
+<body>
+<pre>
+<h1>Build Log</h1>
+<h3>
+--------------------Configuration: byteio - Win32
Release--------------------
+</h3>
+<h3>Command Lines</h3>
+Creating temporary file "d:\temp\RSPFD.tmp" with contents
+[
+/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB"
/Fp"Release/byteio.pch" /Yu"prehdr.h" /Fo"Release/" /Fd"Release/" /FD /c
+"D:\Projects\UniKey\byteio\byteio.cpp"
+]
+Creating command line "cl.exe @d:\temp\RSPFD.tmp"
+Creating command line "link.exe -lib /nologo
/out:"..\Release\byteio.lib" .\Release\byteio.obj .\Release\prehdr.obj "
+<h3>Output Window</h3>
+Compiling...
+byteio.cpp
+Creating library...
+
+
+
+<h3>Results</h3>
+byteio.lib - 0 error(s), 0 warning(s)
+</pre>
+</body>
+</html>
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username
trung...@gmail.com/byteio/byteio.vcproj Mon Oct 10 16:21:04 2011
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="byteio"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="4"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32,_DEBUG,_LIB"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="prehdr.h"
+ PrecompiledHeaderFile=".\Debug/byteio.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile=".\Debug\byteio.lib"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="4"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32,NDEBUG,_LIB"
+ StringPooling="TRUE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="prehdr.h"
+ PrecompiledHeaderFile=".\Release/byteio.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile=".\Release\byteio.lib"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath=".\byteio.cpp">
+ </File>
+ <File
+ RelativePath=".\prehdr.cpp">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl">
+ <File
+ RelativePath=".\byteio.h">
+ </File>
+ <File
+ RelativePath=".\prehdr.h">
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\Readme.txt">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username
trung...@gmail.com/byteio/byteio.vcproj.old Mon Oct 10 16:21:04 2011
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding = "windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.00"
+ Name="byteio"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="4"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32,_DEBUG,_LIB"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="prehdr.h"
+ PrecompiledHeaderFile=".\Debug/byteio.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile=".\Debug\byteio.lib"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="4"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32,NDEBUG,_LIB"
+ StringPooling="TRUE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="prehdr.h"
+ PrecompiledHeaderFile=".\Release/byteio.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile=".\Release\byteio.lib"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath=".\byteio.cpp">
+ </File>
+ <File
+ RelativePath=".\prehdr.cpp">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl">
+ <File
+ RelativePath=".\byteio.h">
+ </File>
+ <File
+ RelativePath=".\prehdr.h">
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\Readme.txt">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/byteio/prehdr.cpp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,6 @@
+// stdafx.cpp : source file that includes just the standard includes
+// byteio.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "prehdr.h"
+
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/byteio/prehdr.h Mon
Oct 10 16:21:04 2011
@@ -0,0 +1,23 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__E9288DDD_DB2B_413C_A8E3_E079B0E3C763__INCLUDED_)
+#define AFX_STDAFX_H__E9288DDD_DB2B_413C_A8E3_E079B0E3C763__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows
headers
+
+
+// TODO: reference additional headers your program requires here
+#include <stdio.h>
+#include <memory.h>
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately
before the previous line.
+
+#endif
// !defined(AFX_STDAFX_H__E9288DDD_DB2B_413C_A8E3_E079B0E3C763__INCLUDED_)
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/gpl.txt Mon Oct 10
16:21:04 2011
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange;
or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free
Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show
w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/keyhook/Keyhook.dsp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,154 @@
+# Microsoft Developer Studio Project File - Name="keyhook" - Package
Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=keyhook - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "Keyhook.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "Keyhook.mak" CFG="keyhook - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "keyhook - Win32 Release" (based on "Win32 (x86) Dynamic-Link
Library")
+!MESSAGE "keyhook - Win32 Debug" (based on "Win32 (x86) Dynamic-Link
Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "keyhook - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir ".\Release"
+# PROP BASE Intermediate_Dir ".\Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "../Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG"
/D "_WINDOWS" /YX /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"
/Yu"prehdr.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 user32.lib shell32.lib /nologo /stack:0x4e20,0x1000
/subsystem:windows /dll /machine:I386 /def:".\keyhook.def"
/out:"../Release/UKHook35.dll" /heap:0x4e20,0x1000
+# SUBTRACT LINK32 /pdb:none /nodefaultlib
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=copy ..\release\ukhook35.dll ..\urelease\ukhook35.dll
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "keyhook - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir ".\Debug"
+# PROP BASE Intermediate_Dir ".\Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "../Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG"
/D "_WINDOWS" /YX /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG"
/D "_WINDOWS" /YX /FD /c
+# ADD BASE MTL /nologo /D "_DEBUG" /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
+# ADD LINK32 kernel32.lib user32.lib shell32.lib /nologo
/subsystem:windows /dll /debug /machine:I386 /out:"../Debug/UKhook35.dll"
+
+!ENDIF
+
+# Begin Target
+
+# Name "keyhook - Win32 Release"
+# Name "keyhook - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
+# Begin Source File
+
+SOURCE=.\keyhook.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\keyhook.def
+
+!IF "$(CFG)" == "keyhook - Win32 Release"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF "$(CFG)" == "keyhook - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\prehdr.cpp
+
+!IF "$(CFG)" == "keyhook - Win32 Release"
+
+# ADD CPP /Yc"prehdr.h"
+
+!ELSEIF "$(CFG)" == "keyhook - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\vietkey.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
+# Begin Source File
+
+SOURCE=.\keycons.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\keyhook.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\preHdr.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\vietkey.h
+# End Source File
+# End Group
+# End Target
+# End Project
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/keyhook/Keyhook.plg
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,25 @@
+<html>
+<body>
+<pre>
+<h1>Build Log</h1>
+<h3>
+--------------------Configuration: keyhook - Win32
Release--------------------
+</h3>
+<h3>Command Lines</h3>
+Creating temporary file "D:\TEMP\RSP18FC.tmp" with contents
+[
+/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"
/Fp"Release/Keyhook.pch" /Yu"prehdr.h" /Fo"Release/" /Fd"Release/" /FD /c
+"D:\Projects\UniKey\KEYHOOK\vietkey.cpp"
+]
+Creating command line "cl.exe @D:\TEMP\RSP18FC.tmp"
+<h3>Output Window</h3>
+Compiling...
+vietkey.cpp
+
+
+
+<h3>Results</h3>
+vietkey.obj - 0 error(s), 0 warning(s)
+</pre>
+</body>
+</html>
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username
trung...@gmail.com/keyhook/Keyhook.vcproj Mon Oct 10 16:21:04 2011
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="keyhook"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\../Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderFile=".\Debug/Keyhook.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ OutputFile="../Debug/UKhook35.dll"
+ LinkIncremental="2"
+ SuppressStartupBanner="TRUE"
+ ModuleDefinitionFile=".\keyhook.def"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile=".\../Debug/UKhook35.pdb"
+ SubSystem="2"
+ ImportLibrary=".\../Debug/UKhook35.lib"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\../Debug/Keyhook.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\../Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE">
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ StringPooling="TRUE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="prehdr.h"
+ PrecompiledHeaderFile=".\Release/Keyhook.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ OutputFile="../Release/UKHook35.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ ModuleDefinitionFile=".\keyhook.def"
+ ProgramDatabaseFile=".\../Release/UKHook35.pdb"
+ SubSystem="2"
+ HeapReserveSize="20000"
+ HeapCommitSize="4096"
+ StackReserveSize="20000"
+ StackCommitSize="4096"
+ ImportLibrary=".\../Release/UKHook35.lib"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\../Release/Keyhook.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="copy ..\release\ukhook35.dll ..\urelease\ukhook35.dll"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90">
+ <File
+ RelativePath=".\keyhook.cpp">
+ </File>
+ <File
+ RelativePath=".\keyhook.def">
+ </File>
+ <File
+ RelativePath=".\prehdr.cpp">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\vietkey.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;fi;fd">
+ <File
+ RelativePath=".\keycons.h">
+ </File>
+ <File
+ RelativePath=".\keyhook.h">
+ </File>
+ <File
+ RelativePath=".\preHdr.h">
+ </File>
+ <File
+ RelativePath=".\vietkey.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username
trung...@gmail.com/keyhook/Keyhook.vcproj.old Mon Oct 10 16:21:04 2011
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding = "windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.00"
+ Name="keyhook"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\../Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderFile=".\Debug/Keyhook.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ OutputFile="../Debug/UKhook35.dll"
+ LinkIncremental="2"
+ SuppressStartupBanner="TRUE"
+ ModuleDefinitionFile=".\keyhook.def"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile=".\../Debug/UKhook35.pdb"
+ SubSystem="2"
+ ImportLibrary=".\../Debug/UKhook35.lib"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\../Debug/Keyhook.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\../Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE">
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ StringPooling="TRUE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="prehdr.h"
+ PrecompiledHeaderFile=".\Release/Keyhook.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ OutputFile="../Release/UKHook35.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ ModuleDefinitionFile=".\keyhook.def"
+ ProgramDatabaseFile=".\../Release/UKHook35.pdb"
+ SubSystem="2"
+ HeapReserveSize="20000"
+ HeapCommitSize="4096"
+ StackReserveSize="20000"
+ StackCommitSize="4096"
+ ImportLibrary=".\../Release/UKHook35.lib"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\../Release/Keyhook.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="copy ..\release\ukhook35.dll ..\urelease\ukhook35.dll"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ </Configurations>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90">
+ <File
+ RelativePath=".\keyhook.cpp">
+ </File>
+ <File
+ RelativePath=".\keyhook.def">
+ </File>
+ <File
+ RelativePath=".\prehdr.cpp">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\vietkey.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;fi;fd">
+ <File
+ RelativePath=".\keycons.h">
+ </File>
+ <File
+ RelativePath=".\keyhook.h">
+ </File>
+ <File
+ RelativePath=".\preHdr.h">
+ </File>
+ <File
+ RelativePath=".\vietkey.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/keyhook/keycons.h
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,86 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#ifndef __KEY_CONS_H
+#define __KEY_CONS_H
+
+/*
+Explanation of ecoding in DT table:
+In DT:
+- Bits 0-4: index of vowels
+- Bits 5-8: index of macro keys (e.g. TELEX: w, W, [, ]
+- Bits 9-13: index of double characters (including: a, d, e, o, a^, dd,
e^, o^, a(, u+...)
+- Bits 14-17: index of tone marks
+- Bits 18-21: determines the index of the tone associated with a
character, e.g tone_index(a') = 1.
+- Bit 22: is set if this character is used to type a breve. (in texlex,
they are w, W)
+- Bit 24: soft separator. Soft separators don't cause the buffer to be
cleared.
+- Bit 25: separator flag. Buffer must be cleared when separator character
is encountered.
+- Bit 26-28: index of VNI double marks ('6', '7', '8', '9')
+*/
+
+// Macros for entries in DT table
+#define ATTR_VOWEL_INDEX(x) (x & 0x1F)
+#define ATTR_IS_BREVE(x) ((x >> 22) & 0x1)
+#define ATTR_TONE_INDEX(x) ((x >> 14) & 0xF)
+#define ATTR_IS_SOFT_SEPARATOR(x) ((x >> 24) & 0x1)
+#define ATTR_DBCHAR_INDEX(x) ((x >> 9) & 0x1F)
+#define ATTR_MACRO_INDEX(x) ((x >> 5) & 0xF)
+#define ATTR_IS_SEPARATOR(x) (x & 0x2000000)
+#define ATTR_VNI_DOUBLE_INDEX(x) ((x >> 26) & 0x7)
+#define ATTR_CURRENT_TONE(x) ((x >> 18) & 0xF)
+#define ATTR_IS_WORD_STOP(x) ((x >> 29) & 0x1)
+
+// Character sets. See encoding.cpp
+#define TOTAL_CHARSET 17
+
+#define TCVN3_CHARSET 0
+#define UNICODE_CHARSET 0x101
+#define VIQR_CHARSET 0x100
+#define VNI_CHARSET 0x102 // Every 2-byte charset must be placed after
VNI_CHARSET
+#define DECOMPOSED_UNICODE_CHARSET 0x108
+#define WINCP1258_CHARSET 0x109
+
+
+// Input methods
+#define INPUT_METHODS 4 // Currently supports 2 input methods, TELEX & VNI
+#define TELEX_INPUT 0
+#define VNI_INPUT 1
+#define VIQR_INPUT 2
+#define VIQR_STAR_INPUT 3
+
+// Unicode encoding
+#define UNICODE_UCS2 0
+#define UNICODE_UTF8 1
+#define UNICODE_REF 2
+#define UNICODE_HEX 3
+#define UNICODE_UTF8_X 4
+#define UNICODE_CSTRING 5
+
+// macro table constants
+#define MAX_MACRO_KEY_LEN 16
+//#define MAX_MACRO_TEXT_LEN 256
+#define MAX_MACRO_TEXT_LEN 1024
+#define MAX_MACRO_ITEMS 1024
+#define MAX_MACRO_LINE (MAX_MACRO_TEXT_LEN + MAX_MACRO_KEY_LEN)
+
+#define MACRO_MEM_SIZE (1024*64) //64 KB
+
+#define CP_US_ANSI 1252
+
+#endif
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username
trung...@gmail.com/keyhook/keyhook-stable.cpp Mon Oct 10 16:21:04 2011
@@ -0,0 +1,707 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2001 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+
+#include "prehdr.h"
+#include <stdio.h>
+#include <memory.h>
+#include "keycons.h"
+#include "keyhook.h"
+#include "vietkey.h"
+
+const long IsExtended = 0x1000000,
+ FlagScancode = 0xFF0000,
+ IsALT = 0x20000000,
+ IsPrevDown = 0x40000000,
+ IsReleased = 0x80000000,
+ KeyUp = 0xC0000000;
+
+VietKey VnKbd;
+
+SharedMem * pShMem = NULL ;
+HINSTANCE MyInstance = NULL;
+
+unsigned char KeyState[256];
+unsigned short CharBuf;
+int BackTracks;
+int ClipboardIsEmpty = 1;
+int PendingSwitch = 0;
+int PuttingBacks = 0;
+
+//DWORD TlsIdx;
+
+void InitProcess();
+void ClearClipboard();
+void ResetBuffer();
+//HMODULE LoadUnicowsProc(void);
+//void UnloadUnicowsProc();
+
+#define VK_V 0x56
+
+//////////////////////////////////
+/*
+struct ThreadData {
+ HHOOK GetMsgHook;
+ int receivingClipboard;
+};
+*/
+//void InitThread();
+
+
+int CheckSwitchKey(WPARAM wParam, LPARAM lParam);
+int CheckShortcuts(WPARAM wParam, LPARAM lParam);
+
+int CheckBack(WPARAM wParam);
+void PushBacks();
+void PushBuffer(HWND wndFocused);
+
+
+#define ID_VIETKEY_ICON 1000
+#define VIETNAMESE_INPUT_ID 0x042a //language identifier for Vietnamese
+
+//UINT VK_SHIFT_SCAN;
+UINT VK_BACK_SCAN;
+//UINT VK_INSERT_SCAN;
+UINT VK_PAUSE_SCAN;
+
+// local helper functions
+void initDLL();
+
+// temporarily release shift keys
+// release = 1: release
+// release = 0: change shifts to original state
+void ReleaseShift(int release);
+
+//-------------------------------------------------
+BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD reason, LPVOID reserved)
+{
+ HANDLE hMapObject = NULL; /* handle to file mapping */
+ BOOL fInit, fIgnore;
+// ThreadData *pThread;
+ switch (reason) {
+ case DLL_PROCESS_ATTACH:
+
+ /* Create a named file mapping object */
+ MyInstance = hModule;
+ hMapObject = CreateFileMapping(
+ (HANDLE) 0xFFFFFFFF, /* use paging file */
+ NULL, /* no security attr. */
+ PAGE_READWRITE, /* read/write access */
+ 0, /* size: high 32-bits */
+ sizeof(SharedMem), /* size: low 32-bits */
+ _TEXT("UniKeyHookShareMem3.5.Final-testing"));/* name of
map object */
+ if (hMapObject == NULL)
+ return FALSE;
+
+ fInit = (GetLastError() != ERROR_ALREADY_EXISTS);
+ /* Get a pointer to the file-mapped shared memory. */
+
+ pShMem = (SharedMem *) MapViewOfFile(
+ hMapObject, /* object to map view of */
+ FILE_MAP_WRITE, /* read/write access */
+ 0, /* high offset: map from */
+ 0, /* low offset: beginning */
+ 0); /* default: map entire file */
+ if (pShMem == NULL)
+ return FALSE;
+ InitProcess();
+ if (fInit)
+ initDLL();
+// TlsIdx = TlsAlloc();
+// InitThread();
+ break;
+
+ /*
+ * The DLL is detaching from a process due to
+ * process termination or a call to FreeLibrary.
+ */
+/*
+ case DLL_THREAD_ATTACH:
+ InitThread();
+ break;
+ case DLL_THREAD_DETACH:
+ pThread = (ThreadData *)TlsGetValue(TlsIdx);
+ if (pThread != NULL)
+ delete pThread;
+ break;
+*/
+ case DLL_PROCESS_DETACH:
+
+ /* Unmap shared memory from the process's address space. */
+
+ fIgnore = UnmapViewOfFile(pShMem);
+
+ /* Close the process's handle to the file-mapping object. */
+
+ fIgnore = CloseHandle(hMapObject);
+// TlsFree(TlsIdx);
+ break;
+
+ default:
+ break;
+
+ }
+
+ return TRUE;
+ UNREFERENCED_PARAMETER(hModule);
+ UNREFERENCED_PARAMETER(reserved);
+
+}
+
+/*
+void InitThread()
+{
+ ThreadData *pThread;
+ pThread = new ThreadData();
+ memset(pThread, 0, sizeof(ThreadData));
+ TlsSetValue(TlsIdx, pThread);
+}
+*/
+
+//-------------------------------------------------
+void InitProcess()
+{
+ BackTracks = 0;
+ VnKbd.setCodeTable(&pShMem->codeTable);
+ VK_BACK_SCAN = MapVirtualKey(VK_BACK, 0);
+ VK_PAUSE_SCAN = MapVirtualKey(VK_PAUSE, 0);
+
+ /*
+ TCHAR fileName[100];
+ GetModuleFileName(NULL, fileName, 100);
+ _tcsupr(fileName);
+ FILE *f;
+ f = _tfopen(_T("d:\\uklog.txt"), _T("at"));
+ _ftprintf(f, _T("%s\n"), fileName);
+ fclose(f);
+ IsConsoleApp = (_tcsstr(fileName, _T("UNIKEY")) != NULL);
+ */
+}
+
+//-------------------------------------------------
+LRESULT CALLBACK MyKeyHook(int code, WPARAM wParam, LPARAM lParam)
+{
+ int keyType;
+ if (!pShMem->Initialized) return 0;
+ if (code < 0)
+ return CallNextHookEx(pShMem->keyHook,code,wParam,lParam);
+
+ // determine if current window is a console, if so returns
+ TCHAR className[128];
+ className[0] = 0;
+ GetClassName(GetForegroundWindow(), className, 128);
+ if (_tcscmp(className, _T("ConsoleWindowClass")) == 0)
+ return CallNextHookEx(pShMem->keyHook,code,wParam,lParam);
+
+ GetKeyboardState(KeyState);
+
+ if (CheckSwitchKey(wParam,lParam) || CheckShortcuts(wParam, lParam))
+ return 1;
+
+ if (pShMem->vietKey && code == HC_ACTION && !ClipboardIsEmpty) {
+ if (wParam != VK_INSERT && wParam != VK_SHIFT && !(lParam & IsReleased))
{
+ // postpone this key
+ keybd_event(wParam,
+ HIBYTE(LOWORD(lParam)),
+ (lParam & IsExtended)? KEYEVENTF_EXTENDEDKEY : 0,
+ 0);
+ return 1;
+ }
+ if (wParam == VK_INSERT && (lParam & IsReleased)) {
+ ClearClipboard();
+ }
+ }
+
+ if (pShMem->vietKey && (code == HC_ACTION) && !(lParam & IsReleased)) {
+ if (CheckBack(wParam)) return 1;
+ if (PuttingBacks) {
+ if (wParam != VK_BACK) {
+ keybd_event(wParam,
+ HIBYTE(LOWORD(lParam)),
+ (lParam & IsExtended)? KEYEVENTF_EXTENDEDKEY : 0,
+ 0);
+ return 1;
+ }
+ return CallNextHookEx(pShMem->keyHook,code,wParam,lParam);
+ }
+
+ if ((KeyState[VK_CONTROL] & 0x80) == 0 && (KeyState[VK_MENU] & 0x80) ==
0) {
+ keyType = ToAscii(wParam,UINT(HIWORD(lParam)),KeyState,&CharBuf,0);
+ if (keyType == 1) {
+ unsigned char c = (unsigned char)CharBuf;
+ if (wParam >= VK_NUMPAD0 && wParam <= VK_NUMPAD9)
+ VnKbd.putChar(c); // don't process numeric keypad
+ else {
+ VnKbd.process(c);
+ if (VnKbd.backs!=0 || VnKbd.keysPushed!=0) {
+ PushBacks();
+ return 1;
+ }
+ }
+ //SendMessage(GetFocus(), WM_CHAR, CharBuf, 1);
+ //return 1;
+ }
+ else if (wParam!=VK_SHIFT && wParam!=VK_INSERT)
+ ResetBuffer();
+ }
+ else ResetBuffer();
+ }
+ return CallNextHookEx(pShMem->keyHook,code,wParam,lParam);
+}
+
+
+//-------------------------------------------------
+void PushBuffer(HWND wndFocused)
+{
+ SHORT scanCode;
+ WPARAM lParam;
+
+ PostMessage(wndFocused,WM_KEYUP,VK_PAUSE,
+ (LPARAM(VK_PAUSE_SCAN)<<16)+LPARAM(IsReleased)+1);
+ if (pShMem->keyMode == UNICODE_CHARSET && pShMem->codeTable.encoding ==
UNICODE_UCS2) {
+ if (!pShMem->options.useUnicodeClipboard && pShMem->unicodePlatform &&
IsWindowUnicode(wndFocused)) {
+ for (int i=0; i<VnKbd.keysPushed; i++) {
+ scanCode = VkKeyScanW(VnKbd.uniPush[i]);
+ lParam = (scanCode << 16) + 1;
+ PostMessageW(wndFocused, WM_CHAR, VnKbd.uniPush[i], lParam);
+ }
+ }
+ else {
+ OpenClipboard(pShMem->hMainDlg);
+
+ EmptyClipboard();
+
+ VnKbd.uniPush[VnKbd.keysPushed] = 0; // null-terminated
+ VnKbd.ansiPush[VnKbd.keysPushed] = 0;
+ VnKbd.keysPushed++;
+
+ HGLOBAL hBuf = GlobalAlloc(GMEM_MOVEABLE, sizeof(WORD) *
VnKbd.keysPushed);
+ HGLOBAL hBufAnsi = GlobalAlloc(GMEM_MOVEABLE, VnKbd.keysPushed);
+
+ LPVOID pBuf = GlobalLock(hBuf);
+ LPVOID pBufAnsi = GlobalLock(hBufAnsi);
+
+ memcpy(pBuf, VnKbd.uniPush, sizeof(WORD) * VnKbd.keysPushed);
+ memcpy(pBufAnsi, VnKbd.ansiPush, VnKbd.keysPushed);
+ GlobalUnlock(hBuf);
+ GlobalUnlock(hBufAnsi);
+
+ SetClipboardData(CF_UNICODETEXT, hBuf);
+ SetClipboardData(CF_TEXT, hBufAnsi);
+
+ CloseClipboard();
+
+ //GetKeyboardState(KeyState);
+ keybd_event(VK_SHIFT, 0, 0, 0);
+ keybd_event(VK_INSERT, 0, KEYEVENTF_EXTENDEDKEY, 0);
+ keybd_event(VK_INSERT, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
+
+ if ((KeyState[VK_SHIFT] & 0x80) == 0 || (KeyState[VK_RSHIFT] & 0x80) !=
0)
+ keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
+ ClipboardIsEmpty = 0;
+ }
+ }
+ else if (pShMem->keyMode == DECOMPOSED_UNICODE_CHARSET) {
+ if (pShMem->unicodePlatform && IsWindowUnicode(wndFocused)) {
+ for (int i=0; i<VnKbd.keysPushed; i++) {
+ scanCode = VkKeyScanW(VnKbd.uniPush[i]);
+ lParam = (scanCode << 16) + 1;
+ PostMessageW(wndFocused, WM_CHAR, VnKbd.uniPush[i],lParam);
+ }
+ }
+ else {
+ ActivateKeyboardLayout((HKL)VIETNAMESE_INPUT_ID, 0);
+ int count = WideCharToMultiByte(1258, 0, VnKbd.uniPush,
VnKbd.keysPushed,
+ (char *)VnKbd.ansiPush, VnKbd.keysPushed,
0, 0);
+ for (int i=0; i<count; i++) {
+ scanCode = VkKeyScan(VnKbd.ansiPush[i]);
+ lParam = (scanCode << 16) + 1;
+ PostMessage(wndFocused,WM_CHAR, VnKbd.ansiPush[i], lParam);
+ }
+ }
+ }
+ else {
+ if (pShMem->keyMode == WINCP1258_CHARSET)
+ ActivateKeyboardLayout((HKL)VIETNAMESE_INPUT_ID, 0);
+ for (int i=0; i<VnKbd.keysPushed; i++) {
+ scanCode = VkKeyScan(VnKbd.ansiPush[i]);
+ lParam = (scanCode << 16) + 1;
+ PostMessage(wndFocused,WM_CHAR, VnKbd.ansiPush[i], lParam);
+ }
+ }
+ return;
+}
+
+
+//-------------------------------------------------
+// temporarily release shift keys
+// release = 1: release
+// release = 0: change shifts to original state
+//-------------------------------------------------
+void ReleaseShift(int release)
+{
+ static BYTE sh = 0;
+ static BYTE lsh = 0;
+ static BYTE rsh = 0;
+ static int TempReleased = 0;
+
+ if (release) {
+ sh = KeyState[VK_SHIFT];
+ lsh = KeyState[VK_LSHIFT];
+ rsh = KeyState[VK_RSHIFT];
+ KeyState[VK_SHIFT] = 0;
+ KeyState[VK_LSHIFT] = 0;
+ KeyState[VK_RSHIFT] = 0;
+ SetKeyboardState(KeyState);
+ TempReleased = 1;
+ }
+ else if (TempReleased) {
+ TempReleased = 0;
+ KeyState[VK_SHIFT] = sh;
+ KeyState[VK_LSHIFT] = lsh;
+ KeyState[VK_RSHIFT] = rsh;
+ SetKeyboardState(KeyState);
+ }
+}
+
+//-------------------------------------------------
+void PushBacks()
+{
+ if (VnKbd.backs == 0) {
+ BackTracks = 0;
+ PushBuffer(GetFocus());
+ }
+ else {
+ PuttingBacks = 1;
+ if (KeyState[VK_SHIFT] & 0x80)
+ ReleaseShift(1);
+ for (int i=0; i<VnKbd.backs; i++) {
+ keybd_event(VK_BACK, VK_BACK_SCAN,0,0);
+ keybd_event(VK_BACK, VK_BACK_SCAN, KEYEVENTF_KEYUP, 0);
+ }
+ keybd_event(VK_PAUSE, VK_PAUSE_SCAN, 0, 0);
+ }
+ return;
+}
+
+//-------------------------------------------------
+int CheckBack(WPARAM wParam)
+{
+ if (wParam == VK_PAUSE && PuttingBacks) {
+ PuttingBacks = 0;
+ ReleaseShift(0);
+ PushBuffer(GetFocus());
+ return 1;
+ }
+ return 0;
+}
+
+//-------------------------------------------------
+int CheckSwitchKey(WPARAM wParam, LPARAM lParam)
+{
+ if (!ClipboardIsEmpty)
+ return 0;
+ int ret = 0;
+ // In WinXP CTRL-SHIFT is used to change text alignment. Disable this
functionality
+
+ static int ctrlPressed = 0;
+ static int shiftPressed = 0;
+
+ if (pShMem->winMajorVersion == 5 && pShMem->winMinorVersion == 1) { //
WinXP
+ if ((KeyState[VK_CONTROL] & 0x80) && (KeyState[VK_SHIFT] & 0x80)) {
+ ctrlPressed = 1;
+ shiftPressed = 1;
+ }
+
+ if (ctrlPressed && (lParam & IsReleased) && wParam == VK_CONTROL) {
+ ctrlPressed = 0;
+ ret = 1;
+ }
+
+ if (shiftPressed && (lParam & IsReleased) && wParam == VK_SHIFT) {
+ shiftPressed = 0;
+ ret = 1;
+ }
+ }
+
+ // Check switch key
+ UINT key1, key2;
+ switch (pShMem->switchKey) {
+ case CTRL_SHIFT_SW:
+ key1 = VK_SHIFT;
+ key2 = VK_CONTROL;
+ break;
+ default:
+ key1 = VK_MENU;
+ key2 = 'Z';
+ break;
+ }
+
+ if (wParam == key1 || wParam == key2) {
+ if (lParam & IsReleased) {
+ if (PendingSwitch) {
+ PendingSwitch = 0;
+ SwitchMode();
+ MessageBeep(MB_ICONASTERISK);
+ return 1;
+ }
+ }
+ else {
+ if ((KeyState[key1] & 0x80) && (KeyState[key2] & 0x80))
+ PendingSwitch = 1;
+ }
+ }
+ else PendingSwitch = 0;
+
+ return ret;
+}
+
+//-------------------------------------------------
+LRESULT CALLBACK MyMouseHook(int code, WPARAM wParam, LPARAM lParam)
+{
+ if (pShMem->Initialized && code == HC_ACTION && wParam == WM_LBUTTONDOWN)
+ ResetBuffer();
+ return CallNextHookEx(pShMem->mouseHook,code,wParam,lParam);
+}
+
+//-------------------------------------------------
+void SwitchMode()
+{
+ if (pShMem->vietKey) pShMem->vietKey = 0;
+ else pShMem->vietKey = 1;
+ if (pShMem->iconShown) ModifyStatusIcon();
+ ClearClipboard();
+}
+
+
+//-------------------------------------------------
+void ModifyStatusIcon()
+{
+ NOTIFYICONDATA tnid;
+
+ tnid.cbSize = sizeof(NOTIFYICONDATA);
+ tnid.hWnd = pShMem->hMainDlg;
+ tnid.uID = ID_VIETKEY_ICON;
+ if (pShMem->vietKey) {
+ tnid.hIcon = pShMem->hVietIcon;
+ lstrcpy(tnid.szTip,_TEXT("Click to turn off Vienamese mode"));
+
+ } else {
+ tnid.hIcon = pShMem->hEnIcon;
+ lstrcpy(tnid.szTip,_TEXT("Click to turn on Vienamese mode"));
+ }
+ tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
+ tnid.uCallbackMessage = pShMem->iconMsgId;
+ Shell_NotifyIcon(pShMem->iconShown?NIM_MODIFY:NIM_ADD, &tnid);
+ pShMem->iconShown = 1;
+}
+
+//-------------------------------------------------
+void DeleteStatusIcon()
+{
+ NOTIFYICONDATA tnid;
+ if (pShMem->iconShown) {
+ tnid.cbSize = sizeof(NOTIFYICONDATA);
+ tnid.hWnd = pShMem->hMainDlg;
+ tnid.uID = ID_VIETKEY_ICON;
+ Shell_NotifyIcon(NIM_DELETE, &tnid);
+ pShMem->iconShown = 0;
+ }
+}
+
+//-------------------------------------------------
+int IsVietnamese()
+{
+ return pShMem->vietKey;
+}
+
+//-------------------------------------------------
+void SetKeyMode(WORD mode, int inMethod, CodeInfo *pTable)
+{
+ pShMem->keyMode = mode;
+ pShMem->inMethod = inMethod;
+ pShMem->codeTable = *pTable;
+ ResetBuffer();
+}
+
+//-------------------------------------------------
+void ClearClipboard()
+{
+ ClipboardIsEmpty = 1;
+// OpenClipboard(NULL);
+// EmptyClipboard();
+// CloseClipboard();
+}
+
+
+//-------------------------------------------------
+void ResetBuffer()
+{
+ VnKbd.clearBuf();
+ ClearClipboard();
+}
+
+
+//-------------------------------------------------
+void SetSwitchKey(int swKey)
+{
+ pShMem->switchKey = swKey;
+}
+
+//-------------------------------------------------
+void SetInputMethod(int method, DWORD *DT)
+{
+ pShMem->inMethod = method;
+ memcpy(pShMem->codeTable.DT, DT, sizeof(pShMem->codeTable.DT));
+ ResetBuffer();
+}
+
+
+//-------------------------------------------------
+HINSTANCE GetVietHookDll()
+{
+ return MyInstance;
+}
+
+//-------------------------------------------------
+int CheckShortcuts(WPARAM wParam, LPARAM lParam)
+{
+ if (!ClipboardIsEmpty)
+ return 0;
+
+ int ctrlPressed = KeyState[VK_CONTROL] & 0x80;
+ int shiftPressed = KeyState[VK_SHIFT] & 0x80;
+
+
+ UINT msg = 0;
+ WPARAM wNotify = 0;
+ LPARAM lNotify = 0;
+ static int shortcutActivated = 0;
+
+ if (!(lParam & IsReleased) && ctrlPressed && shiftPressed) {
+ switch (wParam) {
+ case VK_F5:
+ msg = WM_HOOK_PANEL_SHORTCUT;
+ break;
+ case VK_F6:
+ msg = WM_HOOK_TOOLKIT_SHORTCUT;
+ break;
+ case VK_F1:
+ // first charset, Unicode
+ msg = WM_HOOK_CHANGE_CHARSET;
+ wNotify = 0;
+ break;
+ case VK_F2:
+ // second charset, TCVN3
+ msg = WM_HOOK_CHANGE_CHARSET;
+ wNotify = 1;
+ break;
+ case VK_F3:
+ // second charset, TCVN3
+ msg = WM_HOOK_CHANGE_CHARSET;
+ wNotify = 2;
+ break;
+ case VK_F4:
+ // second charset, TCVN3
+ msg = WM_HOOK_CHANGE_CHARSET;
+ wNotify = 3;
+ break;
+ case VK_F9: // Steal VK_F9, and the release of it will be processed.later
+ return 1;
+ }
+
+ if (msg != 0) {
+ if (msg == WM_HOOK_PANEL_SHORTCUT || msg == WM_HOOK_TOOLKIT_SHORTCUT) {
+ BringWindowToTop(pShMem->hMainDlg);
+ SetForegroundWindow(pShMem->hMainDlg);
+ }
+ else {
+ MessageBeep(MB_ICONASTERISK);
+ }
+ PostMessage(pShMem->hMainDlg, msg, wNotify, lNotify);
+ shortcutActivated = 1;
+ return 1;
+ }
+ return 0;
+ }
+
+ if (lParam & IsReleased) {
+ if (shortcutActivated &&
+ (wParam == VK_F1 || wParam == VK_F2 || wParam == VK_F3 || wParam ==
VK_F4)) {
+ shortcutActivated = 0;
+ return 1;
+ }
+
+ if (ctrlPressed && shiftPressed) {
+ switch (wParam) {
+ case VK_F9:
+ msg = WM_HOOK_FLY_CONVERT;
+ break;
+ }
+ if (msg != 0) {
+ SendMessage(pShMem->hMainDlg, msg, wNotify, lNotify);
+ MessageBeep(MB_ICONASTERISK);
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+/*
+HMODULE hUnicows = NULL;
+
+HMODULE LoadUnicowsProc(void)
+{
+ OSVERSIONINFO osinfo;
+ osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&osinfo);
+
+ if (hUnicows == NULL && osinfo.dwMajorVersion<5)
+ hUnicows = LoadLibraryA("c:\\tools\\unikey\\test\\unicows.dll");
+ return hUnicows;
+}
+
+void UnloadUnicowsProc()
+{
+ if (hUnicows != NULL)
+ FreeLibrary(hUnicows);
+}
+
+*/
+
+//-------------------------------------------------
+SharedMem *GetSharedMem()
+{
+ return pShMem;
+}
+
+//-------------------------------------------------
+void initDLL()
+{
+ pShMem->Initialized = 0;
+ // check unicode platform
+ OSVERSIONINFO osinfo;
+ osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&osinfo);
+ pShMem->unicodePlatform = (osinfo.dwMajorVersion > 4 ||
+ (osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
osinfo.dwMajorVersion ==4));
+ pShMem->winMajorVersion = osinfo.dwMajorVersion;
+ pShMem->winMinorVersion = osinfo.dwMinorVersion;
+}
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/keyhook/keyhook.cpp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,1032 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+
+#include "prehdr.h"
+#include <stdio.h>
+#include <memory.h>
+#include "keycons.h"
+#include "keyhook.h"
+#include "vietkey.h"
+
+const long IsExtended = 0x1000000,
+ FlagScancode = 0xFF0000,
+ IsALT = 0x20000000,
+ IsPrevDown = 0x40000000,
+ IsReleased = 0x80000000,
+ KeyUp = 0xC0000000;
+
+VietKey VnKbd;
+
+HKL UsKeyboardLayout, ViKeyboardLayout;
+HKL OriginalLayout;
+
+SharedMem * pShMem = NULL ;
+HINSTANCE MyInstance = NULL;
+
+unsigned char KeyState[256];
+int BackTracks;
+int ClipboardIsEmpty = 1;
+int PendingSwitch = 0;
+int PendingReset = 0;
+int PuttingBacks = 0;
+
+
+//DWORD TlsIdx;
+
+void InitProcess();
+void ClearClipboard();
+void ResetBuffer();
+
+//////////////////////////////////
+/*
+struct ThreadData {
+ HHOOK GetMsgHook;
+ int receivingClipboard;
+};
+*/
+//void InitThread();
+
+
+int CheckSwitchKey(WPARAM wParam, LPARAM lParam);
+int CheckShortcuts(WPARAM wParam, LPARAM lParam);
+
+int CheckBack(WPARAM wParam);
+void PushBacks();
+void PushBuffer(HWND wndFocused);
+
+
+#define ID_VIETKEY_ICON 1000
+#define VI_KEYBOARD_LAYOUT _T("0000042a")
+#define US_KEYBOARD_LAYOUT _T("00000409")
+
+
+UINT VK_BACK_SCAN;
+UINT VK_PAUSE_SCAN;
+UINT VK_CONTROL_SCAN;
+
+// local helper functions
+void initDLL();
+
+// temporarily release control keys
+// release = 1: release
+// release = 0: change control keys to their original states
+void ReleaseControlKeys(int release);
+
+#define SHIFT_INSERT_KEY 1
+#define CTRL_V_KEY 2
+
+/*
+// List of programs that only use CTRL+V (not SHIFT+INSERT) as paste
command
+TCHAR *ProgNeedCtrlV[] = {
+ _T("JAVAW.EXE"),
+ _T("JAVA.EXE"),
+ _T("PHOTOSHP.EXE"),
+ _T("DUMMY.EXE")};
+const int ProgCtrlVCount = sizeof(ProgNeedCtrlV) / sizeof(TCHAR *);
+
+int PasteShortcut = SHIFT_INSERT_KEY;
+BYTE PasteKey1 = VK_SHIFT;
+BYTE PasteKey2 = VK_INSERT;
+//void detectPasteShortcut();
+*/
+
+int PasteShortcut = CTRL_V_KEY;
+int LayoutChangeForced = 0;
+
+BYTE PasteKey1 = VK_CONTROL;
+BYTE PasteKey2 = 'V';
+
+void sendPasteCmd();
+
+//-------------------------------------------------
+BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD reason, LPVOID reserved)
+{
+ HANDLE hMapObject = NULL; /* handle to file mapping */
+ BOOL fInit, fIgnore;
+// ThreadData *pThread;
+ switch (reason) {
+ case DLL_PROCESS_ATTACH:
+
+ /* Create a named file mapping object */
+ MyInstance = hModule;
+ hMapObject = CreateFileMapping(
+ (HANDLE) 0xFFFFFFFF, /* use paging file */
+ NULL, /* no security attr. */
+ PAGE_READWRITE, /* read/write access */
+ 0, /* size: high 32-bits */
+ sizeof(SharedMem), /* size: low 32-bits */
+ _TEXT("UniKeyHookSharedMem3.65 Release"));/* name of map
object */
+ if (hMapObject == NULL)
+ return FALSE;
+
+ fInit = (GetLastError() != ERROR_ALREADY_EXISTS);
+ /* Get a pointer to the file-mapped shared memory. */
+
+ pShMem = (SharedMem *) MapViewOfFile(
+ hMapObject, /* object to map view of */
+ FILE_MAP_WRITE, /* read/write access */
+ 0, /* high offset: map from */
+ 0, /* low offset: beginning */
+ 0); /* default: map entire file */
+ if (pShMem == NULL)
+ return FALSE;
+ InitProcess();
+ if (fInit)
+ initDLL();
+// TlsIdx = TlsAlloc();
+// InitThread();
+ break;
+
+ /*
+ * The DLL is detaching from a process due to
+ * process termination or a call to FreeLibrary.
+ */
+/*
+ case DLL_THREAD_ATTACH:
+ InitThread();
+ break;
+ case DLL_THREAD_DETACH:
+ pThread = (ThreadData *)TlsGetValue(TlsIdx);
+ if (pThread != NULL)
+ delete pThread;
+ break;
+*/
+ case DLL_PROCESS_DETACH:
+
+ /* Unmap shared memory from the process's address space. */
+
+ fIgnore = UnmapViewOfFile(pShMem);
+
+ /* Close the process's handle to the file-mapping object. */
+
+ fIgnore = CloseHandle(hMapObject);
+// TlsFree(TlsIdx);
+ break;
+
+ default:
+ break;
+
+ }
+
+ return TRUE;
+ UNREFERENCED_PARAMETER(hModule);
+ UNREFERENCED_PARAMETER(reserved);
+
+}
+
+/*
+void InitThread()
+{
+ ThreadData *pThread;
+ pThread = new ThreadData();
+ memset(pThread, 0, sizeof(ThreadData));
+ TlsSetValue(TlsIdx, pThread);
+}
+*/
+
+//-------------------------------------------------
+void InitProcess()
+{
+ BackTracks = 0;
+ VnKbd.setCodeTable(&pShMem->codeTable);
+ VK_BACK_SCAN = MapVirtualKey(VK_BACK, 0);
+ VK_PAUSE_SCAN = MapVirtualKey(VK_PAUSE, 0);
+ VK_CONTROL_SCAN = MapVirtualKey(VK_CONTROL, 0);
+// detectPasteShortcut();
+ UsKeyboardLayout = LoadKeyboardLayout(US_KEYBOARD_LAYOUT, KLF_REPLACELANG
| KLF_SUBSTITUTE_OK);
+ ViKeyboardLayout = LoadKeyboardLayout(VI_KEYBOARD_LAYOUT, KLF_REPLACELANG
| KLF_SUBSTITUTE_OK);
+ OriginalLayout = GetKeyboardLayout(0);
+ LayoutChangeForced = 0;
+}
+
+//-------------------------------------------------
+LRESULT CALLBACK MyKeyHook(int code, WPARAM wParam, LPARAM lParam)
+{
+ int keyType;
+ unsigned short charBuf;
+
+ if (!pShMem->Initialized) return 0;
+ if (code < 0)
+ return CallNextHookEx(pShMem->keyHook,code,wParam,lParam);
+
+ // determine if current window is a console, if so returns
+ TCHAR className[128];
+ className[0] = 0;
+ GetClassName(GetForegroundWindow(), className, 128);
+ if (_tcscmp(className, _T("ConsoleWindowClass")) == 0)
+ return CallNextHookEx(pShMem->keyHook,code,wParam,lParam);
+
+ GetKeyboardState(KeyState);
+ HKL curLayout = GetKeyboardLayout(0);
+
+ if (curLayout != OriginalLayout && curLayout != ViKeyboardLayout)
+ OriginalLayout = curLayout;
+
+ if (CheckSwitchKey(wParam,lParam) || CheckShortcuts(wParam, lParam))
+ return 1;
+
+ if ((pShMem->vietKey || (pShMem->options.macroEnabled &&
pShMem->options.alwaysMacro)) &&
+ code == HC_ACTION && !ClipboardIsEmpty) {
+
+ if (wParam != PasteKey1 && wParam != PasteKey2 && !(lParam &
IsReleased)) {
+ // postpone this key
+ keybd_event(wParam,
+ HIBYTE(LOWORD(lParam)),
+ (lParam & IsExtended)? KEYEVENTF_EXTENDEDKEY : 0,
+ 0);
+ return 1;
+ }
+ if (wParam == PasteKey2 && (lParam & IsReleased)) {
+ ClearClipboard();
+ }
+ }
+
+ if (CheckBack(wParam)) return 1;
+ if ((pShMem->vietKey || (pShMem->options.macroEnabled &&
pShMem->options.alwaysMacro)) &&
+ (code == HC_ACTION) && !(lParam & IsReleased)) {
+// if (CheckBack(wParam)) return 1;
+ if (PuttingBacks) {
+ if (wParam != VK_BACK) {
+ keybd_event(wParam,
+ HIBYTE(LOWORD(lParam)),
+ (lParam & IsExtended)? KEYEVENTF_EXTENDEDKEY : 0,
+ 0);
+ return 1;
+ }
+ return CallNextHookEx(pShMem->keyHook,code,wParam,lParam);
+ }
+
+ if (pShMem->keyMode != WINCP1258_CHARSET && LayoutChangeForced) {
+ ActivateKeyboardLayout(OriginalLayout, 0);
+ LayoutChangeForced = 0;
+ }
+
+ // HKL curLayout = GetKeyboardLayout(0);
+ if (((KeyState[VK_CONTROL] & 0x80) == 0 && (KeyState[VK_MENU] & 0x80) ==
0) ||
+ ( curLayout != UsKeyboardLayout && ClipboardIsEmpty)) {
+ //(pShMem->inMethod == VIQR_INPUT || pShMem->inMethod ==
VIQR_STAR_INPUT) &&
+ int remap = 0;
+ keyType = ToAscii(wParam,UINT(HIWORD(lParam)),KeyState, &charBuf, 0);
+
+ if (keyType == 1 && UsKeyboardLayout && ViKeyboardLayout &&
+ (KeyState[VK_CONTROL] & 0x80) == 0 &&
+ (KeyState[VK_MENU] & 0x80) == 0 &&
+ curLayout == ViKeyboardLayout) {
+ //need to remap
+ unsigned short mappedChar;
+ int res = ToAsciiEx(wParam, UINT(HIWORD(lParam)), KeyState,
&mappedChar, 0, UsKeyboardLayout);
+ if (res == 1 && ((unsigned char)mappedChar) != ((unsigned
char)charBuf)) {
+ charBuf = mappedChar;
+ remap = 1;
+ }
+ }
+
+ if (keyType == 1 || keyType < 0) {
+ unsigned char c = (unsigned char)charBuf;
+ if (wParam >= VK_NUMPAD0 && wParam <= VK_NUMPAD9)
+ VnKbd.putChar(c); // don't process numeric keypad
+ else {
+ VnKbd.process(c);
+ if (VnKbd.backs!=0 || VnKbd.keysPushed!=0) {
+ if (keyType < 0) //dead key, one more back
+ VnKbd.backs++;
+ PushBacks();
+ return 1;
+ }
+ if (remap) {
+ SHORT scanCode = VkKeyScan((unsigned char)charBuf);
+ lParam = (scanCode << 16) + 1;
+ PostMessage(GetFocus(), (pShMem->options.useIME)? WM_IME_CHAR :
WM_CHAR,
+ (unsigned char)charBuf, lParam);
+ return 1;
+ }
+ }
+ }
+ else {
+ if (wParam!=VK_SHIFT && wParam!=VK_INSERT &&
+ wParam != VK_MENU &&
+ wParam != VK_CONTROL &&
+ ClipboardIsEmpty) {
+ ResetBuffer();
+ }
+ }
+ }
+ else {
+ if (wParam != VK_MENU && wParam != VK_CONTROL && ClipboardIsEmpty) {
+ ResetBuffer();
+ }
+ }
+ }
+ else if ((code == HC_ACTION) && !(lParam & IsReleased)) {
+ if (LayoutChangeForced && OriginalLayout &&
+ GetKeyboardLayout(0) == ViKeyboardLayout &&
+ OriginalLayout != ViKeyboardLayout) {
+
+ ActivateKeyboardLayout(OriginalLayout, 0);
+ LayoutChangeForced = 0;
+
+ if (ToAsciiEx(wParam, UINT(HIWORD(lParam)), KeyState, &charBuf, 0,
OriginalLayout) == 1) {
+ SHORT scanCode = VkKeyScan((unsigned char)charBuf);
+ lParam = (scanCode << 16) + 1;
+ PostMessage(GetFocus(), (pShMem->options.useIME)? WM_IME_CHAR :
WM_CHAR,
+ (unsigned char)charBuf, lParam);
+ return 1;
+ }
+ }
+ }
+
+ return CallNextHookEx(pShMem->keyHook,code,wParam,lParam);
+}
+
+/*
+
+LRESULT CALLBACK DummyWindowProc(
+ HWND hwnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+)
+{
+ return TRUE;
+}
+
+//-------------------------------------------------
+int IsReallyWindowUnicode(HWND hWnd)
+{
+ LONG oldProc = SetWindowLongW(hWnd, GWL_WNDPROC, (LONG)DummyWindowProc);
+ int isUnicode = (HIWORD(oldProc) != 0xFFFF);
+ if (isUnicode)
+ SetWindowLongW(hWnd, GWL_WNDPROC, oldProc);
+ else
+ SetWindowLongA(hWnd, GWL_WNDPROC, oldProc);
+ return isUnicode;
+}
+*/
+
+//-------------------------------------------------
+void PushBuffer(HWND wndFocused)
+{
+ SHORT scanCode;
+ WPARAM lParam;
+
+ PostMessage(wndFocused,WM_KEYUP,VK_PAUSE,
+ (LPARAM(VK_PAUSE_SCAN)<<16)+LPARAM(IsReleased)+1);
+ if (pShMem->keyMode == UNICODE_CHARSET && pShMem->codeTable.encoding ==
UNICODE_UCS2) {
+ if (!pShMem->options.useUnicodeClipboard && pShMem->unicodePlatform &&
+ IsWindowUnicode(wndFocused)) {
+ for (int i=0; i<VnKbd.keysPushed; i++) {
+ scanCode = VkKeyScanW(VnKbd.uniPush[i]);
+ lParam = (scanCode << 16) + 1;
+ PostMessageW(wndFocused, (pShMem->options.useIME)? WM_IME_CHAR :
WM_CHAR,
+ VnKbd.uniPush[i], lParam);
+ }
+ }
+ else {
+ OpenClipboard(pShMem->hMainDlg);
+
+ EmptyClipboard();
+
+ VnKbd.uniPush[VnKbd.keysPushed] = 0; // null-terminated
+ VnKbd.ansiPush[VnKbd.keysPushed] = 0;
+ VnKbd.keysPushed++;
+
+ HGLOBAL hBuf = GlobalAlloc(GMEM_MOVEABLE, sizeof(WORD) *
VnKbd.keysPushed);
+ HGLOBAL hBufAnsi = GlobalAlloc(GMEM_MOVEABLE, VnKbd.keysPushed);
+
+ LPVOID pBuf = GlobalLock(hBuf);
+ LPVOID pBufAnsi = GlobalLock(hBufAnsi);
+
+ memcpy(pBuf, VnKbd.uniPush, sizeof(WORD) * VnKbd.keysPushed);
+ memcpy(pBufAnsi, VnKbd.ansiPush, VnKbd.keysPushed);
+ GlobalUnlock(hBuf);
+ GlobalUnlock(hBufAnsi);
+
+ SetClipboardData(CF_UNICODETEXT, hBuf);
+ SetClipboardData(CF_TEXT, hBufAnsi);
+
+ CloseClipboard();
+ sendPasteCmd();
+ ClipboardIsEmpty = 0;
+ }
+ }
+ else if (pShMem->keyMode == DECOMPOSED_UNICODE_CHARSET) {
+ if (pShMem->unicodePlatform && IsWindowUnicode(wndFocused)) {
+ for (int i=0; i<VnKbd.keysPushed; i++) {
+ scanCode = VkKeyScanW(VnKbd.uniPush[i]);
+ lParam = (scanCode << 16) + 1;
+ PostMessageW(wndFocused, (pShMem->options.useIME)? WM_IME_CHAR :
WM_CHAR,
+ VnKbd.uniPush[i],lParam);
+ }
+ }
+ else {
+ if (ViKeyboardLayout != NULL) {
+ ActivateKeyboardLayout(ViKeyboardLayout, 0);
+ LayoutChangeForced = 1;
+ }
+
+ int count = WideCharToMultiByte(1258, 0, VnKbd.uniPush,
VnKbd.keysPushed,
+ (char *)VnKbd.ansiPush, VnKbd.keysPushed,
0, 0);
+ for (int i=0; i<count; i++) {
+ scanCode = VkKeyScan(VnKbd.ansiPush[i]);
+ lParam = (scanCode << 16) + 1;
+ PostMessage(wndFocused, (pShMem->options.useIME)? WM_IME_CHAR :
WM_CHAR,
+ VnKbd.ansiPush[i], lParam);
+ }
+ }
+ }
+ else {
+ if (pShMem->keyMode == WINCP1258_CHARSET && ViKeyboardLayout!=NULL) {
+ ActivateKeyboardLayout(ViKeyboardLayout, 0);
+ LayoutChangeForced = 1;
+ }
+
+ for (int i=0; i<VnKbd.keysPushed; i++) {
+ scanCode = VkKeyScan(VnKbd.ansiPush[i]);
+ lParam = (scanCode << 16) + 1;
+// PostMessage(wndFocused, WM_IME_CHAR, VnKbd.ansiPush[i], lParam);
+ PostMessage(wndFocused, (pShMem->options.useIME)? WM_IME_CHAR : WM_CHAR,
+ VnKbd.ansiPush[i], lParam);
+ }
+ }
+ return;
+}
+
+/*
+//-------------------------------------------------
+// temporarily release shift keys
+// release = 1: release
+// release = 0: change shifts to original state
+//-------------------------------------------------
+void ReleaseShift(int release)
+{
+ static BYTE sh = 0;
+ static BYTE lsh = 0;
+ static BYTE rsh = 0;
+ static int TempReleased = 0;
+
+ if (release) {
+ sh = KeyState[VK_SHIFT];
+ lsh = KeyState[VK_LSHIFT];
+ rsh = KeyState[VK_RSHIFT];
+ KeyState[VK_SHIFT] = 0;
+ KeyState[VK_LSHIFT] = 0;
+ KeyState[VK_RSHIFT] = 0;
+ SetKeyboardState(KeyState);
+ TempReleased = 1;
+ }
+ else if (TempReleased) {
+ TempReleased = 0;
+ KeyState[VK_SHIFT] = sh;
+ KeyState[VK_LSHIFT] = lsh;
+ KeyState[VK_RSHIFT] = rsh;
+ SetKeyboardState(KeyState);
+ }
+}
+*/
+
+//-------------------------------------------------
+// temporarily release control keys (CTRL, ALT, SHIFT)
+// release = 1: release
+// release = 0: change control keys to their original state
+//-------------------------------------------------
+void ReleaseControlKeys(int release)
+{
+ static BYTE ctrl = 0;
+ static BYTE lctrl = 0;
+ static BYTE rctrl = 0;
+
+ static BYTE alt = 0;
+ static BYTE lalt = 0;
+ static BYTE ralt = 0;
+
+ static BYTE sh = 0;
+ static BYTE lsh = 0;
+ static BYTE rsh = 0;
+
+
+ static int TempReleased = 0;
+
+ if (release) {
+ ctrl = KeyState[VK_CONTROL];
+ lctrl = KeyState[VK_LCONTROL];
+ rctrl = KeyState[VK_RCONTROL];
+
+ sh = KeyState[VK_SHIFT];
+ lsh = KeyState[VK_LSHIFT];
+ rsh = KeyState[VK_RSHIFT];
+
+ alt = KeyState[VK_MENU];
+ lalt = KeyState[VK_LMENU];
+ ralt = KeyState[VK_RMENU];
+
+ KeyState[VK_CONTROL] = 0;
+ KeyState[VK_LCONTROL] = 0;
+ KeyState[VK_RCONTROL] = 0;
+
+ KeyState[VK_SHIFT] = 0;
+ KeyState[VK_LSHIFT] = 0;
+ KeyState[VK_RSHIFT] = 0;
+
+ KeyState[VK_MENU] = 0;
+ KeyState[VK_LMENU] = 0;
+ KeyState[VK_RMENU] = 0;
+
+ SetKeyboardState(KeyState);
+ TempReleased = 1;
+ }
+ else if (TempReleased) {
+ TempReleased = 0;
+
+ KeyState[VK_CONTROL] = ctrl;
+ KeyState[VK_LCONTROL] = lctrl;
+ KeyState[VK_RCONTROL] = rctrl;
+
+ KeyState[VK_SHIFT] = sh;
+ KeyState[VK_LSHIFT] = lsh;
+ KeyState[VK_RSHIFT] = rsh;
+
+ KeyState[VK_MENU] = alt;
+ KeyState[VK_LMENU] = lalt;
+ KeyState[VK_RMENU] = ralt;
+
+ SetKeyboardState(KeyState);
+ }
+}
+
+//-------------------------------------------------
+void PushBacks()
+{
+ if (VnKbd.backs == 0) {
+ BackTracks = 0;
+ PushBuffer(GetFocus());
+ }
+ else {
+ PuttingBacks = 1;
+/*
+ if (KeyState[VK_SHIFT] & 0x80)
+ ReleaseShift(1);
+*/
+ if (KeyState[VK_CONTROL] & 0x80 || KeyState[VK_SHIFT] & 0x80 ||
KeyState[VK_MENU] & 0x80)
+ ReleaseControlKeys(1);
+
+ for (int i=0; i<VnKbd.backs; i++) {
+ keybd_event(VK_BACK, VK_BACK_SCAN,0,0);
+ keybd_event(VK_BACK, VK_BACK_SCAN, KEYEVENTF_KEYUP, 0);
+ }
+// keybd_event(VK_PAUSE, VK_PAUSE_SCAN, 0, 0);
+ keybd_event(VK_PAUSE, VK_PAUSE_SCAN, KEYEVENTF_KEYUP, 0);
+ }
+}
+
+//-------------------------------------------------
+int CheckBack(WPARAM wParam)
+{
+ if (wParam == VK_PAUSE && PuttingBacks) {
+ PuttingBacks = 0;
+ //ReleaseShift(0);
+ ReleaseControlKeys(0);
+ PushBuffer(GetFocus());
+ return 1;
+ }
+ return 0;
+}
+
+//-------------------------------------------------
+int CheckSwitchKey(WPARAM wParam, LPARAM lParam)
+{
+ if (!ClipboardIsEmpty)
+ return 0;
+ int ret = 0;
+ // In WinXP CTRL-SHIFT is used to change text alignment. Disable this
functionality
+
+ static int ctrlPressed = 0;
+ static int shiftPressed = 0;
+
+ if (pShMem->winMajorVersion == 5 && pShMem->winMinorVersion == 1) { //
WinXP
+ if ((KeyState[VK_CONTROL] & 0x80) && (KeyState[VK_SHIFT] & 0x80)) {
+ ctrlPressed = 1;
+ shiftPressed = 1;
+ }
+
+ if (ctrlPressed && (lParam & IsReleased) && wParam == VK_CONTROL) {
+ ctrlPressed = 0;
+ ret = 1;
+ }
+
+ if (shiftPressed && (lParam & IsReleased) && wParam == VK_SHIFT) {
+ shiftPressed = 0;
+ ret = 1;
+ }
+ }
+
+ /////////////////
+ //although the goal of this function is to check switch key,
+ //we also check if CTRL is used to reset buffer here (for convenience).
+ if (!(lParam & IsReleased) && wParam == VK_CONTROL &&
+ !(KeyState[VK_MENU] & 0x80)) {
+ PendingReset = 1;
+ }
+
+ //on FR, GER keyboards, AltGr == CTRL+ALT is used for typing accents,
+ // so we should not reset buffer if we see Alt is pressed
+ if (!(lParam & IsReleased) && wParam == VK_MENU)
+ PendingReset = 0;
+
+ if (PendingReset &&
+ (((lParam & IsReleased) && wParam == VK_CONTROL) ||
+ (!(lParam & IsReleased) && wParam != VK_CONTROL)) ) {
+
+ PendingReset = 0;
+ ResetBuffer();
+ }
+ /////////////////
+
+ // Check switch key
+ UINT key1, key2;
+ switch (pShMem->switchKey) {
+ case CTRL_SHIFT_SW:
+ key1 = VK_SHIFT;
+ key2 = VK_CONTROL;
+ break;
+ default:
+ key1 = VK_MENU;
+ key2 = 'Z';
+ break;
+ }
+
+ if (wParam == key1 || wParam == key2) {
+ if (lParam & IsReleased) {
+ if (PendingSwitch) {
+ PendingSwitch = 0;
+ SwitchMode();
+ MessageBeep(MB_ICONASTERISK);
+ return 1;
+ }
+ }
+ else {
+ if ((KeyState[key1] & 0x80) && (KeyState[key2] & 0x80))
+ PendingSwitch = 1;
+ }
+ }
+ else PendingSwitch = 0;
+
+ return ret;
+}
+
+//-------------------------------------------------
+LRESULT CALLBACK MyMouseHook(int code, WPARAM wParam, LPARAM lParam)
+{
+ if (pShMem->Initialized && code == HC_ACTION && wParam == WM_LBUTTONDOWN)
+ ResetBuffer();
+ return CallNextHookEx(pShMem->mouseHook,code,wParam,lParam);
+}
+
+//-------------------------------------------------
+void SwitchMode()
+{
+ if (pShMem->vietKey) pShMem->vietKey = 0;
+ else pShMem->vietKey = 1;
+ if (pShMem->iconShown) ModifyStatusIcon();
+ ResetBuffer();
+/*
+ if (!pShMem->vietKey && UsKeyboardLayout &&
+ ViKeyboardLayout && GetKeyboardLayout(0) == ViKeyboardLayout)
+ ActivateKeyboardLayout(UsKeyboardLayout, 0);
+*/
+}
+
+
+//-------------------------------------------------
+void ModifyStatusIcon()
+{
+ NOTIFYICONDATA tnid;
+
+ tnid.cbSize = sizeof(NOTIFYICONDATA);
+ tnid.hWnd = pShMem->hMainDlg;
+ tnid.uID = ID_VIETKEY_ICON;
+ if (pShMem->vietKey) {
+ tnid.hIcon = pShMem->hVietIcon;
+ lstrcpy(tnid.szTip,_TEXT("Click to turn off Vietnamese mode"));
+
+ } else {
+ tnid.hIcon = pShMem->hEnIcon;
+ lstrcpy(tnid.szTip,_TEXT("Click to turn on Vietnamese mode"));
+ }
+ tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
+ tnid.uCallbackMessage = pShMem->iconMsgId;
+ Shell_NotifyIcon(pShMem->iconShown?NIM_MODIFY:NIM_ADD, &tnid);
+ pShMem->iconShown = 1;
+}
+
+//-------------------------------------------------
+void DeleteStatusIcon()
+{
+ NOTIFYICONDATA tnid;
+ if (pShMem->iconShown) {
+ tnid.cbSize = sizeof(NOTIFYICONDATA);
+ tnid.hWnd = pShMem->hMainDlg;
+ tnid.uID = ID_VIETKEY_ICON;
+ Shell_NotifyIcon(NIM_DELETE, &tnid);
+ pShMem->iconShown = 0;
+ }
+}
+
+//-------------------------------------------------
+int IsVietnamese()
+{
+ return pShMem->vietKey;
+}
+
+//-------------------------------------------------
+void SetKeyMode(WORD mode, int inMethod, CodeInfo *pTable)
+{
+ pShMem->keyMode = mode;
+ pShMem->inMethod = inMethod;
+ pShMem->codeTable = *pTable;
+ ResetBuffer();
+/*
+ if (pShMem->keyMode != WINCP1258_CHARSET &&
+ UsKeyboardLayout && ViKeyboardLayout &&
+ GetKeyboardLayout(0) == ViKeyboardLayout) {
+ ActivateKeyboardLayout(UsKeyboardLayout, 0);
+ MessageBeep(MB_ICONASTERISK);
+ }
+*/
+}
+
+//-------------------------------------------------
+void ClearClipboard()
+{
+ //ReleaseShift(0);
+ ReleaseControlKeys(0);
+ ClipboardIsEmpty = 1;
+}
+
+
+//-------------------------------------------------
+void ResetBuffer()
+{
+ VnKbd.clearBuf();
+ ClearClipboard();
+}
+
+//-------------------------------------------------
+void SetSwitchKey(int swKey)
+{
+ pShMem->switchKey = swKey;
+}
+
+//-------------------------------------------------
+void SetInputMethod(int method, DWORD *DT)
+{
+ pShMem->inMethod = method;
+ memcpy(pShMem->codeTable.DT, DT, sizeof(pShMem->codeTable.DT));
+ ResetBuffer();
+}
+
+
+//-------------------------------------------------
+HINSTANCE GetVietHookDll()
+{
+ return MyInstance;
+}
+
+//-------------------------------------------------
+int CheckShortcuts(WPARAM wParam, LPARAM lParam)
+{
+ if (!ClipboardIsEmpty)
+ return 0;
+
+ int ctrlPressed = KeyState[VK_CONTROL] & 0x80;
+ int shiftPressed = KeyState[VK_SHIFT] & 0x80;
+
+
+ UINT msg = 0;
+ WPARAM wNotify = 0;
+ LPARAM lNotify = 0;
+ static int shortcutActivated = 0;
+
+ if (!(lParam & IsReleased) && ctrlPressed && shiftPressed) {
+ switch (wParam) {
+ case VK_F5:
+ msg = WM_HOOK_PANEL_SHORTCUT;
+ break;
+ case VK_F6:
+ msg = WM_HOOK_TOOLKIT_SHORTCUT;
+ break;
+ case VK_F1:
+ // first charset, Unicode
+ msg = WM_HOOK_CHANGE_CHARSET;
+ wNotify = 0;
+ break;
+ case VK_F2:
+ // second charset, TCVN3
+ msg = WM_HOOK_CHANGE_CHARSET;
+ wNotify = 1;
+ break;
+ case VK_F3:
+ // second charset, TCVN3
+ msg = WM_HOOK_CHANGE_CHARSET;
+ wNotify = 2;
+ break;
+ case VK_F4:
+ // second charset, TCVN3
+ msg = WM_HOOK_CHANGE_CHARSET;
+ wNotify = 3;
+ break;
+ case VK_F9: // Steal VK_F9, and the release of it will be processed.later
+ return 1;
+ }
+
+ if (msg != 0) {
+ if (msg == WM_HOOK_PANEL_SHORTCUT || msg == WM_HOOK_TOOLKIT_SHORTCUT) {
+ BringWindowToTop(pShMem->hMainDlg);
+ SetForegroundWindow(pShMem->hMainDlg);
+ }
+ else {
+ MessageBeep(MB_ICONASTERISK);
+ }
+ PostMessage(pShMem->hMainDlg, msg, wNotify, lNotify);
+ shortcutActivated = 1;
+ return 1;
+ }
+ return 0;
+ }
+
+ if (lParam & IsReleased) {
+ if (shortcutActivated &&
+ (wParam == VK_F1 || wParam == VK_F2 || wParam == VK_F3 || wParam ==
VK_F4)) {
+ shortcutActivated = 0;
+ return 1;
+ }
+
+ if (ctrlPressed && shiftPressed) {
+ switch (wParam) {
+ case VK_F9:
+ msg = WM_HOOK_FLY_CONVERT;
+ break;
+ }
+ if (msg != 0) {
+ SendMessage(pShMem->hMainDlg, msg, wNotify, lNotify);
+ MessageBeep(MB_ICONASTERISK);
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+/*
+HMODULE hUnicows = NULL;
+
+HMODULE LoadUnicowsProc(void)
+{
+ OSVERSIONINFO osinfo;
+ osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&osinfo);
+
+ if (hUnicows == NULL && osinfo.dwMajorVersion<5)
+ hUnicows = LoadLibraryA("c:\\tools\\unikey\\test\\unicows.dll");
+ return hUnicows;
+}
+
+void UnloadUnicowsProc()
+{
+ if (hUnicows != NULL)
+ FreeLibrary(hUnicows);
+}
+
+*/
+
+//-------------------------------------------------
+SharedMem *GetSharedMem()
+{
+ return pShMem;
+}
+
+//-------------------------------------------------
+void initDLL()
+{
+ pShMem->Initialized = 0;
+ // check unicode platform
+ OSVERSIONINFO osinfo;
+ osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&osinfo);
+ pShMem->unicodePlatform = (osinfo.dwMajorVersion > 4 ||
+ (osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
osinfo.dwMajorVersion ==4));
+ pShMem->winMajorVersion = osinfo.dwMajorVersion;
+ pShMem->winMinorVersion = osinfo.dwMinorVersion;
+}
+
+
+//-------------------------------------------------
+void sendPasteCmd()
+{
+ if (PasteShortcut == SHIFT_INSERT_KEY) {
+ //generate SHIFT+INSERT key strokes
+ keybd_event(VK_SHIFT, 0, 0, 0);
+ keybd_event(VK_INSERT, 0, KEYEVENTF_EXTENDEDKEY, 0);
+ keybd_event(VK_INSERT, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
+
+ if ((KeyState[VK_SHIFT] & 0x80) == 0 || (KeyState[VK_RSHIFT] & 0x80) !=
0)
+ keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
+ }
+ else {
+ //generate CTRL+V key strokes
+ //if (KeyState[VK_SHIFT] & 0x80)
+ // ReleaseShift(1);
+ if (KeyState[VK_CONTROL] & 0x80 || KeyState[VK_SHIFT] & 0x80 ||
KeyState[VK_MENU] & 0x80)
+ ReleaseControlKeys(1);
+
+ keybd_event(VK_CONTROL, 0, 0, 0);
+ keybd_event('V', 0, 0, 0);
+ keybd_event('V', 0, KEYEVENTF_KEYUP, 0);
+ keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
+ }
+}
+
+/*
+//-------------------------------------------------
+void detectPasteShortcut()
+{
+ TCHAR fileName[_MAX_PATH];
+ PasteShortcut = SHIFT_INSERT_KEY;
+ PasteKey1 = VK_SHIFT;
+ PasteKey2 = VK_INSERT;
+
+ if (!GetModuleFileName(NULL, fileName, sizeof(fileName)/sizeof(TCHAR)))
+ return;
+ int i = 0;
+ TCHAR *backSlash = NULL;
+ TCHAR *p = fileName;
+ while (*p) {
+ if (*p == '\\')
+ backSlash = p;
+ p++;
+ }
+ if (!backSlash)
+ return;
+
+ backSlash++;
+ _tcsupr(backSlash);
+ for (i=0; i<ProgCtrlVCount && _tcscmp(backSlash, ProgNeedCtrlV[i])!=0;
i++);
+ if (i < ProgCtrlVCount) {
+ PasteShortcut = CTRL_V_KEY;
+ PasteKey1 = VK_CONTROL;
+ PasteKey2 = 'V';
+ }
+ return;
+}
+
+*/
***The diff for this file has been truncated for email.***
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/keyhook/keyhook.def
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,34 @@
+;------------------------------------------------------------------------------
+; UniKey - Vietnamese Keyboard for Windows
+; Copyright (C) 1998-2002 Pham Kim Long
+; Contact: lo...@cslab.felk.cvut.cz
+;
+; This program is free software; you can redistribute it and/or
+; modify it under the terms of the GNU General Public License
+; as published by the Free Software Foundation; either version 2
+; of the License, or (at your option) any later version.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program; if not, write to the Free Software
+; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
+;--------------------------------------------------------------------------------
+LIBRARY UKHook35
+EXPORTS
+ MyKeyHook @1
+; InitSharedMem @2
+ MyMouseHook @3
+ SwitchMode @4
+ ModifyStatusIcon @05
+ DeleteStatusIcon @06
+ IsVietnamese @07
+ SetKeyMode @08
+ SetSwitchKey @09
+ SetInputMethod @10
+ GetVietHookDll @11
+ GetSharedMem @12
+; SetKeyOptions
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/keyhook/keyhook.h
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,111 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#ifndef _KEYHOOK_H
+#define _KEYHOOK_H 1
+#include <windows.h>
+#include "keycons.h"
+
+struct CodeInfo {
+ DWORD DT[256];
+ unsigned char BD[12][6];
+ unsigned char BK[8];
+ unsigned char BW[6];
+ unsigned char BT[6];
+ WORD ToUniH[256];
+ WORD ToUniL[256];
+ int multiBytes; // 2 bytes charset (Unicode, VNI, ....)
+ int encoding; //UCS-2, UTF-8, Reference
+ int singleBackspace;
+// unsigned char remapLayout[256]; //used to remap Vietnamese layout to US
layout
+};
+
+#define CTRL_SHIFT_SW 0
+#define ALT_Z_SW 1
+
+struct KeyboardOptions
+{
+ int freeMarking;
+ int toneNextToVowel;
+ int modernStyle;
+ int macroEnabled;
+ int useUnicodeClipboard;
+ int alwaysMacro;
+ int useIME;
+};
+
+struct HookMacroDef
+{
+ int keyOffset;
+ int textOffset;
+};
+
+struct SharedMem {
+ //states
+ int Initialized;
+ int vietKey;
+ int iconShown;
+ int switchKey;
+
+ KeyboardOptions options;
+
+ WORD keyMode;
+ int inMethod;
+ CodeInfo codeTable;
+
+ // system
+ HHOOK keyHook,mouseHook;
+ HWND hMainDlg;
+ UINT iconMsgId;
+ HICON hVietIcon,hEnIcon;
+ int unicodePlatform;
+ DWORD winMajorVersion, winMinorVersion;
+
+ // macro table
+// MacroDef macroTable[MAX_MACRO_ITEMS];
+ HookMacroDef macroTable[MAX_MACRO_ITEMS];
+ char macroMem[MACRO_MEM_SIZE];
+ int macroCount;
+};
+
+//----------------------------------------------------------------
+// Interface functions
+LRESULT CALLBACK MyKeyHook(int code, WPARAM wParam, LPARAM lParam);
+LRESULT CALLBACK MyMouseHook(int code, WPARAM wParam, LPARAM lParam);
+HINSTANCE GetVietHookDll();
+
+void SwitchMode();
+void ModifyStatusIcon();
+void DeleteStatusIcon();
+
+int IsVietnamese();
+//void InitSharedMem(SharedMem *pPara);
+void SetInputMethod(int method, DWORD *DT);
+void SetKeyMode(WORD mode, int inMethod, CodeInfo *pTable);
+void SetSwitchKey(int swKey);
+//void SetKeyOptions(int freeMarking, int toneNextToVowel, int
modernStyle);
+
+SharedMem *GetSharedMem();
+
+#define WM_HOOK_TOOLKIT_SHORTCUT (WM_USER+102)
+#define WM_HOOK_PANEL_SHORTCUT (WM_USER+103)
+#define WM_HOOK_FLY_CONVERT (WM_USER+104)
+#define WM_HOOK_CHANGE_CHARSET (WM_USER+105)
+
+#endif
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/keyhook/preHdr.h
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,27 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#ifndef __KEYHOOK_PRECOMPILED_HEADER_H
+#define __KEYHOOK_PRECOMPILED_HEADER_H
+
+#include <windows.h>
+#include <winuser.h>
+#include <tchar.h>
+
+#endif
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/keyhook/prehdr.cpp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,23 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+
+#include "prehdr.h"
+
+//This file is used for precompiling header files.
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/keyhook/vietkey.cpp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,1108 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#include "prehdr.h"
+#include <ctype.h>
+#include "keycons.h"
+#include "keyhook.h"
+#include "vietkey.h"
+
+// key category constants
+#define BACK_CHAR 8
+#define ENTER_CHAR 13
+
+#define BREVE_MARK 1 // for marks: ( in "a(", and also "+" in u+, o+
+#define TONE_MARK 2 // tone marks, eg. a', a`,...
+#define DOUBLE_KEY 3
+#define SHORT_KEY 4
+#define VOWEL_CHAR 5
+#define SEPARATOR_KEY 6
+#define VNI_DOUBLE_CHAR_MARK 7 // in VNI method
+#define ESCAPE_KEY 8
+#define SOFT_SEPARATOR_KEY 9
+
+#define VNI_CIRCUMFLEX_INDEX 1
+#define VNI_HORN_INDEX 2
+#define VNI_BREVE_INDEX 3
+#define VNI_D_INDEX 4
+
+#define MAX_AFTER_VOWEL 2 // the max number of characters after a vowels
+#define MAX_VOWEL_SQUENCE 3
+#define MAX_MODIFY_LENGTH 6
+
+extern SharedMem *pShMem;
+extern unsigned char KeyState[256];
+
+// for processing in VIQR mode
+unsigned char VIQRsym[] = {'\'','`','?','~','.','^','(','+'};
+//unsigned char ShortcutReverse[] = {'o', 'u', 'u', 'U'}; // We have 4
shortcuts: [,],w,W (see tcvn.cpp)
+/////
+unsigned char DoubleReverse[] = {'d','D','e','E','a','A','o','O'};
+unsigned char WReverse[] = {'a','A','o','O','u','U'};
+
+//------------------------------------
+// Unicode composite information
+//------------------------------------
+// composite bases that are greater than FF
+// 0: A( 0x102
+// 1: a( 0x103
+// 2: O+ 0x1A0
+// 3: o+ 0x1A1
+// 4: U+ 0x1AF
+// 5: u+ 0x1B0
+// 6: DD 0x110
+// 7: dd 0x111
+//
+// Use high byte as the index to the tone table below:
+// 1: '
+// 2: `
+// 3: ?
+// 4: ~
+// 5: .
+WORD UnicodeCompBigBase[] = {0x102, 0x103, 0x1A0, 0x1A1, 0x1AF, 0x1B0,
0x110, 0x111};
+WORD UnicodeCompTone[] = {0x301, 0x300, 0x309, 0x303, 0x323};
+
+//-----------------------------------------------
+int uniCharLen(WORD ch, int encoding)
+{
+ if (encoding == UNICODE_UTF8)
+ return (ch < 0x0080)? 1 : ((ch < 0x0800)? 2 : 3);
+ if (encoding == UNICODE_REF)
+ return (ch < 128)? 1 : ((ch < 1000)? 6 : ((ch < 10000)? 7 : 8));
+ if (encoding == UNICODE_HEX)
+ return (ch < 256)? 1 : ((ch < 0x1000)? 7 : 8);
+ if (encoding == UNICODE_CSTRING) {
+ if (ch > 0x00FF && ch < 0x1000)
+ return 5;
+ if (ch >= 0x1000)
+ return 6;
+ if (isxdigit(ch))
+ return 4;
+ return 1;
+ }
+// return (ch < 128)? 1 : ((ch < 0x100)? 6 : ((ch < 0x1000)? 7 : 8));
+ return 2;
+}
+
+VietKey::VietKey() {
+ keys = 0;
+ DT = 0;
+ BD = 0;
+ BK = 0;
+ BW = 0;
+ BT = 0;
+ lastWConverted = 0;
+ lastIsEscape = 0;
+ tempVietOff = 0;
+}
+
+unsigned char ChangedChar, OldChar;
+
+//-----------------------------------------------
+// puts char into buffer without processing it
+//-----------------------------------------------
+void VietKey::putChar(unsigned char ch, int isLowerCase)
+{
+ if (keys==KEY_BUFSIZE)
+ throwBuf();
+ lowerCase[keys] = isLowerCase; //(OldChar);
+ buf[keys] = ch;
+ keys++;
+}
+
+//-----------------------------------------------
+void VietKey::process(unsigned char c)
+{
+ int kieu;
+
+ keysPushed = 0;
+ backs = 0;
+ OldChar = c;
+ int thisWConverted = 0;
+
+
+ if (pShMem->codeTable.multiBytes)
+ c = tolower(c);
+
+
+ kieu = keyCategory(c);
+
+ if (!pShMem->vietKey && pShMem->options.alwaysMacro) {
+ //vietnamese is off, but macro is enabled
+ if (pShMem->options.macroEnabled &&
+ ((kieu == SOFT_SEPARATOR_KEY && ATTR_IS_WORD_STOP(DT[c])) || c ==
ENTER_CHAR)) {
+ if (checkMacro(OldChar))
+ return;
+ }
+ if (kieu == SEPARATOR_KEY) {
+ if (c == BACK_CHAR)
+ processBackspace();
+ else
+ clearBuf();
+ }
+ else putChar(c, islower(OldChar));
+
+ return;
+ }
+
+
+ if (lastIsEscape && keys > 0 && kieu != SEPARATOR_KEY && kieu !=
SOFT_SEPARATOR_KEY) {
+ backs = 1;
+ ChangedChar = buf[keys-1];
+ buf[keys-1] = c;
+ lowerCase[keys-1] = islower(OldChar);
+ ansiPush[keysPushed++] = c;
+ postProcess();
+ lastIsEscape = 0;
+ lastWConverted = 0;
+ return;
+ }
+ lastIsEscape = 0;
+
+ if (pShMem->options.macroEnabled &&
+ ((kieu == SOFT_SEPARATOR_KEY && ATTR_IS_WORD_STOP(DT[c])) || c ==
ENTER_CHAR)) {
+ if (checkMacro(OldChar))
+ return;
+ }
+
+ if (tempVietOff) {
+ if (!isalpha(c))
+ tempVietOff = 0;
+ if (kieu == SEPARATOR_KEY) {
+ if (c == BACK_CHAR)
+ processBackspace();
+ else
+ clearBuf();
+ }
+ else putChar(c, islower(OldChar));
+ lastWConverted = 0;
+ return;
+ }
+
+ switch(kieu){
+ case BREVE_MARK:
+ if (pShMem->inMethod == TELEX_INPUT && lastWConverted && (c == 'w' || c
== 'W'))
+ shortKey(c);
+ else {
+ putBreveMark(c);
+ if (pShMem->inMethod == TELEX_INPUT && keysPushed == 0 && backs == 0 &&
(c == 'w' || c == 'W')) {
+ shortKey(c); // Special case for W key in TELEX mode.
+ thisWConverted = 1;
+ }
+ }
+ break;
+ case DOUBLE_KEY:
+ doubleChar(c);
+ break;
+ case TONE_MARK:
+ putToneMark(c);
+ break;
+ case SHORT_KEY:
+ shortKey(c);
+ break;
+ case VNI_DOUBLE_CHAR_MARK:
+ vniDoubleCharMark(c);
+ break;
+ case ESCAPE_KEY:
+ lastIsEscape = 1;
+ break;
+ case SEPARATOR_KEY:
+ if (c == BACK_CHAR)
+ processBackspace();
+ else
+ clearBuf();
+
+ lastWConverted = 0;
+ return;
+ /*
+ case SOFT_SEPARATOR_KEY:
+ if (pShMem->options.macroEnabled) {
+ if (checkMacro(OldChar))
+ return;
+ }
+ break;
+ */
+ }
+ lastWConverted = thisWConverted;
+
+ if (keysPushed==0 && backs==0) {
+ if (pShMem->inMethod != VIQR_INPUT &&
+ pShMem->keyMode == VIQR_CHARSET &&
+ checkEscapeVIQR(OldChar))
+ return;
+ putChar(c, islower(OldChar));
+ }
+
+ if (keysPushed == 0) {
+ if (backs == 0 && pShMem->keyMode== UNICODE_CHARSET &&
+ pShMem->codeTable.encoding==UNICODE_CSTRING) {
+ keysPushed = 1;
+ ansiPush[0] = c;
+ }
+ else return;
+ }
+
+ if (keys < keysPushed && pShMem->codeTable.multiBytes) {
+ keysPushed = 0;
+ backs = 0;
+ return;
+ }
+
+ postProcess();
+}
+
+static unsigned char tempPush[KEY_BUFSIZE*8];
+
+void VietKey::processBackspace()
+{
+ if (keys <= 0)
+ return;
+
+ unsigned char t;
+ WORD mapping;
+
+ backs = 1;
+ if (pShMem->keyMode == VIQR_CHARSET) {
+ mapping = lowerCase[keys-1]? ToUniL[buf[keys-1]] : ToUniH[buf[keys-1]];
+ if (HIBYTE(mapping))
+ backs++;
+ t = LOBYTE(mapping);
+ mapping = lowerCase[keys-1]? ToUniL[t] : ToUniH[t];
+ if (HIBYTE(mapping))
+ backs++;
+ }
+ else if (pShMem->keyMode == UNICODE_CHARSET){
+ if (!pShMem->codeTable.singleBackspace) {
+ mapping = (lowerCase[keys-1])? ToUniL[buf[keys-1]] :
ToUniH[buf[keys-1]];
+ if (pShMem->codeTable.encoding != UNICODE_UCS2)
+ backs += uniCharLen(mapping, pShMem->codeTable.encoding) - 1;
+ }
+ }
+ else if (pShMem->codeTable.multiBytes) {
+ mapping = (lowerCase[keys-1])? ToUniL[buf[keys-1]] : ToUniH[buf[keys-1]];
+ if (HIBYTE(mapping))
+ backs++;
+ }
+ keys--;
+}
+
+//-------------------------------------
+void VietKey::postProcess()
+{
+ unsigned char t;
+ int i, j, k;
+ WORD mapping, map2;
+
+ if (pShMem->keyMode == UNICODE_CHARSET) {
+ if (pShMem->codeTable.encoding == UNICODE_UCS2) {
+ for (i = 0, j = keys-keysPushed; i < keysPushed; i++, j++)
+ uniPush[i] = (lowerCase[j]) ? ToUniL[ansiPush[i]] :
ToUniH[ansiPush[i]];
+ }
+ else
+ encodeUnicode(pShMem->codeTable.encoding);
+ return;
+ }
+
+ if (pShMem->keyMode == VIQR_CHARSET) {
+ memcpy(tempPush, ansiPush, keysPushed);
+ for (i = k = 0, j=keys-keysPushed; i<keysPushed; i++, j++) {
+ mapping = lowerCase[j]? ToUniL[tempPush[i]] : ToUniH[tempPush[i]];
+ t = LOBYTE(mapping);
+ map2 = lowerCase[j]? ToUniL[t] : ToUniH[t];
+ ansiPush[k++] = LOBYTE(map2);
+ if (HIBYTE(map2)) {
+ ansiPush[k++] = HIBYTE(map2);
+ if (backs > 0 && i > 0)
+ backs++;
+ }
+ if (HIBYTE(mapping)) {
+ ansiPush[k++] = HIBYTE(mapping);
+ if (backs > 0 && i > 0) // if backs was already = 0, we never have to
push any more back
+ backs++;
+ }
+ }
+ // determine the number of backs
+ if (backs > 0) {
+ // check the changed char
+ mapping = lowerCase[keys-keysPushed]? ToUniL[ChangedChar] :
ToUniH[ChangedChar];
+ if (HIBYTE(mapping))
+ backs++;
+ t = LOBYTE(mapping);
+ mapping = lowerCase[keys-keysPushed]? ToUniL[t] : ToUniH[t];
+ if (HIBYTE(mapping))
+ backs++;
+ }
+ keysPushed = k;
+ return;
+ }
+
+ if (pShMem->keyMode == DECOMPOSED_UNICODE_CHARSET) {
+ WORD base, tone;
+ for (i = k = 0, j=keys-keysPushed; i<keysPushed; i++, j++) {
+ mapping = lowerCase[j]? ToUniL[ansiPush[i]] : ToUniH[ansiPush[i]];
+ base = LOBYTE(mapping);
+ if (base < 0x20)
+ base = UnicodeCompBigBase[base];
+ uniPush[k++] = base;
+
+ tone = HIBYTE(mapping);
+ if (tone > 0) {
+ uniPush[k++] = UnicodeCompTone[tone-1];
+ if (backs > 0 && i > 0) // if backs was already = 0, we never have to
push any more back
+ backs++;
+ }
+ }
+
+ // determine the number of backs
+ if (backs > 0) {
+ mapping = lowerCase[keys-keysPushed]? ToUniL[ChangedChar] :
ToUniH[ChangedChar];
+ if (HIBYTE(mapping))
+ backs++;
+ }
+ keysPushed = k;
+ return;
+ }
+
+ if (pShMem->codeTable.multiBytes) {
+ memcpy(tempPush, ansiPush, keysPushed);
+ for (i = k = 0, j=keys-keysPushed; i<keysPushed; i++, j++) {
+ mapping = lowerCase[j]? ToUniL[tempPush[i]] : ToUniH[tempPush[i]];
+ ansiPush[k++] = LOBYTE(mapping);
+ if (HIBYTE(mapping)) {
+ ansiPush[k++] = HIBYTE(mapping);
+ if (backs > 0 && i > 0) // if backs was already = 0, we never have to
push any more back
+ backs++;
+ }
+ }
+ // determine the number of backs
+ if (backs > 0) {
+ mapping = lowerCase[keys-keysPushed]? ToUniL[ChangedChar] :
ToUniH[ChangedChar];
+ if (HIBYTE(mapping))
+ backs++;
+ }
+ keysPushed = k;
+ return;
+ }
+}
+
+//-------------------------------------
+void VietKey::clearBuf()
+{
+ keys = 0;
+ lastWConverted = 0;
+ lastIsEscape = 0;
+ tempVietOff = 0;
+}
+
+
+//--------------------------------
+int VietKey::keyCategory(unsigned char c)
+{
+ long index, attr;
+ attr = DT[c];
+
+ if (ATTR_IS_BREVE(attr) > 0)
+ return BREVE_MARK;
+
+ if (ATTR_TONE_INDEX(attr) > 0)
+ return TONE_MARK;
+
+ index = ATTR_DBCHAR_INDEX(attr);
+ if (pShMem->inMethod == TELEX_INPUT && index > 0 && index < 9)
+ return DOUBLE_KEY;
+ if (pShMem->inMethod != TELEX_INPUT && ATTR_VNI_DOUBLE_INDEX(attr) > 0)
+ return VNI_DOUBLE_CHAR_MARK;
+
+ if (ATTR_MACRO_INDEX(attr) > 0)
+ return SHORT_KEY;
+
+ if (ATTR_IS_SEPARATOR(attr) > 0)
+ return SEPARATOR_KEY;
+
+ if ((pShMem->inMethod == VIQR_INPUT || pShMem->inMethod ==
VIQR_STAR_INPUT) && c == '\\')
+ return ESCAPE_KEY;
+
+ if (ATTR_IS_SOFT_SEPARATOR(attr))
+ return SOFT_SEPARATOR_KEY;
+ return 0;
+}
+
+//--------------------------------
+void VietKey::putBreveMark(unsigned char c)
+{
+ int i, k;
+ long attr;
+ unsigned char t, newChar;
+ int leftMost;
+
+ int index, index_c, toneIndex = 0;
+ // determine the position to drop the breve mark
+ i = keys-1;
+ if (pShMem->inMethod != TELEX_INPUT)
+ index_c = ATTR_VNI_DOUBLE_INDEX(DT[c]);
+ leftMost = pShMem->options.freeMarking ? 0 : keys-1;
+ leftMost = max(leftMost, keys - MAX_MODIFY_LENGTH);
+
+ while (i >= leftMost) {
+ attr = DT[buf[i]];
+ toneIndex = ATTR_CURRENT_TONE(DT[buf[i]]);
+ if (toneIndex == 0 || toneIndex == 6)
+ index = ATTR_DBCHAR_INDEX(attr);
+ else
+ index = ATTR_DBCHAR_INDEX(DT[BD[ATTR_VOWEL_INDEX(attr)-1][5]]);
+ if (index > 4) { // from 11 are the indexes of VNI double-charater marks
+ if (pShMem->inMethod != TELEX_INPUT) {
+ if ((index_c == VNI_HORN_INDEX && index > 6) ||
+ (index_c == VNI_BREVE_INDEX && index <= 6))
+ break;
+ }
+ else
+ break;
+ }
+ else if (ATTR_IS_SEPARATOR(attr) || ATTR_IS_SOFT_SEPARATOR(attr))
+ break;
+ i--;
+ }
+ if (i < leftMost || (index <= 4))
+ return;
+
+ if (pShMem->options.freeMarking && i > 0) {
+ unsigned char prevChar;
+ int tmpIdx;
+ if (ATTR_VOWEL_INDEX(DT[prevChar = buf[i-1]]) > 0)
+ prevChar = BD[ATTR_VOWEL_INDEX(DT[prevChar])-1][5];
+
+ tmpIdx = ATTR_DBCHAR_INDEX(DT[prevChar]);
+ if (tmpIdx > 4)
+ prevChar = WReverse[tmpIdx-4-1];
+ if ((prevChar == 'o' || prevChar == 'O' || prevChar == 'u' || prevChar
== 'U') &&
+ (buf[i] == 'u' || buf[i] == 'U')) {
+ i--;
+ toneIndex = ATTR_CURRENT_TONE(DT[buf[i]]);
+ }
+
+ if (i > 0) {
+ if (ATTR_VOWEL_INDEX(DT[prevChar = buf[i-1]]) > 0)
+ prevChar = BD[ATTR_VOWEL_INDEX(DT[prevChar])-1][5];
+ if ((prevChar == 'U' || prevChar == 'u') &&
+ (i == 1 || (i > 1 && buf[i-2] != 'q' && buf[i-2] != 'Q'))) {
+ t = buf[i];
+ if (ATTR_VOWEL_INDEX(DT[t]) > 0)
+ t = BD[ATTR_VOWEL_INDEX(DT[t])-1][5];
+ tmpIdx = ATTR_DBCHAR_INDEX(DT[t]) - 4;
+ t = toupper(t);
+ if ((t == 'A' && pShMem->inMethod == TELEX_INPUT) ||
+ ((t == 'O' || WReverse[tmpIdx-1] == 'o' || WReverse[tmpIdx-1] == 'O')
&& i != keys-1)) {
+ i--;
+ toneIndex = ATTR_CURRENT_TONE(DT[buf[i]]);
+ }
+ }
+ }
+ }
+
+ if (toneIndex == 0 || toneIndex == 6) {
+ index = ATTR_DBCHAR_INDEX(DT[buf[i]]) - 4;
+ newChar = BW[index - 1];
+ }
+ else {
+ index = ATTR_DBCHAR_INDEX(DT[BD[ATTR_VOWEL_INDEX(DT[buf[i]])-1][5]]) - 4;
+ newChar = BD[ATTR_VOWEL_INDEX(DT[BW[index-1]])-1][toneIndex-1];
+ }
+ if (newChar != buf[i]) {
+ if (pShMem->keyMode == VIQR_CHARSET) {
+ if ((buf[i]=='a' && c==VIQRsym[7]) || (buf[i] != 'a' && c ==
VIQRsym[6]))
+ return;
+ }
+ backs = keys - i;
+ ChangedChar = buf[i];
+ ansiPush[keysPushed++] = buf[i] = newChar;
+ for (k = i+1; k < keys; k++)
+ ansiPush[keysPushed++] = buf[k];
+ }
+ else {
+ // duplicate, convert back to english
+ backs = keys - i;
+ ChangedChar = buf[i];
+ if (toneIndex == 0 || toneIndex == 6)
+ ansiPush[keysPushed++] = buf[i] = WReverse[index-1];
+ else
+ ansiPush[keysPushed++] = buf[i] =
BD[ATTR_VOWEL_INDEX(DT[WReverse[index-1]])-1][toneIndex-1];
+ for (k = i+1; k < keys; k++)
+ ansiPush[keysPushed++] = buf[k];
+ putChar(c, islower(OldChar));
+ ansiPush[keysPushed++] = c;
+ tempVietOff = 1;
+ }
+}
+
+//--------------------------------
+void VietKey::doubleChar(unsigned char c)
+{
+ int i, k, leftMost;
+ long attr;
+ unsigned char newChar;
+
+ int index, index_c, toneIndex = 0;
+ // determine the position to drop the cirumflex mark
+ i = keys-1;
+ if (pShMem->inMethod != TELEX_INPUT)
+ index_c = ATTR_VNI_DOUBLE_INDEX(DT[c]);
+ else
+ index_c = ATTR_DBCHAR_INDEX(DT[c]);
+ leftMost = pShMem->options.freeMarking ? 0 : keys -1;
+ leftMost = max(leftMost, keys - MAX_MODIFY_LENGTH);
+
+ while (i >= leftMost) {
+ attr = DT[buf[i]];
+ toneIndex = ATTR_CURRENT_TONE(DT[buf[i]]);
+ if (toneIndex == 0 || toneIndex == 6)
+ index = ATTR_DBCHAR_INDEX(attr);
+ else
+ index = ATTR_DBCHAR_INDEX(DT[BD[ATTR_VOWEL_INDEX(attr)-1][5]]);
+ if (index > 0 && index < 9) {
+ if (pShMem->keyMode == VIQR_CHARSET && c == VIQRsym[5])
+ break;
+ if (pShMem->inMethod != TELEX_INPUT) {
+ if ( (index_c == VNI_CIRCUMFLEX_INDEX && index > 2) ||
+ (index_c == VNI_D_INDEX && index <= 2) )
+ break;
+ }
+ else if (index == index_c)
+ break;
+ }
+ else if (ATTR_IS_SEPARATOR(attr) || ATTR_IS_SOFT_SEPARATOR(attr)) {
+ break;
+ }
+ i--;
+ }
+ if (i < leftMost || index == 0 || index >= 9)
+ return;
+
+ if (pShMem->keyMode == VIQR_CHARSET && c==VIQRsym[5] && (buf[i] == 'd' ||
buf[i] == 'D'))
+ return;
+
+ // if oeo, o must not be understood as a double character
+ if (pShMem->inMethod == TELEX_INPUT && toupper(c) == 'O' && i < keys-1) {
+ unsigned char ch = buf[i+1];
+ int vowelIndex = ATTR_VOWEL_INDEX(DT[ch]);
+ if (vowelIndex > 0 && BD[vowelIndex-1][5] == 'e')
+ return;
+ }
+
+
+ if (toneIndex == 0 || toneIndex == 6)
+ newChar = BK[index-1];
+ else
+ newChar = BD[ATTR_VOWEL_INDEX(DT[BK[index-1]])-1][toneIndex-1];
+
+ if (newChar != buf[i]) {
+ backs = keys - i;
+ ChangedChar = buf[i];
+ ansiPush[keysPushed++] = buf[i] = newChar;
+ for (k = i+1; k < keys; k++)
+ ansiPush[keysPushed++] = buf[k];
+ }
+ else {
+ // back to english
+ backs = keys - i;
+ ChangedChar = buf[i];
+ if (toneIndex == 0 || toneIndex == 6)
+ ansiPush[keysPushed++] = buf[i] = DoubleReverse[index-1];
+ else
+ ansiPush[keysPushed++] = buf[i] =
BD[ATTR_VOWEL_INDEX(DT[DoubleReverse[index-1]])-1][toneIndex-1];
+ for (k = i+1; k < keys; k++)
+ ansiPush[keysPushed++] = buf[k];
+ putChar(c, islower(OldChar));
+ ansiPush[keysPushed++] = c;
+ tempVietOff = 1;
+ }
+}
+
+
+//--------------------------------
+void VietKey::shortKey(unsigned char c)
+{
+ int lower;
+ SHORT shift, capital;
+ shift = GetKeyState(VK_SHIFT);
+ capital = GetKeyState(VK_CAPITAL);
+ if (((shift & 0x8000) && (capital & 0x0001)) ||
+ ((shift & 0x8000) == 0 && (capital & 0x00001) == 0))
+ lower = 1;
+ else
+ lower = 0;
+
+
+ unsigned char newChar;
+ int duplicate;
+ int index = ATTR_MACRO_INDEX(DT[c]);
+ newChar = BT[index-1];
+
+ if (pShMem->codeTable.multiBytes) {
+ // hard-coded!!!!
+ if (c == '{')
+ newChar = BT[0];
+ else if (c == '}')
+ newChar = BT[1];
+ }
+
+ keysPushed = 0;
+
+ duplicate = (keys > 0) && (buf[keys-1] == newChar);
+ if (duplicate) {
+ // convert back to english
+ ChangedChar = buf[keys-1];
+ buf[keys-1] = c;
+ ansiPush[keysPushed++] = c;
+ backs = 1;
+ tempVietOff = 1;
+ return;
+ }
+
+ backs = 0;
+ ansiPush[keysPushed++] = newChar;
+ if (keys == KEY_BUFSIZE)
+ throwBuf();
+
+ lowerCase[keys] = lower;
+ buf[keys] = newChar;
+ keys++;
+}
+
+
+//--------------------------------
+void VietKey::putToneMark(unsigned char c)
+{
+ int i,k,l,cuoi,index,vowel, duplicate, leftMost;
+ unsigned char newChar,t;
+ long attr;
+
+ // Tim nguyen am dau tien ke tu ben phai
+ i = keys-1;
+ leftMost = (pShMem->options.toneNextToVowel)? i : 0;
+ leftMost = max(keys - 1 - MAX_AFTER_VOWEL, leftMost);
+ while (i >= leftMost) {
+ attr = DT[buf[i]];
+ if (ATTR_IS_SEPARATOR(attr) || ATTR_IS_SOFT_SEPARATOR(attr) ||
ATTR_VOWEL_INDEX(attr))
+ break;
+ i--;
+ }
+ if (i < leftMost || ATTR_VOWEL_INDEX(attr) == 0)
+ return;
+
+ // Tim day cac nguyen am lien tiep
+ // neu gap 1 nguyen am da co dau thi dung
+ cuoi = i;
+ leftMost = (pShMem->options.toneNextToVowel)? i : 0;
+ leftMost = max(cuoi - MAX_VOWEL_SQUENCE + 1, leftMost);
+ while (i >= leftMost && ATTR_VOWEL_INDEX(DT[buf[i]])
+ && ((buf[i]<='z' && buf[i]>='a')
+ || (buf[i]<='Z' && buf[i]>='A')))
+ i--;
+
+ if (i<leftMost || ATTR_VOWEL_INDEX(DT[buf[i]])==0) {
+ l = cuoi-i; // l la do dai day nguyen am
+ switch (l) {
+ case 2:
+ if (pShMem->options.modernStyle &&
+ ( (buf[cuoi-1] == 'o' && buf[cuoi] == 'a') ||
+ (buf[cuoi-1] == 'o' && buf[cuoi] == 'e') ||
+ (buf[cuoi-1] == 'u' && buf[cuoi] == 'y') ))
+ i = cuoi;
+ else {
+ t = toupper(buf[i]);
+ if (i>=0 && (t=='Q' || (t=='G' && toupper(buf[i+1])=='I')))
+ i = cuoi;
+ else if (keys>cuoi+1)
+ i = cuoi; // co phu am di sau buf[cuoi]
+ else
+ i = cuoi-1;
+ }
+ break;
+ case 3:
+ i = cuoi - 1;
+ break;
+ default:
+ i = cuoi;
+ }
+ }
+ vowel = ATTR_VOWEL_INDEX(DT[buf[i]]) - 1;
+
+ if (c>=5)
+ index = ATTR_TONE_INDEX(DT[c]) - 1;
+ else
+ index = c;
+
+ newChar = BD[vowel][index];
+ duplicate = (newChar == buf[i]);
+ if (duplicate)
+ newChar = BD[vowel][5];
+
+ if (duplicate && (index == 5 || (pShMem->keyMode == VIQR_CHARSET && c <
5)))
+ return;
+ backs = keys - i;
+ ChangedChar = buf[i];
+ buf[i] = ansiPush[keysPushed++] = newChar;
+ for (k=1; k<keys-i; k++)
+ ansiPush[keysPushed++] = buf[i+k];
+ if (duplicate) {
+ ansiPush[keysPushed++] = c;
+ putChar(c, islower(OldChar));
+ tempVietOff = 1;
+ }
+}
+
+//--------------------------------
+void VietKey::setCodeTable(CodeInfo * pInfo)
+{
+ DT = pInfo->DT;
+ BD = pInfo->BD;
+ BK = pInfo->BK;
+ BW = pInfo->BW;
+ BT = pInfo->BT;
+ ToUniH = pInfo->ToUniH;
+ ToUniL = pInfo->ToUniL;
+}
+
+//--------------------------------
+void VietKey::vniDoubleCharMark(unsigned char c)
+{
+ long index;//, n;
+ if (keys == 0)
+ return;
+ index = ATTR_VNI_DOUBLE_INDEX(DT[c]); // in VNI method, index is from 11
to 14
+ switch (index) {
+ case VNI_CIRCUMFLEX_INDEX:
+ case VNI_D_INDEX:
+ doubleChar(c);
+ break;
+ case VNI_HORN_INDEX: // mark + for u, o
+ case VNI_BREVE_INDEX: // mark ( for a
+ putBreveMark(c);
+ break;
+ }
+}
+
+
+//--------------------------------
+void VietKey::throwBuf()
+{
+ memmove(buf, &buf[keys-KEYS_MAINTAIN], KEYS_MAINTAIN * sizeof(buf[0]));
+ memmove(lowerCase, &lowerCase[keys-KEYS_MAINTAIN], KEYS_MAINTAIN *
sizeof(lowerCase[0]));
+ keys = KEYS_MAINTAIN;
+}
+
+//--------------------------------
+unsigned char *putUnicodeCharRef(unsigned char *buf, WORD ch, int & len)
+{
+// if (ch < 256) {
+ if (ch < 128) {
+ len = 1;
+ *buf++ = (unsigned char)ch;
+ }
+ else {
+ *buf++ = '&';
+ *buf++ = '#';
+ len = 2;
+ int i, digit, prev, base;
+ prev = 0;
+ base = 10000;
+ for (i=0; i < 5; i++) {
+ digit = ch / base;
+ if (digit || prev) {
+ prev = 1;
+ *buf++ = '0' + ((unsigned char)digit);
+ len++;
+ }
+ ch %= base;
+ base /= 10;
+ }
+ *buf++ = ';';
+ len++;
+ }
+ return buf;
+}
+
+#define HEX_DIGIT(x) ((x < 10)? ('0'+x) : ('A'+x-10))
+
+//--------------------------------
+unsigned char *putUnicodeCharHex(unsigned char *buf, WORD ch, int & len)
+{
+// if (ch < 128) {
+ if (ch < 256) {
+ len = 1;
+ *buf++ = (unsigned char)ch;
+ }
+ else {
+ *buf++ = '&';
+ *buf++ = '#';
+ *buf++ = 'x';
+ len = 3;
+
+ int i, digit;
+ int prev = 0;
+ int shifts = 12;
+ for (i=0; i < 4; i++) {
+ digit = ((ch >> shifts) & 0x000F);
+ if (digit > 0 || prev) {
+ prev = 1;
+ *buf++ = HEX_DIGIT(digit);
+ len++;
+ }
+ shifts -= 4;
+ }
+ *buf++ = ';';
+ len++;
+ }
+ return buf;
+}
+
+//-----------------------------------------------------
+unsigned char *putUnicodeCharCString(unsigned char *buf, WORD ch, int &
len)
+{
+ if (ch < 256 && !isxdigit(ch)) {
+ len = 1;
+ *buf++ = (unsigned char)ch;
+ }
+ else {
+ *buf++ = '\\';
+ *buf++ = 'x';
+
+ len = 2;
+
+ int i, digit;
+ int prev = 0;
+ int shifts = 12;
+ for (i=0; i < 4; i++) {
+ digit = ((ch >> shifts) & 0x000F);
+ if (digit > 0 || prev) {
+ prev = 1;
+ *buf++ = HEX_DIGIT(digit);
+ len++;
+ }
+ shifts -= 4;
+ }
+ }
+ return buf;
+}
+//--------------------------------
+unsigned char *putUnicodeCharUtf8(unsigned char *buf, WORD ch, int & len)
+{
+ if (ch < 0x0080) {
+ len = 1;
+ *buf++ = (unsigned char)ch;
+ } else if (ch < 0x0800) {
+ len = 2;
+ *buf++ = (0xC0 | (BYTE)(ch >> 6));
+ *buf++ = (0x80 | (BYTE)(ch & 0x003F));
+ } else {
+ len = 3;
+ *buf++ = (0xE0 | (BYTE)(ch >> 12));
+ *buf++ = (0x80 | (BYTE)((ch >> 6) & 0x003F));
+ *buf++ = (0x80 | (BYTE)(ch & 0x003F));
+ }
+ return buf;
+}
+
+//--------------------------------
+void VietKey::encodeUnicode(int encoding)
+{
+ int i, j;
+ memcpy(tempPush, ansiPush, keysPushed);
+ WORD w;
+ int len, bytes;
+ BYTE *p = ansiPush;
+ bytes = 0;
+
+ for (i = 0, j = keys-keysPushed; i < keysPushed; i++, j++) {
+ w = (lowerCase[j]) ? ToUniL[tempPush[i]] : ToUniH[tempPush[i]];
+ if (encoding == UNICODE_REF)
+ p = putUnicodeCharRef(p, w, len);
+ else if (encoding == UNICODE_HEX)
+ p = putUnicodeCharHex(p, w, len);
+ else if (encoding == UNICODE_CSTRING)
+ p = putUnicodeCharCString(p, w, len);
+ else
+ p = putUnicodeCharUtf8(p, w, len);
+ bytes += len;
+
+ if (!pShMem->codeTable.singleBackspace && backs > 0 && i > 0)
+ backs += len-1;
+ }
+
+ if (!pShMem->codeTable.singleBackspace && backs > 0) {
+ w = lowerCase[keys-keysPushed]? ToUniL[ChangedChar] :
ToUniH[ChangedChar];
+ len = uniCharLen(w, encoding);
+ backs += len - 1;
+ }
+
+ keysPushed = bytes;
+}
+
+//--------------------------------
+int macroKeyCompare(const void *ele1, const void *ele2)
+{
+ char *key = pShMem->macroMem + ((HookMacroDef *)ele2)->keyOffset;
+ return strcmp((const char *)ele1, key);
+// return strcmp((const char *)ele1, ((MacroDef *)ele2)->key);
+}
+
+//--------------------------------
+int VietKey::checkMacro(unsigned char lastChar)
+{
+ if ((KeyState[VK_SHIFT] & 0x80) && lastChar==' ')
+ return 0; //SHIFT+SPACEBAR: disable macro
+
+ // get the macro key
+ HookMacroDef *pMacro = NULL;
+ char key[MAX_MACRO_KEY_LEN+1];
+ int i, j, keyLen;
+ i = keys-1;
+
+ while (i >= 0) {
+ while (i>=0 && !ATTR_IS_WORD_STOP(DT[buf[i]]) && (keys-i <=
MAX_MACRO_KEY_LEN - 1))
+ i--;
+ if (i>=0 && !ATTR_IS_WORD_STOP(DT[buf[i]]))
+ return 0;
+
+ if (i>=0)
+ key[0] = buf[i];
+
+ for (j=i+1; j<keys; j++) {
+ if (lowerCase[j])
+ key[j-i] = buf[j];
+ else
+ key[j-i] = toupper(buf[j]);
+ }
+ key[keys-i] = '\0';
+
+ //search macro table
+ keyLen = keys-i-1;
+ pMacro = (HookMacroDef *)bsearch(key+1, pShMem->macroTable,
+ pShMem->macroCount, sizeof(HookMacroDef),
***The diff for this file has been truncated for email.***
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/keyhook/vietkey.h
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,71 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#ifndef _VIETKEY_H
+#define _VIETKEY_H 1
+
+#define KEY_BUFSIZE 40
+#define KEYS_MAINTAIN 20
+
+class VietKey {
+private:
+ int keys;
+ unsigned char buf[KEY_BUFSIZE];
+ int lowerCase[KEY_BUFSIZE];
+ int lastWConverted; // used in TELEX, WConverted =1 when last single w
was converted to u+
+ int lastIsEscape; // the last key was an escape key
+ int tempVietOff; // Vietnamese mode is temporarily turned off
+
+ DWORD *DT;
+ unsigned char (*BD)[6];
+ unsigned char *BK;
+ unsigned char *BW;
+ unsigned char *BT;
+ WORD *ToUniH;
+ WORD *ToUniL;
+
+ int keyCategory(unsigned char c);
+ void putBreveMark(unsigned char c);
+ void doubleChar(unsigned char c);
+ void putToneMark(unsigned char c);
+ void shortKey(unsigned char c);
+ void vniDoubleCharMark(unsigned char c);
+ void throwBuf(); // used when buffer is full
+
+ // helper functions
+ void postProcess();
+ void processBackspace();
+ void encodeUnicode(int encoding);
+ int checkMacro(unsigned char ch);
+ int checkEscapeVIQR(unsigned char ch);
+public:
+ VietKey();
+ int keysPushed,backs;
+// unsigned char ansiPush[(KEY_BUFSIZE+2)*8]; // Unicode ref may require 8
bytes/character
+// WORD uniPush[(KEY_BUFSIZE+2)*2];
+ unsigned char ansiPush[1024];
+ WORD uniPush[512];
+
+ void clearBuf();
+ void process(unsigned char ch);
+ void setCodeTable(CodeInfo * pInfo);
+ void putChar(unsigned char ch, int isLowerCase = 1); // puts char into
buffer without processing it
+};
+
+#endif
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/license.txt Mon Oct
10 16:21:04 2011
@@ -0,0 +1,7 @@
+UniKey is provided free of charge. Permission is granted to anyone to use
this software. Redistribution of this software is allowed only for
non-commercial purposes.
+
+This software is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this software.
+
+For more information about UniKey, please visit: http://unikey.org
+
+Copyright (C) 1998-2005 Pham Kim Long
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/NewKey.rc
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,572 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDR_MAINFRAME ICON "res\\Pen.ico"
+IDI_OPEN_FOLDER ICON "res\\Openfold.ico"
+IDI_CONVERT ICON "res\\convert.ico"
+IDI_INFO ICON "res\\info.ico"
+IDI_CANCEL ICON "res\\cancel.ico"
+IDI_EN ICON "res\\viet-off.ico"
+IDI_VIET ICON "res\\viet-on.ico"
+IDI_OK ICON "res\\OK.ico"
+IDI_HELP ICON "res\\help.ico"
+IDI_RESET ICON "res\\2arrow.ico"
+IDI_CONTRACT ICON "res\\ARW06UP.ICO"
+IDI_EXPAND ICON "res\\ARW06DN.ICO"
+IDI_ADD ICON "res\\Add.ico"
+IDI_DELETE ICON "res\\Delete.ico"
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+#if defined(APSTUDIO_INVOKED) || defined(_ANSI)
+#if defined(APSTUDIO_INVOKED)
+IDD_KEY_DIALOG$(_ANSI) DIALOGEX 0, 0, 250, 193
+#else
+IDD_KEY_DIALOG DIALOGEX 0, 0, 250, 193
+#endif
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_POPUP
|
+ WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_APPWINDOW
+CAPTION "UniKey 3.62"
+FONT 8, "MS Sans Serif", 0, 0, 0x0
+BEGIN
+ COMBOBOX IDC_CODE_TABLE,66,14,112,64,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_INPUT_METHOD,66,32,83,52,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ CONTROL "CTRL + SHIFT",IDC_SW_KEY1,"Button",BS_AUTORADIOBUTTON
|
+ WS_GROUP | WS_TABSTOP,66,49,63,10
+ CONTROL "ALT +
Z",IDC_SW_KEY2,"Button",BS_AUTORADIOBUTTON,66,60,
+ 42,10
+ CONTROL "&Taskbar",IDOK,"Button",BS_OWNERDRAW | WS_TABSTOP,188,
+ 11,55,17
+ CONTROL "&KÕt thóc",IDC_EXIT,"Button",BS_OWNERDRAW |
WS_TABSTOP,
+ 188,33,55,17
+ CONTROL "Advanced <<",IDC_EXPAND,"Button",BS_OWNERDRAW |
+ WS_TABSTOP,188,55,55,17
+ CONTROL "Cho phÐp gâ dÊu mò, mãc ë cuèi tõ",IDC_FREE_MARKING,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,94,130,10
+ CONTROL "Ph¶i gâ dÊu ngay sau nguyªn
©m",IDC_TONE_CTRL,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,13,106,142,10
+ CONTROL "Bá dÊu oµ, uý (thay v× ßa,
óy)",IDC_MODERN_STYLE,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,13,118,115,10
+ CONTROL "Sö dông clipboard cho
unicode",IDC_USE_CLIPBOARD,"Button",
+ BS_AUTOCHECKBOX | NOT WS_VISIBLE |
WS_TABSTOP,13,130,130,
+ 10
+ CONTROL "Vietnamese interface",IDC_VIET_GUI,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,157,93,82,10
+ CONTROL "Enable
macros",IDC_MACRO_CHECK,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,157,107,63,10
+ CONTROL "Macro table...",IDC_MACRO_BTN,"Button",BS_OWNERDRAW |
+ WS_TABSTOP,156,119,71,15
+ CONTROL "BËt héi tho¹i nµy khi khëi
®éng",IDC_SHOW_DLG,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,13,148,113,10
+ CONTROL "Auto-run UniKey at boot time",IDC_AUTO_START,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,138,148,105,10
+ CONTROL "&H­íng dÉn",IDC_OPEN_HELP,"Button",BS_OWNERDRAW |
+ WS_TABSTOP,10,168,55,17
+ CONTROL "Th«ng tin",IDC_ABOUT,"Button",BS_OWNERDRAW |
WS_TABSTOP,
+ 69,168,55,17
+ CONTROL "MÆc ®Þnh",IDC_RESET,"Button",BS_OWNERDRAW |
WS_TABSTOP,
+ 128,168,55,17
+ GROUPBOX "§iÒu khiÓn",IDC_CONTROL_GROUP,7,7,175,66
+ LTEXT "B¶ng m·:",IDC_CHARSET_PROMPT,14,17,52,8,SS_NOPREFIX
+ LTEXT "PhÝm chuyÓn:",IDC_SWITCHKEY_PROMPT,13,51,48,8
+ LTEXT "KiÓu gâ phÝm:",IDC_KEYMODE_PROMPT,14,33,48,8
+ CONTROL "",IDC_COMPACT_FRAME,"Static",SS_BLACKFRAME,8,6,244,75
+ CONTROL "",IDC_FOOTER_FRAME,"Static",SS_BLACKFRAME,7,163,234,29
+ GROUPBOX "Lùa chän",IDC_OPTION_GROUP,7,82,236,61
+END
+#endif
+
+#if defined(APSTUDIO_INVOKED) || defined(_ANSI)
+#if defined(APSTUDIO_INVOKED)
+IDD_ABOUT$(_ANSI) DIALOGEX 0, 0, 244, 137
+#else
+IDD_ABOUT DIALOGEX 0, 0, 244, 137
+#endif
+STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "About UniKey 3.62 [Build 050711]"
+FONT 8, "MS Sans Serif", 0, 0, 0x0
+BEGIN
+ CONTROL "OK",IDOK,"Button",BS_OWNERDRAW | WS_TABSTOP,97,114,46,
+ 16
+ LTEXT "http://unikey.org",IDC_WEB_LINK,76,29,54,8
+ GROUPBOX "",IDC_STATIC,7,7,230,49
+ LTEXT "Author: Pham Kim Long, CTU
Prague",IDC_AUTHOR,39,16,163,
+ 8
+ ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
+ LTEXT " UniKey is a free open-source software, you can
redistribute and/or\n modify it under the terms of the GNU General Public
License.\n UniKey supports all Win32 platforms: Windows 9x, ME,
NT/2000/XP.",
+ IDC_INFO,7,64,230,28,SS_NOPREFIX | SS_SUNKEN
+ LTEXT "Copyright (C) 1998 - 2005 Pham Kim
Long",IDC_COPYRIGHT,
+ 39,41,158,8
+ LTEXT "Web site:",IDC_STATIC,39,29,31,8
+ LTEXT "Support forum:",IDC_SUPPORT_PROVIDER,7,100,67,8,NOT
+ WS_VISIBLE
+ LTEXT "http://unikey.org/forum",IDC_SUPPORT_LINK,81,100,80,9,
+ NOT WS_VISIBLE
+END
+#endif
+
+#if defined(APSTUDIO_INVOKED) || defined(_ANSI)
+#if defined(APSTUDIO_INVOKED)
+IDD_TOOLKIT$(_ANSI) DIALOGEX 0, 0, 319, 212
+#else
+IDD_TOOLKIT DIALOGEX 0, 0, 319, 212
+#endif
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_POPUP
|
+ WS_CAPTION
+EXSTYLE WS_EX_APPWINDOW
+CAPTION "UniKey Toolkit"
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+ COMBOBOX IDC_IN_CHARSET,61,16,126,157,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_OUT_CHARSET,61,35,126,149,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ CONTROL "Swap charset",IDC_SWAP_CHARSET,"Button",BS_OWNERDRAW |
+ WS_TABSTOP,61,60,68,17
+ CONTROL "Convert clipboard",IDC_CLIPBOARD,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,92,94,10
+ EDITTEXT IDC_IN_FILE,65,122,196,14,ES_AUTOHSCROLL
+ CONTROL "",IDC_IN_BROWSE,"Button",BS_OWNERDRAW |
WS_TABSTOP,277,
+ 124,26,14
+ EDITTEXT IDC_OUT_FILE,66,143,196,14,ES_AUTOHSCROLL
+ CONTROL "",IDC_OUT_BROWSE,"Button",BS_OWNERDRAW |
WS_TABSTOP,277,
+ 143,26,14
+ CONTROL "Convert",IDC_CONVERT,"Button",BS_OWNERDRAW |
WS_TABSTOP,
+ 7,189,57,16
+ CONTROL "Close",IDOK,"Button",BS_OWNERDRAW |
WS_TABSTOP,255,189,
+ 57,16
+ CONTROL "To upper case",IDC_TO_UPPER,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,204,19,102,11
+ CONTROL "To lower case",IDC_TO_LOWER,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,204,32,102,11
+ CONTROL "Remove tone marks",IDC_REMOVE_TONE,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,204,45,102,11
+ CONTROL "Do not use rich text
format",IDC_NO_RICH_TEXT,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,204,58,101,11
+ CONTROL "Use minimal font set",IDC_MINIMAL_FONTSET,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,204,70,102,11
+ GROUPBOX "Character set",IDC_STATIC_CHARSET,7,7,183,78
+ GROUPBOX "File",IDC_STATIC_FILE,7,108,305,69
+ LTEXT "Source",IDC_STATIC_IN_CHARSET,13,19,35,8
+ LTEXT "Input file",IDC_STATIC_IN_FILE,13,127,45,8
+ LTEXT "Destination",IDC_STATIC_OUT_CHARSET,13,38,42,8
+ LTEXT "Output file",IDC_STATIC_OUT_FILE,13,148,46,8
+ GROUPBOX "Options",IDC_STATIC_OPTION,195,7,117,78
+ LTEXT "Only plain text and Rich Text Format are supported",
+ IDC_FILE_NOTE,65,161,211,12
+END
+#endif
+
+#if defined(APSTUDIO_INVOKED) || defined(_ANSI)
+#if defined(APSTUDIO_INVOKED)
+IDD_MACRO$(_ANSI) DIALOGEX 0, 0, 347, 215
+#else
+IDD_MACRO DIALOGEX 0, 0, 347, 215
+#endif
+STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Macro Table"
+FONT 8, "MS Sans Serif", 0, 0, 0x0
+BEGIN
+ EDITTEXT IDC_KEY,7,24,54,14,ES_AUTOHSCROLL
+ EDITTEXT IDC_TEXT,65,24,214,14,ES_AUTOHSCROLL
+ LISTBOX IDC_ITEMLIST,7,45,271,110,LBS_SORT | LBS_USETABSTOPS |
+ LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL |
+ WS_TABSTOP
+ CONTROL "Add",IDC_EDIT,"Button",BS_OWNERDRAW | WS_TABSTOP,286,
+ 117,50,16
+ CONTROL "Delete",IDC_DELETE,"Button",BS_OWNERDRAW | WS_TABSTOP,
+ 286,139,50,16
+ CONTROL "OK",IDOK,"Button",BS_OWNERDRAW | WS_TABSTOP,286,25,50,
+ 16
+ CONTROL "Cancel",IDCANCEL,"Button",BS_OWNERDRAW |
WS_TABSTOP,286,
+ 48,50,16
+ LTEXT "Note: Replacement texts are displayed here in VIQR
format",
+ IDC_NOTE,7,159,202,11
+ LTEXT "Replace:",IDC_STATIC_REPLACE,7,10,30,8
+ LTEXT "With:",IDC_STATIC_WITH,65,10,18,8
+ CONTROL "Allow macros even if Vietnamese is off",
+ IDC_ALWAYS_MACRO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
+ 159,189,153,11
+ CONTROL "Load File...",IDC_SELECT_FILE,"Button",BS_OWNERDRAW |
+ WS_TABSTOP,7,187,64,17
+ CONTROL "Select Default",IDC_SELECT_DEFAULT,"Button",
+ BS_OWNERDRAW | WS_TABSTOP,77,187,64,17
+ LTEXT "Static",IDC_FILE_NAME,53,173,199,9
+ LTEXT "Current File:",IDC_PATH_LABEL,9,173,40,9
+END
+#endif
+
+#if defined(APSTUDIO_INVOKED) || defined(_UNICODE)
+#if defined(APSTUDIO_INVOKED)
+IDD_KEY_DIALOG$(_UNICODE) DIALOGEX 0, 0, 257, 188
+#else
+IDD_KEY_DIALOG DIALOGEX 0, 0, 257, 188
+#endif
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_POPUP
|
+ WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_APPWINDOW
+CAPTION "UniKey 3.62"
+FONT 8, "Arial", 0, 0, 0x0
+BEGIN
+ COMBOBOX IDC_CODE_TABLE,69,15,119,64,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_INPUT_METHOD,69,33,95,52,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ CONTROL "CTRL + SHIFT",IDC_SW_KEY1,"Button",BS_AUTORADIOBUTTON
|
+ WS_GROUP | WS_TABSTOP,69,50,63,10
+ CONTROL "ALT +
Z",IDC_SW_KEY2,"Button",BS_AUTORADIOBUTTON,69,61,
+ 42,10
+ CONTROL "&Taskbar",IDOK,"Button",BS_OWNERDRAW | WS_TABSTOP,200,
+ 11,49,17
+ CONTROL "&KÕt thóc",IDC_EXIT,"Button",BS_OWNERDRAW |
WS_TABSTOP,
+ 200,33,49,17
+ CONTROL "Advanced",IDC_EXPAND,"Button",BS_OWNERDRAW |
WS_TABSTOP,
+ 200,55,49,17
+ CONTROL "Cho phÐp gâ dÊu mò, mãc ë cuèi tõ",IDC_FREE_MARKING,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,94,138,10
+ CONTROL "Ph¶i gâ dÊu ngay sau nguyªn
©m",IDC_TONE_CTRL,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,13,106,140,10
+ CONTROL "Bá dÊu oµ, uý (thay v× ßa,
óy)",IDC_MODERN_STYLE,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,13,118,127,10
+ CONTROL "Sö dông clipboard cho
unicode",IDC_USE_CLIPBOARD,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,13,130,130,9
+ CONTROL "Vietnamese interface",IDC_VIET_GUI,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,157,93,82,10
+ CONTROL "Enable
macros",IDC_MACRO_CHECK,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,157,107,63,10
+ CONTROL "Macro table...",IDC_MACRO_BTN,"Button",BS_OWNERDRAW |
+ WS_TABSTOP,156,119,71,15
+ CONTROL "BËt héi tho¹i nµy khi khëi
®éng",IDC_SHOW_DLG,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,13,146,121,10
+ CONTROL "Auto-run UniKey at boot time",IDC_AUTO_START,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,142,146,109,10
+ CONTROL "&H­íng dÉn",IDC_OPEN_HELP,"Button",BS_OWNERDRAW |
+ WS_TABSTOP,10,163,60,17
+ CONTROL "Th«ng tin",IDC_ABOUT,"Button",BS_OWNERDRAW |
WS_TABSTOP,
+ 73,163,60,17
+ CONTROL "MÆc ®Þnh",IDC_RESET,"Button",BS_OWNERDRAW |
WS_TABSTOP,
+ 136,163,60,17
+ GROUPBOX "§iÒu khiÓn",IDC_CONTROL_GROUP,7,7,187,66
+ LTEXT "B¶ng m·:",IDC_CHARSET_PROMPT,14,17,52,8,SS_NOPREFIX
+ LTEXT "PhÝm chuyÓn:",IDC_SWITCHKEY_PROMPT,13,51,49,8
+ LTEXT "KiÓu gâ phÝm:",IDC_KEYMODE_PROMPT,14,33,48,8
+ CONTROL "",IDC_COMPACT_FRAME,"Static",SS_BLACKFRAME,5,6,254,75
+ CONTROL "",IDC_FOOTER_FRAME,"Static",SS_BLACKFRAME,7,160,234,27
+ GROUPBOX "Lùa chän",IDC_OPTION_GROUP,7,82,242,60
+END
+#endif
+
+#if defined(APSTUDIO_INVOKED) || defined(_UNICODE)
+#if defined(APSTUDIO_INVOKED)
+IDD_TOOLKIT$(_UNICODE) DIALOGEX 0, 0, 305, 195
+#else
+IDD_TOOLKIT DIALOGEX 0, 0, 305, 195
+#endif
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_POPUP
|
+ WS_CAPTION
+EXSTYLE WS_EX_APPWINDOW
+CAPTION "UniKey Toolkit"
+FONT 8, "Arial", 0, 0, 0x1
+BEGIN
+ COMBOBOX IDC_IN_CHARSET,55,17,117,150,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_OUT_CHARSET,55,33,117,149,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ CONTROL "Swap charset",IDC_SWAP_CHARSET,"Button",BS_OWNERDRAW |
+ WS_TABSTOP,55,57,68,16
+ CONTROL "Convert clipboard",IDC_CLIPBOARD,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,87,94,9
+ EDITTEXT IDC_IN_FILE,57,112,194,14,ES_AUTOHSCROLL
+ CONTROL "",IDC_IN_BROWSE,"Button",BS_OWNERDRAW |
WS_TABSTOP,259,
+ 112,26,14
+ EDITTEXT IDC_OUT_FILE,57,132,194,14,ES_AUTOHSCROLL
+ CONTROL "",IDC_OUT_BROWSE,"Button",BS_OWNERDRAW |
WS_TABSTOP,259,
+ 132,26,14
+ CONTROL "Chuyen ma",IDC_CONVERT,"Button",BS_OWNERDRAW |
+ WS_TABSTOP,7,172,68,16
+ CONTROL "Close",IDOK,"Button",BS_OWNERDRAW |
WS_TABSTOP,245,172,
+ 53,16
+ CONTROL "To upper case",IDC_TO_UPPER,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,190,16,102,10
+ CONTROL "To lower case",IDC_TO_LOWER,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,190,28,100,10
+ CONTROL "Remove tone marks",IDC_REMOVE_TONE,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,190,40,98,10
+ CONTROL "Do not use rich text
format",IDC_NO_RICH_TEXT,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,190,52,101,10
+ CONTROL "Use minimal font set",IDC_MINIMAL_FONTSET,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,190,64,102,10
+ GROUPBOX "Character set",IDC_STATIC_CHARSET,7,7,171,72
+ GROUPBOX "File",IDC_STATIC_FILE,7,100,291,67
+ LTEXT "Source:",IDC_STATIC_IN_CHARSET,12,20,26,8
+ LTEXT "Input",IDC_STATIC_IN_FILE,13,115,40,8
+ LTEXT "Destination:",IDC_STATIC_OUT_CHARSET,12,35,38,8
+ LTEXT "Output",IDC_STATIC_OUT_FILE,13,135,41,8
+ GROUPBOX "Options",IDC_STATIC_OPTION,181,7,117,72
+ LTEXT "Only plain text and Rich Text Format are supported",
+ IDC_FILE_NOTE,57,151,211,11
+END
+#endif
+
+#if defined(APSTUDIO_INVOKED) || defined(_UNICODE)
+#if defined(APSTUDIO_INVOKED)
+IDD_ABOUT$(_UNICODE) DIALOGEX 0, 0, 238, 132
+#else
+IDD_ABOUT DIALOGEX 0, 0, 238, 132
+#endif
+STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "About UniKey 3.62 [Build 050711 NT]"
+FONT 8, "Arial", 0, 0, 0x0
+BEGIN
+ CONTROL "OK",IDOK,"Button",BS_OWNERDRAW | WS_TABSTOP,95,108,46,
+ 16
+ LTEXT "http://unikey.org",IDC_WEB_LINK,83,27,52,8
+ GROUPBOX "",IDC_STATIC,7,7,224,47
+ LTEXT "Author: Pham Kim Long, CTU
Prague",IDC_AUTHOR,39,16,163,
+ 8
+ ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
+ LTEXT " UniKey is a free open-source software, you can
redistribute and/or\n modify it under the terms of the GNU General Public
License.\n UniKey supports all Win32 platforms: Windows 9x, ME,
NT/2000/XP.",
+ IDC_INFO,7,61,224,28,SS_NOPREFIX | SS_SUNKEN
+ LTEXT "Copyright (C) 1998 - 2005 Pham Kim
Long",IDC_COPYRIGHT,
+ 39,38,158,8
+ LTEXT " Web site:",IDC_STATIC,39,27,33,8
+ LTEXT "Support forum:",IDC_SUPPORT_PROVIDER,7,93,73,8,NOT
+ WS_VISIBLE
+ LTEXT "http://unikey.org/forum",IDC_SUPPORT_LINK,82,93,73,8,
+ NOT WS_VISIBLE
+END
+#endif
+
+#if defined(APSTUDIO_INVOKED) || defined(_UNICODE)
+#if defined(APSTUDIO_INVOKED)
+IDD_MACRO$(_UNICODE) DIALOGEX 0, 0, 327, 202
+#else
+IDD_MACRO DIALOGEX 0, 0, 327, 202
+#endif
+STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Macro Definition"
+FONT 8, "Arial", 0, 0, 0x0
+BEGIN
+ EDITTEXT IDC_KEY,7,19,51,14,ES_AUTOHSCROLL
+ EDITTEXT IDC_TEXT,62,19,205,14,ES_AUTOHSCROLL
+ LISTBOX IDC_ITEMLIST,7,40,261,110,LBS_SORT | LBS_USETABSTOPS |
+ LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL |
+ WS_TABSTOP
+ CONTROL "OK",IDOK,"Button",BS_OWNERDRAW | WS_TABSTOP,278,41,42,
+ 16
+ CONTROL "Cancel",IDCANCEL,"Button",BS_OWNERDRAW |
WS_TABSTOP,278,
+ 61,42,16
+ CONTROL "Add",IDC_EDIT,"Button",BS_OWNERDRAW | WS_TABSTOP,278,
+ 114,42,16
+ CONTROL "Delete",IDC_DELETE,"Button",BS_OWNERDRAW | WS_TABSTOP,
+ 278,134,42,16
+ CONTROL "Load File...",IDC_SELECT_FILE,"Button",BS_OWNERDRAW |
+ WS_TABSTOP,7,177,64,16
+ CONTROL "Select Default",IDC_SELECT_DEFAULT,"Button",
+ BS_OWNERDRAW | WS_TABSTOP,77,177,64,16
+ CONTROL "Allow macros even if Vietnamese is off",
+ IDC_ALWAYS_MACRO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
+ 151,180,153,10
+ LTEXT "Note: Replacement texts are displayed here in VIQR
format",
+ IDC_NOTE,7,152,202,11,NOT WS_VISIBLE
+ LTEXT "Replace:",IDC_STATIC_REPLACE,7,7,30,8
+ LTEXT "With:",IDC_STATIC_WITH,62,7,25,8
+ LTEXT "Static",IDC_FILE_NAME,56,164,199,8
+ LTEXT "Current File:",IDC_PATH_LABEL,10,164,40,8
+END
+#endif
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ "IDD_ABOUT$(_ANSI)", DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 237
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 130
+ END
+
+ "IDD_TOOLKIT$(_ANSI)", DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 312
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 205
+ END
+
+ "IDD_MACRO$(_ANSI)", DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 340
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 208
+ END
+
+ "IDD_KEY_DIALOG$(_UNICODE)", DIALOG
+ BEGIN
+ RIGHTMARGIN, 252
+ BOTTOMMARGIN, 187
+ END
+
+ "IDD_TOOLKIT$(_UNICODE)", DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 298
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 188
+ END
+
+ "IDD_ABOUT$(_UNICODE)", DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 231
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 125
+ END
+
+ "IDD_MACRO$(_UNICODE)", DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 320
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 195
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDR_KEY_MENU MENU
+BEGIN
+ POPUP "Keyboard Menu"
+ BEGIN
+ MENUITEM "Exit", ID_END_KEY
+ MENUITEM SEPARATOR
+ MENUITEM "Help", ID_OPEN_HELP
+ MENUITEM "Configuration...[CS+F5]", ID_KEY_PANEL
+ MENUITEM "Toolkit... [CS+F6]", ID_TOOLKIT
+ MENUITEM "Convert on the fly - [CS+F9]", ID_FLY_CONVERT
+ MENUITEM SEPARATOR
+ MENUITEM "Telex Typing", ID_TELEX_TYPING
+ MENUITEM "VNI Typing", ID_VNI_TYPING
+ MENUITEM "VIQR Typing", ID_VIQR_TYPING
+ MENUITEM "VIQR* typing", ID_VIQR_STAR_TYPING
+ MENUITEM SEPARATOR
+ MENUITEM "Unicode ", ID_KEY_UNICODE
+ MENUITEM "TCVN3 (ABC)", ID_KEY_TCVN
+ MENUITEM "VNI Windows", ID_KEY_VNI
+ MENUITEM "VIQR", ID_KEY_VIQR
+ MENUITEM "Vietnamese locale CP 1258", ID_KEY_CP1258
+ MENUITEM "UTF-8 Literal", ID_KEY_UNICODE_UTF8
+ MENUITEM "Other", ID_KEY_OTHER
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Cursor
+//
+
+IDC_HAND_CURSOR CURSOR "res\\H_POINT.CUR"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE
+BEGIN
+ IDS_APP_TITLE "UniKey 3.62"
+ IDS_ABOUT "&About UniKey..."
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username
trung...@gmail.com/newkey/NewKey.vcproj Mon Oct 10 16:21:04 2011
@@ -0,0 +1,444 @@
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="NewKey"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Unicode Release|Win32"
+ OutputDirectory=".\../URelease"
+ IntermediateDirectory=".\URelease"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="1">
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../keyhook,../vnconv,../rtfio"
+ PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS,UNICODE"
+ StringPooling="TRUE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="prehdr.h"
+ PrecompiledHeaderFile=".\URelease/NewKey.pch"
+ AssemblerListingLocation=".\URelease/"
+ ObjectFile=".\URelease/"
+ ProgramDataBaseFileName=".\URelease/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="Comdlg32.lib Advapi32.lib"
+ OutputFile="../URelease/UniKeyNT.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+
IgnoreDefaultLibraryNames="kernel32.lib,advapi32.lib,user32.lib,gdi32.lib,shell32.lib,comdlg32.lib,version.lib,mpr.lib,rasapi32.lib,winmm.lib,winspool.lib,vfw32.lib,secur32.lib,oleacc.lib,oledlg.lib,sensapi.lib"
+ ProgramDatabaseFile=".\../URelease/UniKeyNT.pdb"
+ SubSystem="2"
+ StackReserveSize="20000"
+ StackCommitSize="4096"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\../URelease/NewKey.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG,_UNICODE"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\../Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../keyhook,../vnconv,../rtfio"
+ PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="prehdr.h"
+ PrecompiledHeaderFile=".\Debug/NewKey.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="4"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="Comdlg32.lib"
+ OutputFile=".\../Debug/NewKey.exe"
+ LinkIncremental="2"
+ SuppressStartupBanner="TRUE"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile=".\../Debug/NewKey.pdb"
+ SubSystem="2"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\../Debug/NewKey.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG,_ANSI"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\../Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE">
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../keyhook,../vnconv,../rtfio"
+ PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
+ StringPooling="TRUE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="prehdr.h"
+ PrecompiledHeaderFile=".\Release/NewKey.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="Advapi32.lib Comdlg32.lib"
+ OutputFile="../Release/UniKey.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ ProgramDatabaseFile=".\../Release/UniKey.pdb"
+ SubSystem="2"
+ StackReserveSize="20000"
+ StackCommitSize="4096"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\../Release/NewKey.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG,_ANSI"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath=".\about.cpp">
+ </File>
+ <File
+ RelativePath=".\button.cpp">
+ </File>
+ <File
+ RelativePath=".\encode.cpp">
+ </File>
+ <File
+ RelativePath=".\ExpDlg.cpp">
+ </File>
+ <File
+ RelativePath=".\font.cpp">
+ </File>
+ <File
+ RelativePath=".\keydlg.cpp">
+ </File>
+ <File
+ RelativePath=".\label.cpp">
+ </File>
+ <File
+ RelativePath=".\macrodlg.cpp">
+ </File>
+ <File
+ RelativePath=".\mactab.cpp">
+ </File>
+ <File
+ RelativePath=".\mainwnd.cpp">
+ </File>
+ <File
+ RelativePath=".\odmenu.cpp">
+ </File>
+ <File
+ RelativePath=".\prehdr.cpp">
+ <FileConfiguration
+ Name="Unicode Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\smedit.cpp">
+ </File>
+ <File
+ RelativePath=".\tooldlg.cpp">
+ </File>
+ <File
+ RelativePath=".\ukmenu.cpp">
+ </File>
+ <File
+ RelativePath=".\userpref.cpp">
+ </File>
+ <File
+ RelativePath=".\util.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl">
+ <File
+ RelativePath=".\about.h">
+ </File>
+ <File
+ RelativePath=".\button.h">
+ </File>
+ <File
+ RelativePath=".\encode.h">
+ </File>
+ <File
+ RelativePath=".\ExpDlg.h">
+ </File>
+ <File
+ RelativePath=".\font.h">
+ </File>
+ <File
+ RelativePath=".\keydlg.h">
+ </File>
+ <File
+ RelativePath=".\label.h">
+ </File>
+ <File
+ RelativePath=".\macrodlg.h">
+ </File>
+ <File
+ RelativePath=".\mactab.h">
+ </File>
+ <File
+ RelativePath=".\mainwnd.h">
+ </File>
+ <File
+ RelativePath=".\odmenu.h">
+ </File>
+ <File
+ RelativePath=".\preHdr.h">
+ </File>
+ <File
+ RelativePath=".\resource.h">
+ </File>
+ <File
+ RelativePath=".\smedit.h">
+ </File>
+ <File
+ RelativePath=".\tooldlg.h">
+ </File>
+ <File
+ RelativePath=".\ukmenu.h">
+ </File>
+ <File
+ RelativePath=".\userpref.h">
+ </File>
+ <File
+ RelativePath=".\util.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+ <File
+ RelativePath=".\res\2arrow.ico">
+ </File>
+ <File
+ RelativePath=".\res\3keys.ico">
+ </File>
+ <File
+ RelativePath=".\res\3keys_d.ico">
+ </File>
+ <File
+ RelativePath=".\res\Add.ico">
+ </File>
+ <File
+ RelativePath=".\res\ARW05DN.ICO">
+ </File>
+ <File
+ RelativePath=".\res\ARW06DN.ICO">
+ </File>
+ <File
+ RelativePath=".\res\ARW06UP.ICO">
+ </File>
+ <File
+ RelativePath=".\res\cancel.ico">
+ </File>
+ <File
+ RelativePath=".\res\convert.ico">
+ </File>
+ <File
+ RelativePath=".\res\Delete.ico">
+ </File>
+ <File
+ RelativePath=".\res\FACE01.ICO">
+ </File>
+ <File
+ RelativePath=".\res\FACE02.ICO">
+ </File>
+ <File
+ RelativePath=".\res\H_POINT.CUR">
+ </File>
+ <File
+ RelativePath=".\res\help.ico">
+ </File>
+ <File
+ RelativePath=".\RES\ico00001.ico">
+ </File>
+ <File
+ RelativePath=".\res\ico00002.ico">
+ </File>
+ <File
+ RelativePath=".\res\ico00003.ico">
+ </File>
+ <File
+ RelativePath=".\RES\icon1.ico">
+ </File>
+ <File
+ RelativePath=".\res\info.ico">
+ </File>
+ <File
+ RelativePath=".\res\Key.ico">
+ </File>
+ <File
+ RelativePath=".\newkey.rc">
+ </File>
+ <File
+ RelativePath=".\res\OK.ico">
+ </File>
+ <File
+ RelativePath=".\res\Openfold.ico">
+ </File>
+ <File
+ RelativePath=".\RES\PC.ico">
+ </File>
+ <File
+ RelativePath=".\res\Pen.ico">
+ </File>
+ <File
+ RelativePath=".\res\v.ico">
+ </File>
+ <File
+ RelativePath=".\res\v2.ico">
+ </File>
+ <File
+ RelativePath=".\res\viet-off.ico">
+ </File>
+ <File
+ RelativePath=".\res\viet-on.ico">
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\gpl.txt">
+ </File>
+ <File
+ RelativePath="..\rtfio\rtfio.lib">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username
trung...@gmail.com/newkey/NewKey.vcproj.old Mon Oct 10 16:21:04 2011
@@ -0,0 +1,448 @@
+<?xml version="1.0" encoding = "windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.00"
+ Name="NewKey"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Unicode Release|Win32"
+ OutputDirectory=".\../URelease"
+ IntermediateDirectory=".\URelease"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="1">
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../keyhook,../vnconv"
+ PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS,UNICODE"
+ StringPooling="TRUE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="prehdr.h"
+ PrecompiledHeaderFile=".\URelease/NewKey.pch"
+ AssemblerListingLocation=".\URelease/"
+ ObjectFile=".\URelease/"
+ ProgramDataBaseFileName=".\URelease/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="Comdlg32.lib Advapi32.lib"
+ OutputFile="../URelease/UniKeyNT.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+
IgnoreDefaultLibraryNames="kernel32.lib,advapi32.lib,user32.lib,gdi32.lib,shell32.lib,comdlg32.lib,version.lib,mpr.lib,rasapi32.lib,winmm.lib,winspool.lib,vfw32.lib,secur32.lib,oleacc.lib,oledlg.lib,sensapi.lib"
+ ProgramDatabaseFile=".\../URelease/UniKeyNT.pdb"
+ SubSystem="2"
+ StackReserveSize="20000"
+ StackCommitSize="4096"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\../URelease/NewKey.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG,_UNICODE"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\../Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../keyhook,../vnconv"
+ PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="prehdr.h"
+ PrecompiledHeaderFile=".\Debug/NewKey.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="4"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="Comdlg32.lib"
+ OutputFile=".\../Debug/NewKey.exe"
+ LinkIncremental="2"
+ SuppressStartupBanner="TRUE"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile=".\../Debug/NewKey.pdb"
+ SubSystem="2"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\../Debug/NewKey.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG,_ANSI"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\../Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE">
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../keyhook,../vnconv"
+ PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
+ StringPooling="TRUE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="prehdr.h"
+ PrecompiledHeaderFile=".\Release/NewKey.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="Advapi32.lib Comdlg32.lib"
+ OutputFile="../Release/UniKey.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ ProgramDatabaseFile=".\../Release/UniKey.pdb"
+ SubSystem="2"
+ StackReserveSize="20000"
+ StackCommitSize="4096"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\../Release/NewKey.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG,_ANSI"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ </Configurations>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath=".\ExpDlg.cpp">
+ </File>
+ <File
+ RelativePath=".\about.cpp">
+ </File>
+ <File
+ RelativePath=".\button.cpp">
+ </File>
+ <File
+ RelativePath=".\encode.cpp">
+ </File>
+ <File
+ RelativePath=".\font.cpp">
+ </File>
+ <File
+ RelativePath=".\keydlg.cpp">
+ </File>
+ <File
+ RelativePath=".\label.cpp">
+ </File>
+ <File
+ RelativePath=".\macrodlg.cpp">
+ </File>
+ <File
+ RelativePath=".\mactab.cpp">
+ </File>
+ <File
+ RelativePath=".\mainwnd.cpp">
+ </File>
+ <File
+ RelativePath=".\odmenu.cpp">
+ </File>
+ <File
+ RelativePath=".\prehdr.cpp">
+ <FileConfiguration
+ Name="Unicode Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\smedit.cpp">
+ </File>
+ <File
+ RelativePath=".\tooldlg.cpp">
+ </File>
+ <File
+ RelativePath=".\ukmenu.cpp">
+ </File>
+ <File
+ RelativePath=".\userpref.cpp">
+ </File>
+ <File
+ RelativePath=".\util.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl">
+ <File
+ RelativePath=".\ExpDlg.h">
+ </File>
+ <File
+ RelativePath=".\about.h">
+ </File>
+ <File
+ RelativePath=".\button.h">
+ </File>
+ <File
+ RelativePath=".\encode.h">
+ </File>
+ <File
+ RelativePath=".\font.h">
+ </File>
+ <File
+ RelativePath=".\keydlg.h">
+ </File>
+ <File
+ RelativePath=".\label.h">
+ </File>
+ <File
+ RelativePath=".\macrodlg.h">
+ </File>
+ <File
+ RelativePath=".\mactab.h">
+ </File>
+ <File
+ RelativePath=".\mainwnd.h">
+ </File>
+ <File
+ RelativePath=".\odmenu.h">
+ </File>
+ <File
+ RelativePath=".\preHdr.h">
+ </File>
+ <File
+ RelativePath=".\smedit.h">
+ </File>
+ <File
+ RelativePath=".\tooldlg.h">
+ </File>
+ <File
+ RelativePath=".\ukmenu.h">
+ </File>
+ <File
+ RelativePath=".\userpref.h">
+ </File>
+ <File
+ RelativePath=".\util.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+ <File
+ RelativePath=".\res\2arrow.ico">
+ </File>
+ <File
+ RelativePath=".\res\3keys.ico">
+ </File>
+ <File
+ RelativePath=".\res\3keys_d.ico">
+ </File>
+ <File
+ RelativePath=".\res\ARW05DN.ICO">
+ </File>
+ <File
+ RelativePath=".\res\ARW06DN.ICO">
+ </File>
+ <File
+ RelativePath=".\res\ARW06UP.ICO">
+ </File>
+ <File
+ RelativePath=".\res\Add.ico">
+ </File>
+ <File
+ RelativePath=".\res\Delete.ico">
+ </File>
+ <File
+ RelativePath=".\res\FACE01.ICO">
+ </File>
+ <File
+ RelativePath=".\res\FACE02.ICO">
+ </File>
+ <File
+ RelativePath=".\res\H_POINT.CUR">
+ </File>
+ <File
+ RelativePath=".\res\Key.ico">
+ </File>
+ <File
+ RelativePath=".\res\OK.ico">
+ </File>
+ <File
+ RelativePath=".\res\Openfold.ico">
+ </File>
+ <File
+ RelativePath=".\RES\PC.ico">
+ </File>
+ <File
+ RelativePath=".\res\Pen.ico">
+ </File>
+ <File
+ RelativePath=".\res\cancel.ico">
+ </File>
+ <File
+ RelativePath=".\res\convert.ico">
+ </File>
+ <File
+ RelativePath=".\res\help.ico">
+ </File>
+ <File
+ RelativePath=".\RES\ico00001.ico">
+ </File>
+ <File
+ RelativePath=".\res\ico00002.ico">
+ </File>
+ <File
+ RelativePath=".\res\ico00003.ico">
+ </File>
+ <File
+ RelativePath=".\RES\icon1.ico">
+ </File>
+ <File
+ RelativePath=".\res\info.ico">
+ </File>
+ <File
+ RelativePath=".\newkey.rc">
+ </File>
+ <File
+ RelativePath=".\res\v.ico">
+ </File>
+ <File
+ RelativePath=".\res\v2.ico">
+ </File>
+ <File
+ RelativePath=".\res\viet-off.ico">
+ </File>
+ <File
+ RelativePath=".\res\viet-on.ico">
+ </File>
+ </Filter>
+ <File
+ RelativePath="..\Release\UKHook35.lib">
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="TRUE">
+ <Tool
+ Name="VCCustomBuildTool"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="TRUE">
+ <Tool
+ Name="VCCustomBuildTool"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\gpl.txt">
+ </File>
+ <File
+ RelativePath="..\Release\vnconv.lib">
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="TRUE">
+ <Tool
+ Name="VCCustomBuildTool"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="TRUE">
+ <Tool
+ Name="VCCustomBuildTool"/>
+ </FileConfiguration>
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/about.cpp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,171 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: uni...@gmail.com
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+//#include <windows.h>
+#include "prehdr.h"
+#include "resource.h"
+#include "mainwnd.h"
+#include "about.h"
+#include "userpref.h"
+#include "vnconv.h"
+
+#define UNIKEY_HOME_PAGE _TEXT("http://unikey.org")
+#define AUTHOR_EMAIL _TEXT("mailto:uni...@gmail.com")
+#define SUPPORT_HOME_PAGE _TEXT("http://unikey.org/forum")
+
+extern HINSTANCE AppInstance;
+extern CUserPref UserPref; // user preference
+
+AnsiDlgItemInfo VnAboutDlgItems[] = {
+ {IDC_AUTHOR, "T¸c gi¶: Ph¹m Kim Long, §¹i häc Kü thuËt Praha"},
+ {IDC_SUPPORT_PROVIDER, "DiÔn ®µn trî gióp:"},
+ {IDC_SUPPORT_LINK, "http://unikey.org/forum"},
+ {IDC_COPYRIGHT, "Copyright (C) 1998 - 2005 Ph¹m Kim Long"},
+ {IDC_INFO, " UniKey lµ ch­¬ng tr×nh m· nguån më. B¹n cã thÓ ph©n
phèi,\n"
+ " söa ®æi UniKey tu©n theo The GNU General Public License.\n"
+ " UniKey hç trî c¸c hÖ ®iÒu hµnh: Windows 9x/ME/NT/2000/XP."}};
+
+#define MAX_ITEM_LEN 256
+
+#ifdef _UNICODE
+
+wchar_t
UniVnAboutDlgTexts[sizeof(VnAboutDlgItems)/sizeof(AnsiDlgItemInfo)][MAX_ITEM_LEN];
+DlgItemInfo
UniVnAboutDlgItems[sizeof(VnAboutDlgItems)/sizeof(AnsiDlgItemInfo)];
+
+#endif
+
+BOOL CAboutDlg::DialogProc(
+ HWND hDlg, // handle to dialog box
+ UINT uMsg, // message
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+)
+{
+ switch (uMsg) {
+ case WM_DRAWITEM:
+ // Send the reflection message back to the control
+ return SendDlgItemMessage(hDlg, wParam, WM_DRAWITEM, wParam, lParam);
+ case WM_CTLCOLORSTATIC:
+ // Send the reflection message back to the control
+ return SendMessage((HWND)lParam, WM_CTLCOLORSTATIC, wParam, 0);
+ case WM_DESTROY:
+ DestroyCursor(m_hLinkCursor);
+ if (m_hStdFont != NULL) {
+ DeleteObject(m_hStdFont);
+ m_hStdFont = NULL;
+ }
+ break;
+ }
+ return CVirDialog::DialogProc(hDlg, uMsg, wParam, lParam);
+}
+
+//---------------------------------------------
+BOOL CAboutDlg::onInitDialog()
+{
+ if (!CVirDialog::onInitDialog()) return FALSE;
+ if (m_langID == 1) {
+ setItemsText(1);
+ setDlgFont(1);
+ }
+
+ //setup buttons
+ m_okBtn.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDOK));
+ //m_okBtn.setTextColor(RGB(255, 0, 0));
+ m_okBtn.setIcon(IDI_OK, 16, 16);
+ m_okBtn.setDefaultButton(TRUE);
+ //setup hyper-link labels
+ m_hLinkCursor = (HCURSOR)LoadImage(
+ m_hInst,
+ MAKEINTRESOURCE(IDC_HAND_CURSOR),
+ IMAGE_CURSOR, 32, 32, 0);
+ CLinkLabel::setLinkCursor(m_hLinkCursor);
+ m_webLink.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDC_WEB_LINK),
UNIKEY_HOME_PAGE);
+ m_supportLink.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDC_SUPPORT_LINK),
SUPPORT_HOME_PAGE);
+/*
+#ifndef _UNICODE
+ m_supportLink.setFontName(VIET_FONT_NAME);
+ m_supportLink.reconstructFont();
+#endif
+*/
+ //m_backupWebLink.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd,
IDC_BACKUP_WEB_LINK), UNIKEY_BACKUP_HOME_PAGE);
+ //m_mailLink.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDC_MAIL_LINK),
AUTHOR_EMAIL);
+
+ return TRUE;
+}
+//----------------------------------------------
+// set text labels according to the chosen GUI language
+// langID = 0 -> English (default)
+//----------------------------------------------
+void CAboutDlg::setItemsText(int langID)
+{
+ int items, i;
+// DlgItemInfo *texts;
+ if (langID == 0)
+ return; // default language is English, the texts are taken from the
resource
+// texts = VnAboutDlgItems;
+ items = sizeof(VnAboutDlgItems)/sizeof(AnsiDlgItemInfo);
+ for (i=0; i<items; i++) {
+#ifndef _UNICODE
+ SendDlgItemMessage(m_hWnd,
+ VnAboutDlgItems[i].id, WM_SETTEXT, 0,
+ (LPARAM)VnAboutDlgItems[i].text);
+#else
+ int inLen, maxOutLen;
+ wchar_t str[256];
+ inLen = -1;
+ maxOutLen = sizeof(str);
+ VnConvert(CONV_CHARSET_TCVN3, CONV_CHARSET_UNICODE,
+ (BYTE *)VnAboutDlgItems[i].text, (BYTE *)str,
+ inLen, maxOutLen);
+ SendDlgItemMessage(
+ m_hWnd,
+ VnAboutDlgItems[i].id,
+ WM_SETTEXT, 0, (LPARAM)str);
+#endif
+ }
+}
+
+//----------------------------------------------
+// set font for dialog items accoring to the selected GUI language
+// langID = 0 -> English (default)
+//----------------------------------------------
+void CAboutDlg::setDlgFont(int langID)
+{
+ if (m_hStdFont != NULL)
+ DeleteObject(m_hStdFont);
+ HDC hDC = GetDC(m_hWnd);
+ if (langID == 0)
+ m_hStdFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
+ else
+ m_hStdFont = CustomCreateFont(hDC, VIET_FONT_NAME, VIET_DLG_FONT_SIZE);
+ SendMessage(m_hWnd, WM_SETFONT, (WPARAM)m_hStdFont, TRUE);
+ HWND wndChild = GetTopWindow(m_hWnd);
+ for ( ; wndChild != NULL; wndChild = GetWindow(wndChild, GW_HWNDNEXT))
+ SendMessage(wndChild, WM_SETFONT, (WPARAM)m_hStdFont, TRUE);
+ ReleaseDC(m_hWnd, hDC);
+}
+
+//------------------------------------------------
+void DoAbout(HINSTANCE hInst, HWND hParent, int langID)
+{
+ CAboutDlg dlg(langID);
+ dlg.init(hInst, MAKEINTRESOURCE(IDD_ABOUT), hParent);
+ dlg.ShowDialog();
+}
+
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/about.h Mon
Oct 10 16:21:04 2011
@@ -0,0 +1,61 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#ifndef _ABOUT_DLG_H
+#define _ABOUT_DLG_H
+#include "util.h"
+#include "button.h"
+#include "label.h"
+
+void DoAbout(HINSTANCE hInst, HWND hParent, int langID);
+
+class CAboutDlg : public CVirDialog
+{
+protected:
+ CCustomButton m_okBtn;
+ CLinkLabel m_webLink, m_supportLink;
+ //CLinkLabel m_backupWebLink;
+ //CLinkLabel m_mailLink;
+ CSmLabel m_author;
+ HICON m_hLinkCursor;
+ HFONT m_hStdFont;
+ int m_langID; // 0: English, 1: Vietnamese
+public:
+ CAboutDlg(int langID = 0) : CVirDialog()
+ {
+ m_hStdFont = NULL;
+ m_langID = langID;
+ }
+ // Overrides
+ virtual BOOL DialogProc(
+ HWND hWndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam);
+ virtual BOOL onInitDialog();
+ void setItemsText(int langID);
+ void setDlgFont(int langID);
+ void setLangID(int langID)
+ {
+ m_langID = langID;
+ }
+ friend void DoAbout(HINSTANCE hInst, HWND hParent, int langID);
+};
+
+#endif
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/button.cpp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,422 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#include "prehdr.h"
+#include "button.h"
+
+#define RECT_WIDTH(r) (r.right - r.left)
+#define RECT_HEIGHT(r) (r.bottom - r.top)
+
+int IsPushButton(HWND hWnd)
+{
+ if (!(SendMessage(hWnd, WM_GETDLGCODE, 0, 0) & DLGC_BUTTON))
+ return 0;
+
+ // button type is represented by only last 4 bits of window style
+ // ==> not portable code, always check button styles in winuser.h for
possible changes
+ long btnType = GetWindowLong(hWnd, GWL_STYLE) & 0xFL;
+
+ // Consider owner-draw buttons as push buttons
+ return (btnType == BS_PUSHBUTTON || btnType == BS_DEFPUSHBUTTON ||
btnType == BS_OWNERDRAW);
+}
+
+LRESULT CALLBACK CustomBtnProc(
+ HWND hWnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+ )
+{
+ CCustomButton *pBtn = (CCustomButton *)GetWindowLong(hWnd, GWL_USERDATA);
+ if (pBtn)
+ return pBtn->wndProc(hWnd, uMsg, wParam, lParam);
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
+}
+
+//-------------------------------------------------------
+void CCustomButton::attachWindow(HWND hWnd)
+{
+ m_hWnd = hWnd;
+ SetWindowLong(hWnd, GWL_USERDATA, (LONG)this);
+ // Subclass the button
+ m_prevWndProc = SetWindowLong(hWnd, GWL_WNDPROC, (LONG)CustomBtnProc);
+}
+
+//-------------------------------------------------------
+LRESULT CCustomButton::wndProc(
+ HWND hWnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam) // second message parameter
+{
+ switch (uMsg) {
+ case WM_DRAWITEM:
+ drawItem((LPDRAWITEMSTRUCT)lParam);
+ return TRUE;
+ case WM_SETFOCUS:
+ onSetFocus((HWND)wParam);
+ break;
+ case WM_KILLFOCUS:
+ onKillFocus((HWND)wParam);
+ break;
+ case CBM_SETDEFAULT:
+ setDefaultButton(wParam ? TRUE : FALSE);
+ redraw();
+ return 1;
+ }
+ return CallWindowProc((WNDPROC)m_prevWndProc, hWnd, uMsg, wParam, lParam);
+}
+
+void CCustomButton::redraw()
+{
+ InvalidateRect(m_hWnd, NULL, TRUE);
+}
+//-------------------------------------------------------
+void CCustomButton::onSetFocus(HWND prevFocus)
+{
+ if (!isDefaultButton()) {
+ setDefaultButton(TRUE);
+ redraw();
+ }
+ if (!IsPushButton(prevFocus)) {
+ WORD defId = LOWORD(SendMessage(m_hOwner, DM_GETDEFID, 0, 0));
+ if (defId && GetDlgItem(m_hOwner, defId) != m_hWnd)
+ SendDlgItemMessage(m_hOwner, defId, CBM_SETDEFAULT, 0, 0);
+ }
+}
+
+//-------------------------------------------------------
+void CCustomButton::onKillFocus(HWND newFocus)
+{
+ int newIsButton = IsPushButton(newFocus);
+ WORD defId = LOWORD(SendMessage(m_hOwner, DM_GETDEFID, 0, 0));
+ HWND hDefWnd = GetDlgItem(m_hOwner, defId);
+ if (isDefaultButton() && (m_hWnd != hDefWnd || newIsButton)) {
+ setDefaultButton(FALSE);
+ redraw();
+ }
+ if (!newIsButton && m_hWnd != hDefWnd)
+ SendDlgItemMessage(m_hOwner, defId, CBM_SETDEFAULT, 1, 0);
+}
+
+//-------------------------------------------------------
+void CCustomButton::init(HINSTANCE hInst, HWND hOwner, HWND hWndMe)
+{
+ m_hInstance = hInst;
+ m_hOwner = hOwner;
+ attachWindow(hWndMe);
+
+ m_hIcon = 0;
+// m_hBitmap = 0;
+// m_hBitmapDisabled = 0;
+
+ m_bDefault = FALSE;
+ m_nOldState = 0;
+ m_nOldAction = 0;
+
+ m_textColor = RGB(0, 0, 0);
+
+
+ m_nImageOffsetFromBorder = 4;
+ m_nTextOffsetFromImage = 4;
+ m_bUseOffset = TRUE;
+ m_pointImage.x = m_pointImage.y = 0;
+ m_pointText.x = m_pointText.y = 0;
+
+}
+
+/*
+//-------------------------------------------------------
+CCustomButton::CCustomButton()
+{
+ m_hWnd = NULL;
+ m_hInstance = NULL;
+
+ m_hIcon = 0;
+// m_hBitmap = 0;
+// m_hBitmapDisabled = 0;
+
+ m_textColor = RGB(0, 0, 0);
+
+ m_bDefault = FALSE;
+ m_nOldState = 0;
+ m_nOldAction = 0;
+
+ m_nImageOffsetFromBorder = 4;
+ m_nTextOffsetFromImage = 8;
+ m_bUseOffset = TRUE;
+ m_pointImage.x = m_pointImage.y = 0;
+ m_pointText.x = m_pointText.y = 0;
+}
+*/
+
+//-------------------------------------------------------
+CCustomButton::~CCustomButton()
+{
+ if( m_hIcon != 0 )
+ DestroyIcon(m_hIcon); //DeleteObject( m_hIcon );
+// if( m_hBitmap != 0 )
+// DeleteObject( m_hBitmap );
+// if( m_hBitmapDisabled != 0 )
+// DeleteObject( m_hBitmapDisabled );
+}
+
+//-------------------------------------------------------
+BOOL CCustomButton::setIcon( UINT nID, int nWidth, int nHeight )
+{
+ if (m_hIcon != NULL)
+ DestroyIcon(m_hIcon);
+ m_hIcon = (HICON)::LoadImage(m_hInstance,
+ MAKEINTRESOURCE(nID),
+ IMAGE_ICON, nWidth, nHeight, 0);
+
+ if( m_hIcon == NULL )
+ return FALSE;
+
+ m_nImageWidth = nWidth;
+ m_nImageHeight = nHeight;
+
+// m_hBitmap = 0;
+ return TRUE;
+}
+
+
+//-------------------------------------------------------
+BOOL CCustomButton::setDefaultButton( BOOL bState )
+{
+ BOOL bPrevious = m_bDefault;
+ m_bDefault = bState;
+
+ return bPrevious;
+}
+
+// Positioning Functions
+//-------------------------------------------------------
+int CCustomButton::setImageOffset( int nPixels )
+{
+ int nPrevious = m_nImageOffsetFromBorder;
+
+ m_bUseOffset = TRUE;
+ m_nImageOffsetFromBorder = nPixels;
+ return nPrevious;
+}
+
+//-------------------------------------------------------
+int CCustomButton::setTextOffset( int nPixels )
+{
+ int nPrevious = m_nTextOffsetFromImage;
+
+ m_bUseOffset = TRUE;
+ m_nTextOffsetFromImage = nPixels;
+
+ return nPrevious;
+}
+
+//-------------------------------------------------------
+POINT CCustomButton::setImagePos(const POINT & p )
+{
+ POINT pointPrevious = m_pointImage;
+
+ m_bUseOffset = FALSE;
+ m_pointImage = p;
+
+ return pointPrevious;
+}
+
+//-------------------------------------------------------
+POINT CCustomButton::setTextPos(const POINT & p )
+{
+ POINT pointPrevious = m_pointText;
+
+ m_bUseOffset = FALSE;
+ m_pointText = p;
+
+ return pointPrevious;
+}
+
+//-------------------------------------------------------
+// Centering a point helper function
+//-------------------------------------------------------
+void CCustomButton::checkPointForCentering( POINT &p, int nWidth, int
nHeight)
+{
+ RECT rect;
+ GetClientRect(m_hWnd, &rect);
+
+ if( p.x == CUSTOMBUTTON_CENTER )
+ p.x = (RECT_WIDTH(rect) - nWidth) >> 1;
+ if( p.y == CUSTOMBUTTON_CENTER )
+ p.y = (RECT_HEIGHT(rect) - nHeight) >> 1;
+}
+
+//-------------------------------------------------------
+void CCustomButton::drawItem(LPDRAWITEMSTRUCT lpDIS)
+{
+ TCHAR text[100];
+ RECT rect = lpDIS->rcItem;
+
+ UINT nOffset = 0; // For position adjustment of a pushed button
+ UINT nFrameStyle=0;
+ BOOL bDRAWFOCUSONLY = FALSE; // Optimize a bit
+ int nStateFlag; // Normal or Disabled
+// HBITMAP hBitmapToDraw; // Normal or Disabled bitmap (not used if uses
icon)
+
+ UINT nNewState = lpDIS->itemState;
+ UINT nNewAction = lpDIS->itemAction;
+
+ // Find out what state the control and set some drawing flags
+ // according to the state.
+ if ( nNewState & ODS_SELECTED)
+ {
+ nFrameStyle = DFCS_PUSHED;
+ nOffset += 1;
+ }
+
+ if( nNewState & ODS_DISABLED )
+ {
+ nStateFlag = DSS_DISABLED;
+// hBitmapToDraw = m_hBitmapDisabled;
+ }
+ else
+ {
+ nStateFlag = DSS_NORMAL;
+// hBitmapToDraw = m_hBitmap;
+ }
+
+ // If only the focus is changing, don't redraw the whole control
+ if (nNewAction == ODA_FOCUS )
+ bDRAWFOCUSONLY = TRUE;
+
+ // If this is the default button, deflate the control so everything
+ // we do below (icon, text, focus ) is adjusted properly
+ if( m_bDefault )
+ InflateRect(&rect, -1, -1);
+
+ if( !bDRAWFOCUSONLY )
+ {
+ //
+ // Draw 'default button' rectangle
+ //
+ if( m_bDefault ) // Can't use ODS_DEFAULT w/owner draw!!
+ {
+ HGDIOBJ hOldPen = SelectObject(lpDIS->hDC, GetStockObject(BLACK_PEN));
+ Rectangle(lpDIS->hDC, lpDIS->rcItem.left, lpDIS->rcItem.top,
lpDIS->rcItem.right, lpDIS->rcItem.bottom);
+ SelectObject(lpDIS->hDC, hOldPen);
+ }
+
+ //
+ // Draw button frame
+ //
+ if (GetWindowLong(m_hWnd, GWL_STYLE) & BS_FLAT)
+ nFrameStyle |= DFCS_FLAT;
+ DrawFrameControl(lpDIS->hDC, &rect, DFC_BUTTON, DFCS_BUTTONPUSH |
nFrameStyle);
+
+ // Get control text
+ GetWindowText(m_hWnd, text, sizeof(text)/sizeof(TCHAR));
+ //
+ // Draw Image
+ //
+ if( hasImage() )
+ {
+ POINT pt;
+
+ if( m_bUseOffset )
+ {
+ pt.x = (text[0] == 0) ? CUSTOMBUTTON_CENTER : rect.left +
m_nImageOffsetFromBorder;
+ pt.y = CUSTOMBUTTON_CENTER;
+ }
+ else
+ pt = m_pointImage;
+
+ checkPointForCentering( pt, m_nImageWidth, m_nImageHeight );
+
+ pt.x += nOffset;
+ pt.y += nOffset;
+
+ if( m_hIcon )
+ DrawState(lpDIS->hDC, NULL, NULL, (LPARAM)m_hIcon, 0, pt.x, pt.y,
m_nImageWidth, m_nImageHeight, DST_ICON | nStateFlag);
+ //else if( m_hBitmap )
+ // pDC->DrawState( pt, CSize(m_nImageWidth, m_nImageHeight),
(HBITMAP)hBitmapToDraw, DST_BITMAP | nStateFlag );
+ }
+ //
+ // Draw Text
+ //
+ if ( text[0] != 0)
+ {
+ POINT pt;
+ SIZE size;
+ GetTextExtentPoint32(lpDIS->hDC, text, _tcslen(text), &size);
+ if( m_bUseOffset )
+ {
+ RECT rcClient;
+ GetClientRect(m_hWnd, &rcClient);
+ if (hasImage()) {
+ if (RECT_WIDTH(rcClient)
+ - (m_nImageWidth + m_nTextOffsetFromImage + m_nImageOffsetFromBorder)
+ - size.cx > 0)
+ pt.x = m_nImageWidth + m_nTextOffsetFromImage +
m_nImageOffsetFromBorder;
+ else
+ pt.x = m_nImageWidth + m_nImageOffsetFromBorder +
2;//m_nTextOffsetFromImage;
+ }
+ else pt.x = CUSTOMBUTTON_CENTER;
+ pt.y = CUSTOMBUTTON_CENTER;
+ }
+ else
+ pt = m_pointText;
+
+ // If we are centering the text vertically, it looks best of we
+ // center based on the height of the text, then move it up 1 more pixel
+ int nOffsetFixY = pt.y == CUSTOMBUTTON_CENTER ? -1 : 0;
+
+ checkPointForCentering( pt, size.cx, size.cy);
+
+ pt.x += nOffset;
+ pt.y += nOffset + nOffsetFixY;
+ COLORREF oldColor = SetTextColor(lpDIS->hDC, m_textColor);
+ DrawState(lpDIS->hDC, NULL, NULL, (LPARAM)text, 0, pt.x, pt.y, 0, 0,
DST_PREFIXTEXT|nStateFlag);
+ SetTextColor(lpDIS->hDC, oldColor);
+ }
+
+ } // End !focus only
+
+ //
+ // Draw focus rectange
+ //
+ if( !( nNewState & ODS_DISABLED ) ) // Make sure it's not disabled
+ {
+ // Redraw the focus if:
+ // 1. There is a change in focus state
+ // OR 2. The entire control was just redrawn and Focus is set
+ if( ( nNewState & ODS_FOCUS ) ^ ( m_nOldState & ODS_FOCUS ) ||
+ ( !bDRAWFOCUSONLY && ( nNewState & ODS_FOCUS ) ) )
+ {
+
+ #define FOCUSOFFSET 3
+ RECT tempRect = rect;
+
+ // As control gets smaller, decrease focus size
+ int nDeflate = min( FOCUSOFFSET,
+ min( RECT_WIDTH(tempRect), RECT_HEIGHT(tempRect)) >> 2 );
+ InflateRect(&tempRect, -nDeflate, -nDeflate);
+ DrawFocusRect(lpDIS->hDC, &tempRect);
+ }
+ }
+
+ m_nOldAction = nNewAction;
+ m_nOldState = nNewState;
+}
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/button.h Mon
Oct 10 16:21:04 2011
@@ -0,0 +1,113 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#ifndef __CUSTOM_BUTTON_H
+#define __CUSTOM_BUTTON_H
+
+#define CUSTOMBUTTON_CENTER -1
+
+//-----------------------------------------------
+// Message: Set default button
+// wParam = 1: Set, wParam = 0 clear
+//-----------------------------------------------
+#define CBM_SETDEFAULT (WM_USER + 1)
+
+//----------------------------------------------
+// Check if a control is a push button (owner-draw button included)
+//----------------------------------------------
+int IsPushButton(HWND hWnd);
+
+LRESULT CALLBACK CustomBtnProc(
+ HWND hwnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+ );
+
+class CCustomButton {
+public:
+ HWND m_hWnd;
+ HINSTANCE m_hInstance;
+ //CCustomButton();
+ ~CCustomButton();
+ void init(HINSTANCE hInst, HWND hOwner, HWND hWndMe);
+ void drawItem(LPDRAWITEMSTRUCT lpDIS);
+ BOOL setIcon( UINT nID, int nWidth, int nHeight);
+ BOOL setDefaultButton( BOOL bState ); // returns previous state
+ BOOL isDefaultButton()
+ {
+ return m_bDefault;
+ }
+ int setImageOffset( int nPixels ); // returns previous state
+ int setTextOffset( int nPixels );
+ POINT setImagePos(const POINT & p);
+ POINT setTextPos(const POINT & p );
+ void checkPointForCentering( POINT & p, int nWidth, int nHeight );
+ void setTextColor(COLORREF color)
+ {
+ m_textColor = color;
+ }
+
+ BOOL hasImage()
+ {
+ return (BOOL)( m_hIcon != 0);
+ }
+ void redraw();
+protected:
+ virtual LRESULT wndProc(
+ HWND hwnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+ );
+ virtual void onSetFocus(HWND prevFocus);
+ virtual void onKillFocus(HWND newFocus);
+
+ HWND m_hOwner;
+ LONG m_prevWndProc;
+ // Positioning
+ BOOL m_bUseOffset;
+ POINT m_pointImage;
+ POINT m_pointText;
+ int m_nImageOffsetFromBorder;
+ int m_nTextOffsetFromImage;
+ // color
+ COLORREF m_textColor;
+ // Image
+ HICON m_hIcon;
+// HBITMAP m_hBitmap;
+// HBITMAP m_hBitmapDisabled;
+ int m_nImageWidth, m_nImageHeight;
+
+ // State
+ BOOL m_bDefault;
+ UINT m_nOldAction;
+ UINT m_nOldState;
+
+ friend LRESULT CALLBACK ::CustomBtnProc(
+ HWND hwnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+ );
+private:
+ void attachWindow(HWND hWnd);
+};
+
+#endif
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/encode.cpp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,712 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#include "prehdr.h"
+#include "keyhook.h"
+#include "encode.h"
+#include "vnconv.h"
+
+#include <stdio.h>
+/*
+Explanation of encoding in DT table:
+In DT:
+- Bits 0-4: index of vowels
+- Bits 5-8: index of macro keys (e.g. TELEX: w, W, [, ]
+- Bits 9-13: index of double characters (including: a, d, e, o, a^, dd,
e^, o^, a(, u+...)
+- Bits 14-17: index of tone marks
+- Bits 18-21: determines the index of the tone associated with a
character, e.g tone_index(a') = 1.
+- Bit 22: is set if this character is used to type a breve. (in telex,
they are w, W)
+- Bit 24: soft separator. Soft separators don't cause the buffer to be
cleared.
+- Bit 25: separator flag. Buffer must be cleared when separator character
is encountered.
+- Bit 26-28: index of VNI double marks ('6', '7', '8', '9')
+- Bit 29: Word stops
+*/
+
+
+/*/////////////////////////////////////////////////////////////////////
+
+STEPS TO ADD NEW CHARSETS
+
+1. For 1-byte charsets
+- Append charset to the end of table MapBD, MapBK, MapBW, MapBT
+- Insert charset information into CharsetTable (to any position you like),
provide following information:
+ + Charset name
+ + The index of the charset in the table MapBD (the same as in MapBK,
MapBW, MapBT)
+- Increase TOTAL_CHARSET constant (in keycons.h) by 1 to reflex the number
of supported charsets
+
+2. For 2-byte charsets
+- Append charset to the end of BOTH tables UniVnL (for lowercase), UniVnH
(for upper case)
+- Insert charset information into CharsetTable (to any position you like),
provide following information:
+ + Charset name
+ + The index of the charset in the tables UniVnL (the same as in UniVnH)
PLUS 0x101
+- Increase TOTAL_CHARSET constant by 1 in keycons.h to reflex the number
of supported charsets
+
+//////////////////////////////////////////////////////////////////////*/
+CharsetInfo CharsetTable[TOTAL_CHARSET] = {
+ {_TEXT("Unicode"), 0x101, CONV_CHARSET_UNICODE, UNICODE_UCS2},
+ {_TEXT("TCVN3 (ABC)"), 0, CONV_CHARSET_TCVN3, 0},
+ {_TEXT("VNI Windows"), 0x102, CONV_CHARSET_VNIWIN, 0},
+ {_TEXT("VIQR"), 0x100, CONV_CHARSET_VIQR, 0},
+ {_TEXT("Vietnamese locale CP 1258"), 0x109, CONV_CHARSET_WINCP1258, 0},
+ {_TEXT("UTF-8 Literal"), 0x101, CONV_CHARSET_UNIUTF8, UNICODE_UTF8},
+ {_TEXT("NCR Decimal"), 0x101, CONV_CHARSET_UNIREF, UNICODE_REF},
+ {_TEXT("NCR Hex"), 0x101, CONV_CHARSET_UNIREF_HEX,UNICODE_HEX},
+ {_TEXT("Composite Unicode (To hop)"), 0x108, CONV_CHARSET_UNIDECOMPOSED,
0},
+ {_TEXT("VISCII"), 0x106, CONV_CHARSET_VISCII, 0},
+ {_TEXT("VPS"), 0x104, CONV_CHARSET_VPS, 0},
+ {_TEXT("BK HCM 2"), 0x103, CONV_CHARSET_BKHCM2, 0},
+ {_TEXT("BK HCM 1"), 0x107, CONV_CHARSET_BKHCM1, 0},
+ {_TEXT("Vietware X"), 0x105, CONV_CHARSET_VIETWAREX, 0},
+ {_TEXT("Vietware F"), 1, CONV_CHARSET_VIETWAREF, 0},
+ {_TEXT("X UTF-8"), 0x101, CONV_CHARSET_UNIUTF8, UNICODE_UTF8_X},
+ {_TEXT("Unicode C String"), 0x101, CONV_CHARSET_UNI_CSTRING,
UNICODE_CSTRING}
+};
+
+////////////////////////////////////
+// 1-byte charsets
+////////////////////////////////////
+unsigned char MapBD[][12][6] = {
+//TCVN 3
+ {{'¸','µ','¶','·','¹','a'}, // 0: a
+ {'Ê','Ç','È','É','Ë','©'}, // 1: a^
+ {'¾','»','¼','½','Æ','¨'}, // 2: a(
+ {'Ð','Ì','Î','Ï','Ñ','e'}, // 3: e
+ {'Õ','Ò','Ó','Ô','Ö','ª'}, // 4: e^
+ {'Ý','×','Ø','Ü','Þ','i'}, // 5: i
+ {'ã','ß','á','â','ä','o'}, // 6: o
+ {'è','å','æ','ç','é','«'}, // 7: o^
+ {'í','ê','ë','ì','î','¬'}, // 8: o+
+ {'ó','ï','ñ','ò','ô','u'}, // 9: u
+ {'ø','õ','ö','÷','ù','­'}, //10: u+
+ {'ý','ú','û','ü','þ','y'}}, //11: y
+//Vietware-F
+ {{'À','ª','¶','º','Á','a'},
+ {'Ê','Ç','È','É','Ë','¡'},
+ {'Å','Â','Ã','Ä','Æ','Ÿ'},
+ {'Ï','Ì','Í','Î','Ñ','e'},
+ {'Õ','Ò','Ó','Ô','Ö','£'},
+ {'Û','Ø','Ù','Ú','Ü','i'},
+ {'â','ß','à','á','ã','o'},
+ {'ç','ä','å','æ','è','¤'},
+ {'ì','é','ê','ë','í','¥'},
+ {'ò','î','ï','ñ','ó','u'},
+ {'÷','ô','õ','ö','ø','§'},
+ {'ü','ù','ú','û','ÿ','y'}}
+};
+
+
+unsigned char MapBK[][8] = {
+ {'®', '§', 'ª', '£', '©', '¢', '«', '¤'}, //TCVN3
+ {'¢', '˜', '£', '™', '¡', '—', '¤', 'š'} //Vietware-F
+};
+
+
+unsigned char MapBW[][6] = {
+ {'¨', '¡', '¬', '¥', '­', '¦'}, //TCVNI3
+ {'Ÿ', '–', '¥', '›', '§', 'œ'} //Vietware-F
+};
+
+unsigned char MapBT[][6] = { // this tables must correspond to
TelexShortcuts table
+ {'¬', '­', '­', '¦', '¥', '¦'}, //TCVN3
+ {'¥', '§', '§', 'œ', '¦', '§'} //Vietware-F
+};
+
+/*
+unsigned char
VnLayout[]={'ã', 'â', 'ê', 'ô', 'Ì', 'Ò', 'Þ', 'ì', 'ò', 'ð', 'þ', 'ý', 'õ',
+ 'Ã', 'Â', 'Ê', 'Ô', 'Ð',
+
+
+unsigned char
USLayout[]={'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '=', '[', ']',
+ '!', '@', '#', '$', ')'
+*/
+
+//////////////////////////////////////////////////
+// Unicode and 2-byte charsets
+//////////////////////////////////////////////////
+
+// Lower case
+WORD UniVnL[][72] = {
+//Unicode
+ {0x00e1, 0x00e0, 0x1ea3, 0x00e3, 0x1ea1, 0x0061,
+ 0x1ea5, 0x1ea7, 0x1ea9, 0x1eab, 0x1ead, 0x00e2,
+ 0x1eaf, 0x1eb1, 0x1eb3, 0x1eb5, 0x1eb7, 0x0103,
+ 0x00e9, 0x00e8, 0x1ebb, 0x1ebd, 0x1eb9, 0x0065,
+ 0x1ebf, 0x1ec1, 0x1ec3, 0x1ec5, 0x1ec7, 0x00ea,
+ 0x00ed, 0x00ec, 0x1ec9, 0x0129, 0x1ecb, 0x0069,
+ 0x00f3, 0x00f2, 0x1ecf, 0x00f5, 0x1ecd, 0x006f,
+ 0x1ed1, 0x1ed3, 0x1ed5, 0x1ed7, 0x1ed9, 0x00f4,
+ 0x1edb, 0x1edd, 0x1edf, 0x1ee1, 0x1ee3, 0x01a1,
+ 0x00fa, 0x00f9, 0x1ee7, 0x0169, 0x1ee5, 0x0075,
+ 0x1ee9, 0x1eeb, 0x1eed, 0x1eef, 0x1ef1, 0x01b0,
+ 0x00fd, 0x1ef3, 0x1ef7, 0x1ef9, 0x1ef5, 0x0079},
+//VNI
+ {0xf961, 0xf861, 0xfb61, 0xf561, 0xef61, 0x0061,
+ 0xe161, 0xe061, 0xe561, 0xe361, 0xe461, 0xe261,
+ 0xe961, 0xe861, 0xfa61, 0xfc61, 0xeb61, 0xea61,
+ 0xf965, 0xf865, 0xfb65, 0xf565, 0xef65, 0x0065,
+ 0xe165, 0xe065, 0xe565, 0xe365, 0xe465, 0xe265,
+ 0x00ed, 0x00ec, 0x00e6, 0x00f3, 0x00f2, 0x0069,
+ 0xf96f, 0xf86f, 0xfb6f, 0xf56f, 0xef6f, 0x006f,
+ 0xe16f, 0xe06f, 0xe56f, 0xe36f, 0xe46f, 0xe26f,
+ 0xf9f4, 0xf8f4, 0xfbf4, 0xf5f4, 0xeff4, 0x00f4,
+ 0xf975, 0xf875, 0xfb75, 0xf575, 0xef75, 0x0075,
+ 0xf9f6, 0xf8f6, 0xfbf6, 0xf5f6, 0xeff6, 0x00f6,
+ 0xf979, 0xf879, 0xfb79, 0xf579, 0x00ee, 0x0079},
+//BKHCM2
+ {0xe161, 0xe261, 0xe361, 0xe461, 0xe561, 0x0061,
+ 0xebea, 0xecea, 0xEDEA, 0xEEEA, 0xE5EA, 0x00EA,
+ 0xE6F9, 0xE7F9, 0xE8F9, 0xE9F9, 0xE5F9, 0x00F9,
+ 0xE165, 0xE265, 0xE365, 0xE465, 0xE565, 0x0065,
+ 0xEBEF, 0xECEF, 0xEDEF, 0xEEEF, 0xE5EF, 0x00EF,
+ 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x0069,
+ 0xE16F, 0xE26F, 0xE36F, 0xE46F, 0xE56F, 0x006F,
+ 0xEBF6, 0xECF6, 0xEDF6, 0xEEF6, 0xE5F6, 0x00F6,
+ 0xE1FA, 0xE2FA, 0xE3FA, 0xE4FA, 0xE5FA, 0x00FA,
+ 0xE175, 0xE275, 0xE375, 0xE475, 0xE575, 0x0075,
+ 0xE1FB, 0xE2FB, 0xE3FB, 0xE4FB, 0xE5FB, 0x00FB,
+ 0xE179, 0xE279, 0xE379, 0xE479, 0xE579, 0x0079},
+//VPS
+ {0x00E1, 0x00E0, 0x00E4, 0x00E3, 0x00E5, 0x0061,
+ 0x00C3, 0x00C0, 0x00C4, 0x00C5, 0x00C6, 0x00E2,
+ 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00E6,
+ 0x00E9, 0x00E8, 0x00C8, 0x00EB, 0x00CB, 0x0065,
+ 0x0089, 0x008A, 0x008B, 0x00CD, 0x008C, 0x00EA,
+ 0x00ED, 0x00EC, 0x00CC, 0x00EF, 0x00CE, 0x0069,
+ 0x00F3, 0x00F2, 0x00D5, 0x00F5, 0x0086, 0x006F,
+ 0x00D3, 0x00D2, 0x00B0, 0x0087, 0x00B6, 0x00F4,
+ 0x00A7, 0x00A9, 0x00AA, 0x00AB, 0x00AE, 0x00D6,
+ 0x00FA, 0x00F9, 0x00FB, 0x00DB, 0x00F8, 0x0075,
+ 0x00D9, 0x00D8, 0x00BA, 0x00BB, 0x00BF, 0x00DC,
+ 0x009A, 0x00FF, 0x009B, 0x00CF, 0x009C, 0x0079},
+//VIETWARE X
+ {0xEF61, 0xEC61, 0xED61, 0xEE61, 0xFB61, 0x0061,
+ 0xFAE1, 0xF6E1, 0xF8E1, 0xF9E1, 0xFBE1, 0x00E1,
+ 0xF5E0, 0xF2E0, 0xF3E0, 0xF4E0, 0xFBE0, 0x00E0,
+ 0xEF65, 0xEC65, 0xED65, 0xEE65, 0xFB65, 0x0065,
+ 0xFAE3, 0xF6E3, 0xF8E3, 0xF9E3, 0xFBE3, 0x00E3,
+ 0x00EA, 0x00E7, 0x00E8, 0x00E9, 0x00EB, 0x0069,
+ 0xEF6F, 0xEC6F, 0xED6F, 0xEE6F, 0xFC6F, 0x006F,
+ 0xFAE4, 0xF6E4, 0xF8E4, 0xF9E4, 0xFCE4, 0x00E4,
+ 0xEFE5, 0xECE5, 0xEDE5, 0xEEE5, 0xFCE5, 0x00E5,
+ 0xEF75, 0xEC75, 0xED75, 0xEE75, 0xFB75, 0x0075,
+ 0xEFE6, 0xECE6, 0xEDE6, 0xEEE6, 0xFBE6, 0x00E6,
+ 0xEF79, 0xEC79, 0xED79, 0xEE79, 0xF179, 0x0079},
+//VISCII
+ {0x00E1, 0x00E0, 0x00E4, 0x00E3, 0x00D5, 0x0061,
+ 0x00A4, 0x00A5, 0x00A6, 0x00E7, 0x00A7, 0x00E2,
+ 0x00A1, 0x00A2, 0x00C6, 0x00C7, 0x00A3, 0x00E5,
+ 0x00E9, 0x00E8, 0x00EB, 0x00A8, 0x00A9, 0x0065,
+ 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00EA,
+ 0x00ED, 0x00EC, 0x00EF, 0x00EE, 0x00B8, 0x0069,
+ 0x00F3, 0x00F2, 0x00F6, 0x00F5, 0x00F7, 0x006F,
+ 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B5, 0x00F4,
+ 0x00BE, 0x00B6, 0x00B7, 0x00DE, 0x00FE, 0x00BD,
+ 0x00FA, 0x00F9, 0x00FC, 0x00FB, 0x00F8, 0x0075,
+ 0x00D1, 0x00D7, 0x00D8, 0x00E6, 0x00F1, 0x00DF,
+ 0x00FD, 0x00CF, 0x00D6, 0x00DB, 0x00DC, 0x0079},
+//BKHCM1
+ {0x00BE, 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x0061,
+ 0x00DE, 0x00DF, 0x00E0, 0x00E1, 0x00E2, 0x00DD,
+ 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00D7,
+ 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x0065,
+ 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E3,
+ 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x0069,
+ 0x00CD, 0x00CE, 0x00CF, 0x00D0, 0x00D1, 0x006F,
+ 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00E9,
+ 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00EF,
+ 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x0075,
+ 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00F5,
+ 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF, 0x0079},
+//composed unicode
+// composite bases that are greater than FF
+// 0: A( 0x102
+// 1: a( 0x103
+// 2: O+ 0x1A0
+// 3: o+ 0x1A1
+// 4: U+ 0x1AF
+// 5: u+ 0x1B0
+// 6: DD 0x110
+// 7: dd 0x111
+//
+// Use high byte as the index to the tone table below:
+// 1: '
+// 2: `
+// 3: ?
+// 4: ~
+// 5: .
+ {0x0161, 0x0261, 0x0361, 0x0461, 0x0561, 0x0061, //a
+ 0x01e2, 0x02e2, 0x03e2, 0x04e2, 0x05e2, 0x00e2, //a^
+ 0x0101, 0x0201, 0x0301, 0x0401, 0x0501, 0x0001, //a(
+ 0x0165, 0x0265, 0x0365, 0x0465, 0x0565, 0x0065, //e
+ 0x01ea, 0x02ea, 0x03ea, 0x04ea, 0x05ea, 0x00ea, //e^
+ 0x0169, 0x0269, 0x0369, 0x0469, 0x0569, 0x0069, //i
+ 0x016f, 0x026f, 0x036f, 0x046f, 0x056f, 0x006f, //o
+ 0x01f4, 0x02f4, 0x03f4, 0x04f4, 0x05f4, 0x00f4, //o^
+ 0x0103, 0x0203, 0x0303, 0x0403, 0x0503, 0x0003, //o+
+ 0x0175, 0x0275, 0x0375, 0x0475, 0x0575, 0x0075, //u
+ 0x0105, 0x0205, 0x0305, 0x0405, 0x0505, 0x0005, //u+
+ 0x0179, 0x0279, 0x0379, 0x0479, 0x0579, 0x0079}, //y
+// Windows CP 1258
+ {0xec61, 0xcc61, 0xd261, 0xde61, 0xf261, 0x0061, //a
+ 0xece2, 0xcce2, 0xd2e2, 0xdee2, 0xf2e2, 0x00e2, //a^
+ 0xece3, 0xcce3, 0xd2e3, 0xdee3, 0xf2e3, 0x00e3, //a(
+ 0xec65, 0xcc65, 0xd265, 0xde65, 0xf265, 0x0065, //e
+ 0xecea, 0xccea, 0xd2ea, 0xdeea, 0xf2ea, 0x00ea, //e^
+ 0xec69, 0xcc69, 0xd269, 0xde69, 0xf269, 0x0069, //i
+ 0xec6f, 0xcc6f, 0xd26f, 0xde6f, 0xf26f, 0x006f, //o
+ 0xecf4, 0xccf4, 0xd2f4, 0xdef4, 0xf2f4, 0x00f4, //o^
+ 0xecf5, 0xccf5, 0xd2f5, 0xdef5, 0xf2f5, 0x00f5, //o+
+ 0xec75, 0xcc75, 0xd275, 0xde75, 0xf275, 0x0075, //u
+ 0xecfd, 0xccfd, 0xd2fd, 0xdefd, 0xf2fd, 0x00fd, //u+
+ 0xec79, 0xcc79, 0xd279, 0xde79, 0xf279, 0x0079}, //y
+};
+
+
+// Uppercase
+WORD UniVnH[][72] = {
+// Unicode
+ {0x00c1, 0x00c0, 0x1ea2, 0x00c3, 0x1ea0, 0x0041,
+ 0x1ea4, 0x1ea6, 0x1ea8, 0x1eaa, 0x1eac, 0x00c2,
+ 0x1eae, 0x1eb0, 0x1eb2, 0x1eb4, 0x1eb6, 0x0102,
+ 0x00c9, 0x00c8, 0x1eba, 0x1ebc, 0x1eb8, 0x0045,
+ 0x1ebe, 0x1ec0, 0x1ec2, 0x1ec4, 0x1ec6, 0x00ca,
+ 0x00cd, 0x00cc, 0x1ec8, 0x0128, 0x1eca, 0x0049,
+ 0x00d3, 0x00d2, 0x1ece, 0x00d5, 0x1ecc, 0x004f,
+ 0x1ed0, 0x1ed2, 0x1ed4, 0x1ed6, 0x1ed8, 0x00d4,
+ 0x1eda, 0x1edc, 0x1ede, 0x1ee0, 0x1ee2, 0x01a0,
+ 0x00da, 0x00d9, 0x1ee6, 0x0168, 0x1ee4, 0x0055,
+ 0x1ee8, 0x1eea, 0x1eec, 0x1eee, 0x1ef0, 0x01af,
+ 0x00dd, 0x1ef2, 0x1ef6, 0x1ef8, 0x1ef4, 0x0059},
+// VNI
+ {0xd941, 0xd841, 0xdb41, 0xd541, 0xcf41, 0x0041,
+ 0xc141, 0xc041, 0xc541, 0xc341, 0xc441, 0xc241,
+ 0xc941, 0xc841, 0xda41, 0xdc41, 0xcb41, 0xca41,
+ 0xd945, 0xd845, 0xdb45, 0xd545, 0xcf45, 0x0045,
+ 0xc145, 0xc045, 0xc545, 0xc345, 0xc445, 0xc245,
+ 0x00cd, 0x00cc, 0x00c6, 0x00d3, 0x00d2, 0x0049,
+ 0xd94f, 0xd84f, 0xdb4f, 0xd54f, 0xcf4f, 0x004f,
+ 0xc14f, 0xc04f, 0xc54f, 0xc34f, 0xc44f, 0xc24f,
+ 0xd9d4, 0xd8d4, 0xdbd4, 0xd5d4, 0xcfd4, 0x00d4,
+ 0xd955, 0xd855, 0xdb55, 0xd555, 0xcf55, 0x0055,
+ 0xd9d6, 0xd8d6, 0xdbd6, 0xd5d6, 0xcfd6, 0x00d6,
+ 0xd959, 0xd859, 0xdb59, 0xd559, 0x00ce, 0x0059},
+//BKHCM2
+ {0xC141, 0xC241, 0xC341, 0xC441, 0xC541, 0x0041,
+ 0xCBCA, 0xCCCA, 0xCDCA, 0xCECA, 0xC5CA, 0x00CA,
+ 0xC6D9, 0xC7D9, 0xC8D9, 0xC9D9, 0xC5D9, 0x00D9,
+ 0xC145, 0xC245, 0xC345, 0xC445, 0xC545, 0x0045,
+ 0xCBCF, 0xCCCF, 0xCDCF, 0xCECF, 0xE5CF, 0x00CF,
+ 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x0049,
+ 0xC14F, 0xC24F, 0xC34F, 0xC44F, 0xC54F, 0x004F,
+ 0xCBD6, 0xCCD6, 0xCDD6, 0xCED6, 0xC5D6, 0x00D6,
+ 0xC1DA, 0xC2DA, 0xC3DA, 0xC4DA, 0xC5DA, 0x00DA,
+ 0xC155, 0xC255, 0xC355, 0xC455, 0xC555, 0x0055,
+ 0xC1DB, 0xC2DB, 0xC3DB, 0xC4DB, 0xC5DB, 0x00DB,
+ 0xC159, 0xC259, 0xC359, 0xC459, 0xC559, 0x0059},
+//VPS
+ {0x00C1, 0x0080, 0x0081, 0x0082, 0x2E41, 0x0041,
+ 0x0083, 0x0084, 0x0085, 0x7EC2, 0x2EC2, 0x00C2,
+ 0x008D, 0x008E, 0x008F, 0x00F0, 0x2E88, 0x0088,
+ 0x00C9, 0x00D7, 0x00DE, 0x00FE, 0x2E45, 0x0045,
+ 0x0090, 0x0093, 0x0094, 0x0095, 0x2ECA, 0x00CA,
+ 0x00B4, 0x00B5, 0x00B7, 0x00B8, 0x2E49, 0x0049,
+ 0x00B9, 0x00BC, 0x00BD, 0x00BE, 0x2E4F, 0x004F,
+ 0x0096, 0x0097, 0x0098, 0x0099, 0x2ED4, 0x00D4,
+ 0x009D, 0x009E, 0x009F, 0x00A6, 0x2EF7, 0x00F7,
+ 0x00DA, 0x00A8, 0x00D1, 0x00AC, 0x2E55, 0x0055,
+ 0x00AD, 0x00AF, 0x00B1, 0x7ED0, 0x2ED0, 0x00D0,
+ 0x00DD, 0x00B2, 0x00FD, 0x00B3, 0x2E59, 0x0059},
+//VIETWARE X
+ {0xCF41, 0xCC41, 0xCD41, 0xCE41, 0xDB41, 0x0041,
+ 0xDAC1, 0xD6C1, 0xD8C1, 0xD9C1, 0xDBC1, 0x00C1,
+ 0xD5C0, 0xD2C0, 0xD3C0, 0xD4C0, 0xDBC0, 0x00C0,
+ 0xCF45, 0xCC45, 0xCD45, 0xCE45, 0xDB45, 0x0045,
+ 0xDAC3, 0xD6C3, 0xD8C3, 0xD9C3, 0xDBC3, 0x00C3,
+ 0x00CA, 0x00C7, 0x00C8, 0x00C9, 0x00CB, 0x0049,
+ 0xCF4F, 0xCC4F, 0xCD4F, 0xCE4F, 0xDC4F, 0x004F,
+ 0xDAC4, 0xD6C4, 0xD8C4, 0xD9C4, 0xDCC4, 0x00C4,
+ 0xCFC5, 0xCCC5, 0xCDC5, 0xCEC5, 0xDCC5, 0x00C5,
+ 0xCF55, 0xCC55, 0xCD55, 0xCE55, 0xDB55, 0x0055,
+ 0xCFC6, 0xCCC6, 0xCDC6, 0xCEC6, 0xDBC6, 0x00C6,
+ 0xCF59, 0xCC59, 0xCD59, 0xCE59, 0xD159, 0x0059},
+//VISCII
+ {0x00C1, 0x00C0, 0x00C4, 0x00C3, 0x0080, 0x0041,
+ 0x0084, 0x0085, 0x0086, 0x00E7, 0x0087, 0x00C2,
+ 0x0081, 0x0082, 0x00C6, 0x00C7, 0x0083, 0x00C5,
+ 0x00C9, 0x00C8, 0x00CB, 0x0088, 0x0089, 0x0045,
+ 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x00CA,
+ 0x00CD, 0x00CC, 0x009B, 0x00CE, 0x0098, 0x0049,
+ 0x00D3, 0x00D2, 0x0099, 0x00F5, 0x009A, 0x004F,
+ 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x00D4,
+ 0x0095, 0x0096, 0x0097, 0x00B3, 0x0094, 0x00B4,
+ 0x00DA, 0x00D9, 0x009C, 0x009D, 0x009E, 0x0055,
+ 0x00BA, 0x00BB, 0x00BC, 0x00FF, 0x00B9, 0x00BF,
+ 0x00DD, 0x009F, 0x00D6, 0x00DB, 0x00DC, 0x0059},
+//BKHCM1
+ {0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0041,
+ 0x007E, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x009F,
+ 0x009A, 0x009B, 0x009C, 0x009D, 0x0098, 0x0099,
+ 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x0045,
+ 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA, 0x00A5,
+ 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x0049,
+ 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x004F,
+ 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00AB,
+ 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B1,
+ 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0055,
+ 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00B7,
+ 0x007B, 0x005E, 0x0060, 0x007C, 0x008E, 0x0059},
+//unicode compound
+//unicode compound
+// composite bases that are greater than FF
+// 0: A( 0x102
+// 1: a( 0x103
+// 2: O+ 0x1A0
+// 3: o+ 0x1A1
+// 4: U+ 0x1AF
+// 5: u+ 0x1B0
+// 6: DD 0x110
+// 7: dd 0x111
+//
+// Use high byte is the index to the tone table below:
+// 1: '
+// 2: `
+// 3: ?
+// 4: ~
+// 5: .
+ {0x0141, 0x0241, 0x0341, 0x0441, 0x0541, 0x0041, //a
+ 0x01c2, 0x02c2, 0x03c2, 0x04c2, 0x05c2, 0x00c2, //a^
+ 0x0100, 0x0200, 0x0300, 0x0400, 0x0500, 0x0000, //a(
+ 0x0145, 0x0245, 0x0345, 0x0445, 0x0545, 0x0045, //e
+ 0x01ca, 0x02ca, 0x03ca, 0x04ca, 0x05ca, 0x00ca, //e^
+ 0x0149, 0x0249, 0x0349, 0x0449, 0x0549, 0x0049, //i
+ 0x014f, 0x024f, 0x034f, 0x044f, 0x054f, 0x004f, //o
+ 0x01d4, 0x02d4, 0x03d4, 0x04d4, 0x05d4, 0x00d4, //o^
+ 0x0102, 0x0202, 0x0302, 0x0402, 0x0502, 0x0002, //o+
+ 0x0155, 0x0255, 0x0355, 0x0455, 0x0555, 0x0055, //u
+ 0x0104, 0x0204, 0x0304, 0x0404, 0x0504, 0x0004, //u+
+ 0x0159, 0x0259, 0x0359, 0x0459, 0x0559, 0x0059}, //y
+// Windows CP 1258
+ {0xec41, 0xcc41, 0xd241, 0xde41, 0xf241, 0x0041, //a
+ 0xecc2, 0xccc2, 0xd2c2, 0xdec2, 0xf2c2, 0x00c2, //a^
+ 0xecc3, 0xccc3, 0xd2c3, 0xdec3, 0xf2c3, 0x00c3, //a(
+ 0xec45, 0xcc45, 0xd245, 0xde45, 0xf245, 0x0045, //e
+ 0xecca, 0xccca, 0xd2ca, 0xdeca, 0xf2ca, 0x00ca, //e^
+ 0xec49, 0xcc49, 0xd249, 0xde49, 0xf249, 0x0049, //i
+ 0xec4f, 0xcc4f, 0xd24f, 0xde4f, 0xf24f, 0x004f, //o
+ 0xecd4, 0xccd4, 0xd2d4, 0xded4, 0xf2d4, 0x00d4, //o^
+ 0xecd5, 0xccd5, 0xd2d5, 0xded5, 0xf2d5, 0x00d5, //o+
+ 0xec55, 0xcc55, 0xd255, 0xde55, 0xf255, 0x0055, //u
+ 0xecdd, 0xccdd, 0xd2dd, 0xdedd, 0xf2dd, 0x00dd, //u+
+ 0xec59, 0xcc59, 0xd259, 0xde59, 0xf259, 0x0059} //y
+
+};
+
+
+// Character d-
+WORD UniVndd[] = {
+ 0x0111, // Unicode
+ 0x00f1, // VNI
+ 0x00E0, // BKHCM2
+ 0x00C7, // VPS
+ 0x00E2, // VIETWARE X
+ 0x00F0, // VISCII
+ 0x00BD, // BKHCM1
+ 0x0007, // unicode compound
+ 0x00f0 // Windows CP 1258
+};
+
+
+
+// Character -D
+WORD UniVnDD[] = {
+ 0x0110, // Unicode
+ 0x00d1, // VNI
+ 0x00C0, // BKHCM2
+ 0x00F1, // VPS
+ 0x00C2, // VIETWARE X
+ 0x00D0, // VISCII
+ 0x007D, // BKHCM1
+ 0x0006, // unicode compound
+ 0x00d0 // Windows CP 1258
+};
+
+
+///// End of charset specification ///////////////////
+//////////////////////////////////////////////////////
+
+// Base characters of "doule" characters (like a^, a(, u+ )
+// the order here must not be changed
+unsigned char DoubleChars[] =
{'d', 'D', 'e', 'E', 'a', 'A', 'o', 'O', 'u', 'U'};
+
+unsigned char TelexTones[6] = {'s', 'f', 'r', 'x', 'j', 'z'};
+unsigned char TelexBreves[] = {'w', 'W'}; // Da^'u tra(ng (breve mark)
+unsigned char TelexShortcuts[] = {'[', ']', 'w', 'W', '{', '}'};
+
+unsigned char ToneLimits[] = {
+ 'b', 'd', 'f', 'j', 'k', 'l', 'q', 'r', 's', 'v', 'w', 'x', 'z',
+ 'B', 'D', 'F', 'J', 'K', 'L', 'Q', 'R', 'S', 'V', 'W', 'X', 'Z',
+ ',', ';', ':', '.', '\"', '\'', '!', '?',
+ ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ '<', '>', '=', '+', '-', '*', '/', '\\',
+ '_', '~', '`', '@', '#', '$', '%', '^', '&', '(', ')', '{', '}', '[', ']'};
+
+
+unsigned char WordStops[] = {
+ ',', ';', ':', '.', '\"', '\'', '!', '?', ' ',
+ '<', '>', '=', '+', '-', '*', '/', '\\',
+ '_', '~', '`', '@', '#', '$', '%', '^', '&', '(', ')', '{', '}', '[', ']'};
+
+// VIQR charset
+unsigned char VIQRtones[] = {'\'','`','?','~','.', 0};
+unsigned char VIQRcircumflex = '^';
+unsigned char VIQRbreve = '(';
+unsigned char VIQRhorn = '+';
+
+// VNI-like (VNI, VIQR, VIQR*) input keys
+unsigned char VniToneKeys[] = {'1', '2', '3', '4', '5', '0'};
+unsigned char VniDoubleKeys[] = {'6', '7', '8', '9'};
+
+unsigned char VIQRToneKeys[] = {'\'', '`', '?', '~', '.', '0'};
+unsigned char VIQRDoubleKeys[] = {'^', '+', '(', 'd'};
+
+unsigned char VIQRStarToneKeys[] = {'\'', '`', '?', '~', '.', '0'};
+unsigned char VIQRStarDoubleKeys[] = {'^', '*', '(', 'd'};
+
+
+
+void BuildTelexMethod(CodeInfo *pTab);
+void BuildVniLikeMethod(CodeInfo *pTab, int method); //vniLike = 1 for
VIQR mode
+
+void BuildInputMethod(int method, CodeInfo *pTab)
+{
+ if (method == TELEX_INPUT)
+ BuildTelexMethod(pTab);
+ else
+ BuildVniLikeMethod(pTab, method);
+}
+
+void BuildTelexMethod(CodeInfo *pTab)
+{
+ long i, j, offset;
+ unsigned char ch;
+
+ for (i=0; i<256; i++)
+ pTab->DT[i] = 0x2000000; // bit 25: hard separator
+
+ for (ch = 'a'; ch <= 'z'; ch++)
+ pTab->DT[ch] = 0;
+
+ for (ch = 'A'; ch <= 'Z'; ch++)
+ pTab->DT[ch] = 0;
+
+ for (i = 0; i < sizeof(ToneLimits); i++)
+ pTab->DT[ToneLimits[i]] = 0;
+
+ for (i = 0; i < sizeof(pTab->BK); i++)
+ pTab->DT[pTab->BK[i]] = 0;
+
+ for (i = 0; i < sizeof(pTab->BW); i++)
+ pTab->DT[pTab->BW[i]] = 0;
+
+ for (i=0; i<12; i++) { // we have 12 vowel sets
+ for (j=0; j<6; j++) {// each vowel set has 6
+ pTab->DT[pTab->BD[i][j]] = i+1;
+ pTab->DT[pTab->BD[i][j]] |= (j+1) << 18; // tone index (from bit 18)
+ }
+ }
+
+ // Set index for for characters like: dd, or a(,
+ offset = sizeof(DoubleChars) - sizeof(pTab->BW);
+ for (i=0; i < sizeof(DoubleChars); i++) {
+ pTab->DT[DoubleChars[i]] |= ((i+1) << 9);
+ if (i < sizeof(pTab->BK))
+ pTab->DT[pTab->BK[i]] |= ((i+1) << 9);
+ if (i+1 > offset)
+ pTab->DT[pTab->BW[i-offset]] |= ((i+1) << 9);
+ }
+
+ // Set tone limits (soft separator)
+ for (i = 0; i < sizeof(ToneLimits); i++)
+ pTab->DT[ToneLimits[i]] |= 0x1000000; // Set bit 24 for soft separators
+
+ // Set word stops
+ for (i = 0; i < sizeof(WordStops); i++)
+ pTab->DT[WordStops[i]] |= 0x20000000; // Set bit 29 for word stops
+
+ // For tone makrs
+ for (i=0; i < sizeof(TelexTones); i++) {
+ pTab->DT[TelexTones[i]] |= (i+1) << 14; // tone mark from bit 14 to 17
+ pTab->DT[toupper(TelexTones[i])] |= pTab->DT[TelexTones[i]];
+ }
+
+ // For the mark ( or +
+ for (i=0; i < sizeof(TelexBreves); i++)
+ pTab->DT[TelexBreves[i]] |= 0x400000; // set bit 22 for the breve mark
+
+ // For macro keys
+ for (i=0; i < sizeof(TelexShortcuts); i++)
+ pTab->DT[TelexShortcuts[i]] |= (i+1) << 5; // macro keys from bit 5
+}
+
+//-------------------------------------------
+void BuildVniLikeMethod(CodeInfo *pTab, int method)
+{
+ int i, j;
+ unsigned char ch;
+ int offset;
+
+ for (i=0; i<256; i++)
+ pTab->DT[i] = 0x2000000; // bit 25: hard separator
+
+ for (ch = 'a'; ch <= 'z'; ch++)
+ pTab->DT[ch] = 0;
+
+ for (ch = 'A'; ch <= 'Z'; ch++)
+ pTab->DT[ch] = 0;
+
+ for (i = 0; i < sizeof(ToneLimits); i++)
+ pTab->DT[ToneLimits[i]] = 0;
+
+ for (i = 0; i < sizeof(pTab->BK); i++)
+ pTab->DT[pTab->BK[i]] = 0;
+
+ for (i = 0; i < sizeof(pTab->BW); i++)
+ pTab->DT[pTab->BW[i]] = 0;
+
+ for (i=0; i<12; i++) { // we have 12 vowel sets
+ for (j=0; j<6; j++) {
+ // each vowel set has 6
+ pTab->DT[pTab->BD[i][j]] = i+1;
+ pTab->DT[pTab->BD[i][j]] |= (j+1) << 18; // tone index (from bit 18)
+ }
+ }
+
+ // For characters like: dd, or a(,
+ offset = sizeof(DoubleChars) - sizeof(pTab->BW);
+ for (i=0; i < sizeof(DoubleChars); i++) {
+ pTab->DT[DoubleChars[i]] |= ((i+1) << 9);
+ if (i < sizeof(pTab->BK))
+ pTab->DT[pTab->BK[i]] |= ((i+1) << 9);
+ if (i+1 > offset)
+ pTab->DT[pTab->BW[i-offset]] |= ((i+1) << 9);
+ }
+
+ // Set tone limits
+ for (i = 0; i < sizeof(ToneLimits); i++)
+ pTab->DT[ToneLimits[i]] |= 0x1000000; // Set bit 24 for soft separator
+
+ // Set word stops
+ for (i = 0; i < sizeof(WordStops); i++)
+ pTab->DT[WordStops[i]] |= 0x20000000; // Set bit 29 for word stops
+
+ unsigned char *doubleKeys;
+ unsigned char *toneKeys;
+ if (method == VNI_INPUT) {
+ doubleKeys = VniDoubleKeys;
+ toneKeys = VniToneKeys;
+ } else if (method == VIQR_INPUT) {
+ doubleKeys = VIQRDoubleKeys;
+ toneKeys = VIQRToneKeys;
+ } else { //VIQR*
+ doubleKeys = VIQRStarDoubleKeys;
+ toneKeys = VIQRStarToneKeys;
+ }
+
+ for (j=0; j < sizeof(VniDoubleKeys); j++)
+ pTab->DT[doubleKeys[j]] |= (j + 1) << 26; // VNI-like double marks: from
bit 26 - 28
+ for (i=0; i < sizeof(VniToneKeys); i++)
+ pTab->DT[toneKeys[i]] |= (i+1) << 14; // VNI-like tone marks from bit 14
+}
+
+
+//---------------------------------------------
+void BuildCodeTable(WORD charSet, int inputMethod, CodeInfo *pTab)
+{
+ int index;
+ WORD i, j;
+ unsigned char ch, up;
+
+ index = charSet;
+ if (charSet >= 0x100) {
+ index = TCVN3_CHARSET;
+ pTab->multiBytes = 1;
+ }
+ else pTab->multiBytes = 0;
+
+ memcpy(pTab->BD, MapBD[index], sizeof(pTab->BD));
+ memcpy(pTab->BK, MapBK[index], sizeof(pTab->BK));
+ memcpy(pTab->BT, MapBT[index], sizeof(pTab->BT));
+ memcpy(pTab->BW, MapBW[index], sizeof(pTab->BW));
+
+ BuildInputMethod(inputMethod, pTab);
+ //------- Build conversion table from TCVN3 to 2-bytes charsets -------
+ if (charSet == VIQR_CHARSET) {
+ for (i = 0; i < 256; i++) {
+ pTab->ToUniL[i] = i;
+ pTab->ToUniH[i] = i;
+ }
+ for (ch= 'a', up = 'A'; ch <= 'z'; ch++, up++)
+ pTab->ToUniH[ch] = up;
+ for (i=0; i<12; i++) { // we have 12 vowel sets
+ for (j=0; j<6; j++) {
+ pTab->ToUniL[pTab->BD[i][j]] = MAKEWORD(pTab->BD[i][5], VIQRtones[j]);
+ pTab->ToUniH[pTab->BD[i][j]] = MAKEWORD(toupper(pTab->BD[i][5]),
VIQRtones[j]);
+ }
+ }
+
+ pTab->ToUniL[pTab->BK[0]] = MAKEWORD('d', 'd');
+ pTab->ToUniH[pTab->BK[0]] = MAKEWORD('D', 'D');
+ for (i = 1; i < sizeof(pTab->BK); i++) {
+ pTab->ToUniL[pTab->BK[i]] = MAKEWORD(DoubleChars[i], VIQRcircumflex);
+ pTab->ToUniH[pTab->BK[i]] = MAKEWORD(toupper(DoubleChars[i]),
VIQRcircumflex);
+ }
+
+ int offset = sizeof(DoubleChars) - sizeof(pTab->BW);
+ for (i = 0; i < sizeof(pTab->BW); i++) {
+ pTab->ToUniL[pTab->BW[i]] = MAKEWORD(DoubleChars[i+offset], (i < 2)?
VIQRbreve : VIQRhorn);
+ pTab->ToUniH[pTab->BW[i]] = MAKEWORD(toupper(DoubleChars[i+offset]), (i
< 2)? VIQRbreve : VIQRhorn);
+ }
+ }
+ else if (pTab->multiBytes) {
+ index = charSet - 0x100 - 1; // the first index is assigned to VIQR
+ for (i=0; i<256; i++) {
+ pTab->ToUniH[i] = i;
+ pTab->ToUniL[i] = i;
+ }
+
+ for (ch= 'a', up = 'A'; ch <= 'z'; ch++, up++)
+ pTab->ToUniH[ch] = up;
+
+ unsigned char *p = (unsigned char *)pTab->BD;
+ for (i=0; i<72; i++) {
+ pTab->ToUniH[*p] = UniVnH[index][i];
+ pTab->ToUniL[*p] = UniVnL[index][i];
+ p++;
+ }
+ pTab->ToUniL[pTab->BK[0]] = UniVndd[index];
+ pTab->ToUniH[pTab->BK[0]] = UniVnDD[index];
+
+ pTab->ToUniL[pTab->BT[4]] = UniVnL[index][8*6+5]; // upper O+ (=
BD[8][5])
+ pTab->ToUniH[pTab->BT[4]] = UniVnH[index][8*6+5];
+
+ pTab->ToUniL[pTab->BT[5]] = UniVnL[index][10*6+5]; // upper U+ (=
BD[10][5])
+ pTab->ToUniH[pTab->BT[5]] = UniVnH[index][10*6+5];
+ }
+}
+
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/encode.h Mon
Oct 10 16:21:04 2011
@@ -0,0 +1,40 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#ifndef _VN_ENCODE_H
+#define _VN_ENCODE_H
+
+#include "keycons.h"
+#include "keyhook.h"
+
+struct CharsetInfo {
+ TCHAR *name;
+ WORD id;
+ int vnconvId; //id of the charset in the vnconv module
+ int encoding; //used for unicode charset
+};
+
+extern CharsetInfo CharsetTable[TOTAL_CHARSET];
+
+
+void BuildCodeTable(WORD charSet, int inMethod, CodeInfo *pTab);
+void BuildInputMethod(int method, CodeInfo *pTab);
+
+
+#endif
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/expdlg.cpp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,283 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+
+#include "prehdr.h"
+#include <windowsx.h>
+#include "util.h"
+#include "ExpDlg.h"
+
+//------------------------------------------
+int CExpandDialog::init(
+ HINSTANCE hInst,
+ LPCTSTR lpszTemplate,
+ HWND hWndOwner, // parent window, could be NULL
+ int nIDFrame,
+ int nIDButton,
+ int nIDFooter,
+ LPCTSTR strExpand,
+ LPCTSTR strContract,
+ BOOL bAllowContract
+ )
+{
+ CVirDialog::init(hInst, lpszTemplate, hWndOwner);
+ _tcscpy(m_strExpand, strExpand);
+ _tcscpy(m_strContract, strContract);
+ m_nIDFrame = nIDFrame;
+ m_nIDButton = nIDButton;
+ m_nIDFooter = nIDFooter;
+ m_bExpanded = TRUE;
+ m_bAllowContract = bAllowContract;
+ m_wasShown = FALSE;
+ return TRUE;
+}
+
+//-------------------------------------------
+BOOL CExpandDialog::onDialogExpanding(BOOL /*bExpanded*/)
+{
+ return (TRUE);
+}
+
+//-------------------------------------------
+void CExpandDialog::onDialogExpanded(BOOL /*bExpanded*/)
+{
+ return;
+}
+
+
+//-------------------------------------------
+BOOL CExpandDialog::onInitDialog()
+{
+ CVirDialog::onInitDialog();
+ // during initialization, before any windows are shown, shrink the
+ // dialog box so that only the default portion is shown.
+ HWND wndCtrl = GetDlgItem(m_hWnd, m_nIDFrame);
+ ShowWindow(wndCtrl, SW_HIDE);
+ wndCtrl = GetDlgItem(m_hWnd, m_nIDFooter);
+ ShowWindow(wndCtrl, SW_HIDE);
+ wndCtrl = GetDlgItem(m_hWnd, m_nIDButton);
+ SetWindowText(wndCtrl, m_bExpanded? m_strContract : m_strExpand);
+
+ m_wasShown = FALSE;
+// expandBox(TRUE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
+}
+
+
+//-------------------------------------------
+BOOL CExpandDialog::onCommand(WPARAM wParam, LPARAM lParam)
+{
+ HWND hwndCtl;
+ int id;
+ UINT codeNotify;
+
+ // crack the WM_COMMAND message
+ id = GET_WM_COMMAND_ID(wParam,lParam);
+ hwndCtl = GET_WM_COMMAND_HWND(wParam,lParam);
+ codeNotify = GET_WM_COMMAND_CMD(wParam,lParam);
+
+ // if the "Advanced" button was clicked, then call the
+ // message handler.
+ if ((id == m_nIDButton) && (codeNotify==BN_CLICKED))
+ {
+ onClickAdvanced();
+ }
+
+ return CVirDialog::onCommand(wParam, lParam);
+}
+
+
+//-------------------------------------------
+void CExpandDialog::onClickAdvanced()
+{
+ expand(!m_bExpanded);
+}
+
+
+//-------------------------------------------
+BOOL CExpandDialog::expand(BOOL bExpand)
+{
+ BOOL bShouldExpand;
+
+ // if the current state matches the flag passed into this
+ // routine, then there is no need to do anything. Note that
+ // the virtual functions OnDialogExpanding and OnDialogExpanded
+ // are not called.
+ if (bExpand == m_bExpanded) return TRUE;
+
+ // call the virtual function to see if it is OK to expand the dialog.
+ bShouldExpand = onDialogExpanding(m_bExpanded);
+
+
+ // if OnDialogExpanding returns OK (TRUE), then call the appropriate
+ // functions to expand the dialog.
+ if (bShouldExpand)
+ {
+ expandBox(bExpand);
+ // call the notification for the post-expand
+ onDialogExpanded(m_bExpanded);
+ }
+
+ return(m_bExpanded == bExpand);
+}
+
+
+//-------------------------------------------
+void CExpandDialog::expandBox(BOOL fExpand)
+{
+ // if the dialog is already in the requested state, return
+ // immediately.
+ if (fExpand == m_bExpanded) return;
+
+ RECT rcWnd, rcDefaultBox, rcChild, rcIntersection, rcFooter, rcTempFooter;
+ HWND wndChild = NULL;
+ HWND wndDefaultBox = NULL;
+
+ GetWindowRect(m_hWnd, &rcWnd);
+
+ // get the window of the button
+ HWND wndCtrl = GetDlgItem(m_hWnd, m_nIDButton);
+ if (wndCtrl == NULL) return;
+
+ wndDefaultBox = GetDlgItem(m_hWnd, m_nIDFrame);
+ if (wndDefaultBox==NULL) return;
+
+ // retrieve coordinates for the default child window
+ GetWindowRect(wndDefaultBox, &rcDefaultBox);
+
+ HWND wndFooter = GetDlgItem(m_hWnd, m_nIDFooter);
+ if (wndFooter == NULL) return;
+ GetWindowRect(wndFooter, &rcFooter);
+ if (m_bExpanded)
+ rcTempFooter = rcFooter;
+ else {
+ rcTempFooter.left = rcDefaultBox.left;
+ rcTempFooter.top = rcDefaultBox.bottom;
+ rcTempFooter.right = rcTempFooter.left + (rcFooter.right -
rcFooter.left);
+ rcTempFooter.bottom = rcTempFooter.top + (rcFooter.bottom -
rcFooter.top);
+ }
+
+ // Calculate offsets to move the footer
+ int dx, dy;
+ dx = rcFooter.left - rcDefaultBox.left;
+ dy = rcFooter.top - rcDefaultBox.bottom;
+ if (!fExpand) {
+ dx = -dx;
+ dy = -dy;
+ }
+ dx = 0;
+
+ // enable/disable all of the child window outside of the default box.
+ wndChild = GetTopWindow(m_hWnd);
+
+ POINT pt;
+ for ( ; wndChild != NULL; wndChild = GetWindow(wndChild, GW_HWNDNEXT))
+ {
+ // get rectangle occupied by child window in screen coordinates.
+ GetWindowRect(wndChild, &rcChild);
+ if (!IntersectRect(&rcIntersection, &rcChild, &rcDefaultBox))
+ {
+ if ((!m_wasShown || IsWindowVisible(wndChild)) &&
+ wndChild != wndFooter &&
+ IntersectRect(&rcIntersection, &rcChild, &rcTempFooter)) {
+ pt.x = rcChild.left + dx;
+ pt.y = rcChild.top + dy;
+ ScreenToClient(m_hWnd, &pt);
+ SetWindowPos(
+ wndChild,
+ HWND_TOP,
+ pt.x, //rcChild.left,
+ pt.y, //rcChild.top,
+ 0,
+ 0,
+ SWP_NOZORDER | SWP_NOSIZE);
+ ShowWindow(wndChild, SW_SHOW);
+ }
+ else {
+ //EnableWindow(wndChild, fExpand); //DEBUG
+ ShowWindow(wndChild, fExpand? SW_SHOW : SW_HIDE);
+ }
+ //EnableWindow(wndChild, fExpand);
+ //ShowWindow(wndChild, fExpand? SW_SHOW : SW_HIDE);
+ }
+ }
+
+ if (!fExpand) // we are contracting
+ {
+ if (!m_wasShown)
+ {
+ m_wasShown = 1;
+ // this is the first time we are being called to shrink the dialog
+ // box. The dialog box is currently in its expanded size and we must
+ // save the expanded width and height so that it can be restored
+ // later when the dialog box is expanded.
+ m_tsize.cx = rcWnd.right - rcWnd.left;
+ m_tsize.cy = rcWnd.bottom - rcWnd.top;
+
+ // we also hide the default box here so that it is not visible
+ ShowWindow(wndDefaultBox, SW_HIDE);
+ }
+ // shrink the dialog box so that it encompasses everything from the top,
+ // left up to and including the default box.
+ SetWindowPos(m_hWnd,
+ HWND_TOP,
+ 0,
+ 0,
+ rcDefaultBox.right - rcWnd.left,
+ rcDefaultBox.bottom - rcWnd.top + (rcFooter.bottom - rcFooter.top), //
adding extra space for the footer
+ SWP_NOZORDER|SWP_NOMOVE);
+
+ SetWindowText(wndCtrl, m_strExpand);
+
+ // record that the dialog is contracted.
+ m_bExpanded = FALSE;
+ }
+ else // we are expanding
+ {
+ SetWindowPos(
+ m_hWnd,
+ HWND_TOP,
+ 0,
+ 0,
+ m_tsize.cx,
+ m_tsize.cy,
+ SWP_NOZORDER|SWP_NOMOVE);
+
+ // make sure that the entire dialog box is visible on the user's
+ // screen.
+ SendMessage(m_hWnd, DM_REPOSITION, 0, 0);
+
+ // hide the footer
+ ShowWindow(wndFooter, SW_HIDE);
+
+ if (m_bAllowContract)
+ {
+ SetWindowText(wndCtrl, m_strContract);
+ }
+ else
+ {
+ //EnableWindow(wndCtrl, FALSE); //debug
+ }
+
+ // record that the dialog is expanded
+ m_bExpanded = TRUE;
+ }
+}
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/expdlg.h Mon
Oct 10 16:21:04 2011
@@ -0,0 +1,94 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+
+#ifndef __EXPANDING_DIALOG_BOX_H
+#define __EXPANDING_DIALOG_BOX_H
+
+
+/*--------------------------------------------------------------------------
+ Class: CExpandDialog
+
+ Summary: Allows dialogs to be expanded/contracted
+----------------------------------------------------------------------------*/
+class CExpandDialog: virtual public CVirDialog
+{
+public:
+ virtual BOOL onInitDialog();
+
+ int init(
+ HINSTANCE hInst,
+ LPCTSTR lpszTemplate,
+ HWND hWndOwner, // parent window, could be NULL
+ int nIDFrame,
+ int nIDButton,
+ int nIDFooter,
+ LPCTSTR strExpand = _T("Advanced >>"),
+ LPCTSTR strContract = _T("Advanced <<"),
+ BOOL bAllowContract = TRUE
+ );
+
+public:
+ // a public function so that the dialog can query whether or not
+ // we are in "advanced" mode.
+ BOOL isExpanded() const {return m_bExpanded;};
+
+ // allow the user to expand or contract the dialog whenever they
+ // please. This is only needed in extreme circumstances, when the
+ // dialog should expand or contract based on something else besides
+ // the "Advanced" button.
+ BOOL expand(BOOL bExpand);
+
+ // a virtual notification function so that the expanding or contracting
+ // can be aborted if need be. The function should return TRUE if the
+ // expanding should happen, or FALSE if it should not.
+ virtual BOOL onDialogExpanding(BOOL bExpanded);
+
+ // a virtual notification function that is called after the expansion
+ // takes place
+ virtual void onDialogExpanded(BOOL bExpanded);
+
+ // Overrides
+ virtual BOOL onCommand(WPARAM wParam, LPARAM lParam);
+
+protected:
+ // property data
+ TCHAR m_strExpand[64]; // string to put on the expand/contract button,
when
+ // the dialog is currently contracted.
+ TCHAR m_strContract[64]; // string to pu on the expand/contract button,
when
+ // the dialog is currently expanded.
+ int m_nIDFrame; // resource ID of the frame that defines the contracted
+ // dimensions of the dialog.
+ int m_nIDButton; // resource ID of the expand/contract button on the
+ // dialog
+ BOOL m_bAllowContract; // whether or not to allow the user to contract
the dialog
+ // after expanding it for the first time.
+
+ SIZE m_tsize;
+ BOOL m_bExpanded; // records whether the dialog is currently expanded or
not.
+ BOOL m_wasShown; // records whether the dialog was shown before
+
+ int m_nIDFooter; // ID of the footer control
+
+private:
+ void expandBox(BOOL fExpand);
+ void onClickAdvanced();
+};
+
+#endif
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/font.cpp Mon
Oct 10 16:21:04 2011
@@ -0,0 +1,55 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+
+#include "prehdr.h"
+#include "font.h"
+
+//---------------------------------------------------------------
+// call-back function for enumerating fonts
+// lParam: the test function will set this data to font name
+//---------------------------------------------------------------
+static int FontFound = 0;
+int CALLBACK myEnumFontCallback(
+ ENUMLOGFONTEX *lpelfe, // logical-font data
+ NEWTEXTMETRICEX *lpntme, // physical-font data
+ DWORD FontType, // type of font
+ LPARAM lParam // application-defined data
+)
+{
+ if (_tcsicmp((const TCHAR *)lParam, lpelfe->elfLogFont.lfFaceName) == 0)
+ FontFound = 1;
+ return 0;
+}
+
+//----------------------------------------------------------------
+int FontExists(const TCHAR *fontFace)
+{
+ LOGFONT lf;
+ HWND hWndDesktop = GetDesktopWindow();
+ HDC hDC = GetDC(hWndDesktop);
+ FontFound = 0;
+ lf.lfCharSet = DEFAULT_CHARSET; //any charset
+ _tcscpy(lf.lfFaceName, fontFace);
+ lf.lfPitchAndFamily = 0;
+ EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC)myEnumFontCallback,
(LPARAM)fontFace, 0);
+ ReleaseDC(hWndDesktop, hDC);
+ return (FontFound);
+}
+
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/font.h Mon
Oct 10 16:21:04 2011
@@ -0,0 +1,25 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#ifndef __FONT_UTILITY_H
+#define __FONT_UTILITY_H
+
+int FontExists(const TCHAR *fontFace);
+
+#endif
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/keydlg.cpp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,547 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+//#include <windows.h>
+#include "prehdr.h"
+#include <windowsx.h>
+#include "resource.h"
+#include "keyhook.h"
+#include "encode.h"
+#include "about.h"
+#include "keydlg.h"
+#include "mainwnd.h"
+#include "userpref.h"
+#include "macrodlg.h"
+#include "vnconv.h"
+
+// external variable in mainwnd.cpp
+extern TCHAR AppTitle[100];
+extern CMainWnd MainWnd;
+extern CUserPref UserPref;
+
+char * ExpandLabel[] = {
+ "Expand",
+ "Më réng"};
+
+char * ContractLabel[] = {
+ "Contract",
+ "Thu nhá"};
+
+AnsiDlgItemInfo VnDlgItems[] = { //use explicit ansi string for vietnamese
in TCVN3
+ {IDC_FREE_MARKING, "Cho phÐp gâ dÊu mò, mãc ë cuèi tõ"},
+ {IDC_TONE_CTRL, "Ph¶i gâ dÊu ngay sau nguyªn ©m"},
+ {IDC_MODERN_STYLE, "§Æt dÊu oµ, uý (thay v× ßa, óy)"},
+ {IDC_VIET_GUI, "Vietnamese interface"},
+ {IDC_SHOW_DLG, "BËt héi tho¹i nµy khi khëi ®éng"},
+ {IDC_RESET, "MÆc ®Þnh"},
+ {IDC_EXIT, "&KÕt thóc"},
+ {IDOK, "§ãng"},
+ {IDC_OPEN_HELP, "&H­íng dÉn"},
+ {IDC_ABOUT, "Th«ng tin"},
+ {IDC_CONTROL_GROUP, "§iÒu khiÓn"},
+ {IDC_CHARSET_PROMPT, "B¶ng m·:"},
+ {IDC_SWITCHKEY_PROMPT, "PhÝm chuyÓn:"},
+ {IDC_KEYMODE_PROMPT, "KiÓu gâ:"},
+ {IDC_OPTION_GROUP, "Tïy chän kh¸c"}, //"Lùa chän"
+ {IDC_AUTO_START, "Khëi ®éng cïng Windows"},
+ {IDC_MACRO_CHECK, "Cho phÐp gâ t¾t"},
+ {IDC_MACRO_BTN, "B¶ng gâ t¾t..."},
+ {IDC_USE_CLIPBOARD, "Sö dông clipboard cho unicode"}
+ };
+
+#define MAX_ITEM_LEN 60
+
+#ifdef _UNICODE
+
+wchar_t
UniVnDlgItemTexts[sizeof(VnDlgItems)/sizeof(AnsiDlgItemInfo)][MAX_ITEM_LEN];
+DlgItemInfo UniVnDlgItems[sizeof(VnDlgItems)/sizeof(AnsiDlgItemInfo)];
+
+#endif
+
+DlgItemInfo EnDlgItems[] = { // use generic string
+ {IDC_FREE_MARKING, _T("Allow typing ^, v, + ... at the end")},
+ {IDC_TONE_CTRL, _T("Tone mark next to vowel")},
+ {IDC_MODERN_STYLE, _T("Use oa`, uy' (instead of o`a, u'y)")},
+ {IDC_VIET_GUI, _T("Giao dien tieng Viet")},
+ {IDC_SHOW_DLG, _T("Show this dialog box at startup")},
+ {IDC_RESET, _T("Default")},
+ {IDC_EXIT, _T("&Exit")},
+ {IDOK, _T("&Close")},
+ {IDC_OPEN_HELP, _T("&Help")},
+ {IDC_ABOUT, _T("About")},
+ {IDC_CONTROL_GROUP, _T("Settings")},
+ {IDC_CHARSET_PROMPT, _T("Character set:")},
+ {IDC_SWITCHKEY_PROMPT, _T("Switch key:")},
+ {IDC_KEYMODE_PROMPT, _T("Input method:")},
+ {IDC_OPTION_GROUP, _T("Advanced options")},
+ {IDC_AUTO_START, _T("Auto-run UniKey at boot time")},
+ {IDC_MACRO_CHECK, _T("Enable macro")},
+ {IDC_MACRO_BTN, _T("Macro table...")},
+ {IDC_USE_CLIPBOARD, _T("Use clipboard for unicode")}
+ };
+
+TCHAR *InputMethodText[] = {
+ _T("TELEX"),
+ _T("VNI"),
+ _T("VIQR"),
+ _T("VIQR*")};
+
+//------------------------------------------
+int CKeyDlg::init(HINSTANCE hInst, HWND hWndOwner)
+{
+ TCHAR expandStr[MAX_ITEM_LEN], contractStr[MAX_ITEM_LEN];
+#ifndef _UNICODE
+ strcpy(expandStr, (UserPref.m_vietGUI)? ExpandLabel[1] : ExpandLabel[0]);
+ strcpy(contractStr, (UserPref.m_vietGUI)? ContractLabel[1] :
ContractLabel[0]);
+#else
+ int inLen, maxOutLen;
+ inLen = -1;
+ maxOutLen = MAX_ITEM_LEN * 2;
+ VnConvert(CONV_CHARSET_TCVN3, CONV_CHARSET_UNICODE,
+ (BYTE *)((UserPref.m_vietGUI)? ExpandLabel[1] : ExpandLabel[0]),
+ (BYTE *)expandStr,
+ inLen, maxOutLen);
+
+ inLen = -1;
+ maxOutLen = MAX_ITEM_LEN * 2;
+ VnConvert(CONV_CHARSET_TCVN3, CONV_CHARSET_UNICODE,
+ (BYTE *)((UserPref.m_vietGUI)? ContractLabel[1] : ContractLabel[0]),
+ (BYTE *)contractStr,
+ inLen, maxOutLen);
+#endif
+
+ int ret = CExpandDialog::init(
+ hInst,
+ MAKEINTRESOURCE(IDD_KEY_DIALOG),
+ hWndOwner,
+ IDC_COMPACT_FRAME,
+ IDC_EXPAND,
+ IDC_FOOTER_FRAME,
+ expandStr,
+ contractStr);
+
+ initLanguageInfo();
+ setupLanguage(0, EnDlgItems, sizeof(EnDlgItems)/sizeof(DlgItemInfo));
+#ifndef _UNICODE
+ setupLanguage(1, VnDlgItems, sizeof(VnDlgItems)/sizeof(AnsiDlgItemInfo),
+ VIET_FONT_NAME, VIET_DLG_FONT_SIZE);
+#else
+ int items = sizeof(VnDlgItems)/sizeof(AnsiDlgItemInfo);
+ for (int i=0; i<items; i++) {
+ inLen = -1;
+ maxOutLen = 2*MAX_ITEM_LEN;
+ VnConvert(CONV_CHARSET_TCVN3, CONV_CHARSET_UNICODE,
+ (BYTE *)VnDlgItems[i].text, (BYTE *)UniVnDlgItemTexts[i],
+ inLen, maxOutLen);
+ UniVnDlgItems[i].id = VnDlgItems[i].id;
+ UniVnDlgItems[i].text = UniVnDlgItemTexts[i];
+ }
+ setupLanguage(1, UniVnDlgItems, items, VIET_FONT_NAME,
VIET_DLG_FONT_SIZE);
+#endif
+ return ret;
+}
+
+//------------------------------------------
+void CKeyDlg::loadDlgInfo(CUserPref *pPref)
+{
+ int i;
+ SendMessage(m_codeList, CB_RESETCONTENT, 0, 0);
+ for (i=0; i < TOTAL_CHARSET; i++)
+ SendMessage(m_codeList, CB_ADDSTRING, 0, (LPARAM)CharsetTable[i].name);
+ SendMessage(m_codeList, CB_SETCURSEL, pPref->m_codeTable, 0);
+
+ SendMessage(m_inputList, CB_RESETCONTENT, 0, 0);
+ int methods = sizeof(InputMethodText)/sizeof(InputMethodText[0]);
+ for (i=0; i < methods; i++)
+ SendMessage(m_inputList, CB_ADDSTRING, 0, (LPARAM)InputMethodText[i]);
+ SendMessage(m_inputList, CB_SETCURSEL, pPref->m_inMethod, 0);
+
+ SendMessage(m_showCtrl,
+ BM_SETCHECK,
+ (pPref->m_showDlg)? BST_CHECKED : BST_UNCHECKED,
+ 0);
+ SendMessage(m_markCheck,
+ BM_SETCHECK,
+ (pPref->m_freeMarking)? BST_CHECKED : BST_UNCHECKED,
+ 0);
+ SendMessage(m_toneCtrl,
+ BM_SETCHECK,
+ (pPref->m_toneNextToVowel)? BST_CHECKED : BST_UNCHECKED,
+ 0);
+
+ SendMessage(m_modernStyleCheck,
+ BM_SETCHECK,
+ (pPref->m_modernStyle)? BST_CHECKED : BST_UNCHECKED,
+ 0);
+
+ SendMessage(m_swKeyBtn1,
+ BM_SETCHECK,
+ (pPref->m_switchKey==0)? BST_CHECKED : BST_UNCHECKED,
+ 0);
+
+ SendMessage(m_swKeyBtn2,
+ BM_SETCHECK,
+ (pPref->m_switchKey==1)? BST_CHECKED : BST_UNCHECKED,
+ 0);
+ SendDlgItemMessage(m_hWnd, IDC_VIET_GUI, BM_SETCHECK,
+ (pPref->m_vietGUI)? BST_CHECKED : BST_UNCHECKED,
+ 0);
+
+ SendDlgItemMessage(m_hWnd, IDC_AUTO_START, BM_SETCHECK,
+ (pPref->m_autoStart)? BST_CHECKED : BST_UNCHECKED,
+ 0);
+
+ Button_SetCheck(m_macroCheck, pPref->m_macroEnabled);
+ Button_SetCheck(m_useUnicodeClipboardCheck, pPref->m_useUnicodeClipboard);
+
+ if (!MainWnd.isVietFontOK())
+ EnableWindow(GetDlgItem(m_hWnd, IDC_VIET_GUI), FALSE);
+
+ pPref->m_changes = 0;
+
+ OSVERSIONINFO osinfo;
+ osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&osinfo);
+ if (osinfo.dwMajorVersion < 4 || osinfo.dwPlatformId !=
VER_PLATFORM_WIN32_NT) {
+ Button_SetCheck(m_useUnicodeClipboardCheck, 1);
+ EnableWindow(m_useUnicodeClipboardCheck, FALSE);
+ }
+
+}
+
+//------------------------------------------
+void CKeyDlg::storeDlgInfo(CUserPref *pPref)
+{
+ int sel;
+ // character set
+ sel = (int)SendMessage(m_codeList,CB_GETCURSEL,0,0);
+ if (sel != (int)pPref->m_codeTable) {
+ pPref->m_changes |= PREF_CHANGE_CHARSET;
+ pPref->m_oldTable = pPref->m_codeTable;
+ pPref->m_codeTable = sel;
+ if (sel != (int)pPref->m_otherCharset && sel >= POPULAR_CHARSETS) {
+ pPref->m_changes |= PREF_CHANGE_OTHERCHARSET;
+ pPref->m_otherCharset = sel;
+ }
+ }
+
+ sel = (int)SendMessage(m_inputList,CB_GETCURSEL,0,0);
+ if (sel != (int)pPref->m_inMethod) {
+ pPref->m_changes |= PREF_CHANGE_METHOD;
+ pPref->m_inMethod = sel;
+ }
+
+ sel = (SendMessage(m_swKeyBtn1, BM_GETCHECK, 0, 0) == BST_CHECKED)? 0 : 1;
+ if (sel != (int)pPref->m_switchKey) {
+ pPref->m_changes |= PREF_CHANGE_SWITCHKEY;
+ pPref->m_switchKey = sel;
+ }
+
+ sel = (SendMessage(m_markCheck, BM_GETCHECK, 0, 0) == BST_CHECKED)? 1 : 0;
+ if (sel && !pPref->m_freeMarking || !sel && pPref->m_freeMarking) {
+ pPref->m_changes |= PREF_CHANGE_OPTIONS;
+ pPref->m_freeMarking = sel;
+ }
+
+ sel = (SendMessage(m_toneCtrl, BM_GETCHECK, 0, 0) == BST_CHECKED)? 1 : 0;
+ if (sel && !pPref->m_toneNextToVowel || !sel && pPref->m_toneNextToVowel)
{
+ pPref->m_changes |= PREF_CHANGE_OPTIONS;
+ pPref->m_toneNextToVowel = sel;
+ }
+
+ sel = (SendMessage(m_modernStyleCheck, BM_GETCHECK, 0, 0) ==
BST_CHECKED)? 1 : 0;
+ if (sel && !pPref->m_modernStyle || !sel && pPref->m_modernStyle) {
+ pPref->m_changes |= PREF_CHANGE_OPTIONS;
+ pPref->m_modernStyle = sel;
+ }
+
+ sel = Button_GetCheck(m_macroCheck);
+ if (sel && !pPref->m_macroEnabled || !sel && pPref->m_macroEnabled) {
+ pPref->m_changes |= PREF_CHANGE_OPTIONS;
+ pPref->m_macroEnabled = sel;
+ }
+
+ sel = Button_GetCheck(m_useUnicodeClipboardCheck);
+ if (sel && !pPref->m_useUnicodeClipboard || !sel &&
pPref->m_useUnicodeClipboard) {
+ pPref->m_changes |= PREF_CHANGE_OPTIONS;
+ pPref->m_useUnicodeClipboard = sel;
+ }
+
+ sel = (SendMessage(m_showCtrl,BM_GETCHECK,0,0) == BST_CHECKED) ? 1 : 0;
+ if (sel && !pPref->m_showDlg || !sel && pPref->m_showDlg) {
+ pPref->m_changes |= PREF_CHANGE_SHOWDLG;
+ pPref->m_showDlg = sel;
+ }
+
+
+ // GUI interface
+ if (SendDlgItemMessage(m_hWnd, IDC_VIET_GUI,BM_GETCHECK, 0, 0) ==
BST_CHECKED)
+ sel = 1;
+ else
+ sel = 0;
+ if (sel && !pPref->m_vietGUI || !sel && pPref->m_vietGUI) {
+ pPref->m_changes |= PREF_CHANGE_GUI;
+ pPref->m_vietGUI = sel;
+ }
+
+ if (SendDlgItemMessage(m_hWnd, IDC_AUTO_START, BM_GETCHECK, 0, 0) ==
BST_CHECKED)
+ sel = 1;
+ else
+ sel = 0;
+ if (sel && !pPref->m_autoStart || !sel && pPref->m_autoStart) {
+ pPref->m_changes |= PREF_CHANGE_AUTOSTART;
+ pPref->m_autoStart = sel;
+ }
+
+ if (m_tempPref.m_alwaysMacro != pPref->m_alwaysMacro) {
+ pPref->m_alwaysMacro = m_tempPref.m_alwaysMacro;
+ pPref->m_changes |= PREF_CHANGE_OPTIONS;
+ }
+
+}
+
+//------------------------------------------
+BOOL CKeyDlg::DialogProc(
+ HWND hDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ switch (uMsg) {
+ case WM_SYSCOMMAND:
+ {
+ WORD cmd = (wParam & 0xFFF0) >> 4;
+ switch (cmd) {
+ case IDM_ABOUT:
+ DoAbout(m_hInst, hDlg,
+ (SendDlgItemMessage(m_hWnd, IDC_VIET_GUI, BM_GETCHECK, 0, 0) ==
BST_CHECKED)? 1 : 0);
+ return TRUE;
+ }
+ }
+ break;
+ case WM_DRAWITEM:
+ // Send reflection message to back the control
+ return SendDlgItemMessage(hDlg, wParam, WM_DRAWITEM, wParam, lParam);
+ case WM_DESTROY:
+ if (m_hStdFont != NULL) {
+ DeleteObject(m_hStdFont);
+ m_hStdFont = NULL;
+ }
+ break;
+ }
+ return CExpandDialog::DialogProc(hDlg, uMsg, wParam, lParam);
+}
+
+//------------------------------------------
+BOOL CKeyDlg::onInitDialog()
+{
+ if (!CExpandDialog::onInitDialog()) return FALSE;
+
+ if (MainWnd.isVietFontOK())
+ setDlgFont(1);
+
+ m_tempPref = *m_pPref;
+
+ applyLanguage(UserPref.m_vietGUI? 1 : 0);
+
+ HICON mainBigIcon, mainSmallIcon;
+
+ // Setup dialog box icons
+ mainBigIcon = (HICON)LoadImage(m_hInst,
+ MAKEINTRESOURCE(IDR_MAINFRAME),
+ IMAGE_ICON,
+ 32, 32,
+ LR_SHARED);
+ mainSmallIcon = (HICON)LoadImage(m_hInst,
+ MAKEINTRESOURCE(IDR_MAINFRAME),
+ IMAGE_ICON,
+ 16, 16,
+ LR_SHARED);
+ SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)mainBigIcon);
+ SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)mainSmallIcon);
+
+ // Setup system menu
+ HMENU hSysMenu = GetSystemMenu(m_hWnd, FALSE);
+ if (hSysMenu) {
+ TCHAR itemStr[100];
+ LoadString(m_hInst, IDS_ABOUT, itemStr, sizeof(itemStr)/sizeof(TCHAR));
+ AppendMenu(hSysMenu, MF_SEPARATOR, 0, NULL);
+ AppendMenu(hSysMenu, MF_STRING, ((UINT)IDM_ABOUT)<<4, itemStr);
+ }
+ // Setup owner-draw button
+ m_aboutBtn.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDC_ABOUT));
+ m_aboutBtn.setIcon(IDI_INFO, 16, 16);
+
+ m_okBtn.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDOK));
+ m_okBtn.setIcon(IDI_OK, 16, 16);
+ m_okBtn.setDefaultButton(TRUE);
+ SendMessage(m_hWnd, DM_SETDEFID, IDOK, 0);
+
+ m_cancelBtn.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDC_EXIT));
+ m_cancelBtn.setIcon(IDI_CANCEL, 16, 16);
+
+ m_helpBtn.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDC_OPEN_HELP));
+ m_helpBtn.setIcon(IDI_HELP, 16, 16);
+
+ m_resetBtn.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDC_RESET));
+ m_resetBtn.setIcon(IDI_RESET, 16, 16);
+
+ m_expandBtn.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDC_EXPAND));
+ m_expandBtn.setIcon(IDI_EXPAND, 16, 16);
+
+ m_macroBtn.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDC_MACRO_BTN));
+ //m_macroBtn.setIcon(IDI_HELP, 16, 16);
+
+ m_codeList = GetDlgItem(m_hWnd,IDC_CODE_TABLE);
+ m_showCtrl = GetDlgItem(m_hWnd,IDC_SHOW_DLG);
+ m_markCheck = GetDlgItem(m_hWnd, IDC_FREE_MARKING);
+ m_toneCtrl = GetDlgItem(m_hWnd, IDC_TONE_CTRL);
+ m_modernStyleCheck = GetDlgItem(m_hWnd, IDC_MODERN_STYLE);
+ m_macroCheck = GetDlgItem(m_hWnd, IDC_MACRO_CHECK);
+ m_useUnicodeClipboardCheck = GetDlgItem(m_hWnd, IDC_USE_CLIPBOARD);
+
+ m_swKeyBtn1 = GetDlgItem(m_hWnd, IDC_SW_KEY1);
+ m_swKeyBtn2 = GetDlgItem(m_hWnd, IDC_SW_KEY2);
+
+ m_inputList = GetDlgItem(m_hWnd, IDC_INPUT_METHOD);
+
+ loadDlgInfo(m_pPref);
+ expand(FALSE);
+ return TRUE;
+}
+
+//-----------------------------------------------
+BOOL CKeyDlg::onOK()
+{
+ HWND hFocusWnd = GetFocus();
+ if (IsPushButton(hFocusWnd)) {
+ int id = GetDlgCtrlID(hFocusWnd);
+ if (id != IDOK) {
+ SendMessage(hFocusWnd, BM_CLICK, 0, 0);
+ return FALSE;
+ }
+ }
+ storeDlgInfo(m_pPref);
+ DestroyWindow(m_hWnd);
+ m_hWnd = NULL;
+ SendMessage(m_hWndOwner, WM_COMMAND, ID_CONFIRM_PANEL, 0);
+ return TRUE;
+}
+
+
+//-----------------------------------------------
+BOOL CKeyDlg::onCancel()
+{
+ ModifyStatusIcon();
+ return TRUE;
+}
+
+//-----------------------------------------------
+BOOL CKeyDlg::onCommand(WPARAM wParam, LPARAM lParam)
+{
+ WORD cmd = GET_WM_COMMAND_ID(wParam, lParam);
+ switch (cmd) {
+ case IDC_ABOUT:
+ DoAbout(m_hInst, m_hWnd,
+ (SendDlgItemMessage(m_hWnd, IDC_VIET_GUI, BM_GETCHECK, 0, 0) ==
BST_CHECKED)? 1 : 0);
+ return TRUE;
+ case IDC_OPEN_HELP:
+ MainWnd.openHelp();
+ return TRUE;
+ case IDC_RESET:
+ {
+ CUserPref current, def;
+ storeDlgInfo(&current);
+ def.setDefault(&current);
+ loadDlgInfo(&def);
+ }
+ break;
+ case IDC_EXIT:
+ storeDlgInfo(m_pPref);
+ DestroyWindow(m_hWnd);
+ m_hWnd = NULL;
+ SendMessage(m_hWndOwner, WM_COMMAND, ID_END_KEY, 0);
+ return TRUE;
+ case IDC_VIET_GUI:
+ if (GET_WM_COMMAND_CMD(wParam, lParam) == BN_CLICKED) {
+ int langID;
+ langID = (SendDlgItemMessage(m_hWnd, IDC_VIET_GUI, BM_GETCHECK, 0, 0)
== BST_CHECKED)? 1 : 0;
+ applyLanguage(langID);
+ }
+ break;
+ case IDC_MACRO_BTN:
+ {
+ CMacroDlg macroDlg(m_pPref, &m_tempPref);
+ macroDlg.init(m_hInst, m_hWnd);
+ macroDlg.setLangID(Button_GetCheck(GetDlgItem(m_hWnd, IDC_VIET_GUI))?
1 : 0);
+ if (macroDlg.ShowDialog() == IDOK) {
+ MainWnd.updateMacroTable();
+ }
+ }
+ break;
+ case IDC_INPUT_METHOD:
+ if (GET_WM_COMMAND_CMD(wParam, lParam) == CBN_SELCHANGE) {
+ Button_SetCheck(m_markCheck, ComboBox_GetCurSel(m_inputList) !=
TELEX_INPUT);
+ }
+ break;
+ }
+ return CExpandDialog::onCommand(wParam, lParam);
+}
+
+//----------------------------------------------
+BOOL CKeyDlg::onDialogExpanding(BOOL bExpanded)
+{
+ CExpandDialog::onDialogExpanding(bExpanded);
+ m_expandBtn.setIcon(bExpanded ? IDI_EXPAND : IDI_CONTRACT, 16, 16);
+ return TRUE;
+}
+
+//----------------------------------------------
+void CKeyDlg::applyLanguage(int langIdx)
+{
+ CMultiLangDialog::applyLanguage(langIdx);
+ if (langIdx >= 0 && langIdx < 2) { // currently support 2 languages En,Vi
+#ifndef _UNICODE
+ strcpy(m_strExpand, ExpandLabel[langIdx]);
+ strcpy(m_strContract, ContractLabel[langIdx]);
+#else
+ int inLen, maxOutLen;
+ inLen = -1;
+ maxOutLen = sizeof(m_strExpand);
+ VnConvert(CONV_CHARSET_TCVN3, CONV_CHARSET_UNICODE,
+ (BYTE *)ExpandLabel[langIdx], (BYTE *)m_strExpand,
+ inLen, maxOutLen);
+
+ inLen = -1;
+ maxOutLen = sizeof(m_strContract);
+ VnConvert(CONV_CHARSET_TCVN3, CONV_CHARSET_UNICODE,
+ (BYTE *)ContractLabel[langIdx], (BYTE *)m_strContract,
+ inLen, maxOutLen);
+#endif
+ SendDlgItemMessage(m_hWnd, m_nIDButton, WM_SETTEXT,
+ 0, (LPARAM)(m_bExpanded ? m_strContract : m_strExpand));
+ }
+}
+
+//----------------------------------------------
+BOOL CKeyDlg::onDestroy()
+{
+ cleanup();
+ return CVirDialog::onDestroy();
+}
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/keydlg.h Mon
Oct 10 16:21:04 2011
@@ -0,0 +1,70 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#ifndef __KEY_DLG_H
+#define __KEY_DLG_H
+
+#include "util.h"
+#include "ExpDlg.h"
+#include "button.h"
+#include "userPref.h"
+
+class CKeyDlg : public CExpandDialog, public CMultiLangDialog
+{
+public:
+ int init(HINSTANCE hInst, HWND hWndOwner = NULL);
+ // overrides
+ virtual BOOL onCommand(WPARAM wParam, LPARAM lParam);
+ virtual BOOL onOK();
+ virtual BOOL onCancel();
+ virtual BOOL onInitDialog();
+
+ // update text labels according to the chosen GUI language
+ // langID = 0 -> English (default)
+ //void setItemsText(int langID); //TEST
+ //void setDlgFont(int langID); //TEST
+protected:
+ //HFONT m_hStdFont; //TEST
+ CCustomButton m_aboutBtn, m_okBtn, m_helpBtn, m_cancelBtn, m_resetBtn,
m_expandBtn, m_macroBtn;
+ HWND m_codeList, m_inputList, m_showCtrl, m_swKeyBtn1, m_swKeyBtn2,
+ m_markCheck, m_toneCtrl, m_modernStyleCheck, m_macroCheck,
m_useUnicodeClipboardCheck;
+ CUserPref *m_pPref, m_tempPref;
+ void loadDlgInfo(CUserPref *pPref);
+ void storeDlgInfo(CUserPref *pPref);
+
+public:
+ CKeyDlg(CUserPref *pPref) : CExpandDialog()
+ {
+ m_pPref = pPref;
+ m_hStdFont = NULL;
+ }
+
+ virtual BOOL DialogProc(
+ HWND hWndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam);
+ //overrides
+ virtual BOOL onDialogExpanding(BOOL bExpanded);
+ virtual BOOL onDestroy();
+ void applyLanguage(int langIdx);
+};
+
+
+#endif
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/label.cpp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,148 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#include "prehdr.h"
+#include "label.h"
+
+LRESULT CALLBACK GenLabelProc(
+ HWND hWnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+ )
+{
+ CSmLabel *pLabel = (CSmLabel *)GetWindowLong(hWnd, GWL_USERDATA);
+ if (pLabel)
+ return pLabel->wndProc(hWnd, uMsg, wParam, lParam);
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
+}
+
+//-----------------------------------------------
+// Attach the static label to this CSmLabel object
+//-----------------------------------------------
+void CSmLabel::attachWindow(HWND hWnd)
+{
+ m_hWnd = hWnd;
+ SetWindowLong(hWnd, GWL_USERDATA, (LONG)this);
+ SetWindowLong(hWnd, GWL_STYLE, SS_NOTIFY | GetWindowLong(hWnd,
GWL_STYLE));
+ // Subclass the button
+ m_prevWndProc = SetWindowLong(hWnd, GWL_WNDPROC, (LONG)GenLabelProc);
+}
+
+//-----------------------------------------------
+void CSmLabel::init(HINSTANCE hInst, HWND hOwner, HWND hWnd)
+{
+ m_hInstance = hInst;
+ m_hOwner = hOwner;
+ attachWindow(hWnd);
+ // setup GDI
+ m_textColor = GetSysColor(COLOR_WINDOWTEXT);
+ m_hBrush = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
+ HFONT hFont = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0);
+ if (hFont != NULL)
+ GetObject(hFont,sizeof(m_lf),&m_lf);
+ else
+ GetObject((HFONT)GetStockObject(DEFAULT_GUI_FONT),sizeof(m_lf),&m_lf);
+ m_hFont = CreateFontIndirect(&m_lf);
+ m_hCursor = NULL;
+}
+
+//-----------------------------------------------
+CSmLabel::~CSmLabel()
+{
+ DeleteObject(m_hFont);
+ DeleteObject(m_hBrush);
+}
+
+//-----------------------------------------------
+void CSmLabel::setBkColor(COLORREF color)
+{
+ if (m_hBrush)
+ ::DeleteObject(m_hBrush);
+ m_hBrush = ::CreateSolidBrush(color);
+}
+
+//-----------------------------------------------
+void CSmLabel::reconstructFont()
+{
+ DeleteObject(m_hFont);
+ m_hFont = CreateFontIndirect(&m_lf);
+
+}
+
+//-----------------------------------------------
+HBRUSH CSmLabel::onCtlColor(HDC hDC, HWND hCtrl)
+{
+ SetTextColor(hDC, m_textColor);
+ SelectObject(hDC, m_hFont);
+ SetBkMode(hDC, TRANSPARENT);
+ return m_hBrush;
+}
+
+//-------------------------------------------------------
+LRESULT CSmLabel::wndProc(
+ HWND hWnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam) // second message parameter
+{
+ switch (uMsg) {
+ case WM_CTLCOLORSTATIC:
+ // This is actually a reflection message from the parent window
+ // The parent window must send this message each time it receives
WM_CTLCOLORSTATIC
+ return (LRESULT)onCtlColor((HDC)wParam, (HWND)lParam);
+ case WM_SETCURSOR:
+ if (m_hCursor)
+ SetCursor(m_hCursor);
+ return TRUE;
+ }
+ return CallWindowProc((WNDPROC)m_prevWndProc, hWnd, uMsg, wParam, lParam);
+}
+
+
+HCURSOR CLinkLabel::m_shLinkCursor = NULL;
+
+//-------------------------------------------------------
+void CLinkLabel::init(HINSTANCE hInst, HWND hOwner, HWND hWnd, const TCHAR
*link)
+{
+ CSmLabel::init(hInst, hOwner, hWnd);
+ setCursor(m_shLinkCursor);
+ setHyperLink(link);
+ setTextColor(RGB(0, 0, 255));
+ setFontUnderline();
+ //setFontBold();
+ reconstructFont();
+}
+
+
+//-------------------------------------------------------
+LRESULT CLinkLabel::wndProc(
+ HWND hWnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam) // second message parameter
+{
+ switch (uMsg) {
+ case WM_LBUTTONDOWN:
+ ShellExecute(NULL, _TEXT("open"), m_link, NULL, NULL, SW_SHOWNORMAL);
+ break;
+ }
+ return CSmLabel::wndProc(hWnd, uMsg, wParam, lParam);
+}
+
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/label.h Mon
Oct 10 16:21:04 2011
@@ -0,0 +1,160 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#ifndef __SMART_LABEL_H
+#define __SMART_LABEL_H
+
+LRESULT CALLBACK GenLabelProc(
+ HWND hWnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+ );
+
+class CSmLabel
+{
+protected:
+ HWND m_hOwner;
+ HINSTANCE m_hInstance;
+ LONG m_prevWndProc; // previous window procedure
+
+ // color
+ COLORREF m_textColor;
+
+ // GDI objects
+ LOGFONT m_lf;
+ HFONT m_hFont;
+ HBRUSH m_hBrush;
+ HCURSOR m_hCursor;
+
+public:
+ HWND m_hWnd;
+ //CSmLabel();
+ ~CSmLabel();
+ void init(HINSTANCE hInst, HWND hOwner, HWND hWnd);
+
+ // color
+ void setTextColor(COLORREF color);
+ void setBkColor(COLORREF color);
+
+ void setText(const TCHAR *text)
+ {
+ SetWindowText(m_hWnd, text);
+ }
+
+ // font settings
+ void setFontBold(BOOL bBold = TRUE);
+ void setFontUnderline(BOOL bSet = TRUE);
+ void setFontItalic(BOOL bSet = TRUE);
+ void setFontName(const TCHAR *fntName);
+ void setFontSize(int nSize);
+ void reconstructFont();
+
+ void setCursor(HCURSOR hCursor);
+
+ void redraw();
+
+ friend LRESULT CALLBACK ::GenLabelProc(
+ HWND hwnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+ );
+
+protected:
+ virtual LRESULT wndProc(
+ HWND hwnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+ );
+ virtual HBRUSH onCtlColor(HDC hDC, HWND hCtrl);
+private:
+ void attachWindow(HWND hWnd);
+};
+
+class CLinkLabel: public CSmLabel
+{
+public:
+ void init(HINSTANCE hInst, HWND hOwner, HWND hWnd, const TCHAR *link);
+ void setHyperLink(const TCHAR *link)
+ {
+ _tcscpy(m_link, link);
+ }
+
+ virtual LRESULT wndProc(
+ HWND hwnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+ );
+ static setLinkCursor(HCURSOR hCursor)
+ {
+ m_shLinkCursor = hCursor;
+ }
+
+protected:
+ TCHAR m_link[100];
+ static HCURSOR m_shLinkCursor;
+};
+
+//-----------------------------------------------
+inline void CSmLabel::setFontBold(BOOL bBold)
+{
+ m_lf.lfWeight = bBold ? FW_BOLD : FW_NORMAL;
+}
+
+//-----------------------------------------------
+inline void CSmLabel::setFontUnderline(BOOL bSet)
+{
+ m_lf.lfUnderline = bSet;
+}
+
+//-----------------------------------------------
+inline void CSmLabel::setFontItalic(BOOL bSet)
+{
+ m_lf.lfItalic = bSet;
+}
+
+//-----------------------------------------------
+inline void CSmLabel::setFontName(const TCHAR *fntName)
+{
+ _tcscpy(m_lf.lfFaceName, fntName);
+}
+
+//-----------------------------------------------
+inline void CSmLabel::redraw()
+{
+ RedrawWindow(m_hWnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW |
RDW_ERASE);
+}
+
+//-----------------------------------------------
+inline void CSmLabel::setCursor(HCURSOR hCursor)
+{
+ m_hCursor = hCursor;
+}
+
+//-----------------------------------------------
+inline void CSmLabel::setTextColor(COLORREF color)
+{
+ m_textColor = color;
+}
+
+#endif
+
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/macrodlg.cpp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,693 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+
+#include "prehdr.h"
+#include "resource.h"
+#include <windowsx.h>
+#include <stdio.h>
+
+#include "keycons.h"
+#include "mainwnd.h"
+#include "macrodlg.h"
+#include "encode.h"
+#include "util.h"
+#include "vnconv.h"
+
+//#define MAX_MACRO_LEN 20
+//#define MAX_REPL_TEXT_LEN 128
+
+#define MACRO_EDIT_KEYDOWN (WM_USER + 105)
+
+char * ReplaceLabel[] = {
+ "Replace",
+ "&Söa"};
+
+char * AddLabel[] = {
+ "&Add",
+ "&Thªm"};
+
+
+AnsiDlgItemInfo VnMacroDlgItems[] = {
+ {IDC_STATIC_REPLACE, "Thay thÕ:"},
+ {IDC_STATIC_WITH, "Bëi:"},
+ {IDOK, "&L­u"},
+ {IDCANCEL, "&Ngõng"},
+ {IDC_DELETE, "&Xo¸"},
+ {IDC_NOTE, "L­u ý: th«ng tin ë ®©y ®­îc thÓ hiÖn d­íi d¹ng VIQR"},
+ {IDC_ALWAYS_MACRO, "Cho phÐp gâ t¾t c¶ khi t¾t tiÕng ViÖt"},
+ {IDC_SELECT_FILE, "Chän File..."},
+ {IDC_SELECT_DEFAULT, "File mÆc dÞnh"},
+ {IDC_PATH_LABEL, "File gâ t¾t:"}
+ };
+
+DlgItemInfo EnMacroDlgItems[] = {
+ {IDC_STATIC_REPLACE, _T("Replace:")},
+ {IDC_STATIC_WITH, _T("With:")},
+ {IDOK, _T("&OK")},
+ {IDCANCEL, _T("&Cancel")},
+ {IDC_DELETE, _T("&Delete")},
+ {IDC_NOTE, _T("Note: Replacement texts are displayed here in VIQR
format")},
+ {IDC_ALWAYS_MACRO, _T("Allow macros even if Vietnamese is off")},
+ {IDC_SELECT_FILE, _T("Select file...")},
+ {IDC_SELECT_DEFAULT, _T("Select default")},
+ {IDC_PATH_LABEL, _T("Macro file:")}
+ };
+
+#define MAX_ITEM_LEN 60
+
+#ifdef _UNICODE
+
+wchar_t
UniVnMacroDlgTexts[sizeof(VnMacroDlgItems)/sizeof(AnsiDlgItemInfo)][MAX_ITEM_LEN];
+DlgItemInfo
UniVnMacroDlgItems[sizeof(VnMacroDlgItems)/sizeof(AnsiDlgItemInfo)];
+
+#endif
+
+extern CMainWnd MainWnd;
+
+//local helpers
+const TCHAR *getKey(const TCHAR *text);
+const TCHAR *getReplText(const TCHAR *text);
+int getExactItem(HWND listCtrl, TCHAR *key, int & nearest);
+
+
+//------------------------------------------
+int CMacroDlg::init(HINSTANCE hInst, HWND hWndOwner)
+{
+ int ret = CMultiLangDialog::init(hInst, MAKEINTRESOURCE(IDD_MACRO),
hWndOwner);
+ initLanguageInfo();
+ setupLanguage(0, EnMacroDlgItems,
sizeof(EnMacroDlgItems)/sizeof(DlgItemInfo));
+
+#ifndef _UNICODE
+ setupLanguage(1, VnMacroDlgItems,
sizeof(VnMacroDlgItems)/sizeof(AnsiDlgItemInfo),
+ VIET_FONT_NAME, VIET_DLG_FONT_SIZE);
+#else
+ int items = sizeof(VnMacroDlgItems)/sizeof(AnsiDlgItemInfo);
+ int inLen, maxOutLen;
+ for (int i=0; i<items; i++) {
+ inLen = -1;
+ maxOutLen = 2*MAX_ITEM_LEN;
+ VnConvert(CONV_CHARSET_TCVN3, CONV_CHARSET_UNICODE,
+ (BYTE *)VnMacroDlgItems[i].text, (BYTE *)UniVnMacroDlgTexts[i],
+ inLen, maxOutLen);
+ UniVnMacroDlgItems[i].id = VnMacroDlgItems[i].id;
+ UniVnMacroDlgItems[i].text = UniVnMacroDlgTexts[i];
+ }
+ setupLanguage(1, UniVnMacroDlgItems, items, VIET_FONT_NAME,
VIET_DLG_FONT_SIZE);
+#endif
+
+ return ret;
+}
+
+//--------------------------------------------
+int CMacroDlg::loadMacTab(CMacroTable *pTab)
+{
+ // init list box items
+ TCHAR str[MAX_MACRO_LINE];
+ ListBox_ResetContent(m_itemListCtrl);
+ for (int i=0; i < pTab->m_count; i++) {
+#ifndef _UNICODE
+ sprintf(str, "%s\t%s",
+ pTab->m_table[i].key,
+ pTab->m_table[i].text);
+#else
+ wchar_t wKeyStr[MAX_MACRO_KEY_LEN];
+ wchar_t wTextStr[MAX_MACRO_TEXT_LEN];
+ int inLen, maxOutLen;
+ inLen = -1;
+ maxOutLen = sizeof(wKeyStr);
+ VnConvert(CONV_CHARSET_VIQR, CONV_CHARSET_UNICODE,
+ (BYTE *)pTab->m_table[i].key,
+ (BYTE *)wKeyStr,
+ inLen, maxOutLen);
+
+ inLen = -1;
+ maxOutLen = sizeof(wTextStr);
+ VnConvert(CONV_CHARSET_VIQR, CONV_CHARSET_UNICODE,
+ (BYTE *)pTab->m_table[i].text,
+ (BYTE *)wTextStr,
+ inLen, maxOutLen);
+
+ //MultiByteToWideChar(CP_US_ANSI, 0, pTab->m_table[i]->key, -1, wKeyStr,
256);
+ //MultiByteToWideChar(CP_US_ANSI, 0, pTab->m_table[i]->text, -1,
wTextStr, 256);
+ swprintf(str, _TEXT("%s\t%s"), wKeyStr, wTextStr);
+#endif
+ ListBox_AddString(m_itemListCtrl, str);
+ }
+ return 1;
+}
+//------------------------------------------
+BOOL CMacroDlg::onInitDialog()
+{
+ if (!CMultiLangDialog::onInitDialog())
+ return FALSE;
+
+ if (MainWnd.isVietFontOK())
+ setDlgFont(1);
+
+ applyLanguage(m_langID? 1 : 0);
+
+ m_selectFileBtn.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd,
IDC_SELECT_FILE));
+ m_selectFileBtn.setIcon(IDI_OPEN_FOLDER, 16, 16);
+
+ m_defFileBtn.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd,
IDC_SELECT_DEFAULT));
+ m_defFileBtn.setIcon(IDI_RESET, 16, 16);
+
+ m_okBtn.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDOK));
+ m_okBtn.setIcon(IDI_OK, 16, 16);
+
+ m_cancelBtn.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDCANCEL));
+ m_cancelBtn.setIcon(IDI_CANCEL, 16, 16);
+
+ m_editBtn.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDC_EDIT));
+ m_editBtn.setIcon(IDI_ADD, 16, 16);
+ m_editBtn.setDefaultButton(TRUE);
+ SendMessage(m_hWnd, DM_SETDEFID, IDC_EDIT, 0);
+
+ m_deleteBtn.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDC_DELETE));
+ m_deleteBtn.setIcon(IDI_DELETE, 16, 16);
+
+ m_itemListCtrl = GetDlgItem(m_hWnd, IDC_ITEMLIST);
+
+ //m_textEdit.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDC_TEXT));
+ m_textCtrl = GetDlgItem(m_hWnd, IDC_TEXT);
+ m_keyEdit.init(m_hInst, m_hWnd, GetDlgItem(m_hWnd, IDC_KEY));
+
+ m_alwaysMacroCheck = GetDlgItem(m_hWnd, IDC_ALWAYS_MACRO);
+ Button_SetCheck(m_alwaysMacroCheck, m_pTempPref->m_alwaysMacro);
+
+ m_pathCtrl = GetDlgItem(m_hWnd, IDC_FILE_NAME);
+ _tcscpy(m_path, MainWnd.m_currentMacPath);
+ Static_SetText(m_pathCtrl, m_path);
+
+ int tab = 56;
+ ListBox_SetTabStops(m_itemListCtrl, 1, &tab);
+ setReplaceBtn(0);
+ EnableWindow(m_editBtn.m_hWnd, FALSE);
+ EnableWindow(m_deleteBtn.m_hWnd, FALSE);
+
+// setEditFont();
+ loadMacTab(&MainWnd.m_macTab);
+
+ return TRUE;
+}
+
+//-----------------------------------------------
+BOOL CMacroDlg::onOK()
+{
+ //DestroyWindow(m_hWnd);
+ //m_hWnd = NULL;
+ _tcscpy(MainWnd.m_currentMacPath, m_path);
+ MainWnd.m_macTab.resetContent();
+ int count = ListBox_GetCount(m_itemListCtrl);
+ TCHAR str[MAX_MACRO_LINE];
+ for (int i=0; i < count; i++) {
+ ListBox_GetText(m_itemListCtrl, i, str);
+
+#ifndef _UNICODE
+ MainWnd.m_macTab.addItem(getKey(str), getReplText(str));
+#else
+ char keyStr[MAX_MACRO_KEY_LEN];
+ char textStr[MAX_MACRO_TEXT_LEN];
+// WideCharToMultiByte(CP_US_ANSI, 0, getKey(str), -1, keyStr,
sizeof(keyStr), NULL, NULL);
+// WideCharToMultiByte(CP_US_ANSI, 0, getReplText(str), -1, textStr,
sizeof(textStr), NULL, NULL);
+ int inLen, maxOutLen;
+
+ inLen = -1;
+ maxOutLen = sizeof(keyStr);
+ if (VnConvert(CONV_CHARSET_UNICODE, CONV_CHARSET_VIQR,
+ (BYTE *)getKey(str),
+ (BYTE *)keyStr,
+ inLen, maxOutLen) != 0)
+ continue;
+
+ inLen = -1;
+ maxOutLen = sizeof(textStr);
+ if (VnConvert(CONV_CHARSET_UNICODE, CONV_CHARSET_VIQR,
+ (BYTE *)getReplText(str),
+ (BYTE *)textStr,
+ inLen, maxOutLen) != 0)
+ continue;
+
+ MainWnd.m_macTab.addItem(keyStr, textStr);
+#endif
+
+ }
+ MainWnd.m_macTab.writeToFile(m_path);
+ m_pTempPref->m_alwaysMacro = Button_GetCheck(m_alwaysMacroCheck);
+
+ return TRUE;
+}
+
+//-----------------------------------------------
+BOOL CMacroDlg::onDefaultButton()
+{
+ HWND hFocusWnd = GetFocus();
+ if (IsPushButton(hFocusWnd)) {
+ WORD defId = LOWORD(SendMessage(m_hWnd, DM_GETDEFID, 0, 0));
+ int id = GetDlgCtrlID(hFocusWnd);
+ if (id != defId) {
+ SendMessage(hFocusWnd, BM_CLICK, 0, 0);
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+//------------------------------------------
+void CMacroDlg::applyLanguage(int langIdx)
+{
+ CMultiLangDialog::applyLanguage(langIdx);
+ if (langIdx >= 0 && langIdx < 2) { // currently support 2 languages En,Vi
+ char *text;
+ if (m_isEditReplace)
+ text = ReplaceLabel[langIdx];
+ else
+ text = AddLabel[langIdx];
+#ifndef _UNICODE
+ SendDlgItemMessage(m_hWnd, IDC_EDIT, WM_SETTEXT, 0, (LPARAM)text);
+#else
+ wchar_t str[MAX_ITEM_LEN];
+ int inLen, maxOutLen;
+ inLen = -1;
+ maxOutLen = sizeof(str);
+ VnConvert(CONV_CHARSET_TCVN3, CONV_CHARSET_UNICODE,
+ (BYTE *)text, (BYTE *)str,
+ inLen, maxOutLen);
+ SendDlgItemMessage(m_hWnd, IDC_EDIT, WM_SETTEXT, 0, (LPARAM)str);
+#endif
+
+ }
+}
+
+//------------------------------------------
+BOOL CMacroDlg::onDestroy()
+{
+ if (m_hEditFont != NULL) {
+ DeleteObject(m_hEditFont);
+ m_hEditFont = NULL;
+ }
+ return CMultiLangDialog::onDestroy();
+}
+
+
+//------------------------------------------
+void CMacroDlg::setEditFont()
+{
+ if (m_hEditFont != NULL) {
+ DeleteObject(m_hEditFont);
+ m_hEditFont = NULL;
+ }
+ HDC hDC = GetDC(m_hWnd);
+ m_hEditFont = CustomCreateFont(hDC, _TEXT("Arial"), 10);
+// if (m_hEditFont)
+// SendMessage(m_contentCtrl, WM_SETFONT, (WPARAM)m_hEditFont, TRUE);
+}
+
+
+//--------------------------------------------------
+BOOL CMacroDlg::DialogProc(
+ HWND hDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ switch (uMsg) {
+ case WM_DRAWITEM:
+ // Send reflection message to back the control
+ return SendDlgItemMessage(hDlg, wParam, WM_DRAWITEM, wParam, lParam);
+ case WM_ACTIVATE:
+ updateKeyHook(wParam != WA_INACTIVE);
+ break;
+
+ case WM_KEYDOWN:
+ {
+ HWND hWndFocus = GetFocus();
+ if (hWndFocus == m_keyEdit.m_hWnd) {
+ if (wParam == VK_DOWN || wParam == VK_UP ||
+ wParam == VK_PRIOR || wParam == VK_NEXT)
+ //SetFocus(m_itemListCtrl);
+ SendMessage(m_itemListCtrl, WM_KEYDOWN, wParam, lParam);
+ return 0;
+ }
+ }
+ break;
+ }
+ return CMultiLangDialog::DialogProc(hDlg, uMsg, wParam, lParam);
+}
+
+//------------------------------------------------------------------
+// ownMode: 0 : Reset to system mode
+// 1 : Set appropriate mode in order to input macro text
(VIQR/Unicode)
+//------------------------------------------------------------------
+void CMacroDlg::updateKeyHook(int ownMode)
+{
+ if (ownMode) {
+#ifndef _UNICODE
+ BuildCodeTable(VIQR_CHARSET, m_pPref->m_inMethod,
&pSharedMem->codeTable);
+ SetKeyMode(VIQR_CHARSET, m_pPref->m_inMethod, &pSharedMem->codeTable);
+#else
+ BuildCodeTable(UNICODE_CHARSET, m_pPref->m_inMethod,
&pSharedMem->codeTable);
+ SetKeyMode(UNICODE_CHARSET, m_pPref->m_inMethod, &pSharedMem->codeTable);
+/*
+ BuildCodeTable(WINCP1258_CHARSET, m_pPref->m_inMethod,
&pSharedMem->codeTable);
+ SetKeyMode(WINCP1258_CHARSET, m_pPref->m_inMethod,
&pSharedMem->codeTable);
+*/
+#endif
+ pSharedMem->codeTable.encoding = 0;
+ DWORD temp = m_pPref->m_macroEnabled;
+ m_pPref->m_macroEnabled = 0;
+ SetHookOptions(*m_pPref);
+ m_pPref->m_macroEnabled = temp;
+ }
+ else {
+ //MessageBeep(MB_ICONASTERISK);
+ BuildCodeTable(CharsetTable[m_pPref->m_codeTable].id,
m_pPref->m_inMethod, &pSharedMem->codeTable);
+ pSharedMem->codeTable.encoding =
CharsetTable[m_pPref->m_codeTable].encoding;
+ SetKeyMode(CharsetTable[m_pPref->m_codeTable].id, m_pPref->m_inMethod,
&pSharedMem->codeTable);
+ SetHookOptions(*m_pPref);
+ }
+}
+
+
+//------------------------------------------
+int selectFileDlg(HWND hWndOwner, TCHAR *fileName, int size)
+{
+ OPENFILENAME of;
+ ZeroMemory(&of, sizeof(OPENFILENAME));
+
+ *fileName = 0;
+ of.lStructSize = sizeof(OPENFILENAME);
+ of.hwndOwner = hWndOwner;
+ of.lpstrFile = fileName;
+ of.nMaxFile = size;
+ of.lpstrFilter = _TEXT("Plain text (*.txt)\0*.txt\0All files
(*.*)\0*.*\0");
+ of.nFilterIndex = 1;
+ of.lpstrFileTitle = NULL;
+ of.nMaxFileTitle = 0;
+ of.lpstrInitialDir = NULL;
+ of.lpstrTitle = _TEXT("Select macro file");
+ of.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+
+ return GetOpenFileName(&of);
+}
+
+//---------------------------------------------------
+int CMacroDlg::loadMacFile(TCHAR *path)
+{
+ CMacroTable macTab;
+ if (!macTab.loadFromFile(path))
+ return 0;
+ loadMacTab(&macTab);
+ return 1;
+}
+
+//-----------------------------------------------
+BOOL CMacroDlg::onCommand(WPARAM wParam, LPARAM lParam)
+{
+ WORD cmdID = GET_WM_COMMAND_ID(wParam, lParam);
+ WORD cmd = GET_WM_COMMAND_CMD(wParam, lParam);
+
+ switch (cmdID) {
+ case IDC_ITEMLIST:
+ if (cmd == LBN_SELCHANGE) {
+ onItemSelChange();
+ }
+ break;
+ case IDC_DELETE:
+ if (cmd == BN_CLICKED) {
+ onDeleteItem();
+ }
+ break;
+ case IDC_EDIT:
+ if (!onDefaultButton())
+ break;
+ if (cmd == BN_CLICKED) {
+ onEditItem();
+ }
+ break;
+ case IDC_TEXT:
+ if (cmd == EN_CHANGE) {
+ onTextChange();
+ }
+ break;
+ case IDC_KEY:
+ if (cmd == EN_CHANGE) {
+ onKeyChange();
+ }
+ break;
+ case IDC_SELECT_FILE:
+ {
+ TCHAR path[MAX_PATH];
+ _tcscpy(path, m_path);
+ if (selectFileDlg(m_hWnd, path, sizeof(path)/sizeof(TCHAR))) {
+ if (loadMacFile(path)) {
+ _tcscpy(m_path, path);
+ Static_SetText(m_pathCtrl, m_path);
+ }
+ else MessageBox(m_hWnd, _T("Failed to load the specified macro file"),
+ _T("Error"), MB_ICONERROR);
+ }
+ }
+ break;
+ case IDC_SELECT_DEFAULT:
+ {
+ if (loadMacFile(MainWnd.m_macroPath)) {
+ _tcscpy(m_path, MainWnd.m_macroPath);
+ Static_SetText(m_pathCtrl, m_path);
+ }
+ else MessageBox(m_hWnd, _T("Failed to load the specified macro file"),
+ _T("Error"), MB_ICONERROR);
+ }
+ break;
+ }
+
+ return CMultiLangDialog::onCommand(wParam, lParam);
+}
+
+
+//-----------------------------------------------
+void CMacroDlg::onItemSelChange()
+{
+ int sel = ListBox_GetCurSel(m_itemListCtrl);
+ if (sel != LB_ERR) {
+ TCHAR str[MAX_MACRO_LINE];
+ ListBox_GetText(m_itemListCtrl, sel, str);
+ SetWindowText(m_keyEdit.m_hWnd, getKey(str));
+ SetWindowText(m_textCtrl, getReplText(str));
+ SetFocus(m_keyEdit.m_hWnd);
+ Edit_SetSel(m_keyEdit.m_hWnd, 0, -1);
+ setReplaceBtn(1);
+ EnableWindow(m_editBtn.m_hWnd, FALSE);
+ EnableWindow(m_deleteBtn.m_hWnd, TRUE);
+ }
+}
+
+//-----------------------------------------------
+void CMacroDlg::setReplaceBtn(int replace)
+{
+ m_isEditReplace = replace;
+ char *text = (replace)? ReplaceLabel[m_langID] : AddLabel[m_langID];
+
+#ifndef _UNICODE
+ Button_SetText(m_editBtn.m_hWnd, text);
+#else
+ wchar_t str[MAX_ITEM_LEN];
+ int inLen, maxOutLen;
+ inLen = -1;
+ maxOutLen = sizeof(str);
+ VnConvert(CONV_CHARSET_TCVN3, CONV_CHARSET_UNICODE,
+ (BYTE *)text, (BYTE *)str,
+ inLen, maxOutLen);
+ Button_SetText(m_editBtn.m_hWnd, str);
+#endif
+
+}
+
+
+//-----------------------------------------------
+void CMacroDlg::onDeleteItem()
+{
+ TCHAR key[MAX_MACRO_KEY_LEN+1];
+ TCHAR text[MAX_MACRO_TEXT_LEN];
+
+ Edit_GetText(m_textCtrl, text, MAX_MACRO_TEXT_LEN);
+ Edit_GetText(m_keyEdit.m_hWnd, key, MAX_MACRO_KEY_LEN);
+// _tcscat(key, _TEXT("\t"));
+
+ int exactSel, nearest;
+ exactSel = getExactItem(m_itemListCtrl, key, nearest);
+ if (exactSel != LB_ERR) {
+ ListBox_DeleteString(m_itemListCtrl, exactSel);
+ EnableWindow(m_deleteBtn.m_hWnd, FALSE);
+ setReplaceBtn(0); // change to add mode
+ EnableWindow(m_editBtn.m_hWnd, *text != NULL);
+ SetFocus(m_keyEdit.m_hWnd);
+ Edit_SetSel(m_keyEdit.m_hWnd, 0, -1);
+ }
+}
+
+//-----------------------------------------------
+void CMacroDlg::onEditItem()
+{
+ TCHAR key[MAX_MACRO_KEY_LEN+1], text[MAX_MACRO_TEXT_LEN];
+ TCHAR str[MAX_MACRO_LINE+1];
+
+
+ Edit_GetText(m_keyEdit.m_hWnd, key, MAX_MACRO_KEY_LEN);
+ Edit_GetText(m_textCtrl, text, MAX_MACRO_TEXT_LEN);
+ _stprintf(str, _TEXT("%s\t%s"), key, text);
+
+ int sel, exactSel;
+ exactSel = getExactItem(m_itemListCtrl, key, sel);
+ if (exactSel != LB_ERR)
+ ListBox_DeleteString(m_itemListCtrl, exactSel);
+
+ ListBox_SetCurSel(m_itemListCtrl, ListBox_AddString(m_itemListCtrl, str));
+ // update control states
+ setReplaceBtn(1);
+ EnableWindow(m_editBtn.m_hWnd, FALSE);
+ EnableWindow(m_deleteBtn.m_hWnd, TRUE);
+ SetFocus(m_keyEdit.m_hWnd);
+ Edit_SetSel(m_keyEdit.m_hWnd, 0, -1);
+}
+
+//-----------------------------------------------
+void CMacroDlg::onTextChange()
+{
+ TCHAR key[MAX_MACRO_KEY_LEN];
+ TCHAR text[MAX_MACRO_TEXT_LEN];
+
+ Edit_GetText(m_textCtrl, text, MAX_MACRO_TEXT_LEN);
+ Edit_GetText(m_keyEdit.m_hWnd, key, MAX_MACRO_KEY_LEN);
+
+ EnableWindow(m_editBtn.m_hWnd, *text != NULL && *key != NULL);
+}
+
+//-----------------------------------------------
+void CMacroDlg::onKeyChange()
+{
+ TCHAR key[MAX_MACRO_KEY_LEN+1];
+ TCHAR text[MAX_MACRO_TEXT_LEN];
+
+ Edit_GetText(m_textCtrl, text, MAX_MACRO_TEXT_LEN);
+ Edit_GetText(m_keyEdit.m_hWnd, key, MAX_MACRO_KEY_LEN);
+
+ int sel;
+ int exactSel = LB_ERR;
+
+ if (*key != NULL) {
+ exactSel = getExactItem(m_itemListCtrl, key, sel);
+ ListBox_SetCurSel(m_itemListCtrl,
+ (exactSel != LB_ERR)? exactSel : ((sel != LB_ERR)? sel : -1));
+ }
+ else ListBox_SetCurSel(m_itemListCtrl, -1);
+
+ if (exactSel != LB_ERR) {
+ setReplaceBtn(1);
+ EnableWindow(m_editBtn.m_hWnd, *text != NULL);
+ EnableWindow(m_deleteBtn.m_hWnd, TRUE);
+ }
+ else {
+ setReplaceBtn(0);
+ EnableWindow(m_editBtn.m_hWnd, *key!=NULL && *text!=NULL);
+ EnableWindow(m_deleteBtn.m_hWnd, FALSE);
+ }
+}
+
+//-----------------------------------------------
+const TCHAR *getKey(const TCHAR *text)
+{
+ static TCHAR str[MAX_MACRO_LINE];
+ _tcscpy(str, text);
+ TCHAR *p = _tcschr(str, _TEXT('\t'));
+ if (p != NULL)
+ *p = NULL;
+ return str;
+}
+
+//-----------------------------------------------
+const TCHAR *getReplText(const TCHAR *text)
+{
+ static TCHAR str[MAX_MACRO_LINE];
+ _tcscpy(str, text);
+ TCHAR *p = _tcschr(str, _TEXT('\t'));
+ if (p == NULL)
+ return NULL;
+ return (p+1);
+}
+
+
+
+//-------------------------------------------------------
+LRESULT CMacroEdit::wndProc(
+ HWND hWnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam) // second message parameter
+{
+ switch (uMsg) {
+ case WM_KEYDOWN:
+ if (wParam == VK_DOWN || wParam == VK_UP || wParam == VK_PRIOR || wParam
== VK_NEXT) {
+ SendMessage(m_hOwner, WM_KEYDOWN, wParam, lParam);
+ return 0;
+ }
+ /*
+ case WM_CHAR:
+ {
+ if (wParam > 255) {
+ TCHAR msg[100];
+ _stprintf(msg, _T("wParam: %d"), wParam);
+ MessageBox(NULL, msg, _T("Info"), MB_OK);
+ }
+ else if (wParam == 0xFD)
+ MessageBox(NULL, _T("Something is wrong"), _T("Info"), MB_OK);
+ }
+ break;
+ */
+
+ }
+ return CSmartEdit::wndProc(hWnd, uMsg, wParam, lParam);
+}
+
+//-------------------------------------------------------
+int getExactItem(HWND listCtrl, TCHAR *key, int & nearest)
+{
+ nearest = ListBox_FindString(listCtrl, -1, key);
+ if (nearest == LB_ERR)
+ return LB_ERR;
+
+ TCHAR itemStr[MAX_MACRO_LINE];
+ const TCHAR *pItemKey;
+ int exactFound = 0;
+ int i = nearest;
+ int count = ListBox_GetCount(listCtrl);
+ while (i < count) {
+ ListBox_GetText(listCtrl, i, itemStr);
+ pItemKey = getKey(itemStr);
+ if (_tcsicmp(key, pItemKey) != 0)
+ break;
+ if (_tcscmp(key, pItemKey) == 0) {// exact found
+ exactFound = 1;
+ break;
+ }
+ i++;
+ }
+ return exactFound? i : LB_ERR;
+}
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/macrodlg.h
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,114 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#ifndef __MACRO_DIALOG_H
+#define __MACRO_DIALOG_H
+
+#include "util.h"
+#include "userpref.h"
+#include "button.h"
+#include "smedit.h"
+
+class CMacroEdit : public CSmartEdit
+{
+protected:
+ virtual LRESULT wndProc(
+ HWND hwnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+ );
+};
+
+class CMacroDlg: public CMultiLangDialog
+{
+protected:
+ CUserPref * m_pPref, *m_pTempPref;
+ HFONT m_hEditFont;
+ HWND m_itemListCtrl;
+ HWND m_textCtrl;
+ HWND m_alwaysMacroCheck;
+ HWND m_pathCtrl;
+
+ CCustomButton m_editBtn, m_deleteBtn, m_okBtn, m_cancelBtn,
+ m_selectFileBtn, m_defFileBtn;
+
+ CMacroEdit m_keyEdit;
+
+ int m_isEditReplace; // state of Add/Replace button
+ int m_langID;
+ TCHAR m_path[MAX_PATH];
+
+public:
+ CMacroDlg(CUserPref *pPref, CUserPref *pTempPref) : CMultiLangDialog()
+ {
+ m_pPref = pPref;
+ m_pTempPref = pTempPref;
+ m_hEditFont = NULL;
+ m_isEditReplace = 1;
+ m_langID = 0;
+ }
+
+// void loadDlgInfo(CUserPref *pPref);
+// void storeDlgInfo(CUserPref *pPref);
+
+ void setLangID(int langID) {
+ m_langID = langID;
+ if (m_langID > 1) // supports only 2 languages
+ m_langID = 0;
+ }
+
+ // helper function members;
+ void setEditFont();
+
+
+ // overrides
+ int init(HINSTANCE hInst, HWND hWndOwner = NULL);
+ virtual BOOL onInitDialog();
+ virtual BOOL onDestroy();
+ virtual BOOL onCommand(WPARAM wParam, LPARAM lParam);
+ void applyLanguage(int langIdx);
+
+ virtual BOOL onOK();
+ virtual BOOL DialogProc(
+ HWND hWndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam);
+
+ void updateKeyHook(int ownMode);
+
+ // event handlers
+ void onItemSelChange();
+ void onDeleteItem();
+ void onEditItem();
+ void onTextChange();
+ void onKeyChange();
+ BOOL onDefaultButton();
+
+ // helper functions
+ void setReplaceBtn(int replace = 1);
+protected:
+ int loadMacTab(CMacroTable *pTab);
+ int loadMacFile(TCHAR *path);
+
+};
+
+
+#endif
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/mactab.cpp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,161 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+
+#include "prehdr.h"
+#include <stdio.h>
+#include "mactab.h"
+
+//---------------------------------------------------------------
+CMacroTable::CMacroTable(int memSize)
+{
+ m_count = 0;
+ m_table = new MacroDef[MAX_MACRO_ITEMS];
+ m_macroMem = new char[MACRO_MEM_SIZE];
+ m_memSize = memSize;
+ m_occupied = 0;
+}
+
+//---------------------------------------------------------------
+CMacroTable::~CMacroTable()
+{
+ delete [] m_macroMem;
+ delete [] m_table;
+}
+
+//---------------------------------------------------------------
+int CMacroTable::loadFromFile(const TCHAR *fname)
+{
+ FILE *f = _tfopen(fname, _TEXT("rt"));
+ if (f == NULL)
+ return 0;
+ char line[MAX_MACRO_LINE];
+ int len;
+ while (!feof(f)) {
+ fgets(line, sizeof(line), f);
+ len = strlen(line);
+ if (line[len-1] == '\n')
+ line[len-1] = '\0';
+ addItem(line);
+ }
+ fclose(f);
+ return 1;
+}
+
+//---------------------------------------------------------------
+int CMacroTable::writeToFile(const TCHAR *fname)
+{
+ FILE *f = _tfopen(fname, _TEXT("wt"));
+ if (f == NULL)
+ return 0;
+
+ char line[MAX_MACRO_LINE];
+ for (int i=0; i < m_count; i++) {
+ if (i < m_count-1)
+ sprintf(line, "%s:%s\n", m_table[i].key, m_table[i].text);
+ else
+ sprintf(line, "%s:%s", m_table[i].key, m_table[i].text);
+ fputs(line, f);
+ }
+ fclose(f);
+ return 1;
+}
+
+//---------------------------------------------------------------
+int CMacroTable::addItem(const char *key, const char *text)
+{
+ if (m_count >= MAX_MACRO_ITEMS)
+ return -1;
+
+ int keyLen, textLen;
+ keyLen = strlen(key);
+ if (keyLen == 0)
+ return -1;
+ if (keyLen > MAX_MACRO_KEY_LEN -1)
+ keyLen = MAX_MACRO_KEY_LEN - 1;
+
+ textLen = strlen(text);
+ if (textLen == 0)
+ return -1;
+ if (textLen > MAX_MACRO_TEXT_LEN - 1)
+ textLen = MAX_MACRO_TEXT_LEN - 1;
+
+
+ // add to the sorted table
+ int c;
+ int i = 0;
+ while (i<m_count) {
+ c = strcmp(m_table[i].key, key);
+ if (c == 0)
+ // string already exists
+ return i;
+ if (c > 0)
+ break;
+ i++;
+ }
+
+ if (m_occupied + keyLen + textLen + 2 > m_memSize)
+ return -1;
+
+ // moving
+ for (int k=m_count; k>i; k--)
+ m_table[k] = m_table[k-1];
+
+ // store new macro
+ char *p = m_macroMem + m_occupied;
+ m_table[i].key = p;
+ memcpy(p, key, keyLen);
+ p[keyLen] = 0;
+ p += keyLen+1;
+ m_table[i].text = p;
+ memcpy(p, text, textLen);
+ p[textLen] = 0;
+
+ m_occupied += keyLen+textLen+2;
+ m_count++;
+
+ return i;
+}
+
+//---------------------------------------------------------------
+// add a new macro into the sorted macro table
+// item format: key:text (key and text are separated by a colon)
+//---------------------------------------------------------------
+int CMacroTable::addItem(const char *item)
+{
+ char key[MAX_MACRO_KEY_LEN];
+
+ // Parse the input item
+ char * pos = strchr(item, ':');
+ if (pos == NULL)
+ return -1;
+ int keyLen = (int)(pos - item);
+ if (keyLen > MAX_MACRO_KEY_LEN-1)
+ keyLen = MAX_MACRO_KEY_LEN-1;
+ strncpy(key, item, keyLen);
+ key[keyLen] = '\0';
+ return addItem(key, ++pos);
+}
+
+//---------------------------------------------------------------
+void CMacroTable::resetContent()
+{
+ m_occupied = 0;
+ m_count = 0;
+}
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/mactab.h Mon
Oct 10 16:21:04 2011
@@ -0,0 +1,51 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#ifndef __MACRO_TABLE_H
+#define __MACRO_TABLE_H
+
+#include "keycons.h"
+
+struct MacroDef
+{
+ char *key;
+ char *text;
+};
+
+class CMacroTable
+{
+public:
+// MacroDef *m_table[MAX_MACRO_ITEMS];
+ MacroDef *m_table;
+ char *m_macroMem;
+// char *m_current;
+
+ int m_count;
+ int m_memSize, m_occupied;
+
+ CMacroTable(int memSize = MACRO_MEM_SIZE);
+ ~CMacroTable();
+ int loadFromFile(const TCHAR *fname);
+ int writeToFile(const TCHAR *fname);
+ void resetContent();
+ int addItem(const char *item);
+ int addItem(const char *key, const char *text);
+};
+
+#endif
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/mainwnd.cpp
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,583 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#include "prehdr.h"
+#include "mainwnd.h"
+#include "resource.h"
+#include "encode.h"
+#include "keydlg.h"
+#include "userpref.h"
+#include "font.h"
+#include "tooldlg.h"
+#include "vnconv.h"
+#include "intrtfio.h"
+
+#define WM_MYICON_NOTIFY (WM_USER+1)
+
+// Global variables
+HINSTANCE AppInstance, HookDll;
+
+HHOOK hKeyHook,hMouseHook;
+TCHAR AppTitle[100];
+
+SharedMem *pSharedMem = NULL;
+
+BOOL initDLL(HWND hWnd);
+
+CUserPref UserPref; // user preference
+CMainWnd MainWnd(&UserPref);
+
+BOOL CMainWnd::initInstance(HINSTANCE hInstance)
+{
+ HWND hWnd = Create(
+ WS_EX_TOOLWINDOW,
+ MAIN_WINDOW_CLASS_NAME,
+ AppTitle,
+ WS_OVERLAPPEDWINDOW,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ NULL,
+ NULL,
+ hInstance);
+ if (!hWnd)
+ return FALSE;
+ ShowWindow(hWnd, SW_HIDE);
+ UpdateWindow(hWnd);
+
+ m_vietFontOK = 0;
+ if (FontExists(VIET_FONT_NAME)) {
+ m_vietFontOK = 1;
+ }
+ else {
+ if (loadVietFont()) {
+ m_vietFontOK = 1;
+ }
+ }
+
+ if (UserPref.m_vietGUI && !m_vietFontOK)
+ UserPref.m_vietGUI = 0;
+ m_menu.init(hInstance, hWnd, &UserPref);
+ m_menu.reload();
+ UserPref.m_changes = 0;
+ // Locate help file. The name of help file is "UniKey.hlp", it is
supposed to be
+ // in the same location with the exe file.
+ GetModuleFileName(NULL, m_helpPath, sizeof(m_helpPath)/sizeof(TCHAR));
+ TCHAR *p = _tcsrchr(m_helpPath, _TEXT('\\'));
+ _tcscpy(p+1, _TEXT("ukmacro.txt"));
+ _tcscpy(m_macroPath, m_helpPath);
+
+#ifndef _UNICODE
+ _tcscpy(p+1, _TEXT("UniKey.hlp"));
+#else
+ _tcscpy(p+1, _TEXT("ukmanual.htm"));
+#endif
+
+ _tcscpy(m_currentMacPath, m_macroPath);
+ m_macTab.loadFromFile(m_macroPath);
+ return TRUE;
+}
+
+//-------------------------------------------------
+LRESULT CMainWnd::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT result;
+ result = FALSE;
+ static UINT taskbarCreatedMsg;
+
+ switch (uMsg) {
+ /*
+ case WM_MULTI_INSTANCE:
+ MessageBox(m_hWnd, "UniKey is already running", "Information",
MB_ICONINFORMATION);
+ result = TRUE;
+ break;
+ */
+ case WM_CREATE:
+ taskbarCreatedMsg = RegisterWindowMessage(TEXT("TaskbarCreated"));
+ result = TRUE;
+ break;
+ case WM_MEASUREITEM:
+ m_menu.measureItem((LPMEASUREITEMSTRUCT)lParam);
+ result = TRUE;
+ break;
+ case WM_DRAWITEM:
+ {
+ LPDRAWITEMSTRUCT lpd = (LPDRAWITEMSTRUCT)lParam;
+ if (lpd->CtlType == ODT_MENU)
+ m_menu.drawItem(lpd);
+ }
+ result = TRUE;
+ break;
+ case WM_MYICON_NOTIFY:
+ switch (lParam) {
+ case WM_LBUTTONDOWN:
+ SwitchMode();
+ break;
+ case WM_RBUTTONUP:
+ {
+ POINT point;
+ GetCursorPos(&point);
+ SetForegroundWindow(m_hWnd);
+ m_menu.trackPopupMenu(
+ TPM_RIGHTALIGN | TPM_BOTTOMALIGN,
+ point.x,
+ point.y);
+ PostMessage(m_hWnd, WM_NULL, 0, 0);
+ }
+ break;
+ case WM_LBUTTONDBLCLK:
+ {
+ UINT id = GetMenuDefaultItem(m_menu.m_hMenu, FALSE, 0);
+ if (id != -1) {
+ SwitchMode();
+ PostMessage(m_hWnd, WM_COMMAND, id, 0);
+ }
+ }
+ break;
+ }
+ result = TRUE;
+ break;
+ case WM_DESTROY:
+ case WM_QUERYENDSESSION:
+ UserPref.m_vietnamese = IsVietnamese();
+ UserPref.setValue();
+ if (uMsg == WM_DESTROY)
+ PostQuitMessage(1);
+ result = TRUE;
+ break;
+ case WM_HOOK_TOOLKIT_SHORTCUT:
+ onToolkit();
+ result = TRUE;
+ break;
+ case WM_HOOK_PANEL_SHORTCUT:
+ onPanel();
+ result = TRUE;
+ break;
+ case WM_HOOK_FLY_CONVERT:
+ {
+ int convErrCode;
+ ConvertClipboard(InConvCharsetList[UserPref.m_inConvCharset].id,
+ OutConvCharsetList[UserPref.m_outConvCharset].id,
+ convErrCode);
+ result = TRUE;
+ }
+ break;
+ case WM_HOOK_CHANGE_CHARSET:
+ {
+ UserPref.m_changes = PREF_CHANGE_CHARSET;
+ UserPref.m_codeTable = wParam;
+ updateChanges(UserPref);
+ m_menu.update();
+ UserPref.m_changes = 0;
+ }
+ break;
+ case WM_RENDERFORMAT:
+ RenderFormat(wParam);
+ result = 0;
+ break;
+ case WM_RENDERALLFORMATS:
+ RenderAllFormats();
+ result = 0;
+ break;
+ case WM_COMMAND:
+ switch (wParam) {
+ case ID_OPEN_HELP:
+ openHelp();
+ result = TRUE;
+ break;
+ case ID_END_KEY:
+ DeleteStatusIcon();
+ DestroyWindow(m_hWnd);
+ result = FALSE;
+ break;
+ case ID_TOOLKIT:
+ onToolkit();
+ result = TRUE;
+ break;
+ case ID_KEY_PANEL:
+ onPanel();
+ result = TRUE;
+ break;
+ case ID_FLY_CONVERT:
+ {
+ int convErrCode;
+ ConvertClipboard(InConvCharsetList[UserPref.m_inConvCharset].id,
+ OutConvCharsetList[UserPref.m_outConvCharset].id,
+ convErrCode, 1, m_hWnd);
+ result = TRUE;
+ }
+ break;
+ case ID_CONFIRM_PANEL:
+ if (UserPref.m_changes) {
+ updateChanges(UserPref);
+ m_menu.update();
+ UserPref.m_changes = 0;
+ }
+ break;
+ default:
+ if (m_menu.processCommand(wParam)) {
+ updateChanges(UserPref);
+ UserPref.m_changes = 0;
+ }
+ }
+ break;
+ default:
+ if (uMsg == taskbarCreatedMsg) {
+ //recreate systray icon
+ pSharedMem->iconShown = 0;
+ ModifyStatusIcon();
+ }
+ result = DefWindowProc(m_hWnd, uMsg, wParam, lParam);
+ }
+ return result;
+}
+
+//---------------------------------------------
+BOOL InitApplication(
+ HINSTANCE hInstance)
+{
+ BOOL bOk;
+ // The window class for all instances of the main window.
+ WNDCLASSEX wcf;
+
+ // Assign the appropriate values for this main frame window class.
+ wcf.cbSize = sizeof(WNDCLASSEX);
+ wcf.cbClsExtra = 0; // No per-class extra data.
+ wcf.cbWndExtra = 0; // No per-window extra data.
+ wcf.hInstance = hInstance; // Application module instance.
+ wcf.lpfnWndProc = GenWindowProc; // Global Window Procedure (defined in
+ // UTIL.H for all CVirWindows).
+ wcf.hCursor = NULL; // Load app cursor.
+ wcf.hIcon = (HICON) LoadImage( // Load small icon.
+ hInstance,
+ MAKEINTRESOURCE(IDR_MAINFRAME),
+ IMAGE_ICON,
+ 32, 32,
+ LR_SHARED);
+ wcf.hIconSm = NULL;
+ wcf.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); // Default
backgnd color.
+ wcf.style = 0; // Class style(s).
+ wcf.lpszClassName = MAIN_WINDOW_CLASS_NAME; // Class name.
+ wcf.lpszMenuName = NULL; // Menu name.
+
+ // Register the window class and return FALSE if unsuccesful.
+ bOk = RegisterClassEx(&wcf);
+
+ return (bOk);
+}
+
+//-------------------------------------------
+int WINAPI WinMain(
+ HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow
+)
+{
+#ifdef _UNICODE
+ OSVERSIONINFO osinfo;
+ osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&osinfo);
+ if (osinfo.dwMajorVersion < 4 || osinfo.dwPlatformId !=
VER_PLATFORM_WIN32_NT) {
+ MessageBoxA(NULL, "This version runs only in Windows NT.40/2000/XP
only\n"
+ "You can download UniKey running on all Windows platforms at
http://unikey.sourceforge.net",
+ "Platform not supported",
+ MB_ICONERROR);
+ return -1;
+ }
+#endif
+ InitRtfIO();
+
+ MSG msg;
+ //-- Check if a previous instance is loaded
+ AppInstance = hInstance;
+ LoadString(AppInstance,IDS_APP_TITLE,AppTitle,100);
+ if (HWND hPrevWnd = FindWindow(MAIN_WINDOW_CLASS_NAME, NULL)) {
+ // Bring in the last instance and exit
+ BringWindowToTop(hPrevWnd);
+ SetForegroundWindow(hPrevWnd);
+ PostMessage(hPrevWnd,WM_COMMAND,ID_KEY_PANEL,0);
+ //PostMessage(hPrevWnd, WM_MULTI_INSTANCE, 0, 0);
+ return 0;
+ }
+ if (!InitApplication(hInstance))
+ return 0;
+ UserPref.getValue();
+
+ if (!MainWnd.initInstance(hInstance))
+ return 0;
+ // Init DLL
+ HookDll = GetVietHookDll();
+ if (!initDLL(MainWnd.m_hWnd))
+ return 0;
+
+ ModifyStatusIcon(); // Show icon on the tray
+ if (UserPref.m_showDlg)
+ PostMessage(MainWnd.m_hWnd, WM_COMMAND, ID_KEY_PANEL, 0);
+ else
+ MessageBeep(0xFFFFFFFF);
+ while (GetMessage(&msg, (HWND) NULL, 0, 0)) {
+ if ((!IsWindow(MainWnd.m_toolDlg.m_hWnd) |
| !IsDialogMessage(MainWnd.m_toolDlg.m_hWnd,&msg)) &&
+ (!IsWindow(MainWnd.m_configDlg.m_hWnd) |
| !IsDialogMessage(MainWnd.m_configDlg.m_hWnd,&msg))) {
+
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+
+ }
+ }
+
+ // the program is finished
+ if (hKeyHook != NULL)
+ UnhookWindowsHookEx(hKeyHook);
+ if (hMouseHook != NULL)
+ UnhookWindowsHookEx(hMouseHook);
+ MainWnd.cleanup();
+ return 1;
+}
+
+//--------------------------------------------
+BOOL initDLL(HWND hWnd)
+{
+ HOOKPROC keyProc = (HOOKPROC)GetProcAddress(HookDll, "MyKeyHook");
+ HOOKPROC mouseProc = (HOOKPROC)GetProcAddress(HookDll, "MyMouseHook");
+ if (keyProc == NULL || mouseProc == NULL) {
+ MessageBox(NULL, _TEXT("Failed to find hook procedures"),
_TEXT("Error"), MB_OK | MB_ICONERROR);
+ return FALSE;
+ }
+
+ hKeyHook = SetWindowsHookEx(WH_KEYBOARD, keyProc, HookDll, 0);
+ hMouseHook = SetWindowsHookEx(WH_MOUSE,mouseProc, HookDll, 0);
+
+ if (hKeyHook == NULL || hMouseHook == NULL) {
+ MessageBox(NULL, _TEXT("Failed to initialize the program"),
_TEXT("Error"), MB_OK | MB_ICONERROR);
+ return FALSE;
+ }
+
+ pSharedMem = GetSharedMem();
+
+ // Init shared memory
+ pSharedMem->hMainDlg = hWnd;
+ pSharedMem->hEnIcon = LoadIcon(AppInstance,MAKEINTRESOURCE(IDI_EN));
+ pSharedMem->hVietIcon = LoadIcon(AppInstance,MAKEINTRESOURCE(IDI_VIET));
+ pSharedMem->iconShown = 0;
+ pSharedMem->keyHook = hKeyHook;
+ pSharedMem->mouseHook = hMouseHook;
+ pSharedMem->keyMode = CharsetTable[UserPref.m_codeTable].id;
+ pSharedMem->iconMsgId = WM_MYICON_NOTIFY;
+ pSharedMem->switchKey = UserPref.m_switchKey;
+ pSharedMem->vietKey = UserPref.m_vietnamese;
+ pSharedMem->inMethod = UserPref.m_inMethod;
+
+ SetHookOptions(UserPref);
+
+ if (CharsetTable[UserPref.m_codeTable].encoding == UNICODE_UTF8_X) {
+ pSharedMem->codeTable.encoding = UNICODE_UTF8;
+ pSharedMem->codeTable.singleBackspace = 1;
+ }
+ else {
+ pSharedMem->codeTable.encoding =
CharsetTable[UserPref.m_codeTable].encoding;
+ pSharedMem->codeTable.singleBackspace = 0;
+ }
+
+ //pSharedMem->codeTable.encoding =
CharsetTable[UserPref.m_codeTable].encoding;
+
+ BuildCodeTable(CharsetTable[UserPref.m_codeTable].id,
UserPref.m_inMethod, &pSharedMem->codeTable);
+ pSharedMem->Initialized = 1;
+ MainWnd.updateMacroTable();
+ return TRUE;
+}
+
+
+void getFontFile(TCHAR *path, int size)
+{
+ GetModuleFileName(NULL, path, size);
+ TCHAR *p = _tcsrchr(path, _T('\\'));
+ if (p != NULL) p++;
+ else p = path;
+ _tcscpy(p, VIET_FONT_FILE);
+
+}
+
+//----------------------------------------
+CMainWnd::CMainWnd(CUserPref *pPref) : m_configDlg(pPref), m_toolDlg(pPref)
+{
+ m_pPref = pPref;
+ m_menuItems = 0;
+ m_helpPath[0] = 0;
+ m_fontLoaded = 0;
+ m_vietFontOK = 0;
+};
+
+//----------------------------------------
+int CMainWnd::loadVietFont()
+{
+#ifndef _UNICODE
+ TCHAR path[MAX_PATH];
+ getFontFile(path, sizeof(path)*sizeof(TCHAR));
+ if (AddFontResource(path) > 0) {
+ SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
+ m_fontLoaded = 1;
+ //fontInstalled = 1;
+ return 1;
+ }
+ return 0;
+#else
+ return 1;
+#endif
+}
+
+//----------------------------------------
+void CMainWnd::cleanup()
+{
+#ifndef _UNICODE
+ if (m_fontLoaded) {
+ TCHAR path[MAX_PATH];
+ getFontFile(path, sizeof(path)*sizeof(TCHAR));
+ RemoveFontResource(path);
+ m_fontLoaded = 0;
+ }
+#endif
+}
+
+//------------------------------------------------------
+void CMainWnd::updateChanges(const CUserPref &pref)
+{
+ if (pref.m_changes & PREF_CHANGE_CHARSET) {
+ BuildCodeTable(CharsetTable[pref.m_codeTable].id, pref.m_inMethod,
&pSharedMem->codeTable);
+
+ if (CharsetTable[pref.m_codeTable].encoding == UNICODE_UTF8_X) {
+ pSharedMem->codeTable.encoding = UNICODE_UTF8;
+ pSharedMem->codeTable.singleBackspace = 1;
+ }
+ else {
+ pSharedMem->codeTable.encoding =
CharsetTable[pref.m_codeTable].encoding;
+ pSharedMem->codeTable.singleBackspace = 0;
+ }
+
+ SetKeyMode(CharsetTable[pref.m_codeTable].id, pref.m_inMethod,
&pSharedMem->codeTable);
+ updateMacroTable();
+ }
+
+ if ((pref.m_changes & PREF_CHANGE_METHOD) &&
+ ((pref.m_changes & PREF_CHANGE_CHARSET) == 0)) {
+ BuildInputMethod(pref.m_inMethod, &pSharedMem->codeTable);
+ SetInputMethod(pref.m_inMethod, pSharedMem->codeTable.DT);
+ }
+
+ if (pref.m_changes & PREF_CHANGE_SWITCHKEY)
+ SetSwitchKey(pref.m_switchKey);
+
+ if (pref.m_changes & PREF_CHANGE_OPTIONS)
+ SetHookOptions(pref);
+}
+
+//------------------------------------
+void CMainWnd::onToolkit()
+{
+ if (m_toolDlg.m_hWnd == NULL) {
+ m_toolDlg.init(m_hInst, m_hWnd);
+ m_toolDlg.ShowModelessDialog();
+ }
+ else {
+ ShowWindow(m_toolDlg.m_hWnd, SW_SHOW);
+ BringWindowToTop(m_toolDlg.m_hWnd);
+ }
+}
+
+//------------------------------------
+void CMainWnd::onPanel()
+{
+ if (m_configDlg.m_hWnd == NULL) {
+ m_configDlg.init(m_hInst, m_hWnd);
+ m_configDlg.ShowModelessDialog();
+ }
+ else {
+ ShowWindow(m_configDlg.m_hWnd, SW_SHOW);
+ BringWindowToTop(m_configDlg.m_hWnd);
+ }
+}
+
+//------------------------------------
+void SetHookOptions(const CUserPref & pref)
+{
+ pSharedMem->options.freeMarking = pref.m_freeMarking;
+ pSharedMem->options.toneNextToVowel = pref.m_toneNextToVowel;
+ pSharedMem->options.modernStyle = pref.m_modernStyle;
+ pSharedMem->options.macroEnabled = pref.m_macroEnabled;
+ pSharedMem->options.useUnicodeClipboard = pref.m_useUnicodeClipboard;
+ pSharedMem->options.alwaysMacro = pref.m_alwaysMacro;
+ pSharedMem->options.useIME = pref.m_useIME;
+}
+
+//------------------------------------
+void CMainWnd::updateMacroTable()
+{
+ int inLen, maxOutLen;
+ int ret, i, k;
+ int outCharset = CharsetTable[m_pPref->m_codeTable].vnconvId;
+ if (CharsetTable[m_pPref->m_codeTable].id == UNICODE_CHARSET)
+ outCharset = CONV_CHARSET_UNICODE; // it would be a waste to store macro
as UTF-8, or NCR. Use pure Unicode
+
+ char *p = pSharedMem->macroMem;
+ int offset = 0;
+ //int avail = MACRO_MEM_SIZE;
+ int len;
+ for (i=0, k=0; i<m_macTab.m_count && k < MAX_MACRO_ITEMS; i++) {
+ len = strlen(m_macTab.m_table[i].key);
+ //if (len+1 > avail)
+ // break;
+ if (offset+len+1 > MACRO_MEM_SIZE)
+ break;
+ strcpy(p, m_macTab.m_table[i].key);
+ pSharedMem->macroTable[k].keyOffset = offset;
+ p += len+1;
+ //avail -= (len+1);
+ offset += (len+1);
+
+ inLen = -1;
+ maxOutLen = MACRO_MEM_SIZE - offset;
+ ret = VnConvert(CONV_CHARSET_VIQR, outCharset,
+ (BYTE *)m_macTab.m_table[i].text,
+ (BYTE *)p,
+ inLen, maxOutLen);
+ if (ret != 0) {
+ p -= (len+1);
+ offset -= (len+1);
+ continue;
+ }
+
+ pSharedMem->macroTable[k].textOffset = offset;
+ p += maxOutLen;
+ //avail -= maxOutLen;
+ offset += maxOutLen;
+ k++;
+ }
+ pSharedMem->macroCount = k;
+}
+
+//------------------------------------
+void CMainWnd::openHelp()
+{
+#ifndef _UNICODE
+ WinHelp(m_hWnd, m_helpPath, HELP_FINDER, 0);
+#else
+ ShellExecute(NULL, _T("open"), m_helpPath, NULL, NULL, SW_SHOWNORMAL);
+#endif
+}
=======================================
--- /dev/null
+++ /trunk/ unikeyspell --username trung...@gmail.com/newkey/mainwnd.h
Mon Oct 10 16:21:04 2011
@@ -0,0 +1,94 @@
+/*------------------------------------------------------------------------------
+UniKey - Vietnamese Keyboard for Windows
+Copyright (C) 1998-2002 Pham Kim Long
+Contact: lo...@cslab.felk.cvut.cz
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------------*/
+#ifndef __MAIN_WINDOW_H
+#define __MAIN_WINDOW_H
+
+#include "util.h"
+#include "keyhook.h"
+#include "userPref.h"
+#include "ukmenu.h"
+#include "tooldlg.h"
+#include "keydlg.h"
+#include "mactab.h"
+
+#define MAIN_WINDOW_CLASS_NAME _T("UniKey MainWnd")
+
+#ifdef _UNICODE
+ #define VIET_FONT_NAME _T("Arial")
+ #define VIET_DLG_FONT_SIZE 8
+ #define VIET_MENU_FONT_SIZE 8
+#else
+ #define VIET_FONT_NAME _T("ABC Sans Serif")
+ #define VIET_DLG_FONT_SIZE 8
+ #define VIET_MENU_FONT_SIZE 8
+#endif
+
+#define VIET_FONT_FILE _T("abcserif.fon") // used only in non-unicode
version
+
+class CMainWnd : public CVirWindow
+{
+protected:
+// HMENU m_menu, m_subMenu;
+ CUniKeyMenu m_menu;
+ int m_menuItems;
+ TCHAR m_helpPath[MAX_PATH];
+
+ int m_fontLoaded;
+// int m_vietGUI; // vietnamese user interface
+ int m_vietFontOK;
+ CUserPref * m_pPref;
+public:
+ TCHAR m_macroPath[MAX_PATH];
+ TCHAR m_currentMacPath[MAX_PATH];
+
+ CMacroTable m_macTab;
+
+ CKeyDlg m_configDlg;
+ CToolkitDlg m_toolDlg;
+ void updateChanges(const CUserPref & pref);
+ CMainWnd(CUserPref *pPref);
+/*
+ ~CMainWnd()
+ {
+ if (m_menu)
+ DestroyMenu(m_menu);
+ }
+*/
+ BOOL initInstance(HINSTANCE hInstance);
+
+ virtual LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
+ void cleanup();
+ int loadVietFont();
+ void openHelp();
+
+ int isVietFontOK()
+ {
+ return m_vietFontOK;
+ }
+
+ void onToolkit();
+ void onPanel();
+ void updateMacroTable();
+};
+
+extern SharedMem * pSharedMem;
+void SetHookOptions(const CUserPref & pref);
+
+#endif
=======================================
***Additional files exist in this changeset.***

Nguyễn Vũ Hưng

unread,
Oct 11, 2011, 1:02:21 AM10/11/11
to unike...@googlegroups.com


On Tue, Oct 11, 2011 at 06:26, <unike...@googlecode.com> wrote:
Revision: 6
Author:   trung...@gmail.com
Date:     Mon Oct 10 16:21:04 2011
Log:      original code
http://code.google.com/p/unikeyspell/source/detail?r=6

Hi Trung,

Định làm tiếp cái này à? OK thôi hehe


--
Best Regards,
Nguyen Hung Vu [aka: NVH] ( in Vietnamese: Nguyễn Vũ Hưng )
vuhung16plus{remove}@gmail.dot.com , YIM: vuhung16 , Skype: vuhung16plus, twitter: vuhung, MSN: vuhung16.
http://www.facebook.com/nguyenvuhung
http://nguyen-vu-hung.blogspot.com/

Trung An

unread,
Oct 11, 2011, 1:51:25 AM10/11/11
to unike...@googlegroups.com

Vâng, em muốn làm cho nó xong anh ạ

Nguyễn Vũ Hưng

unread,
Oct 11, 2011, 2:43:47 AM10/11/11
to unike...@googlegroups.com
2011/10/11 Trung An <trung...@gmail.com>:

> Vâng, em muốn làm cho nó xong anh ạ

Anh rất ủng hộ.

Em cứ tiến hành những gì còn dở dang, anh support trong trong phạm vi
có thể (trừ code hộ:))

Trung An

unread,
Oct 14, 2011, 12:29:00 AM10/14/11
to unike...@googlegroups.com

Anh Hưng ơi, có cách nào để dọn dẹp đống code trên Google ko anh? Lúc em checkout thì thấy nó nặng tới 26mb, mà em đoán chắc là do rác vì mình chưa có bất kì 1 thay đổi nào trong mã nguồn cả. Thêm nữa là hôm nọ em có commit lên nhầm, đâm ra giờ trên repo có thêm 1 thư mục con với nội dung y hệt như thư mục gốc.

Repo lộn xộn thế này thì khó chịu quá. Anh chỉnh nó giúp em được ko ạ? Em chưa quen với svn lắm nên ko biết làm cách nào. Em cảm ơn anh

Nguyễn Vũ Hưng

unread,
Oct 14, 2011, 12:37:55 AM10/14/11
to unike...@googlegroups.com
2011/10/14 Trung An <trung...@gmail.com>:

> Anh Hưng ơi, có cách nào để dọn dẹp đống code trên Google ko anh?

Em du -sh cái thư mục được checkout thì nó lên 26MB là đúng rồi.
Lý do: Hầu hết size bị chiếm bởi folder .svn (metadata, history data...)
Chứ thực ra code của unikey làm gì có mấy.


> Lúc em
> checkout thì thấy nó nặng tới 26mb, mà em đoán chắc là do rác vì mình chưa
> có bất kì 1 thay đổi nào trong mã nguồn cả. Thêm nữa là hôm nọ em có commit
> lên nhầm, đâm ra giờ trên repo có thêm 1 thư mục con với nội dung y hệt như
> thư mục gốc.
>
> Repo lộn xộn thế này thì khó chịu quá. Anh chỉnh nó giúp em được ko ạ? Em
> chưa quen với svn lắm nên ko biết làm cách nào. Em cảm ơn anh

Lộn xộn là do mình, từ revert, del (một vài thư mục, file) và commit lại thôi

Ngoài ra,
- Tất cả các file trung gian như .manifest, .dll, .exe, .obj đều phải
xóa khỏi svn
(.obj khá to)

Em commit sai nên đang thừa folder "unikeyspell --username trung...@gmail.com"
Xóa nó đi.

Reply all
Reply to author
Forward
0 new messages