From 451c5cc7b9e72f6231085056e91bcd53612e54bb Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 15 May 2002 19:07:48 +0000 Subject: [PATCH] wxSTC changes to help it work better on wxMac git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15572 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/src/stc/PlatWX.cpp | 39 +++++++++++-- contrib/src/stc/ScintillaWX.cpp | 2 +- contrib/src/stc/stc.cpp | 92 ++++++++++++++++--------------- contrib/src/stc/stc.cpp.in | 92 ++++++++++++++++--------------- src/stc/PlatWX.cpp | 39 +++++++++++-- src/stc/ScintillaWX.cpp | 2 +- src/stc/stc.cpp | 92 ++++++++++++++++--------------- src/stc/stc.cpp.in | 92 ++++++++++++++++--------------- wxPython/contrib/stc/mac/stc_.cpp | 22 ++------ 9 files changed, 264 insertions(+), 208 deletions(-) diff --git a/contrib/src/stc/PlatWX.cpp b/contrib/src/stc/PlatWX.cpp index d918eab260..712c3b818f 100644 --- a/contrib/src/stc/PlatWX.cpp +++ b/contrib/src/stc/PlatWX.cpp @@ -646,11 +646,37 @@ void Window::SetTitle(const char *s) { // Helper classes for ListBox -// #undef wxSTC_USE_POPUP -// #define wxSTC_USE_POPUP 0 +#if defined(__WXMAC__) +class wxSTCListBoxWin : public wxListBox { +public: + wxSTCListBoxWin(wxWindow* parent, wxWindowID id) + : wxListBox(parent, id, wxDefaultPosition, wxSize(0,0), + 0, NULL, wxLB_SINGLE | wxSIMPLE_BORDER) { + SetCursor(wxCursor(wxCURSOR_ARROW)); + Hide(); + } + + void OnFocus(wxFocusEvent& event) { + GetParent()->SetFocus(); + event.Skip(); + } + + wxListBox* GetLB() { return this; } + +private: + DECLARE_EVENT_TABLE() +}; + + +BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxListBox) + EVT_SET_FOCUS(wxSTCListBoxWin::OnFocus) +END_EVENT_TABLE() + + + +#else -// A wxListBox that gives focus back to its parent if it gets it. class wxSTCListBox : public wxListBox { public: wxSTCListBox(wxWindow* parent, wxWindowID id) @@ -675,6 +701,9 @@ END_EVENT_TABLE() +// #undef wxSTC_USE_POPUP +// #define wxSTC_USE_POPUP 0 + // A window to place the listbox upon. If wxPopupWindow is supported then // that will be used so the listbox can extend beyond the client area of the // wxSTC if needed. @@ -694,7 +723,7 @@ public: lb = new wxSTCListBox(this, id); lb->SetCursor(wxCursor(wxCURSOR_ARROW)); lb->SetFocus(); - } + } void OnSize(wxSizeEvent& event) { lb->SetSize(GetSize()); @@ -722,7 +751,7 @@ private: BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxSTCListBoxWinBase) EVT_SIZE(wxSTCListBoxWin::OnSize) END_EVENT_TABLE() - +#endif inline wxListBox* GETLB(WindowID win) { return (((wxSTCListBoxWin*)win)->GetLB()); diff --git a/contrib/src/stc/ScintillaWX.cpp b/contrib/src/stc/ScintillaWX.cpp index a633e35e70..ec2297af18 100644 --- a/contrib/src/stc/ScintillaWX.cpp +++ b/contrib/src/stc/ScintillaWX.cpp @@ -527,7 +527,7 @@ void ScintillaWX::DoAddChar(int key) { } int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) { -#ifdef __WXGTK__ +#if defined(__WXGTK__) || defined(__WXMAC__) // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK... if (ctrl && key >= 1 && key <= 26) key += 'A' - 1; diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index b763cac229..463780dd0f 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -27,6 +27,38 @@ const wxChar* wxSTCNameStr = wxT("stcwindow"); +#ifdef MAKELONG +#undef MAKELONG +#endif + +#define MAKELONG(a, b) ((a) | ((b) << 16)) + + +static long wxColourAsLong(const wxColour& co) { + return (((long)co.Blue() << 16) | + ((long)co.Green() << 8) | + ((long)co.Red())); +} + +static wxColour wxColourFromLong(long c) { + wxColour clr; + clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff); + return clr; +} + + +static wxColour wxColourFromSpec(const wxString& spec) { + // spec should be "#RRGGBB" + long red, green, blue; + red = green = blue = 0; + spec.Mid(1,2).ToLong(&red, 16); + spec.Mid(3,2).ToLong(&green, 16); + spec.Mid(5,2).ToLong(&blue, 16); + return wxColour(red, green, blue); +} + +//---------------------------------------------------------------------- + DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED ) @@ -57,13 +89,13 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) EVT_SCROLL (wxStyledTextCtrl::OnScroll) EVT_SIZE (wxStyledTextCtrl::OnSize) EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown) -#ifdef __WXMSW__ +#if defined(__WXMSW__) || defined(__WXMAC__) // Let Scintilla see the double click as a second click EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown) #endif EVT_MOTION (wxStyledTextCtrl::OnMouseMove) EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp) -#ifdef __WXGTK__ +#if defined(__WXGTK__) || defined(__WXMAC__) EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp) #else EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu) @@ -125,36 +157,6 @@ long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) { } -#ifdef MAKELONG -#undef MAKELONG -#endif - -#define MAKELONG(a, b) ((a) | ((b) << 16)) - - -static long wxColourAsLong(const wxColour& co) { - return (((long)co.Blue() << 16) | - ((long)co.Green() << 8) | - ((long)co.Red())); -} - -static wxColour wxColourFromLong(long c) { - wxColour clr; - clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff); - return clr; -} - - -static wxColour wxColourFromSpec(const wxString& spec) { - // spec should be "#RRGGBB" - long red, green, blue; - red = green = blue = 0; - spec.Mid(1,2).ToLong(&red, 16); - spec.Mid(3,2).ToLong(&green, 16); - spec.Mid(5,2).ToLong(&blue, 16); - return wxColour(red, green, blue); -} - //---------------------------------------------------------------------- // BEGIN generated section. The following code is automatically generated @@ -1738,38 +1740,38 @@ int wxStyledTextCtrl::GetCurrentLine() { // void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { - wxStringTokenizer tkz(spec, ","); + wxStringTokenizer tkz(spec, wxT(",")); while (tkz.HasMoreTokens()) { wxString token = tkz.GetNextToken(); wxString option = token.BeforeFirst(':'); wxString val = token.AfterFirst(':'); - if (option == "bold") + if (option == wxT("bold")) StyleSetBold(styleNum, true); - else if (option == "italic") + else if (option == wxT("italic")) StyleSetItalic(styleNum, true); - else if (option == "underline") + else if (option == wxT("underline")) StyleSetUnderline(styleNum, true); - else if (option == "eol") + else if (option == wxT("eol")) StyleSetEOLFilled(styleNum, true); - else if (option == "size") { + else if (option == wxT("size")) { long points; if (val.ToLong(&points)) StyleSetSize(styleNum, points); } - else if (option == "face") + else if (option == wxT("face")) StyleSetFaceName(styleNum, val); - else if (option == "fore") + else if (option == wxT("fore")) StyleSetForeground(styleNum, wxColourFromSpec(val)); - else if (option == "back") + else if (option == wxT("back")) StyleSetBackground(styleNum, wxColourFromSpec(val)); } } @@ -1928,8 +1930,8 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { bool alt = evt.AltDown(); bool skip = ((ctrl || alt) && ! (ctrl && alt)); - //printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n", - // key, m_lastKeyDownConsumed, ctrl, alt, skip); + printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n", + key, m_lastKeyDownConsumed, ctrl, alt, skip); if (key <= WXK_START && /*key >= 32 &&*/ !m_lastKeyDownConsumed && !skip) { m_swx->DoAddChar(key); @@ -1947,8 +1949,8 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed); -// printf("key: %d shift: %d ctrl: %d alt: %d processed: %d consumed: %d\n", -// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed); + printf("KeyDn key:%d shift:%d ctrl:%d alt:%d processed:%d consumed:%d\n", + key, shift, ctrl, alt, processed, m_lastKeyDownConsumed); if (!processed && !m_lastKeyDownConsumed) evt.Skip(); diff --git a/contrib/src/stc/stc.cpp.in b/contrib/src/stc/stc.cpp.in index b68d69655d..a026879d34 100644 --- a/contrib/src/stc/stc.cpp.in +++ b/contrib/src/stc/stc.cpp.in @@ -27,6 +27,38 @@ const wxChar* wxSTCNameStr = wxT("stcwindow"); +#ifdef MAKELONG +#undef MAKELONG +#endif + +#define MAKELONG(a, b) ((a) | ((b) << 16)) + + +static long wxColourAsLong(const wxColour& co) { + return (((long)co.Blue() << 16) | + ((long)co.Green() << 8) | + ((long)co.Red())); +} + +static wxColour wxColourFromLong(long c) { + wxColour clr; + clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff); + return clr; +} + + +static wxColour wxColourFromSpec(const wxString& spec) { + // spec should be "#RRGGBB" + long red, green, blue; + red = green = blue = 0; + spec.Mid(1,2).ToLong(&red, 16); + spec.Mid(3,2).ToLong(&green, 16); + spec.Mid(5,2).ToLong(&blue, 16); + return wxColour(red, green, blue); +} + +//---------------------------------------------------------------------- + DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED ) @@ -57,13 +89,13 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) EVT_SCROLL (wxStyledTextCtrl::OnScroll) EVT_SIZE (wxStyledTextCtrl::OnSize) EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown) -#ifdef __WXMSW__ +#if defined(__WXMSW__) || defined(__WXMAC__) // Let Scintilla see the double click as a second click EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown) #endif EVT_MOTION (wxStyledTextCtrl::OnMouseMove) EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp) -#ifdef __WXGTK__ +#if defined(__WXGTK__) || defined(__WXMAC__) EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp) #else EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu) @@ -125,36 +157,6 @@ long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) { } -#ifdef MAKELONG -#undef MAKELONG -#endif - -#define MAKELONG(a, b) ((a) | ((b) << 16)) - - -static long wxColourAsLong(const wxColour& co) { - return (((long)co.Blue() << 16) | - ((long)co.Green() << 8) | - ((long)co.Red())); -} - -static wxColour wxColourFromLong(long c) { - wxColour clr; - clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff); - return clr; -} - - -static wxColour wxColourFromSpec(const wxString& spec) { - // spec should be "#RRGGBB" - long red, green, blue; - red = green = blue = 0; - spec.Mid(1,2).ToLong(&red, 16); - spec.Mid(3,2).ToLong(&green, 16); - spec.Mid(5,2).ToLong(&blue, 16); - return wxColour(red, green, blue); -} - //---------------------------------------------------------------------- // BEGIN generated section. The following code is automatically generated @@ -188,38 +190,38 @@ int wxStyledTextCtrl::GetCurrentLine() { // void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { - wxStringTokenizer tkz(spec, ","); + wxStringTokenizer tkz(spec, wxT(",")); while (tkz.HasMoreTokens()) { wxString token = tkz.GetNextToken(); wxString option = token.BeforeFirst(':'); wxString val = token.AfterFirst(':'); - if (option == "bold") + if (option == wxT("bold")) StyleSetBold(styleNum, true); - else if (option == "italic") + else if (option == wxT("italic")) StyleSetItalic(styleNum, true); - else if (option == "underline") + else if (option == wxT("underline")) StyleSetUnderline(styleNum, true); - else if (option == "eol") + else if (option == wxT("eol")) StyleSetEOLFilled(styleNum, true); - else if (option == "size") { + else if (option == wxT("size")) { long points; if (val.ToLong(&points)) StyleSetSize(styleNum, points); } - else if (option == "face") + else if (option == wxT("face")) StyleSetFaceName(styleNum, val); - else if (option == "fore") + else if (option == wxT("fore")) StyleSetForeground(styleNum, wxColourFromSpec(val)); - else if (option == "back") + else if (option == wxT("back")) StyleSetBackground(styleNum, wxColourFromSpec(val)); } } @@ -378,8 +380,8 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { bool alt = evt.AltDown(); bool skip = ((ctrl || alt) && ! (ctrl && alt)); - //printf("OnChar key:%%d consumed:%%d ctrl:%%d alt:%%d skip:%%d\n", - // key, m_lastKeyDownConsumed, ctrl, alt, skip); +// printf("OnChar key:%%d consumed:%%d ctrl:%%d alt:%%d skip:%%d\n", +// key, m_lastKeyDownConsumed, ctrl, alt, skip); if (key <= WXK_START && /*key >= 32 &&*/ !m_lastKeyDownConsumed && !skip) { m_swx->DoAddChar(key); @@ -397,8 +399,8 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed); -// printf("key: %%d shift: %%d ctrl: %%d alt: %%d processed: %%d consumed: %%d\n", -// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed); +// printf("KeyDn key:%%d shift:%%d ctrl:%%d alt:%%d processed:%%d consumed:%%d\n", +// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed); if (!processed && !m_lastKeyDownConsumed) evt.Skip(); diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index d918eab260..712c3b818f 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -646,11 +646,37 @@ void Window::SetTitle(const char *s) { // Helper classes for ListBox -// #undef wxSTC_USE_POPUP -// #define wxSTC_USE_POPUP 0 +#if defined(__WXMAC__) +class wxSTCListBoxWin : public wxListBox { +public: + wxSTCListBoxWin(wxWindow* parent, wxWindowID id) + : wxListBox(parent, id, wxDefaultPosition, wxSize(0,0), + 0, NULL, wxLB_SINGLE | wxSIMPLE_BORDER) { + SetCursor(wxCursor(wxCURSOR_ARROW)); + Hide(); + } + + void OnFocus(wxFocusEvent& event) { + GetParent()->SetFocus(); + event.Skip(); + } + + wxListBox* GetLB() { return this; } + +private: + DECLARE_EVENT_TABLE() +}; + + +BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxListBox) + EVT_SET_FOCUS(wxSTCListBoxWin::OnFocus) +END_EVENT_TABLE() + + + +#else -// A wxListBox that gives focus back to its parent if it gets it. class wxSTCListBox : public wxListBox { public: wxSTCListBox(wxWindow* parent, wxWindowID id) @@ -675,6 +701,9 @@ END_EVENT_TABLE() +// #undef wxSTC_USE_POPUP +// #define wxSTC_USE_POPUP 0 + // A window to place the listbox upon. If wxPopupWindow is supported then // that will be used so the listbox can extend beyond the client area of the // wxSTC if needed. @@ -694,7 +723,7 @@ public: lb = new wxSTCListBox(this, id); lb->SetCursor(wxCursor(wxCURSOR_ARROW)); lb->SetFocus(); - } + } void OnSize(wxSizeEvent& event) { lb->SetSize(GetSize()); @@ -722,7 +751,7 @@ private: BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxSTCListBoxWinBase) EVT_SIZE(wxSTCListBoxWin::OnSize) END_EVENT_TABLE() - +#endif inline wxListBox* GETLB(WindowID win) { return (((wxSTCListBoxWin*)win)->GetLB()); diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index a633e35e70..ec2297af18 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -527,7 +527,7 @@ void ScintillaWX::DoAddChar(int key) { } int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) { -#ifdef __WXGTK__ +#if defined(__WXGTK__) || defined(__WXMAC__) // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK... if (ctrl && key >= 1 && key <= 26) key += 'A' - 1; diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index b763cac229..463780dd0f 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -27,6 +27,38 @@ const wxChar* wxSTCNameStr = wxT("stcwindow"); +#ifdef MAKELONG +#undef MAKELONG +#endif + +#define MAKELONG(a, b) ((a) | ((b) << 16)) + + +static long wxColourAsLong(const wxColour& co) { + return (((long)co.Blue() << 16) | + ((long)co.Green() << 8) | + ((long)co.Red())); +} + +static wxColour wxColourFromLong(long c) { + wxColour clr; + clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff); + return clr; +} + + +static wxColour wxColourFromSpec(const wxString& spec) { + // spec should be "#RRGGBB" + long red, green, blue; + red = green = blue = 0; + spec.Mid(1,2).ToLong(&red, 16); + spec.Mid(3,2).ToLong(&green, 16); + spec.Mid(5,2).ToLong(&blue, 16); + return wxColour(red, green, blue); +} + +//---------------------------------------------------------------------- + DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED ) @@ -57,13 +89,13 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) EVT_SCROLL (wxStyledTextCtrl::OnScroll) EVT_SIZE (wxStyledTextCtrl::OnSize) EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown) -#ifdef __WXMSW__ +#if defined(__WXMSW__) || defined(__WXMAC__) // Let Scintilla see the double click as a second click EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown) #endif EVT_MOTION (wxStyledTextCtrl::OnMouseMove) EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp) -#ifdef __WXGTK__ +#if defined(__WXGTK__) || defined(__WXMAC__) EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp) #else EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu) @@ -125,36 +157,6 @@ long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) { } -#ifdef MAKELONG -#undef MAKELONG -#endif - -#define MAKELONG(a, b) ((a) | ((b) << 16)) - - -static long wxColourAsLong(const wxColour& co) { - return (((long)co.Blue() << 16) | - ((long)co.Green() << 8) | - ((long)co.Red())); -} - -static wxColour wxColourFromLong(long c) { - wxColour clr; - clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff); - return clr; -} - - -static wxColour wxColourFromSpec(const wxString& spec) { - // spec should be "#RRGGBB" - long red, green, blue; - red = green = blue = 0; - spec.Mid(1,2).ToLong(&red, 16); - spec.Mid(3,2).ToLong(&green, 16); - spec.Mid(5,2).ToLong(&blue, 16); - return wxColour(red, green, blue); -} - //---------------------------------------------------------------------- // BEGIN generated section. The following code is automatically generated @@ -1738,38 +1740,38 @@ int wxStyledTextCtrl::GetCurrentLine() { // void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { - wxStringTokenizer tkz(spec, ","); + wxStringTokenizer tkz(spec, wxT(",")); while (tkz.HasMoreTokens()) { wxString token = tkz.GetNextToken(); wxString option = token.BeforeFirst(':'); wxString val = token.AfterFirst(':'); - if (option == "bold") + if (option == wxT("bold")) StyleSetBold(styleNum, true); - else if (option == "italic") + else if (option == wxT("italic")) StyleSetItalic(styleNum, true); - else if (option == "underline") + else if (option == wxT("underline")) StyleSetUnderline(styleNum, true); - else if (option == "eol") + else if (option == wxT("eol")) StyleSetEOLFilled(styleNum, true); - else if (option == "size") { + else if (option == wxT("size")) { long points; if (val.ToLong(&points)) StyleSetSize(styleNum, points); } - else if (option == "face") + else if (option == wxT("face")) StyleSetFaceName(styleNum, val); - else if (option == "fore") + else if (option == wxT("fore")) StyleSetForeground(styleNum, wxColourFromSpec(val)); - else if (option == "back") + else if (option == wxT("back")) StyleSetBackground(styleNum, wxColourFromSpec(val)); } } @@ -1928,8 +1930,8 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { bool alt = evt.AltDown(); bool skip = ((ctrl || alt) && ! (ctrl && alt)); - //printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n", - // key, m_lastKeyDownConsumed, ctrl, alt, skip); + printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n", + key, m_lastKeyDownConsumed, ctrl, alt, skip); if (key <= WXK_START && /*key >= 32 &&*/ !m_lastKeyDownConsumed && !skip) { m_swx->DoAddChar(key); @@ -1947,8 +1949,8 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed); -// printf("key: %d shift: %d ctrl: %d alt: %d processed: %d consumed: %d\n", -// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed); + printf("KeyDn key:%d shift:%d ctrl:%d alt:%d processed:%d consumed:%d\n", + key, shift, ctrl, alt, processed, m_lastKeyDownConsumed); if (!processed && !m_lastKeyDownConsumed) evt.Skip(); diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index b68d69655d..a026879d34 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -27,6 +27,38 @@ const wxChar* wxSTCNameStr = wxT("stcwindow"); +#ifdef MAKELONG +#undef MAKELONG +#endif + +#define MAKELONG(a, b) ((a) | ((b) << 16)) + + +static long wxColourAsLong(const wxColour& co) { + return (((long)co.Blue() << 16) | + ((long)co.Green() << 8) | + ((long)co.Red())); +} + +static wxColour wxColourFromLong(long c) { + wxColour clr; + clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff); + return clr; +} + + +static wxColour wxColourFromSpec(const wxString& spec) { + // spec should be "#RRGGBB" + long red, green, blue; + red = green = blue = 0; + spec.Mid(1,2).ToLong(&red, 16); + spec.Mid(3,2).ToLong(&green, 16); + spec.Mid(5,2).ToLong(&blue, 16); + return wxColour(red, green, blue); +} + +//---------------------------------------------------------------------- + DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED ) @@ -57,13 +89,13 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) EVT_SCROLL (wxStyledTextCtrl::OnScroll) EVT_SIZE (wxStyledTextCtrl::OnSize) EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown) -#ifdef __WXMSW__ +#if defined(__WXMSW__) || defined(__WXMAC__) // Let Scintilla see the double click as a second click EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown) #endif EVT_MOTION (wxStyledTextCtrl::OnMouseMove) EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp) -#ifdef __WXGTK__ +#if defined(__WXGTK__) || defined(__WXMAC__) EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp) #else EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu) @@ -125,36 +157,6 @@ long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) { } -#ifdef MAKELONG -#undef MAKELONG -#endif - -#define MAKELONG(a, b) ((a) | ((b) << 16)) - - -static long wxColourAsLong(const wxColour& co) { - return (((long)co.Blue() << 16) | - ((long)co.Green() << 8) | - ((long)co.Red())); -} - -static wxColour wxColourFromLong(long c) { - wxColour clr; - clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff); - return clr; -} - - -static wxColour wxColourFromSpec(const wxString& spec) { - // spec should be "#RRGGBB" - long red, green, blue; - red = green = blue = 0; - spec.Mid(1,2).ToLong(&red, 16); - spec.Mid(3,2).ToLong(&green, 16); - spec.Mid(5,2).ToLong(&blue, 16); - return wxColour(red, green, blue); -} - //---------------------------------------------------------------------- // BEGIN generated section. The following code is automatically generated @@ -188,38 +190,38 @@ int wxStyledTextCtrl::GetCurrentLine() { // void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { - wxStringTokenizer tkz(spec, ","); + wxStringTokenizer tkz(spec, wxT(",")); while (tkz.HasMoreTokens()) { wxString token = tkz.GetNextToken(); wxString option = token.BeforeFirst(':'); wxString val = token.AfterFirst(':'); - if (option == "bold") + if (option == wxT("bold")) StyleSetBold(styleNum, true); - else if (option == "italic") + else if (option == wxT("italic")) StyleSetItalic(styleNum, true); - else if (option == "underline") + else if (option == wxT("underline")) StyleSetUnderline(styleNum, true); - else if (option == "eol") + else if (option == wxT("eol")) StyleSetEOLFilled(styleNum, true); - else if (option == "size") { + else if (option == wxT("size")) { long points; if (val.ToLong(&points)) StyleSetSize(styleNum, points); } - else if (option == "face") + else if (option == wxT("face")) StyleSetFaceName(styleNum, val); - else if (option == "fore") + else if (option == wxT("fore")) StyleSetForeground(styleNum, wxColourFromSpec(val)); - else if (option == "back") + else if (option == wxT("back")) StyleSetBackground(styleNum, wxColourFromSpec(val)); } } @@ -378,8 +380,8 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { bool alt = evt.AltDown(); bool skip = ((ctrl || alt) && ! (ctrl && alt)); - //printf("OnChar key:%%d consumed:%%d ctrl:%%d alt:%%d skip:%%d\n", - // key, m_lastKeyDownConsumed, ctrl, alt, skip); +// printf("OnChar key:%%d consumed:%%d ctrl:%%d alt:%%d skip:%%d\n", +// key, m_lastKeyDownConsumed, ctrl, alt, skip); if (key <= WXK_START && /*key >= 32 &&*/ !m_lastKeyDownConsumed && !skip) { m_swx->DoAddChar(key); @@ -397,8 +399,8 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed); -// printf("key: %%d shift: %%d ctrl: %%d alt: %%d processed: %%d consumed: %%d\n", -// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed); +// printf("KeyDn key:%%d shift:%%d ctrl:%%d alt:%%d processed:%%d consumed:%%d\n", +// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed); if (!processed && !m_lastKeyDownConsumed) evt.Skip(); diff --git a/wxPython/contrib/stc/mac/stc_.cpp b/wxPython/contrib/stc/mac/stc_.cpp index 3c80bf62f4..dc2dd34944 100644 --- a/wxPython/contrib/stc/mac/stc_.cpp +++ b/wxPython/contrib/stc/mac/stc_.cpp @@ -9845,13 +9845,12 @@ static PyObject *_wrap_wxStyledTextEvent_SetDragAllowMove(PyObject *self, PyObje static PyObject *_wrap_wxStyledTextEvent_SetDragResult(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; wxStyledTextEvent * _arg0; - wxDragResult * _arg1; + wxDragResult _arg1; PyObject * _argo0 = 0; - PyObject * _argo1 = 0; char *_kwnames[] = { "self","val", NULL }; self = self; - if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxStyledTextEvent_SetDragResult",_kwnames,&_argo0,&_argo1)) + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oi:wxStyledTextEvent_SetDragResult",_kwnames,&_argo0,&_arg1)) return NULL; if (_argo0) { if (_argo0 == Py_None) { _arg0 = NULL; } @@ -9860,16 +9859,9 @@ static PyObject *_wrap_wxStyledTextEvent_SetDragResult(PyObject *self, PyObject return NULL; } } - if (_argo1) { - if (_argo1 == Py_None) { _arg1 = NULL; } - else if (SWIG_GetPtrObj(_argo1,(void **) &_arg1,"_wxDragResult_p")) { - PyErr_SetString(PyExc_TypeError,"Type error in argument 2 of wxStyledTextEvent_SetDragResult. Expected _wxDragResult_p."); - return NULL; - } - } { PyThreadState* __tstate = wxPyBeginAllowThreads(); - wxStyledTextEvent_SetDragResult(_arg0,*_arg1); + wxStyledTextEvent_SetDragResult(_arg0,_arg1); wxPyEndAllowThreads(__tstate); if (PyErr_Occurred()) return NULL; @@ -10431,11 +10423,10 @@ static PyObject *_wrap_wxStyledTextEvent_GetDragAllowMove(PyObject *self, PyObje #define wxStyledTextEvent_GetDragResult(_swigobj) (_swigobj->GetDragResult()) static PyObject *_wrap_wxStyledTextEvent_GetDragResult(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; - wxDragResult * _result; + wxDragResult _result; wxStyledTextEvent * _arg0; PyObject * _argo0 = 0; char *_kwnames[] = { "self", NULL }; - char _ptemp[128]; self = self; if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxStyledTextEvent_GetDragResult",_kwnames,&_argo0)) @@ -10449,12 +10440,11 @@ static PyObject *_wrap_wxStyledTextEvent_GetDragResult(PyObject *self, PyObject } { PyThreadState* __tstate = wxPyBeginAllowThreads(); - _result = new wxDragResult (wxStyledTextEvent_GetDragResult(_arg0)); + _result = (wxDragResult )wxStyledTextEvent_GetDragResult(_arg0); wxPyEndAllowThreads(__tstate); if (PyErr_Occurred()) return NULL; -} SWIG_MakePtr(_ptemp, (void *) _result,"_wxDragResult_p"); - _resultobj = Py_BuildValue("s",_ptemp); +} _resultobj = Py_BuildValue("i",_result); return _resultobj; } -- 2.45.2