1 ////////////////////////////////////////////////////////////////////////////
3 // Purpose: A wxWidgets implementation of Scintilla. This class is the
4 // one meant to be used directly by wx applications. It does not
5 // derive directly from the Scintilla classes, but instead
6 // delegates most things to the real Scintilla class.
7 // This allows the use of Scintilla without polluting the
8 // namespace with all the classes and identifiers from Scintilla.
12 // Created: 13-Jan-2000
14 // Copyright: (c) 2000 by Total Control Software
15 // Licence: wxWindows license
16 /////////////////////////////////////////////////////////////////////////////
21 #include <wx/tokenzr.h>
22 #include <wx/mstream.h>
26 #include "wx/stc/stc.h"
27 #include "ScintillaWX.h"
29 //----------------------------------------------------------------------
31 const wxChar
* wxSTCNameStr
= wxT("stcwindow");
37 #define MAKELONG(a, b) ((a) | ((b) << 16))
40 static long wxColourAsLong(const wxColour
& co
) {
41 return (((long)co
.Blue() << 16) |
42 ((long)co
.Green() << 8) |
46 static wxColour
wxColourFromLong(long c
) {
48 clr
.Set((unsigned char)(c
& 0xff),
49 (unsigned char)((c
>> 8) & 0xff),
50 (unsigned char)((c
>> 16) & 0xff));
55 static wxColour
wxColourFromSpec(const wxString
& spec
) {
56 // spec should be a colour name or "#RRGGBB"
57 if (spec
.GetChar(0) == wxT('#')) {
59 long red
, green
, blue
;
60 red
= green
= blue
= 0;
61 spec
.Mid(1,2).ToLong(&red
, 16);
62 spec
.Mid(3,2).ToLong(&green
, 16);
63 spec
.Mid(5,2).ToLong(&blue
, 16);
64 return wxColour((unsigned char)red
,
69 return wxColour(spec
);
72 //----------------------------------------------------------------------
74 DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE
)
75 DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED
)
76 DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED
)
77 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED
)
78 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT
)
79 DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT
)
80 DEFINE_EVENT_TYPE( wxEVT_STC_KEY
)
81 DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK
)
82 DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI
)
83 DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED
)
84 DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD
)
85 DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK
)
86 DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN
)
87 DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED
)
88 DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION
)
89 DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED
)
90 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART
)
91 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND
)
92 DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG
)
93 DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER
)
94 DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP
)
95 DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM
)
96 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK
)
97 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK
)
98 DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK
)
102 BEGIN_EVENT_TABLE(wxStyledTextCtrl
, wxControl
)
103 EVT_PAINT (wxStyledTextCtrl::OnPaint
)
104 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin
)
105 EVT_SCROLL (wxStyledTextCtrl::OnScroll
)
106 EVT_SIZE (wxStyledTextCtrl::OnSize
)
107 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown
)
108 // Let Scintilla see the double click as a second click
109 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown
)
110 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
111 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
112 #if defined(__WXGTK__) || defined(__WXMAC__)
113 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp
)
115 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu
)
117 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel
)
118 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp
)
119 EVT_CHAR (wxStyledTextCtrl::OnChar
)
120 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
121 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
122 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
123 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
124 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
125 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu
)
126 EVT_LISTBOX_DCLICK (wxID_ANY
, wxStyledTextCtrl::OnListBox
)
130 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
131 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
134 // forces the linking of the lexer modules
135 int Scintilla_LinkLexers();
138 //----------------------------------------------------------------------
139 // Constructor and Destructor
141 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
146 const wxString
& name
)
149 Create(parent
, id
, pos
, size
, style
, name
);
153 bool wxStyledTextCtrl::Create(wxWindow
*parent
,
158 const wxString
& name
)
161 style
|= wxVSCROLL
| wxHSCROLL
;
163 if (!wxControl::Create(parent
, id
, pos
, size
,
164 style
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
165 wxDefaultValidator
, name
))
169 Scintilla_LinkLexers();
171 m_swx
= new ScintillaWX(this);
173 m_lastKeyDownConsumed
= false;
177 // Put Scintilla into unicode (UTF-8) mode
178 SetCodePage(wxSTC_CP_UTF8
);
181 SetBestFittingSize(size
);
183 // Reduces flicker on GTK+/X11
184 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
189 wxStyledTextCtrl::~wxStyledTextCtrl() {
194 //----------------------------------------------------------------------
196 long wxStyledTextCtrl::SendMsg(int msg
, long wp
, long lp
) {
198 return m_swx
->WndProc(msg
, wp
, lp
);
201 //----------------------------------------------------------------------
203 // Set the vertical scrollbar to use instead of the ont that's built-in.
204 void wxStyledTextCtrl::SetVScrollBar(wxScrollBar
* bar
) {
207 // ensure that the built-in scrollbar is not visible
208 SetScrollbar(wxVERTICAL
, 0, 0, 0);
213 // Set the horizontal scrollbar to use instead of the ont that's built-in.
214 void wxStyledTextCtrl::SetHScrollBar(wxScrollBar
* bar
) {
217 // ensure that the built-in scrollbar is not visible
218 SetScrollbar(wxHORIZONTAL
, 0, 0, 0);
222 //----------------------------------------------------------------------
223 // BEGIN generated section. The following code is automatically generated
224 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
225 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
229 // END of generated section
230 //----------------------------------------------------------------------
233 // Returns the line number of the line with the caret.
234 int wxStyledTextCtrl::GetCurrentLine() {
235 int line
= LineFromPosition(GetCurrentPos());
240 // Extract style settings from a spec-string which is composed of one or
241 // more of the following comma separated elements:
243 // bold turns on bold
244 // italic turns on italics
245 // fore:[name or #RRGGBB] sets the foreground colour
246 // back:[name or #RRGGBB] sets the background colour
247 // face:[facename] sets the font face name to use
248 // size:[num] sets the font size in points
249 // eol turns on eol filling
250 // underline turns on underlining
252 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
254 wxStringTokenizer
tkz(spec
, wxT(","));
255 while (tkz
.HasMoreTokens()) {
256 wxString token
= tkz
.GetNextToken();
258 wxString option
= token
.BeforeFirst(':');
259 wxString val
= token
.AfterFirst(':');
261 if (option
== wxT("bold"))
262 StyleSetBold(styleNum
, true);
264 else if (option
== wxT("italic"))
265 StyleSetItalic(styleNum
, true);
267 else if (option
== wxT("underline"))
268 StyleSetUnderline(styleNum
, true);
270 else if (option
== wxT("eol"))
271 StyleSetEOLFilled(styleNum
, true);
273 else if (option
== wxT("size")) {
275 if (val
.ToLong(&points
))
276 StyleSetSize(styleNum
, points
);
279 else if (option
== wxT("face"))
280 StyleSetFaceName(styleNum
, val
);
282 else if (option
== wxT("fore"))
283 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
285 else if (option
== wxT("back"))
286 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
291 // Set style size, face, bold, italic, and underline attributes from
292 // a wxFont's attributes.
293 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
295 // Ensure that the native font is initialized
297 GetTextExtent(wxT("X"), &x
, &y
, NULL
, NULL
, &font
);
299 int size
= font
.GetPointSize();
300 wxString faceName
= font
.GetFaceName();
301 bool bold
= font
.GetWeight() == wxBOLD
;
302 bool italic
= font
.GetStyle() != wxNORMAL
;
303 bool under
= font
.GetUnderlined();
305 // TODO: add encoding/charset mapping
306 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
);
309 // Set all font style attributes at once.
310 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
311 const wxString
& faceName
,
312 bool bold
, bool italic
,
314 StyleSetSize(styleNum
, size
);
315 StyleSetFaceName(styleNum
, faceName
);
316 StyleSetBold(styleNum
, bold
);
317 StyleSetItalic(styleNum
, italic
);
318 StyleSetUnderline(styleNum
, underline
);
320 // TODO: add encoding/charset mapping
324 // Perform one of the operations defined by the wxSTC_CMD_* constants.
325 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
330 // Set the left and right margin in the edit area, measured in pixels.
331 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
333 SetMarginRight(right
);
337 // Retrieve the start and end positions of the current selection.
338 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
339 if (startPos
!= NULL
)
340 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
342 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
346 // Retrieve the point in the window where a position is displayed.
347 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
348 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
349 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
350 return wxPoint(x
, y
);
353 // Scroll enough to make the given line visible
354 void wxStyledTextCtrl::ScrollToLine(int line
) {
355 m_swx
->DoScrollToLine(line
);
359 // Scroll enough to make the given column visible
360 void wxStyledTextCtrl::ScrollToColumn(int column
) {
361 m_swx
->DoScrollToColumn(column
);
365 bool wxStyledTextCtrl::SaveFile(const wxString
& filename
)
367 wxFile
file(filename
, wxFile::write
);
369 if (!file
.IsOpened())
372 bool success
= file
.Write(GetText(), *wxConvCurrent
);
380 bool wxStyledTextCtrl::LoadFile(const wxString
& filename
)
382 bool success
= false;
383 wxFile
file(filename
, wxFile::read
);
388 // get the file size (assume it is not huge file...)
389 ssize_t len
= (ssize_t
)file
.Length();
394 wxMemoryBuffer
buffer(len
+1);
395 success
= (file
.Read(buffer
.GetData(), len
) == len
);
397 ((char*)buffer
.GetData())[len
] = 0;
398 contents
= wxString(buffer
, *wxConvCurrent
, len
);
402 success
= (file
.Read(wxStringBuffer(buffer
, len
), len
) == len
);
409 success
= true; // empty file is ok
411 success
= false; // len == wxInvalidOffset
426 #if wxUSE_DRAG_AND_DROP
427 wxDragResult
wxStyledTextCtrl::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
428 return m_swx
->DoDragOver(x
, y
, def
);
432 bool wxStyledTextCtrl::DoDropText(long x
, long y
, const wxString
& data
) {
433 return m_swx
->DoDropText(x
, y
, data
);
438 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA
) {
439 m_swx
->SetUseAntiAliasing(useAA
);
442 bool wxStyledTextCtrl::GetUseAntiAliasing() {
443 return m_swx
->GetUseAntiAliasing();
450 void wxStyledTextCtrl::AddTextRaw(const char* text
)
452 SendMsg(SCI_ADDTEXT
, strlen(text
), (long)text
);
455 void wxStyledTextCtrl::InsertTextRaw(int pos
, const char* text
)
457 SendMsg(SCI_INSERTTEXT
, pos
, (long)text
);
460 wxCharBuffer
wxStyledTextCtrl::GetCurLineRaw(int* linePos
)
462 int len
= LineLength(GetCurrentLine());
464 if (linePos
) *linePos
= 0;
469 wxCharBuffer
buf(len
);
470 int pos
= SendMsg(SCI_GETCURLINE
, len
, (long)buf
.data());
471 if (linePos
) *linePos
= pos
;
475 wxCharBuffer
wxStyledTextCtrl::GetLineRaw(int line
)
477 int len
= LineLength(line
);
483 wxCharBuffer
buf(len
);
484 SendMsg(SCI_GETLINE
, line
, (long)buf
.data());
488 wxCharBuffer
wxStyledTextCtrl::GetSelectedTextRaw()
493 GetSelection(&start
, &end
);
494 int len
= end
- start
;
500 wxCharBuffer
buf(len
);
501 SendMsg(SCI_GETSELTEXT
, 0, (long)buf
.data());
505 wxCharBuffer
wxStyledTextCtrl::GetTextRangeRaw(int startPos
, int endPos
)
507 if (endPos
< startPos
) {
512 int len
= endPos
- startPos
;
518 wxCharBuffer
buf(len
);
520 tr
.lpstrText
= buf
.data();
521 tr
.chrg
.cpMin
= startPos
;
522 tr
.chrg
.cpMax
= endPos
;
523 SendMsg(SCI_GETTEXTRANGE
, 0, (long)&tr
);
527 void wxStyledTextCtrl::SetTextRaw(const char* text
)
529 SendMsg(SCI_SETTEXT
, 0, (long)text
);
532 wxCharBuffer
wxStyledTextCtrl::GetTextRaw()
534 int len
= GetTextLength();
535 wxCharBuffer
buf(len
);
536 SendMsg(SCI_GETTEXT
, len
, (long)buf
.data());
540 void wxStyledTextCtrl::AppendTextRaw(const char* text
)
542 SendMsg(SCI_APPENDTEXT
, strlen(text
), (long)text
);
549 //----------------------------------------------------------------------
552 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& WXUNUSED(evt
)) {
554 m_swx
->DoPaint(&dc
, GetUpdateRegion().GetBox());
557 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
558 if (evt
.GetOrientation() == wxHORIZONTAL
)
559 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
561 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
564 void wxStyledTextCtrl::OnScroll(wxScrollEvent
& evt
) {
565 wxScrollBar
* sb
= wxDynamicCast(evt
.GetEventObject(), wxScrollBar
);
567 if (sb
->IsVertical())
568 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
570 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
574 void wxStyledTextCtrl::OnSize(wxSizeEvent
& WXUNUSED(evt
)) {
576 wxSize sz
= GetClientSize();
577 m_swx
->DoSize(sz
.x
, sz
.y
);
581 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
583 wxPoint pt
= evt
.GetPosition();
584 m_swx
->DoLeftButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
585 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
588 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
589 wxPoint pt
= evt
.GetPosition();
590 m_swx
->DoLeftButtonMove(Point(pt
.x
, pt
.y
));
593 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
594 wxPoint pt
= evt
.GetPosition();
595 m_swx
->DoLeftButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
600 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
601 wxPoint pt
= evt
.GetPosition();
602 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
606 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent
& evt
) {
607 wxPoint pt
= evt
.GetPosition();
608 m_swx
->DoMiddleButtonUp(Point(pt
.x
, pt
.y
));
611 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent
& evt
) {
612 wxPoint pt
= evt
.GetPosition();
613 ScreenToClient(&pt
.x
, &pt
.y
);
615 Show context menu at event point if it's within the window,
616 or at caret location if not
618 wxHitTest ht
= this->HitTest(pt
);
619 if (ht
!= wxHT_WINDOW_INSIDE
) {
620 pt
= this->PointFromPosition(this->GetCurrentPos());
622 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
626 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
627 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
629 evt
.GetLinesPerAction(),
635 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
636 // On (some?) non-US PC keyboards the AltGr key is required to enter some
637 // common characters. It comes to us as both Alt and Ctrl down so we need
638 // to let the char through in that case, otherwise if only ctrl or only
639 // alt let's skip it.
640 bool ctrl
= evt
.ControlDown();
642 // On the Mac the Alt key is just a modifier key (like Shift) so we need
643 // to allow the char events to be processed when Alt is pressed.
644 // TODO: Should we check MetaDown instead in this case?
647 bool alt
= evt
.AltDown();
649 bool skip
= ((ctrl
|| alt
) && ! (ctrl
&& alt
));
651 if (!m_lastKeyDownConsumed
&& !skip
) {
653 int key
= evt
.GetUnicodeKey();
656 // if the unicode key code is not really a unicode character (it may
657 // be a function key or etc., the platforms appear to always give us a
658 // small value in this case) then fallback to the ascii key code but
659 // don't do anything for function keys or etc.
661 key
= evt
.GetKeyCode();
662 keyOk
= (key
<= 127);
665 m_swx
->DoAddChar(key
);
669 int key
= evt
.GetKeyCode();
670 if (key
<= WXK_START
|| key
> WXK_COMMAND
) {
671 m_swx
->DoAddChar(key
);
681 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
682 int processed
= m_swx
->DoKeyDown(evt
, &m_lastKeyDownConsumed
);
683 if (!processed
&& !m_lastKeyDownConsumed
)
688 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
689 m_swx
->DoLoseFocus();
694 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
695 m_swx
->DoGainFocus();
700 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(evt
)) {
701 m_swx
->DoSysColourChange();
705 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
)) {
706 // do nothing to help avoid flashing
711 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
712 m_swx
->DoCommand(evt
.GetId());
716 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& WXUNUSED(evt
)) {
717 m_swx
->DoOnListBox();
721 void wxStyledTextCtrl::OnIdle(wxIdleEvent
& evt
) {
722 m_swx
->DoOnIdle(evt
);
726 wxSize
wxStyledTextCtrl::DoGetBestSize() const
728 // What would be the best size for a wxSTC?
729 // Just give a reasonable minimum until something else can be figured out.
730 return wxSize(200,100);
734 //----------------------------------------------------------------------
735 // Turn notifications from Scintilla into events
738 void wxStyledTextCtrl::NotifyChange() {
739 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
740 evt
.SetEventObject(this);
741 GetEventHandler()->ProcessEvent(evt
);
745 static void SetEventText(wxStyledTextEvent
& evt
, const char* text
,
749 // The unicode conversion MUST have a null byte to terminate the
750 // string so move it into a buffer first and give it one.
751 wxMemoryBuffer
buf(length
+1);
752 buf
.AppendData((void*)text
, length
);
754 evt
.SetText(stc2wx(buf
));
758 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
759 SCNotification
& scn
= *_scn
;
760 wxStyledTextEvent
evt(0, GetId());
762 evt
.SetEventObject(this);
763 evt
.SetPosition(scn
.position
);
765 evt
.SetModifiers(scn
.modifiers
);
767 switch (scn
.nmhdr
.code
) {
768 case SCN_STYLENEEDED
:
769 evt
.SetEventType(wxEVT_STC_STYLENEEDED
);
773 evt
.SetEventType(wxEVT_STC_CHARADDED
);
776 case SCN_SAVEPOINTREACHED
:
777 evt
.SetEventType(wxEVT_STC_SAVEPOINTREACHED
);
780 case SCN_SAVEPOINTLEFT
:
781 evt
.SetEventType(wxEVT_STC_SAVEPOINTLEFT
);
784 case SCN_MODIFYATTEMPTRO
:
785 evt
.SetEventType(wxEVT_STC_ROMODIFYATTEMPT
);
789 evt
.SetEventType(wxEVT_STC_KEY
);
792 case SCN_DOUBLECLICK
:
793 evt
.SetEventType(wxEVT_STC_DOUBLECLICK
);
797 evt
.SetEventType(wxEVT_STC_UPDATEUI
);
801 evt
.SetEventType(wxEVT_STC_MODIFIED
);
802 evt
.SetModificationType(scn
.modificationType
);
803 SetEventText(evt
, scn
.text
, scn
.length
);
804 evt
.SetLength(scn
.length
);
805 evt
.SetLinesAdded(scn
.linesAdded
);
806 evt
.SetLine(scn
.line
);
807 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
808 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
811 case SCN_MACRORECORD
:
812 evt
.SetEventType(wxEVT_STC_MACRORECORD
);
813 evt
.SetMessage(scn
.message
);
814 evt
.SetWParam(scn
.wParam
);
815 evt
.SetLParam(scn
.lParam
);
818 case SCN_MARGINCLICK
:
819 evt
.SetEventType(wxEVT_STC_MARGINCLICK
);
820 evt
.SetMargin(scn
.margin
);
824 evt
.SetEventType(wxEVT_STC_NEEDSHOWN
);
825 evt
.SetLength(scn
.length
);
829 evt
.SetEventType(wxEVT_STC_PAINTED
);
832 case SCN_USERLISTSELECTION
:
833 evt
.SetEventType(wxEVT_STC_USERLISTSELECTION
);
834 evt
.SetListType(scn
.listType
);
835 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
839 evt
.SetEventType(wxEVT_STC_URIDROPPED
);
840 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
844 evt
.SetEventType(wxEVT_STC_DWELLSTART
);
850 evt
.SetEventType(wxEVT_STC_DWELLEND
);
856 evt
.SetEventType(wxEVT_STC_ZOOM
);
859 case SCN_HOTSPOTCLICK
:
860 evt
.SetEventType(wxEVT_STC_HOTSPOT_CLICK
);
863 case SCN_HOTSPOTDOUBLECLICK
:
864 evt
.SetEventType(wxEVT_STC_HOTSPOT_DCLICK
);
867 case SCN_CALLTIPCLICK
:
868 evt
.SetEventType(wxEVT_STC_CALLTIP_CLICK
);
875 GetEventHandler()->ProcessEvent(evt
);
879 //----------------------------------------------------------------------
880 //----------------------------------------------------------------------
881 //----------------------------------------------------------------------
883 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
884 : wxCommandEvent(commandType
, id
)
889 m_modificationType
= 0;
902 m_dragAllowMove
= false;
903 #if wxUSE_DRAG_AND_DROP
904 m_dragResult
= wxDragNone
;
908 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
909 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
910 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
913 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent
& event
):
914 wxCommandEvent(event
)
916 m_position
= event
.m_position
;
918 m_modifiers
= event
.m_modifiers
;
919 m_modificationType
= event
.m_modificationType
;
920 m_text
= event
.m_text
;
921 m_length
= event
.m_length
;
922 m_linesAdded
= event
.m_linesAdded
;
923 m_line
= event
.m_line
;
924 m_foldLevelNow
= event
.m_foldLevelNow
;
925 m_foldLevelPrev
= event
.m_foldLevelPrev
;
927 m_margin
= event
.m_margin
;
929 m_message
= event
.m_message
;
930 m_wParam
= event
.m_wParam
;
931 m_lParam
= event
.m_lParam
;
933 m_listType
= event
.m_listType
;
937 m_dragText
= event
.m_dragText
;
938 m_dragAllowMove
=event
.m_dragAllowMove
;
939 #if wxUSE_DRAG_AND_DROP
940 m_dragResult
= event
.m_dragResult
;
944 //----------------------------------------------------------------------
945 //----------------------------------------------------------------------