Added STCDLLEXPORT so wxSTC could be built and used as a DLL.

Fixed DoAddChar handling in unicode mode to translate the char to UTF8
if needed.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17420 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-10-02 00:15:07 +00:00
parent f50b6e1d9b
commit ce500334d8
5 changed files with 42 additions and 12 deletions

View File

@@ -24,6 +24,12 @@
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/dnd.h> #include <wx/dnd.h>
#ifdef STCISDLL
#define STCDLLEXPORT WXDLLEXPORT
#else
#define STCDLLEXPORT
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Should a wxPopupWindow be used for the call tips and autocomplete windows? // Should a wxPopupWindow be used for the call tips and autocomplete windows?
@@ -873,8 +879,11 @@ class ScintillaWX; // forward declare
class WordList; class WordList;
struct SCNotification; struct SCNotification;
#ifndef SWIG
extern const wxChar* wxSTCNameStr; extern STCDLLEXPORT const wxChar* wxSTCNameStr;
class STCDLLEXPORT wxStyledTextCtrl;
class STCDLLEXPORT wxStyledTextEvent;
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -1968,7 +1977,7 @@ private:
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// SWIG can't handle "#if" type of conditionals, onlu "#ifdef" // SWIG can't handle "#if" type of conditionals, only "#ifdef"
#ifdef SWIG #ifdef SWIG
#define STC_USE_DND 1 #define STC_USE_DND 1
#else #else

View File

@@ -561,9 +561,19 @@ void ScintillaWX::DoButtonMove(Point pt) {
void ScintillaWX::DoAddChar(int key) { void ScintillaWX::DoAddChar(int key) {
#if wxUSE_UNICODE
char ansiChars[3];
ansiChars[0] = key;
ansiChars[1] = 0;
wxString uniChar(ansiChars);
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(uniChar);
AddCharUTF((char*)buf.data(), strlen(buf));
#else
AddChar(key); AddChar(key);
#endif
} }
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) { int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) {
#if defined(__WXGTK__) || defined(__WXMAC__) #if defined(__WXGTK__) || defined(__WXMAC__)
// Ctrl chars (A-Z) end up with the wrong keycode on wxGTK... // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK...

View File

@@ -1998,8 +1998,6 @@ void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
int key = evt.GetKeyCode();
// On (some?) non-US keyboards the AltGr key is required to enter some // On (some?) non-US keyboards the AltGr key is required to enter some
// common characters. It comes to us as both Alt and Ctrl down so we need // common characters. It comes to us as both Alt and Ctrl down so we need
// to let the char through in that case, otherwise if only ctrl or only // to let the char through in that case, otherwise if only ctrl or only
@@ -2008,10 +2006,13 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
bool alt = evt.AltDown(); bool alt = evt.AltDown();
bool skip = ((ctrl || alt) && ! (ctrl && alt)); bool skip = ((ctrl || alt) && ! (ctrl && alt));
int key = evt.GetKeyCode();
// printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n", // printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n",
// key, m_lastKeyDownConsumed, ctrl, alt, skip); // key, m_lastKeyDownConsumed, ctrl, alt, skip);
if (key <= WXK_START && /*key >= 32 &&*/ !m_lastKeyDownConsumed && !skip) { if ( (key <= WXK_START || key > WXK_NUMPAD_DIVIDE) &&
!m_lastKeyDownConsumed && !skip) {
m_swx->DoAddChar(key); m_swx->DoAddChar(key);
return; return;
} }

View File

@@ -376,8 +376,6 @@ void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
int key = evt.GetKeyCode();
// On (some?) non-US keyboards the AltGr key is required to enter some // On (some?) non-US keyboards the AltGr key is required to enter some
// common characters. It comes to us as both Alt and Ctrl down so we need // common characters. It comes to us as both Alt and Ctrl down so we need
// to let the char through in that case, otherwise if only ctrl or only // to let the char through in that case, otherwise if only ctrl or only
@@ -386,10 +384,13 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
bool alt = evt.AltDown(); bool alt = evt.AltDown();
bool skip = ((ctrl || alt) && ! (ctrl && alt)); bool skip = ((ctrl || alt) && ! (ctrl && alt));
int key = evt.GetKeyCode();
// printf("OnChar key:%%d consumed:%%d ctrl:%%d alt:%%d skip:%%d\n", // printf("OnChar key:%%d consumed:%%d ctrl:%%d alt:%%d skip:%%d\n",
// key, m_lastKeyDownConsumed, ctrl, alt, skip); // key, m_lastKeyDownConsumed, ctrl, alt, skip);
if (key <= WXK_START && /*key >= 32 &&*/ !m_lastKeyDownConsumed && !skip) { if ( (key <= WXK_START || key > WXK_NUMPAD_DIVIDE) &&
!m_lastKeyDownConsumed && !skip) {
m_swx->DoAddChar(key); m_swx->DoAddChar(key);
return; return;
} }

View File

@@ -24,6 +24,12 @@
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/dnd.h> #include <wx/dnd.h>
#ifdef STCISDLL
#define STCDLLEXPORT WXDLLEXPORT
#else
#define STCDLLEXPORT
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Should a wxPopupWindow be used for the call tips and autocomplete windows? // Should a wxPopupWindow be used for the call tips and autocomplete windows?
@@ -45,8 +51,11 @@ class ScintillaWX; // forward declare
class WordList; class WordList;
struct SCNotification; struct SCNotification;
#ifndef SWIG
extern const wxChar* wxSTCNameStr; extern STCDLLEXPORT const wxChar* wxSTCNameStr;
class STCDLLEXPORT wxStyledTextCtrl;
class STCDLLEXPORT wxStyledTextEvent;
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -210,7 +219,7 @@ private:
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// SWIG can't handle "#if" type of conditionals, onlu "#ifdef" // SWIG can't handle "#if" type of conditionals, only "#ifdef"
#ifdef SWIG #ifdef SWIG
#define STC_USE_DND 1 #define STC_USE_DND 1
#else #else