]>
Commit | Line | Data |
---|---|---|
1 | //////////////////////////////////////////////////////////////////////////// | |
2 | // Name: ScintillaWX.cxx | |
3 | // Purpose: A wxWidgets implementation of Scintilla. A class derived | |
4 | // from ScintillaBase that uses the "wx platform" defined in | |
5 | // PlatformWX.cxx This class is one end of a bridge between | |
6 | // the wx world and the Scintilla world. It needs a peer | |
7 | // object of type wxStyledTextCtrl to function. | |
8 | // | |
9 | // Author: Robin Dunn | |
10 | // | |
11 | // Created: 13-Jan-2000 | |
12 | // RCS-ID: $Id$ | |
13 | // Copyright: (c) 2000 by Total Control Software | |
14 | // Licence: wxWindows license | |
15 | ///////////////////////////////////////////////////////////////////////////// | |
16 | ||
17 | // For compilers that support precompilation, includes "wx.h". | |
18 | #include "wx/wxprec.h" | |
19 | ||
20 | #ifdef __BORLANDC__ | |
21 | #pragma hdrstop | |
22 | #endif | |
23 | ||
24 | #if wxUSE_STC | |
25 | ||
26 | #ifndef WX_PRECOMP | |
27 | #include "wx/scrolbar.h" | |
28 | #include "wx/menu.h" | |
29 | #endif // WX_PRECOMP | |
30 | ||
31 | #include "wx/textbuf.h" | |
32 | #include "wx/dataobj.h" | |
33 | #include "wx/clipbrd.h" | |
34 | #include "wx/dnd.h" | |
35 | ||
36 | #include "ScintillaWX.h" | |
37 | #include "ExternalLexer.h" | |
38 | #include "wx/stc/stc.h" | |
39 | #include "wx/stc/private.h" | |
40 | #include "PlatWX.h" | |
41 | ||
42 | #ifdef __WXMSW__ | |
43 | // GetHwndOf() | |
44 | #include "wx/msw/private.h" | |
45 | #endif | |
46 | ||
47 | //---------------------------------------------------------------------- | |
48 | // Helper classes | |
49 | ||
50 | class wxSTCTimer : public wxTimer { | |
51 | public: | |
52 | wxSTCTimer(ScintillaWX* swx) { | |
53 | m_swx = swx; | |
54 | } | |
55 | ||
56 | void Notify() { | |
57 | m_swx->DoTick(); | |
58 | } | |
59 | ||
60 | private: | |
61 | ScintillaWX* m_swx; | |
62 | }; | |
63 | ||
64 | ||
65 | #if wxUSE_DRAG_AND_DROP | |
66 | class wxStartDragTimer : public wxTimer { | |
67 | public: | |
68 | wxStartDragTimer(ScintillaWX* swx) { | |
69 | m_swx = swx; | |
70 | } | |
71 | ||
72 | void Notify() { | |
73 | m_swx->DoStartDrag(); | |
74 | } | |
75 | ||
76 | private: | |
77 | ScintillaWX* m_swx; | |
78 | }; | |
79 | ||
80 | ||
81 | bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) { | |
82 | return m_swx->DoDropText(x, y, data); | |
83 | } | |
84 | ||
85 | wxDragResult wxSTCDropTarget::OnEnter(wxCoord x, wxCoord y, wxDragResult def) { | |
86 | return m_swx->DoDragEnter(x, y, def); | |
87 | } | |
88 | ||
89 | wxDragResult wxSTCDropTarget::OnDragOver(wxCoord x, wxCoord y, wxDragResult def) { | |
90 | return m_swx->DoDragOver(x, y, def); | |
91 | } | |
92 | ||
93 | void wxSTCDropTarget::OnLeave() { | |
94 | m_swx->DoDragLeave(); | |
95 | } | |
96 | #endif // wxUSE_DRAG_AND_DROP | |
97 | ||
98 | ||
99 | #if wxUSE_POPUPWIN && wxSTC_USE_POPUP | |
100 | #include "wx/popupwin.h" | |
101 | #define wxSTCCallTipBase wxPopupWindow | |
102 | #define param2 wxBORDER_NONE // popup's 2nd param is flags | |
103 | #else | |
104 | #include "wx/frame.h" | |
105 | #define wxSTCCallTipBase wxFrame | |
106 | #define param2 -1 // wxWindow's 2nd param is ID | |
107 | #endif | |
108 | ||
109 | #include "wx/dcbuffer.h" | |
110 | ||
111 | class wxSTCCallTip : public wxSTCCallTipBase { | |
112 | public: | |
113 | wxSTCCallTip(wxWindow* parent, CallTip* ct, ScintillaWX* swx) : | |
114 | #if wxUSE_POPUPWIN && wxSTC_USE_POPUP | |
115 | wxSTCCallTipBase(parent, wxBORDER_NONE), | |
116 | #else | |
117 | wxSTCCallTipBase(parent, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, | |
118 | wxFRAME_NO_TASKBAR | |
119 | | wxFRAME_FLOAT_ON_PARENT | |
120 | | wxBORDER_NONE | |
121 | #ifdef __WXMAC__ | |
122 | | wxPOPUP_WINDOW | |
123 | #endif | |
124 | ), | |
125 | #endif | |
126 | m_ct(ct), m_swx(swx), m_cx(wxDefaultCoord), m_cy(wxDefaultCoord) | |
127 | { | |
128 | } | |
129 | ||
130 | ~wxSTCCallTip() { | |
131 | #if wxUSE_POPUPWIN && wxSTC_USE_POPUP && defined(__WXGTK__) | |
132 | wxRect rect = GetRect(); | |
133 | rect.x = m_cx; | |
134 | rect.y = m_cy; | |
135 | GetParent()->Refresh(false, &rect); | |
136 | #endif | |
137 | } | |
138 | ||
139 | bool AcceptsFocus() const { return false; } | |
140 | ||
141 | void OnPaint(wxPaintEvent& WXUNUSED(evt)) | |
142 | { | |
143 | wxBufferedPaintDC dc(this); | |
144 | Surface* surfaceWindow = Surface::Allocate(); | |
145 | surfaceWindow->Init(&dc, m_ct->wDraw.GetID()); | |
146 | m_ct->PaintCT(surfaceWindow); | |
147 | surfaceWindow->Release(); | |
148 | delete surfaceWindow; | |
149 | } | |
150 | ||
151 | void OnFocus(wxFocusEvent& event) | |
152 | { | |
153 | GetParent()->SetFocus(); | |
154 | event.Skip(); | |
155 | } | |
156 | ||
157 | void OnLeftDown(wxMouseEvent& event) | |
158 | { | |
159 | wxPoint pt = event.GetPosition(); | |
160 | Point p(pt.x, pt.y); | |
161 | m_ct->MouseClick(p); | |
162 | m_swx->CallTipClick(); | |
163 | } | |
164 | ||
165 | virtual void DoSetSize(int x, int y, | |
166 | int width, int height, | |
167 | int sizeFlags = wxSIZE_AUTO) | |
168 | { | |
169 | // convert coords to screen coords since we're a top-level window | |
170 | if (x != wxDefaultCoord) { | |
171 | m_cx = x; | |
172 | GetParent()->ClientToScreen(&x, NULL); | |
173 | } | |
174 | if (y != wxDefaultCoord) { | |
175 | m_cy = y; | |
176 | GetParent()->ClientToScreen(NULL, &y); | |
177 | } | |
178 | wxSTCCallTipBase::DoSetSize(x, y, width, height, sizeFlags); | |
179 | } | |
180 | ||
181 | #if wxUSE_POPUPWIN && wxSTC_USE_POPUP | |
182 | #else | |
183 | virtual bool Show( bool show = true ) | |
184 | { | |
185 | // Although we're a frame, we always want the parent to be active, so | |
186 | // raise it whenever we get shown. | |
187 | bool rv = wxSTCCallTipBase::Show(show); | |
188 | if (rv && show) | |
189 | { | |
190 | wxTopLevelWindow *frame = wxDynamicCast( | |
191 | wxGetTopLevelParent(GetParent()), wxTopLevelWindow); | |
192 | if (frame) | |
193 | frame->Raise(); | |
194 | } | |
195 | return rv; | |
196 | } | |
197 | #endif | |
198 | ||
199 | wxPoint GetMyPosition() | |
200 | { | |
201 | return wxPoint(m_cx, m_cy); | |
202 | } | |
203 | ||
204 | private: | |
205 | CallTip* m_ct; | |
206 | ScintillaWX* m_swx; | |
207 | int m_cx, m_cy; | |
208 | DECLARE_EVENT_TABLE() | |
209 | }; | |
210 | ||
211 | BEGIN_EVENT_TABLE(wxSTCCallTip, wxSTCCallTipBase) | |
212 | EVT_PAINT(wxSTCCallTip::OnPaint) | |
213 | EVT_SET_FOCUS(wxSTCCallTip::OnFocus) | |
214 | EVT_LEFT_DOWN(wxSTCCallTip::OnLeftDown) | |
215 | END_EVENT_TABLE() | |
216 | ||
217 | ||
218 | //---------------------------------------------------------------------- | |
219 | ||
220 | #if wxUSE_DATAOBJ | |
221 | static wxTextFileType wxConvertEOLMode(int scintillaMode) | |
222 | { | |
223 | wxTextFileType type; | |
224 | ||
225 | switch (scintillaMode) { | |
226 | case wxSTC_EOL_CRLF: | |
227 | type = wxTextFileType_Dos; | |
228 | break; | |
229 | ||
230 | case wxSTC_EOL_CR: | |
231 | type = wxTextFileType_Mac; | |
232 | break; | |
233 | ||
234 | case wxSTC_EOL_LF: | |
235 | type = wxTextFileType_Unix; | |
236 | break; | |
237 | ||
238 | default: | |
239 | type = wxTextBuffer::typeDefault; | |
240 | break; | |
241 | } | |
242 | return type; | |
243 | } | |
244 | #endif // wxUSE_DATAOBJ | |
245 | ||
246 | ||
247 | //---------------------------------------------------------------------- | |
248 | // Constructor/Destructor | |
249 | ||
250 | ||
251 | ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) { | |
252 | capturedMouse = false; | |
253 | focusEvent = false; | |
254 | wMain = win; | |
255 | stc = win; | |
256 | wheelRotation = 0; | |
257 | Initialise(); | |
258 | #ifdef __WXMSW__ | |
259 | sysCaretBitmap = 0; | |
260 | sysCaretWidth = 0; | |
261 | sysCaretHeight = 0; | |
262 | #endif | |
263 | #if wxUSE_DRAG_AND_DROP | |
264 | startDragTimer = new wxStartDragTimer(this); | |
265 | #endif // wxUSE_DRAG_AND_DROP | |
266 | } | |
267 | ||
268 | ||
269 | ScintillaWX::~ScintillaWX() { | |
270 | #if wxUSE_DRAG_AND_DROP | |
271 | delete startDragTimer; | |
272 | #endif // wxUSE_DRAG_AND_DROP | |
273 | Finalise(); | |
274 | } | |
275 | ||
276 | //---------------------------------------------------------------------- | |
277 | // base class virtuals | |
278 | ||
279 | ||
280 | void ScintillaWX::Initialise() { | |
281 | //ScintillaBase::Initialise(); | |
282 | #if wxUSE_DRAG_AND_DROP | |
283 | dropTarget = new wxSTCDropTarget; | |
284 | dropTarget->SetScintilla(this); | |
285 | stc->SetDropTarget(dropTarget); | |
286 | #endif // wxUSE_DRAG_AND_DROP | |
287 | #ifdef __WXMAC__ | |
288 | vs.extraFontFlag = false; // UseAntiAliasing | |
289 | #else | |
290 | vs.extraFontFlag = true; // UseAntiAliasing | |
291 | #endif | |
292 | } | |
293 | ||
294 | ||
295 | void ScintillaWX::Finalise() { | |
296 | ScintillaBase::Finalise(); | |
297 | SetTicking(false); | |
298 | SetIdle(false); | |
299 | DestroySystemCaret(); | |
300 | } | |
301 | ||
302 | ||
303 | void ScintillaWX::StartDrag() { | |
304 | #if wxUSE_DRAG_AND_DROP | |
305 | // We defer the starting of the DnD, otherwise the LeftUp of a normal | |
306 | // click could be lost and the STC will think it is doing a DnD when the | |
307 | // user just wanted a normal click. | |
308 | startDragTimer->Start(200, true); | |
309 | #endif // wxUSE_DRAG_AND_DROP | |
310 | } | |
311 | ||
312 | void ScintillaWX::DoStartDrag() { | |
313 | #if wxUSE_DRAG_AND_DROP | |
314 | wxString dragText = stc2wx(drag.s, drag.len); | |
315 | ||
316 | // Send an event to allow the drag text to be changed | |
317 | wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId()); | |
318 | evt.SetEventObject(stc); | |
319 | evt.SetDragText(dragText); | |
320 | evt.SetDragAllowMove(true); | |
321 | evt.SetPosition(wxMin(stc->GetSelectionStart(), | |
322 | stc->GetSelectionEnd())); | |
323 | stc->GetEventHandler()->ProcessEvent(evt); | |
324 | dragText = evt.GetDragText(); | |
325 | ||
326 | if (dragText.length()) { | |
327 | wxDropSource source(stc); | |
328 | wxTextDataObject data(dragText); | |
329 | wxDragResult result; | |
330 | ||
331 | source.SetData(data); | |
332 | dropWentOutside = true; | |
333 | result = source.DoDragDrop(evt.GetDragAllowMove()); | |
334 | if (result == wxDragMove && dropWentOutside) | |
335 | ClearSelection(); | |
336 | inDragDrop = false; | |
337 | SetDragPosition(invalidPosition); | |
338 | } | |
339 | #endif // wxUSE_DRAG_AND_DROP | |
340 | } | |
341 | ||
342 | ||
343 | bool ScintillaWX::SetIdle(bool on) { | |
344 | if (idler.state != on) { | |
345 | // connect or disconnect the EVT_IDLE handler | |
346 | if (on) | |
347 | stc->Connect(wxID_ANY, wxEVT_IDLE, | |
348 | (wxObjectEventFunction) (wxEventFunction) (wxIdleEventFunction) &wxStyledTextCtrl::OnIdle); | |
349 | else | |
350 | stc->Disconnect(wxID_ANY, wxEVT_IDLE, | |
351 | (wxObjectEventFunction) (wxEventFunction) (wxIdleEventFunction) &wxStyledTextCtrl::OnIdle); | |
352 | idler.state = on; | |
353 | } | |
354 | return idler.state; | |
355 | } | |
356 | ||
357 | ||
358 | void ScintillaWX::SetTicking(bool on) { | |
359 | wxSTCTimer* steTimer; | |
360 | if (timer.ticking != on) { | |
361 | timer.ticking = on; | |
362 | if (timer.ticking) { | |
363 | steTimer = new wxSTCTimer(this); | |
364 | steTimer->Start(timer.tickSize); | |
365 | timer.tickerID = steTimer; | |
366 | } else { | |
367 | steTimer = (wxSTCTimer*)timer.tickerID; | |
368 | steTimer->Stop(); | |
369 | delete steTimer; | |
370 | timer.tickerID = 0; | |
371 | } | |
372 | } | |
373 | timer.ticksToWait = caret.period; | |
374 | } | |
375 | ||
376 | ||
377 | void ScintillaWX::SetMouseCapture(bool on) { | |
378 | if (mouseDownCaptures) { | |
379 | if (on && !capturedMouse) | |
380 | stc->CaptureMouse(); | |
381 | else if (!on && capturedMouse && stc->HasCapture()) | |
382 | stc->ReleaseMouse(); | |
383 | capturedMouse = on; | |
384 | } | |
385 | } | |
386 | ||
387 | ||
388 | bool ScintillaWX::HaveMouseCapture() { | |
389 | return capturedMouse; | |
390 | } | |
391 | ||
392 | ||
393 | void ScintillaWX::ScrollText(int linesToMove) { | |
394 | int dy = vs.lineHeight * (linesToMove); | |
395 | stc->ScrollWindow(0, dy); | |
396 | stc->Update(); | |
397 | } | |
398 | ||
399 | void ScintillaWX::SetVerticalScrollPos() { | |
400 | if (stc->m_vScrollBar == NULL) { // Use built-in scrollbar | |
401 | stc->SetScrollPos(wxVERTICAL, topLine); | |
402 | } | |
403 | else { // otherwise use the one that's been given to us | |
404 | stc->m_vScrollBar->SetThumbPosition(topLine); | |
405 | } | |
406 | } | |
407 | ||
408 | void ScintillaWX::SetHorizontalScrollPos() { | |
409 | if (stc->m_hScrollBar == NULL) { // Use built-in scrollbar | |
410 | stc->SetScrollPos(wxHORIZONTAL, xOffset); | |
411 | } | |
412 | else { // otherwise use the one that's been given to us | |
413 | stc->m_hScrollBar->SetThumbPosition(xOffset); | |
414 | } | |
415 | } | |
416 | ||
417 | ||
418 | const int H_SCROLL_STEP = 20; | |
419 | ||
420 | bool ScintillaWX::ModifyScrollBars(int nMax, int nPage) { | |
421 | bool modified = false; | |
422 | ||
423 | int vertEnd = nMax; | |
424 | if (!verticalScrollBarVisible) | |
425 | vertEnd = 0; | |
426 | ||
427 | // Check the vertical scrollbar | |
428 | if (stc->m_vScrollBar == NULL) { // Use built-in scrollbar | |
429 | int sbMax = stc->GetScrollRange(wxVERTICAL); | |
430 | int sbThumb = stc->GetScrollThumb(wxVERTICAL); | |
431 | int sbPos = stc->GetScrollPos(wxVERTICAL); | |
432 | if (sbMax != vertEnd || sbThumb != nPage) { | |
433 | stc->SetScrollbar(wxVERTICAL, sbPos, nPage, vertEnd+1); | |
434 | modified = true; | |
435 | } | |
436 | } | |
437 | else { // otherwise use the one that's been given to us | |
438 | int sbMax = stc->m_vScrollBar->GetRange(); | |
439 | int sbPage = stc->m_vScrollBar->GetPageSize(); | |
440 | int sbPos = stc->m_vScrollBar->GetThumbPosition(); | |
441 | if (sbMax != vertEnd || sbPage != nPage) { | |
442 | stc->m_vScrollBar->SetScrollbar(sbPos, nPage, vertEnd+1, nPage); | |
443 | modified = true; | |
444 | } | |
445 | } | |
446 | ||
447 | ||
448 | // Check the horizontal scrollbar | |
449 | PRectangle rcText = GetTextRectangle(); | |
450 | int horizEnd = scrollWidth; | |
451 | if (horizEnd < 0) | |
452 | horizEnd = 0; | |
453 | if (!horizontalScrollBarVisible || (wrapState != eWrapNone)) | |
454 | horizEnd = 0; | |
455 | int pageWidth = rcText.Width(); | |
456 | ||
457 | if (stc->m_hScrollBar == NULL) { // Use built-in scrollbar | |
458 | int sbMax = stc->GetScrollRange(wxHORIZONTAL); | |
459 | int sbThumb = stc->GetScrollThumb(wxHORIZONTAL); | |
460 | int sbPos = stc->GetScrollPos(wxHORIZONTAL); | |
461 | if ((sbMax != horizEnd) || (sbThumb != pageWidth) || (sbPos != 0)) { | |
462 | stc->SetScrollbar(wxHORIZONTAL, sbPos, pageWidth, horizEnd); | |
463 | modified = true; | |
464 | if (scrollWidth < pageWidth) { | |
465 | HorizontalScrollTo(0); | |
466 | } | |
467 | } | |
468 | } | |
469 | else { // otherwise use the one that's been given to us | |
470 | int sbMax = stc->m_hScrollBar->GetRange(); | |
471 | int sbThumb = stc->m_hScrollBar->GetPageSize(); | |
472 | int sbPos = stc->m_hScrollBar->GetThumbPosition(); | |
473 | if ((sbMax != horizEnd) || (sbThumb != pageWidth) || (sbPos != 0)) { | |
474 | stc->m_hScrollBar->SetScrollbar(sbPos, pageWidth, horizEnd, pageWidth); | |
475 | modified = true; | |
476 | if (scrollWidth < pageWidth) { | |
477 | HorizontalScrollTo(0); | |
478 | } | |
479 | } | |
480 | } | |
481 | ||
482 | return modified; | |
483 | } | |
484 | ||
485 | ||
486 | void ScintillaWX::NotifyChange() { | |
487 | stc->NotifyChange(); | |
488 | } | |
489 | ||
490 | ||
491 | void ScintillaWX::NotifyParent(SCNotification scn) { | |
492 | stc->NotifyParent(&scn); | |
493 | } | |
494 | ||
495 | ||
496 | // This method is overloaded from ScintillaBase in order to prevent the | |
497 | // AutoComplete window from being destroyed when it gets the focus. There is | |
498 | // a side effect that the AutoComp will also not be destroyed when switching | |
499 | // to another window, but I think that is okay. | |
500 | void ScintillaWX::CancelModes() { | |
501 | if (! focusEvent) | |
502 | AutoCompleteCancel(); | |
503 | ct.CallTipCancel(); | |
504 | Editor::CancelModes(); | |
505 | } | |
506 | ||
507 | ||
508 | ||
509 | void ScintillaWX::Copy() { | |
510 | if (currentPos != anchor) { | |
511 | SelectionText st; | |
512 | CopySelectionRange(&st); | |
513 | CopyToClipboard(st); | |
514 | } | |
515 | } | |
516 | ||
517 | ||
518 | void ScintillaWX::Paste() { | |
519 | pdoc->BeginUndoAction(); | |
520 | ClearSelection(); | |
521 | ||
522 | #if wxUSE_DATAOBJ | |
523 | wxTextDataObject data; | |
524 | bool gotData = false; | |
525 | ||
526 | wxTheClipboard->UsePrimarySelection(false); | |
527 | if (wxTheClipboard->Open()) { | |
528 | gotData = wxTheClipboard->GetData(data); | |
529 | wxTheClipboard->Close(); | |
530 | } | |
531 | if (gotData) { | |
532 | wxString text = wxTextBuffer::Translate(data.GetText(), | |
533 | wxConvertEOLMode(pdoc->eolMode)); | |
534 | wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); | |
535 | ||
536 | #if wxUSE_UNICODE | |
537 | // free up the old character buffer in case the text is real big | |
538 | data.SetText(wxEmptyString); | |
539 | text = wxEmptyString; | |
540 | #endif | |
541 | int len = strlen(buf); | |
542 | pdoc->InsertString(currentPos, buf, len); | |
543 | SetEmptySelection(currentPos + len); | |
544 | } | |
545 | #endif // wxUSE_DATAOBJ | |
546 | ||
547 | pdoc->EndUndoAction(); | |
548 | NotifyChange(); | |
549 | Redraw(); | |
550 | } | |
551 | ||
552 | ||
553 | void ScintillaWX::CopyToClipboard(const SelectionText& st) { | |
554 | #if wxUSE_CLIPBOARD | |
555 | wxTheClipboard->UsePrimarySelection(false); | |
556 | if (wxTheClipboard->Open()) { | |
557 | wxString text = wxTextBuffer::Translate(stc2wx(st.s, st.len-1)); | |
558 | wxTheClipboard->SetData(new wxTextDataObject(text)); | |
559 | wxTheClipboard->Close(); | |
560 | } | |
561 | #else | |
562 | wxUnusedVar(st); | |
563 | #endif // wxUSE_CLIPBOARD | |
564 | } | |
565 | ||
566 | ||
567 | bool ScintillaWX::CanPaste() { | |
568 | #if wxUSE_CLIPBOARD | |
569 | bool canPaste = false; | |
570 | bool didOpen; | |
571 | ||
572 | if (Editor::CanPaste()) { | |
573 | wxTheClipboard->UsePrimarySelection(false); | |
574 | didOpen = !wxTheClipboard->IsOpened(); | |
575 | if ( didOpen ) | |
576 | wxTheClipboard->Open(); | |
577 | ||
578 | if (wxTheClipboard->IsOpened()) { | |
579 | canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT); | |
580 | if (didOpen) | |
581 | wxTheClipboard->Close(); | |
582 | } | |
583 | } | |
584 | return canPaste; | |
585 | #else | |
586 | return false; | |
587 | #endif // wxUSE_CLIPBOARD | |
588 | } | |
589 | ||
590 | void ScintillaWX::CreateCallTipWindow(PRectangle) { | |
591 | if (! ct.wCallTip.Created() ) { | |
592 | ct.wCallTip = new wxSTCCallTip(stc, &ct, this); | |
593 | ct.wDraw = ct.wCallTip; | |
594 | } | |
595 | } | |
596 | ||
597 | ||
598 | void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) { | |
599 | if (!label[0]) | |
600 | ((wxMenu*)popup.GetID())->AppendSeparator(); | |
601 | else | |
602 | ((wxMenu*)popup.GetID())->Append(cmd, wxGetTranslation(stc2wx(label))); | |
603 | ||
604 | if (!enabled) | |
605 | ((wxMenu*)popup.GetID())->Enable(cmd, enabled); | |
606 | } | |
607 | ||
608 | ||
609 | // This is called by the Editor base class whenever something is selected. | |
610 | // For wxGTK we can put this text in the primary selection and then other apps | |
611 | // can paste with the middle button. | |
612 | void ScintillaWX::ClaimSelection() { | |
613 | #ifdef __WXGTK__ | |
614 | // Put the selected text in the PRIMARY selection | |
615 | if (currentPos != anchor) { | |
616 | SelectionText st; | |
617 | CopySelectionRange(&st); | |
618 | wxTheClipboard->UsePrimarySelection(true); | |
619 | if (wxTheClipboard->Open()) { | |
620 | wxString text = stc2wx(st.s, st.len); | |
621 | wxTheClipboard->SetData(new wxTextDataObject(text)); | |
622 | wxTheClipboard->Close(); | |
623 | } | |
624 | wxTheClipboard->UsePrimarySelection(false); | |
625 | } | |
626 | #endif | |
627 | } | |
628 | ||
629 | ||
630 | void ScintillaWX::UpdateSystemCaret() { | |
631 | #ifdef __WXMSW__ | |
632 | if (hasFocus) { | |
633 | if (HasCaretSizeChanged()) { | |
634 | DestroySystemCaret(); | |
635 | CreateSystemCaret(); | |
636 | } | |
637 | Point pos = LocationFromPosition(currentPos); | |
638 | ::SetCaretPos(pos.x, pos.y); | |
639 | } | |
640 | #endif | |
641 | } | |
642 | ||
643 | ||
644 | bool ScintillaWX::HasCaretSizeChanged() { | |
645 | #ifdef __WXMSW__ | |
646 | if (( (0 != vs.caretWidth) && (sysCaretWidth != vs.caretWidth) ) | |
647 | || (0 != vs.lineHeight) && (sysCaretHeight != vs.lineHeight)) { | |
648 | return true; | |
649 | } | |
650 | #endif | |
651 | return false; | |
652 | } | |
653 | ||
654 | bool ScintillaWX::CreateSystemCaret() { | |
655 | #ifdef __WXMSW__ | |
656 | sysCaretWidth = vs.caretWidth; | |
657 | if (0 == sysCaretWidth) { | |
658 | sysCaretWidth = 1; | |
659 | } | |
660 | sysCaretHeight = vs.lineHeight; | |
661 | int bitmapSize = (((sysCaretWidth + 15) & ~15) >> 3) * sysCaretHeight; | |
662 | char *bits = new char[bitmapSize]; | |
663 | memset(bits, 0, bitmapSize); | |
664 | sysCaretBitmap = ::CreateBitmap(sysCaretWidth, sysCaretHeight, 1, | |
665 | 1, reinterpret_cast<BYTE *>(bits)); | |
666 | delete [] bits; | |
667 | BOOL retval = ::CreateCaret(GetHwndOf(stc), sysCaretBitmap, | |
668 | sysCaretWidth, sysCaretHeight); | |
669 | ::ShowCaret(GetHwndOf(stc)); | |
670 | return retval != 0; | |
671 | #else | |
672 | return false; | |
673 | #endif | |
674 | } | |
675 | ||
676 | bool ScintillaWX::DestroySystemCaret() { | |
677 | #ifdef __WXMSW__ | |
678 | ::HideCaret(GetHwndOf(stc)); | |
679 | BOOL retval = ::DestroyCaret(); | |
680 | if (sysCaretBitmap) { | |
681 | ::DeleteObject(sysCaretBitmap); | |
682 | sysCaretBitmap = 0; | |
683 | } | |
684 | return retval != 0; | |
685 | #else | |
686 | return false; | |
687 | #endif | |
688 | } | |
689 | ||
690 | ||
691 | //---------------------------------------------------------------------- | |
692 | ||
693 | ||
694 | sptr_t ScintillaWX::DefWndProc(unsigned int /*iMessage*/, uptr_t /*wParam*/, sptr_t /*lParam*/) { | |
695 | return 0; | |
696 | } | |
697 | ||
698 | sptr_t ScintillaWX::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { | |
699 | switch (iMessage) { | |
700 | case SCI_CALLTIPSHOW: { | |
701 | // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx | |
702 | // because of the little tweak that needs done below for wxGTK. | |
703 | // When updating new versions double check that this is still | |
704 | // needed, and that any new code there is copied here too. | |
705 | Point pt = LocationFromPosition(wParam); | |
706 | char* defn = reinterpret_cast<char *>(lParam); | |
707 | AutoCompleteCancel(); | |
708 | pt.y += vs.lineHeight; | |
709 | PRectangle rc = ct.CallTipStart(currentPos, pt, | |
710 | defn, | |
711 | vs.styles[STYLE_DEFAULT].fontName, | |
712 | vs.styles[STYLE_DEFAULT].sizeZoomed, | |
713 | CodePage(), | |
714 | vs.styles[STYLE_DEFAULT].characterSet, | |
715 | wMain); | |
716 | // If the call-tip window would be out of the client | |
717 | // space, adjust so it displays above the text. | |
718 | PRectangle rcClient = GetClientRectangle(); | |
719 | if (rc.bottom > rcClient.bottom) { | |
720 | #ifdef __WXGTK__ | |
721 | int offset = int(vs.lineHeight * 1.25) + rc.Height(); | |
722 | #else | |
723 | int offset = vs.lineHeight + rc.Height(); | |
724 | #endif | |
725 | rc.top -= offset; | |
726 | rc.bottom -= offset; | |
727 | } | |
728 | // Now display the window. | |
729 | CreateCallTipWindow(rc); | |
730 | ct.wCallTip.SetPositionRelative(rc, wMain); | |
731 | ct.wCallTip.Show(); | |
732 | break; | |
733 | } | |
734 | ||
735 | #ifdef SCI_LEXER | |
736 | case SCI_LOADLEXERLIBRARY: | |
737 | LexerManager::GetInstance()->Load((const char*)lParam); | |
738 | break; | |
739 | #endif | |
740 | ||
741 | default: | |
742 | return ScintillaBase::WndProc(iMessage, wParam, lParam); | |
743 | } | |
744 | return 0; | |
745 | } | |
746 | ||
747 | ||
748 | ||
749 | //---------------------------------------------------------------------- | |
750 | // Event delegates | |
751 | ||
752 | void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) { | |
753 | ||
754 | paintState = painting; | |
755 | Surface* surfaceWindow = Surface::Allocate(); | |
756 | surfaceWindow->Init(dc, wMain.GetID()); | |
757 | rcPaint = PRectangleFromwxRect(rect); | |
758 | PRectangle rcClient = GetClientRectangle(); | |
759 | paintingAllText = rcPaint.Contains(rcClient); | |
760 | ||
761 | ClipChildren(*dc, rcPaint); | |
762 | Paint(surfaceWindow, rcPaint); | |
763 | ||
764 | delete surfaceWindow; | |
765 | if (paintState == paintAbandoned) { | |
766 | // Painting area was insufficient to cover new styling or brace | |
767 | // highlight positions | |
768 | FullPaint(); | |
769 | } | |
770 | paintState = notPainting; | |
771 | } | |
772 | ||
773 | ||
774 | void ScintillaWX::DoHScroll(int type, int pos) { | |
775 | int xPos = xOffset; | |
776 | PRectangle rcText = GetTextRectangle(); | |
777 | int pageWidth = rcText.Width() * 2 / 3; | |
778 | if (type == wxEVT_SCROLLWIN_LINEUP || type == wxEVT_SCROLL_LINEUP) | |
779 | xPos -= H_SCROLL_STEP; | |
780 | else if (type == wxEVT_SCROLLWIN_LINEDOWN || type == wxEVT_SCROLL_LINEDOWN) | |
781 | xPos += H_SCROLL_STEP; | |
782 | else if (type == wxEVT_SCROLLWIN_PAGEUP || type == wxEVT_SCROLL_PAGEUP) | |
783 | xPos -= pageWidth; | |
784 | else if (type == wxEVT_SCROLLWIN_PAGEDOWN || type == wxEVT_SCROLL_PAGEDOWN) { | |
785 | xPos += pageWidth; | |
786 | if (xPos > scrollWidth - rcText.Width()) { | |
787 | xPos = scrollWidth - rcText.Width(); | |
788 | } | |
789 | } | |
790 | else if (type == wxEVT_SCROLLWIN_TOP || type == wxEVT_SCROLL_TOP) | |
791 | xPos = 0; | |
792 | else if (type == wxEVT_SCROLLWIN_BOTTOM || type == wxEVT_SCROLL_BOTTOM) | |
793 | xPos = scrollWidth; | |
794 | else if (type == wxEVT_SCROLLWIN_THUMBTRACK || type == wxEVT_SCROLL_THUMBTRACK) | |
795 | xPos = pos; | |
796 | ||
797 | HorizontalScrollTo(xPos); | |
798 | } | |
799 | ||
800 | void ScintillaWX::DoVScroll(int type, int pos) { | |
801 | int topLineNew = topLine; | |
802 | if (type == wxEVT_SCROLLWIN_LINEUP || type == wxEVT_SCROLL_LINEUP) | |
803 | topLineNew -= 1; | |
804 | else if (type == wxEVT_SCROLLWIN_LINEDOWN || type == wxEVT_SCROLL_LINEDOWN) | |
805 | topLineNew += 1; | |
806 | else if (type == wxEVT_SCROLLWIN_PAGEUP || type == wxEVT_SCROLL_PAGEUP) | |
807 | topLineNew -= LinesToScroll(); | |
808 | else if (type == wxEVT_SCROLLWIN_PAGEDOWN || type == wxEVT_SCROLL_PAGEDOWN) | |
809 | topLineNew += LinesToScroll(); | |
810 | else if (type == wxEVT_SCROLLWIN_TOP || type == wxEVT_SCROLL_TOP) | |
811 | topLineNew = 0; | |
812 | else if (type == wxEVT_SCROLLWIN_BOTTOM || type == wxEVT_SCROLL_BOTTOM) | |
813 | topLineNew = MaxScrollPos(); | |
814 | else if (type == wxEVT_SCROLLWIN_THUMBTRACK || type == wxEVT_SCROLL_THUMBTRACK) | |
815 | topLineNew = pos; | |
816 | ||
817 | ScrollTo(topLineNew); | |
818 | } | |
819 | ||
820 | void ScintillaWX::DoMouseWheel(int rotation, int delta, | |
821 | int linesPerAction, int ctrlDown, | |
822 | bool isPageScroll ) { | |
823 | int topLineNew = topLine; | |
824 | int lines; | |
825 | ||
826 | if (ctrlDown) { // Zoom the fonts if Ctrl key down | |
827 | if (rotation < 0) { | |
828 | KeyCommand(SCI_ZOOMIN); | |
829 | } | |
830 | else { | |
831 | KeyCommand(SCI_ZOOMOUT); | |
832 | } | |
833 | } | |
834 | else { // otherwise just scroll the window | |
835 | if ( !delta ) | |
836 | delta = 120; | |
837 | wheelRotation += rotation; | |
838 | lines = wheelRotation / delta; | |
839 | wheelRotation -= lines * delta; | |
840 | if (lines != 0) { | |
841 | if (isPageScroll) | |
842 | lines = lines * LinesOnScreen(); // lines is either +1 or -1 | |
843 | else | |
844 | lines *= linesPerAction; | |
845 | topLineNew -= lines; | |
846 | ScrollTo(topLineNew); | |
847 | } | |
848 | } | |
849 | } | |
850 | ||
851 | ||
852 | void ScintillaWX::DoSize(int WXUNUSED(width), int WXUNUSED(height)) { | |
853 | ChangeSize(); | |
854 | } | |
855 | ||
856 | void ScintillaWX::DoLoseFocus(){ | |
857 | focusEvent = true; | |
858 | SetFocusState(false); | |
859 | focusEvent = false; | |
860 | DestroySystemCaret(); | |
861 | } | |
862 | ||
863 | void ScintillaWX::DoGainFocus(){ | |
864 | focusEvent = true; | |
865 | SetFocusState(true); | |
866 | focusEvent = false; | |
867 | DestroySystemCaret(); | |
868 | CreateSystemCaret(); | |
869 | } | |
870 | ||
871 | void ScintillaWX::DoSysColourChange() { | |
872 | InvalidateStyleData(); | |
873 | } | |
874 | ||
875 | void ScintillaWX::DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) { | |
876 | ButtonDown(pt, curTime, shift, ctrl, alt); | |
877 | } | |
878 | ||
879 | void ScintillaWX::DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl) { | |
880 | ButtonUp(pt, curTime, ctrl); | |
881 | #if wxUSE_DRAG_AND_DROP | |
882 | if (startDragTimer->IsRunning()) { | |
883 | startDragTimer->Stop(); | |
884 | SetDragPosition(invalidPosition); | |
885 | SetEmptySelection(PositionFromLocation(pt)); | |
886 | ShowCaretAtCurrentPosition(); | |
887 | } | |
888 | #endif // wxUSE_DRAG_AND_DROP | |
889 | } | |
890 | ||
891 | void ScintillaWX::DoLeftButtonMove(Point pt) { | |
892 | ButtonMove(pt); | |
893 | } | |
894 | ||
895 | #ifdef __WXGTK__ | |
896 | void ScintillaWX::DoMiddleButtonUp(Point pt) { | |
897 | // Set the current position to the mouse click point and | |
898 | // then paste in the PRIMARY selection, if any. wxGTK only. | |
899 | int newPos = PositionFromLocation(pt); | |
900 | MovePositionTo(newPos, noSel, true); | |
901 | ||
902 | pdoc->BeginUndoAction(); | |
903 | wxTextDataObject data; | |
904 | bool gotData = false; | |
905 | wxTheClipboard->UsePrimarySelection(true); | |
906 | if (wxTheClipboard->Open()) { | |
907 | gotData = wxTheClipboard->GetData(data); | |
908 | wxTheClipboard->Close(); | |
909 | } | |
910 | wxTheClipboard->UsePrimarySelection(false); | |
911 | if (gotData) { | |
912 | wxString text = wxTextBuffer::Translate(data.GetText(), | |
913 | wxConvertEOLMode(pdoc->eolMode)); | |
914 | wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); | |
915 | int len = strlen(buf); | |
916 | pdoc->InsertString(currentPos, buf, len); | |
917 | SetEmptySelection(currentPos + len); | |
918 | } | |
919 | pdoc->EndUndoAction(); | |
920 | NotifyChange(); | |
921 | Redraw(); | |
922 | ||
923 | ShowCaretAtCurrentPosition(); | |
924 | EnsureCaretVisible(); | |
925 | } | |
926 | #else | |
927 | void ScintillaWX::DoMiddleButtonUp(Point WXUNUSED(pt)) { | |
928 | } | |
929 | #endif | |
930 | ||
931 | ||
932 | void ScintillaWX::DoAddChar(int key) { | |
933 | #if wxUSE_UNICODE | |
934 | wxChar wszChars[2]; | |
935 | wszChars[0] = (wxChar)key; | |
936 | wszChars[1] = 0; | |
937 | wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(wszChars); | |
938 | AddCharUTF((char*)buf.data(), strlen(buf)); | |
939 | #else | |
940 | AddChar((char)key); | |
941 | #endif | |
942 | } | |
943 | ||
944 | ||
945 | int ScintillaWX::DoKeyDown(const wxKeyEvent& evt, bool* consumed) | |
946 | { | |
947 | int key = evt.GetKeyCode(); | |
948 | bool shift = evt.ShiftDown(), | |
949 | ctrl = evt.ControlDown(), | |
950 | alt = evt.AltDown(); | |
951 | ||
952 | if (ctrl && key >= 1 && key <= 26 && key != WXK_BACK) | |
953 | key += 'A' - 1; | |
954 | ||
955 | switch (key) { | |
956 | case WXK_DOWN: key = SCK_DOWN; break; | |
957 | case WXK_UP: key = SCK_UP; break; | |
958 | case WXK_LEFT: key = SCK_LEFT; break; | |
959 | case WXK_RIGHT: key = SCK_RIGHT; break; | |
960 | case WXK_HOME: key = SCK_HOME; break; | |
961 | case WXK_END: key = SCK_END; break; | |
962 | case WXK_PAGEUP: key = SCK_PRIOR; break; | |
963 | case WXK_PAGEDOWN: key = SCK_NEXT; break; | |
964 | case WXK_NUMPAD_DOWN: key = SCK_DOWN; break; | |
965 | case WXK_NUMPAD_UP: key = SCK_UP; break; | |
966 | case WXK_NUMPAD_LEFT: key = SCK_LEFT; break; | |
967 | case WXK_NUMPAD_RIGHT: key = SCK_RIGHT; break; | |
968 | case WXK_NUMPAD_HOME: key = SCK_HOME; break; | |
969 | case WXK_NUMPAD_END: key = SCK_END; break; | |
970 | case WXK_NUMPAD_PAGEUP: key = SCK_PRIOR; break; | |
971 | case WXK_NUMPAD_PAGEDOWN: key = SCK_NEXT; break; | |
972 | case WXK_NUMPAD_DELETE: key = SCK_DELETE; break; | |
973 | case WXK_NUMPAD_INSERT: key = SCK_INSERT; break; | |
974 | case WXK_DELETE: key = SCK_DELETE; break; | |
975 | case WXK_INSERT: key = SCK_INSERT; break; | |
976 | case WXK_ESCAPE: key = SCK_ESCAPE; break; | |
977 | case WXK_BACK: key = SCK_BACK; break; | |
978 | case WXK_TAB: key = SCK_TAB; break; | |
979 | case WXK_NUMPAD_ENTER: // fall through | |
980 | case WXK_RETURN: key = SCK_RETURN; break; | |
981 | case WXK_ADD: // fall through | |
982 | case WXK_NUMPAD_ADD: key = SCK_ADD; break; | |
983 | case WXK_SUBTRACT: // fall through | |
984 | case WXK_NUMPAD_SUBTRACT: key = SCK_SUBTRACT; break; | |
985 | case WXK_DIVIDE: // fall through | |
986 | case WXK_NUMPAD_DIVIDE: key = SCK_DIVIDE; break; | |
987 | case WXK_CONTROL: key = 0; break; | |
988 | case WXK_ALT: key = 0; break; | |
989 | case WXK_SHIFT: key = 0; break; | |
990 | case WXK_MENU: key = 0; break; | |
991 | } | |
992 | ||
993 | #ifdef __WXMAC__ | |
994 | if ( evt.MetaDown() ) { | |
995 | // check for a few common Mac Meta-key combos and remap them to Ctrl | |
996 | // for Scintilla | |
997 | switch ( key ) { | |
998 | case 'Z': // Undo | |
999 | case 'X': // Cut | |
1000 | case 'C': // Copy | |
1001 | case 'V': // Paste | |
1002 | case 'A': // Select All | |
1003 | ctrl = true; | |
1004 | break; | |
1005 | } | |
1006 | } | |
1007 | #endif | |
1008 | ||
1009 | int rv = KeyDown(key, shift, ctrl, alt, consumed); | |
1010 | ||
1011 | if (key) | |
1012 | return rv; | |
1013 | else | |
1014 | return 1; | |
1015 | } | |
1016 | ||
1017 | ||
1018 | void ScintillaWX::DoCommand(int ID) { | |
1019 | Command(ID); | |
1020 | } | |
1021 | ||
1022 | ||
1023 | void ScintillaWX::DoContextMenu(Point pt) { | |
1024 | if (displayPopupMenu) | |
1025 | ContextMenu(pt); | |
1026 | } | |
1027 | ||
1028 | void ScintillaWX::DoOnListBox() { | |
1029 | AutoCompleteCompleted(); | |
1030 | } | |
1031 | ||
1032 | ||
1033 | void ScintillaWX::DoOnIdle(wxIdleEvent& evt) { | |
1034 | ||
1035 | if ( Idle() ) | |
1036 | evt.RequestMore(); | |
1037 | else | |
1038 | SetIdle(false); | |
1039 | } | |
1040 | ||
1041 | //---------------------------------------------------------------------- | |
1042 | ||
1043 | #if wxUSE_DRAG_AND_DROP | |
1044 | bool ScintillaWX::DoDropText(long x, long y, const wxString& data) { | |
1045 | SetDragPosition(invalidPosition); | |
1046 | ||
1047 | wxString text = wxTextBuffer::Translate(data, | |
1048 | wxConvertEOLMode(pdoc->eolMode)); | |
1049 | ||
1050 | // Send an event to allow the drag details to be changed | |
1051 | wxStyledTextEvent evt(wxEVT_STC_DO_DROP, stc->GetId()); | |
1052 | evt.SetEventObject(stc); | |
1053 | evt.SetDragResult(dragResult); | |
1054 | evt.SetX(x); | |
1055 | evt.SetY(y); | |
1056 | evt.SetPosition(PositionFromLocation(Point(x,y))); | |
1057 | evt.SetDragText(text); | |
1058 | stc->GetEventHandler()->ProcessEvent(evt); | |
1059 | ||
1060 | dragResult = evt.GetDragResult(); | |
1061 | if (dragResult == wxDragMove || dragResult == wxDragCopy) { | |
1062 | DropAt(evt.GetPosition(), | |
1063 | wx2stc(evt.GetDragText()), | |
1064 | dragResult == wxDragMove, | |
1065 | false); // TODO: rectangular? | |
1066 | return true; | |
1067 | } | |
1068 | return false; | |
1069 | } | |
1070 | ||
1071 | ||
1072 | wxDragResult ScintillaWX::DoDragEnter(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxDragResult def) { | |
1073 | dragResult = def; | |
1074 | return dragResult; | |
1075 | } | |
1076 | ||
1077 | ||
1078 | wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { | |
1079 | SetDragPosition(PositionFromLocation(Point(x, y))); | |
1080 | ||
1081 | // Send an event to allow the drag result to be changed | |
1082 | wxStyledTextEvent evt(wxEVT_STC_DRAG_OVER, stc->GetId()); | |
1083 | evt.SetEventObject(stc); | |
1084 | evt.SetDragResult(def); | |
1085 | evt.SetX(x); | |
1086 | evt.SetY(y); | |
1087 | evt.SetPosition(PositionFromLocation(Point(x,y))); | |
1088 | stc->GetEventHandler()->ProcessEvent(evt); | |
1089 | ||
1090 | dragResult = evt.GetDragResult(); | |
1091 | return dragResult; | |
1092 | } | |
1093 | ||
1094 | ||
1095 | void ScintillaWX::DoDragLeave() { | |
1096 | SetDragPosition(invalidPosition); | |
1097 | } | |
1098 | #endif // wxUSE_DRAG_AND_DROP | |
1099 | //---------------------------------------------------------------------- | |
1100 | ||
1101 | // Force the whole window to be repainted | |
1102 | void ScintillaWX::FullPaint() { | |
1103 | #ifndef __WXMAC__ | |
1104 | stc->Refresh(false); | |
1105 | #endif | |
1106 | stc->Update(); | |
1107 | } | |
1108 | ||
1109 | ||
1110 | void ScintillaWX::DoScrollToLine(int line) { | |
1111 | ScrollTo(line); | |
1112 | } | |
1113 | ||
1114 | ||
1115 | void ScintillaWX::DoScrollToColumn(int column) { | |
1116 | HorizontalScrollTo(column * vs.spaceWidth); | |
1117 | } | |
1118 | ||
1119 | // wxGTK doesn't appear to need this explicit clipping code any longer, but I | |
1120 | // will leave it here commented out for a while just in case... | |
1121 | void ScintillaWX::ClipChildren(wxDC& WXUNUSED(dc), PRectangle WXUNUSED(rect)) | |
1122 | { | |
1123 | // wxRegion rgn(wxRectFromPRectangle(rect)); | |
1124 | // if (ac.Active()) { | |
1125 | // wxRect childRect = ((wxWindow*)ac.lb->GetID())->GetRect(); | |
1126 | // rgn.Subtract(childRect); | |
1127 | // } | |
1128 | // if (ct.inCallTipMode) { | |
1129 | // wxSTCCallTip* tip = (wxSTCCallTip*)ct.wCallTip.GetID(); | |
1130 | // wxRect childRect = tip->GetRect(); | |
1131 | // #if wxUSE_POPUPWIN && wxSTC_USE_POPUP | |
1132 | // childRect.SetPosition(tip->GetMyPosition()); | |
1133 | // #endif | |
1134 | // rgn.Subtract(childRect); | |
1135 | // } | |
1136 | // dc.SetClippingRegion(rgn); | |
1137 | } | |
1138 | ||
1139 | ||
1140 | void ScintillaWX::SetUseAntiAliasing(bool useAA) { | |
1141 | vs.extraFontFlag = useAA; | |
1142 | InvalidateStyleRedraw(); | |
1143 | } | |
1144 | ||
1145 | bool ScintillaWX::GetUseAntiAliasing() { | |
1146 | return vs.extraFontFlag; | |
1147 | } | |
1148 | ||
1149 | //---------------------------------------------------------------------- | |
1150 | //---------------------------------------------------------------------- | |
1151 | ||
1152 | #endif // wxUSE_STC |