Advertisement
Guest User

Untitled

a guest
Jan 30th, 2021
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 106.53 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////
  2. // Name: wxscintilla.cpp
  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.
  9. //
  10. // Author: Robin Dunn
  11. //
  12. // Created: 13-Jan-2000
  13. // RCS-ID: $Id: wxscintilla.cpp,v 1.34 2006/06/24 07:37:29 wyo Exp $
  14. // Copyright: (c) 2004 wxCode
  15. // Licence: wxWindows
  16. /////////////////////////////////////////////////////////////////////////////
  17.  
  18. #include <ctype.h>
  19.  
  20. #include "ScintillaWX.h"
  21. #include "wx/wxscintilla.h"
  22.  
  23. #include <wx/wx.h>
  24. #include <wx/tokenzr.h>
  25. #include <wx/mstream.h>
  26. #include <wx/image.h>
  27. #include <wx/file.h>
  28.  
  29.  
  30. //----------------------------------------------------------------------
  31.  
  32. const wxChar* wxSCINameStr = _T("SCIwindow");
  33.  
  34. #ifdef MAKELONG
  35. #undef MAKELONG
  36. #endif
  37.  
  38. #define MAKELONG(a, b) ((a) | ((b) << 16))
  39.  
  40.  
  41. static long wxColourAsLong(const wxColour& co) {
  42. return (((long)co.Blue() << 16) |
  43. ((long)co.Green() << 8) |
  44. ((long)co.Red()));
  45. }
  46.  
  47. static wxColour wxColourFromLong(long c) {
  48. wxColour clr;
  49. clr.Set((unsigned char)(c & 0xff),
  50. (unsigned char)((c >> 8) & 0xff),
  51. (unsigned char)((c >> 16) & 0xff));
  52. return clr;
  53. }
  54.  
  55.  
  56. static wxColour wxColourFromSpec(const wxString& spec) {
  57. // spec should be a colour name or "#RRGGBB"
  58. if (spec.GetChar(0) == _T('#')) {
  59.  
  60. long red, green, blue;
  61. red = green = blue = 0;
  62. spec.Mid(1,2).ToLong(&red, 16);
  63. spec.Mid(3,2).ToLong(&green, 16);
  64. spec.Mid(5,2).ToLong(&blue, 16);
  65. return wxColour((unsigned char)red, (unsigned char)green, (unsigned char)blue);
  66. }else{
  67. return wxColour(spec);
  68. }
  69. }
  70.  
  71. //----------------------------------------------------------------------
  72.  
  73. DEFINE_EVENT_TYPE( wxEVT_SCI_CHANGE )
  74. DEFINE_EVENT_TYPE( wxEVT_SCI_STYLENEEDED )
  75. DEFINE_EVENT_TYPE( wxEVT_SCI_CHARADDED )
  76. DEFINE_EVENT_TYPE( wxEVT_SCI_SAVEPOINTREACHED )
  77. DEFINE_EVENT_TYPE( wxEVT_SCI_SAVEPOINTLEFT )
  78. DEFINE_EVENT_TYPE( wxEVT_SCI_ROMODIFYATTEMPT )
  79. DEFINE_EVENT_TYPE( wxEVT_SCI_KEY )
  80. DEFINE_EVENT_TYPE( wxEVT_SCI_DOUBLECLICK )
  81. DEFINE_EVENT_TYPE( wxEVT_SCI_UPDATEUI )
  82. DEFINE_EVENT_TYPE( wxEVT_SCI_MODIFIED )
  83. DEFINE_EVENT_TYPE( wxEVT_SCI_MACRORECORD )
  84. DEFINE_EVENT_TYPE( wxEVT_SCI_MARGINCLICK )
  85. DEFINE_EVENT_TYPE( wxEVT_SCI_NEEDSHOWN )
  86. DEFINE_EVENT_TYPE( wxEVT_SCI_PAINTED )
  87. DEFINE_EVENT_TYPE( wxEVT_SCI_USERLISTSELECTION )
  88. DEFINE_EVENT_TYPE( wxEVT_SCI_URIDROPPED )
  89. DEFINE_EVENT_TYPE( wxEVT_SCI_DWELLSTART )
  90. DEFINE_EVENT_TYPE( wxEVT_SCI_DWELLEND )
  91. DEFINE_EVENT_TYPE( wxEVT_SCI_START_DRAG )
  92. DEFINE_EVENT_TYPE( wxEVT_SCI_DRAG_OVER )
  93. DEFINE_EVENT_TYPE( wxEVT_SCI_DO_DROP )
  94. DEFINE_EVENT_TYPE( wxEVT_SCI_ZOOM )
  95. DEFINE_EVENT_TYPE( wxEVT_SCI_HOTSPOT_CLICK )
  96. DEFINE_EVENT_TYPE( wxEVT_SCI_HOTSPOT_DCLICK )
  97. DEFINE_EVENT_TYPE( wxEVT_SCI_CALLTIP_CLICK )
  98. DEFINE_EVENT_TYPE( wxEVT_SCI_AUTOCOMP_SELECTION )
  99.  
  100.  
  101.  
  102. BEGIN_EVENT_TABLE(wxScintilla, wxControl)
  103. EVT_PAINT (wxScintilla::OnPaint)
  104. EVT_SCROLLWIN (wxScintilla::OnScrollWin)
  105. EVT_SCROLL (wxScintilla::OnScroll)
  106. EVT_SIZE (wxScintilla::OnSize)
  107. EVT_LEFT_DOWN (wxScintilla::OnMouseLeftDown)
  108. // Let Scintilla see the double click as a second click
  109. EVT_LEFT_DCLICK (wxScintilla::OnMouseLeftDown)
  110. EVT_MOTION (wxScintilla::OnMouseMove)
  111. EVT_LEFT_UP (wxScintilla::OnMouseLeftUp)
  112. #if defined(__WXGTK__) || defined(__WXMAC__)
  113. EVT_RIGHT_UP (wxScintilla::OnMouseRightUp)
  114. #else
  115. EVT_CONTEXT_MENU (wxScintilla::OnContextMenu)
  116. #endif
  117. EVT_MOUSEWHEEL (wxScintilla::OnMouseWheel)
  118. EVT_MIDDLE_UP (wxScintilla::OnMouseMiddleUp)
  119. EVT_CHAR (wxScintilla::OnChar)
  120. EVT_KEY_DOWN (wxScintilla::OnKeyDown)
  121. EVT_KILL_FOCUS (wxScintilla::OnLoseFocus)
  122. EVT_SET_FOCUS (wxScintilla::OnGainFocus)
  123. EVT_SYS_COLOUR_CHANGED (wxScintilla::OnSysColourChanged)
  124. EVT_ERASE_BACKGROUND (wxScintilla::OnEraseBackground)
  125. EVT_MENU_RANGE (10, 16, wxScintilla::OnMenu)
  126. EVT_LISTBOX_DCLICK (wxID_ANY, wxScintilla::OnListBox)
  127. END_EVENT_TABLE()
  128.  
  129.  
  130. IMPLEMENT_CLASS(wxScintilla, wxControl)
  131. IMPLEMENT_DYNAMIC_CLASS(wxScintillaEvent, wxCommandEvent)
  132.  
  133. #ifdef LINK_LEXERS
  134. // forces the linking of the lexer modules
  135. int Scintilla_LinkLexers();
  136. #endif
  137.  
  138. //----------------------------------------------------------------------
  139. // Constructor and Destructor
  140.  
  141. wxScintilla::wxScintilla (wxWindow *parent,
  142. wxWindowID id,
  143. const wxPoint& pos,
  144. const wxSize& size,
  145. long style,
  146. const wxString& name) {
  147. m_swx = NULL;
  148. Create (parent, id, pos, size, style, name);
  149. }
  150.  
  151.  
  152. bool wxScintilla::Create (wxWindow *parent,
  153. wxWindowID id,
  154. const wxPoint& pos,
  155. const wxSize& size,
  156. long style,
  157. const wxString& name) {
  158. #ifdef __WXMAC__
  159. style |= wxVSCROLL | wxHSCROLL;
  160. #endif
  161. if (!wxControl::Create (parent, id, pos, size,
  162. style | wxWANTS_CHARS | wxCLIP_CHILDREN,
  163. wxDefaultValidator, name)) {
  164. return false;
  165. }
  166.  
  167. #ifdef LINK_LEXERS
  168. Scintilla_LinkLexers();
  169. #endif
  170. m_swx = new ScintillaWX(this);
  171. m_stopWatch.Start();
  172. m_lastKeyDownConsumed = FALSE;
  173. m_vScrollBar = NULL;
  174. m_hScrollBar = NULL;
  175. #if wxUSE_UNICODE
  176. // Put Scintilla into unicode (UTF-8) mode
  177. SetCodePage(wxSCI_CP_UTF8);
  178. #endif
  179.  
  180. #if wxCHECK_VERSION(2, 5, 0)
  181. // Reduces flicker on GTK+/X11
  182. SetBackgroundStyle(wxBG_STYLE_CUSTOM);
  183. SetBestFittingSize(size);
  184. #endif
  185. return false;
  186. }
  187.  
  188. wxScintilla::~wxScintilla() {
  189. delete m_swx;
  190. }
  191.  
  192.  
  193. //----------------------------------------------------------------------
  194. // Send message to Scintilla
  195. long wxScintilla::SendMsg (int msg, long wp, long lp) {
  196. return m_swx->WndProc (msg, wp, lp);
  197. }
  198.  
  199. //----------------------------------------------------------------------
  200.  
  201. // Set the vertical scrollbar to use instead of the ont that's built-in.
  202. void wxScintilla::SetVScrollBar (wxScrollBar* bar) {
  203. m_vScrollBar = bar;
  204. if (bar != NULL) {
  205. // ensure that the built-in scrollbar is not visible
  206. SetScrollbar(wxVERTICAL, 0, 0, 0);
  207. }
  208. }
  209.  
  210. // Set the horizontal scrollbar to use instead of the ont that's built-in.
  211. void wxScintilla::SetHScrollBar (wxScrollBar* bar) {
  212. m_hScrollBar = bar;
  213. if (bar != NULL) {
  214. // ensure that the built-in scrollbar is not visible
  215. SetScrollbar(wxHORIZONTAL, 0, 0, 0);
  216. }
  217. }
  218.  
  219. //----------------------------------------------------------------------
  220. // BEGIN generated section. The following code is automatically generated
  221. // by gen_iface.py from the contents of Scintilla.iface. Do not edit
  222. // this file. Edit wxscintilla.cpp.in or gen_iface.py instead and regenerate.
  223.  
  224. // Add text to the document at current position.
  225. void wxScintilla::AddText (const wxString& text) {
  226. wxWX2MBbuf buf = (wxWX2MBbuf)wx2sci(text);
  227. SendMsg (SCI_ADDTEXT, strlen(buf), (long)(const char*)buf);
  228. }
  229.  
  230. // Add text to the document w/length parameter, this allows for binary data to be added.
  231. void wxScintilla::AddText (const int length, const wxString& text) {
  232. wxWX2MBbuf buf = (wxWX2MBbuf)wx2sci(text);
  233. SendMsg (SCI_ADDTEXT, length, (long)(const char*)buf);
  234. }
  235.  
  236. // Add array of cells to document.
  237. void wxScintilla::AddStyledText (const wxMemoryBuffer& data) {
  238. SendMsg (SCI_ADDSTYLEDTEXT, data.GetDataLen(), (long)data.GetData());
  239. }
  240.  
  241. // Insert string at a position.
  242. void wxScintilla::InsertText (int pos, const wxString& text) {
  243. SendMsg (SCI_INSERTTEXT, pos, (long)(const char*)wx2sci(text));
  244. }
  245.  
  246. // Delete all text in the document.
  247. void wxScintilla::ClearAll() {
  248. SendMsg (SCI_CLEARALL, 0, 0);
  249. }
  250.  
  251. // Set all style bytes to 0, remove all folding information.
  252. void wxScintilla::ClearDocumentStyle() {
  253. SendMsg (SCI_CLEARDOCUMENTSTYLE, 0, 0);
  254. }
  255.  
  256. // Returns the number of characters in the document.
  257. int wxScintilla::GetLength() {
  258. return SendMsg (SCI_GETLENGTH, 0, 0);
  259. }
  260.  
  261. // Returns the character byte at the position.
  262. int wxScintilla::GetCharAt (int pos) {
  263. return (unsigned char)SendMsg (SCI_GETCHARAT, pos, 0);
  264. }
  265.  
  266. // Returns the position of the caret.
  267. int wxScintilla::GetCurrentPos() {
  268. return SendMsg (SCI_GETCURRENTPOS, 0, 0);
  269. }
  270.  
  271. // Returns the position of the opposite end of the selection to the caret.
  272. int wxScintilla::GetAnchor() {
  273. return SendMsg (SCI_GETANCHOR, 0, 0);
  274. }
  275.  
  276. // Returns the style byte at the position.
  277. int wxScintilla::GetStyleAt (int pos) {
  278. return (unsigned char)SendMsg (SCI_GETSTYLEAT, pos, 0);
  279. }
  280.  
  281. // Redoes the next action on the undo history.
  282. void wxScintilla::Redo() {
  283. SendMsg (SCI_REDO, 0, 0);
  284. }
  285.  
  286. // Choose between collecting actions into the undo
  287. // history and discarding them.
  288. void wxScintilla::SetUndoCollection (bool collectUndo) {
  289. SendMsg (SCI_SETUNDOCOLLECTION, collectUndo, 0);
  290. }
  291.  
  292. // Select all the text in the document.
  293. void wxScintilla::SelectAll() {
  294. SendMsg (SCI_SELECTALL, 0, 0);
  295. }
  296.  
  297. // Remember the current position in the undo history as the position
  298. // at which the document was saved.
  299. void wxScintilla::SetSavePoint() {
  300. SendMsg (SCI_SETSAVEPOINT, 0, 0);
  301. }
  302.  
  303. // Retrieve a buffer of cells.
  304. wxMemoryBuffer wxScintilla::GetStyledText (int startPos, int endPos) {
  305. wxMemoryBuffer buf;
  306. if (endPos < startPos) {
  307. int temp = startPos;
  308. startPos = endPos;
  309. endPos = temp;
  310. }
  311. int len = endPos - startPos;
  312. if (!len) return buf;
  313. TextRange tr;
  314. tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
  315. tr.chrg.cpMin = startPos;
  316. tr.chrg.cpMax = endPos;
  317. len = SendMsg (SCI_GETSTYLEDTEXT, 0, (long)&tr);
  318. buf.UngetWriteBuf(len);
  319. return buf;
  320. }
  321.  
  322. // Are there any redoable actions in the undo history?
  323. bool wxScintilla::CanRedo() {
  324. return SendMsg (SCI_CANREDO, 0, 0) != 0;
  325. }
  326.  
  327. // Retrieve the line number at which a particular marker is located.
  328. int wxScintilla::MarkerLineFromHandle (int handle) {
  329. return SendMsg (SCI_MARKERLINEFROMHANDLE, handle, 0);
  330. }
  331.  
  332. // Delete a marker.
  333. void wxScintilla::MarkerDeleteHandle (int handle) {
  334. SendMsg (SCI_MARKERDELETEHANDLE, handle, 0);
  335. }
  336.  
  337. // Is undo history being collected?
  338. bool wxScintilla::GetUndoCollection() {
  339. return SendMsg (SCI_GETUNDOCOLLECTION, 0, 0) != 0;
  340. }
  341.  
  342. // Are white space characters currently visible?
  343. // Returns one of SCWS_* constants.
  344. int wxScintilla::GetViewWhiteSpace() {
  345. return SendMsg (SCI_GETVIEWWS, 0, 0);
  346. }
  347.  
  348. // Make white space characters invisible, always visible or visible outside indentation.
  349. void wxScintilla::SetViewWhiteSpace (int viewWS) {
  350. SendMsg (SCI_SETVIEWWS, viewWS, 0);
  351. }
  352.  
  353. // Find the position from a point within the window.
  354. int wxScintilla::PositionFromPoint (wxPoint pt) {
  355. return SendMsg (SCI_POSITIONFROMPOINT, pt.x, pt.y);
  356. }
  357.  
  358. // Find the position from a point within the window but return
  359. // INVALID_POSITION if not close to text.
  360. int wxScintilla::PositionFromPointClose (int x, int y) {
  361. return SendMsg (SCI_POSITIONFROMPOINTCLOSE, x, y);
  362. }
  363.  
  364. // Set caret to start of a line and ensure it is visible.
  365. void wxScintilla::GotoLine (int line) {
  366. SendMsg (SCI_GOTOLINE, line, 0);
  367. }
  368.  
  369. // Set caret to a position and ensure it is visible.
  370. void wxScintilla::GotoPos (int pos) {
  371. SendMsg (SCI_GOTOPOS, pos, 0);
  372. }
  373.  
  374. // Set the selection anchor to a position. The anchor is the opposite
  375. // end of the selection from the caret.
  376. void wxScintilla::SetAnchor (int posAnchor) {
  377. SendMsg (SCI_SETANCHOR, posAnchor, 0);
  378. }
  379.  
  380. // Retrieve the text of the line containing the caret.
  381. // Returns the index of the caret on the line.
  382. wxString wxScintilla::GetCurLine (int* linePos) {
  383. int len = LineLength(GetCurrentLine());
  384. if (!len) {
  385. if (linePos) *linePos = 0;
  386. return wxEmptyString;
  387. }
  388. wxMemoryBuffer mbuf(len+1);
  389. char* buf = (char*)mbuf.GetWriteBuf(len+1);
  390. int pos = SendMsg (SCI_GETCURLINE, len+1, (long)buf);
  391. mbuf.UngetWriteBuf(len);
  392. mbuf.AppendByte(0);
  393. if (linePos) *linePos = pos;
  394. return sci2wx(buf);
  395. }
  396.  
  397. // Retrieve the position of the last correctly styled character.
  398. int wxScintilla::GetEndStyled() {
  399. return SendMsg (SCI_GETENDSTYLED, 0, 0);
  400. }
  401.  
  402. // Convert all line endings in the document to one mode.
  403. void wxScintilla::ConvertEOLs (int eolMode) {
  404. SendMsg (SCI_CONVERTEOLS, eolMode, 0);
  405. }
  406.  
  407. // Retrieve the current end of line mode - one of CRLF, CR, or LF.
  408. int wxScintilla::GetEOLMode() {
  409. return SendMsg (SCI_GETEOLMODE, 0, 0);
  410. }
  411.  
  412. // Set the current end of line mode.
  413. void wxScintilla::SetEOLMode (int eolMode) {
  414. SendMsg (SCI_SETEOLMODE, eolMode, 0);
  415. }
  416.  
  417. // Set the current styling position to pos and the styling mask to mask.
  418. // The styling mask can be used to protect some bits in each styling byte from modification.
  419. void wxScintilla::StartStyling (int pos, int mask) {
  420. SendMsg (SCI_STARTSTYLING, pos, mask);
  421. }
  422.  
  423. // Change style from current styling position for length characters to a style
  424. // and move the current styling position to after this newly styled segment.
  425. void wxScintilla::SetStyling (int length, int style) {
  426. SendMsg (SCI_SETSTYLING, length, style);
  427. }
  428.  
  429. // Is drawing done first into a buffer or direct to the screen?
  430. bool wxScintilla::GetBufferedDraw() {
  431. return SendMsg (SCI_GETBUFFEREDDRAW, 0, 0) != 0;
  432. }
  433.  
  434. // If drawing is buffered then each line of text is drawn into a bitmap buffer
  435. // before drawing it to the screen to avoid flicker.
  436. void wxScintilla::SetBufferedDraw (bool buffered) {
  437. SendMsg (SCI_SETBUFFEREDDRAW, buffered, 0);
  438. }
  439.  
  440. // Change the visible size of a tab to be a multiple of the width of a space character.
  441. void wxScintilla::SetTabWidth (int tabWidth) {
  442. SendMsg (SCI_SETTABWIDTH, tabWidth, 0);
  443. }
  444.  
  445. // Retrieve the visible size of a tab.
  446. int wxScintilla::GetTabWidth() {
  447. return SendMsg (SCI_GETTABWIDTH, 0, 0);
  448. }
  449.  
  450. // Set the code page used to interpret the bytes of the document as characters.
  451. void wxScintilla::SetCodePage (int codePage) {
  452. #if wxUSE_UNICODE
  453. wxASSERT_MSG (codePage == wxSCI_CP_UTF8,
  454. _T("Only wxSCI_CP_UTF8 may be used when wxUSE_UNICODE is on."));
  455. #else
  456. wxASSERT_MSG (codePage != wxSCI_CP_UTF8,
  457. _T("wxSCI_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
  458. #endif
  459. SendMsg(SCI_SETCODEPAGE, codePage);
  460. }
  461.  
  462. // Set use palette (SCI_SETUSEPALETTE) not supported
  463.  
  464. // Set the symbol used for a particular marker number,
  465. // and optionally the fore and background colours.
  466. void wxScintilla::MarkerDefine (int markerNumber, int markerSymbol) {
  467. SendMsg (SCI_MARKERDEFINE, markerNumber, markerSymbol);
  468. }
  469.  
  470. // Set the foreground colour used for a particular marker number.
  471. void wxScintilla::MarkerSetForeground (int markerNumber, const wxColour& fore) {
  472. SendMsg (SCI_MARKERSETFORE, markerNumber, wxColourAsLong(fore));
  473. }
  474.  
  475. // Set the background colour used for a particular marker number.
  476. void wxScintilla::MarkerSetBackground (int markerNumber, const wxColour& back) {
  477. SendMsg (SCI_MARKERSETBACK, markerNumber, wxColourAsLong(back));
  478. }
  479.  
  480. // Add a marker to a line, returning an ID which can be used to find or delete the marker.
  481. int wxScintilla::MarkerAdd (int line, int markerNumber) {
  482. return SendMsg (SCI_MARKERADD, line, markerNumber);
  483. }
  484.  
  485. // Delete a marker from a line.
  486. void wxScintilla::MarkerDelete (int line, int markerNumber) {
  487. SendMsg (SCI_MARKERDELETE, line, markerNumber);
  488. }
  489.  
  490. // Delete all markers with a particular number from all lines.
  491. void wxScintilla::MarkerDeleteAll (int markerNumber) {
  492. SendMsg (SCI_MARKERDELETEALL, markerNumber, 0);
  493. }
  494.  
  495. // Get a bit mask of all the markers set on a line.
  496. int wxScintilla::MarkerGet (int line) {
  497. return SendMsg (SCI_MARKERGET, line, 0);
  498. }
  499.  
  500. // Find the next line after lineStart that includes a marker in mask.
  501. int wxScintilla::MarkerNext (int lineStart, int markerMask) {
  502. return SendMsg (SCI_MARKERNEXT, lineStart, markerMask);
  503. }
  504.  
  505. // Find the previous line before lineStart that includes a marker in mask.
  506. int wxScintilla::MarkerPrevious (int lineStart, int markerMask) {
  507. return SendMsg (SCI_MARKERPREVIOUS, lineStart, markerMask);
  508. }
  509.  
  510. // Define a marker from a bitmap
  511. void wxScintilla::MarkerDefineBitmap (int markerNumber, const wxBitmap& bmp) {
  512. // convert bmp to a xpm in a string
  513. wxMemoryOutputStream strm;
  514. wxImage img = bmp.ConvertToImage();
  515. #if wxCHECK_VERSION(2, 5, 0)
  516. if (img.HasAlpha()) img.ConvertAlphaToMask();
  517. #endif
  518. img.SaveFile(strm, wxBITMAP_TYPE_XPM);
  519. size_t len = strm.GetSize();
  520. char* buff = new char[len+1];
  521. strm.CopyTo(buff, len);
  522. buff[len] = 0;
  523. SendMsg (SCI_MARKERDEFINEPIXMAP, markerNumber, (long)buff);
  524. delete [] buff;
  525. }
  526.  
  527. // Add a set of markers to a line.
  528. void wxScintilla::MarkerAddSet (int line, int markerSet) {
  529. SendMsg (SCI_MARKERADDSET, line, markerSet);
  530. }
  531.  
  532. // Set the alpha used for a marker that is drawn in the text area, not the margin.
  533. void wxScintilla::MarkerSetAlpha (int markerNumber, int alpha) {
  534. SendMsg (SCI_MARKERSETALPHA, markerNumber, alpha);
  535. }
  536.  
  537. // Set a margin to be either numeric or symbolic.
  538. void wxScintilla::SetMarginType (int margin, int marginType) {
  539. SendMsg (SCI_SETMARGINTYPEN, margin, marginType);
  540. }
  541.  
  542. // Retrieve the type of a margin.
  543. int wxScintilla::GetMarginType (int margin) {
  544. return SendMsg (SCI_GETMARGINTYPEN, margin, 0);
  545. }
  546.  
  547. // Set the width of a margin to a width expressed in pixels.
  548. void wxScintilla::SetMarginWidth (int margin, int pixels) {
  549. SendMsg (SCI_SETMARGINWIDTHN, margin, pixels);
  550. }
  551.  
  552. // Retrieve the width of a margin in pixels.
  553. int wxScintilla::GetMarginWidth (int margin) {
  554. return SendMsg (SCI_GETMARGINWIDTHN, margin, 0);
  555. }
  556.  
  557. // Set a mask that determines which markers are displayed in a margin.
  558. void wxScintilla::SetMarginMask (int margin, int mask) {
  559. SendMsg (SCI_SETMARGINMASKN, margin, mask);
  560. }
  561.  
  562. // Retrieve the marker mask of a margin.
  563. int wxScintilla::GetMarginMask (int margin) {
  564. return SendMsg (SCI_GETMARGINMASKN, margin, 0);
  565. }
  566.  
  567. // Make a margin sensitive or insensitive to mouse clicks.
  568. void wxScintilla::SetMarginSensitive (int margin, bool sensitive) {
  569. SendMsg (SCI_SETMARGINSENSITIVEN, margin, sensitive);
  570. }
  571.  
  572. // Retrieve the mouse click sensitivity of a margin.
  573. bool wxScintilla::GetMarginSensitive (int margin) {
  574. return SendMsg (SCI_GETMARGINSENSITIVEN, margin, 0) != 0;
  575. }
  576.  
  577. // Clear all the styles and make equivalent to the global default style.
  578. void wxScintilla::StyleClearAll() {
  579. SendMsg (SCI_STYLECLEARALL, 0, 0);
  580. }
  581.  
  582. // Set the foreground colour of a style.
  583. void wxScintilla::StyleSetForeground (int style, const wxColour& fore) {
  584. SendMsg (SCI_STYLESETFORE, style, wxColourAsLong(fore));
  585. }
  586.  
  587. // Set the background colour of a style.
  588. void wxScintilla::StyleSetBackground (int style, const wxColour& back) {
  589. SendMsg (SCI_STYLESETBACK, style, wxColourAsLong(back));
  590. }
  591.  
  592. // Set a style to be bold or not.
  593. void wxScintilla::StyleSetBold (int style, bool bold) {
  594. SendMsg (SCI_STYLESETBOLD, style, bold);
  595. }
  596.  
  597. // Set a style to be italic or not.
  598. void wxScintilla::StyleSetItalic (int style, bool italic) {
  599. SendMsg (SCI_STYLESETITALIC, style, italic);
  600. }
  601.  
  602. // Set the size of characters of a style.
  603. void wxScintilla::StyleSetSize (int style, int sizePoints) {
  604. SendMsg (SCI_STYLESETSIZE, style, sizePoints);
  605. }
  606.  
  607. // Set the font of a style.
  608. void wxScintilla::StyleSetFaceName (int style, const wxString& fontName) {
  609. SendMsg (SCI_STYLESETFONT, style, (long)(const char*)wx2sci(fontName));
  610. }
  611.  
  612. // Set a style to have its end of line filled or not.
  613. void wxScintilla::StyleSetEOLFilled (int style, bool filled) {
  614. SendMsg (SCI_STYLESETEOLFILLED, style, filled);
  615. }
  616.  
  617. // Reset the default style to its state at startup
  618. void wxScintilla::StyleResetDefault() {
  619. SendMsg (SCI_STYLERESETDEFAULT, 0, 0);
  620. }
  621.  
  622. // Set a style to be underlined or not.
  623. void wxScintilla::StyleSetUnderline (int style, bool underline) {
  624. SendMsg (SCI_STYLESETUNDERLINE, style, underline);
  625. }
  626.  
  627. // Set a style to be mixed case, or to force upper or lower case.
  628. void wxScintilla::StyleSetCase (int style, int caseMode) {
  629. SendMsg (SCI_STYLESETCASE, style, caseMode);
  630. }
  631.  
  632. // Set a style to be a hotspot or not.
  633. void wxScintilla::StyleSetHotSpot (int style, bool hotspot) {
  634. SendMsg (SCI_STYLESETHOTSPOT, style, hotspot);
  635. }
  636.  
  637. // Get the alpha of the selection.
  638. int wxScintilla::GetSelAlpha () {
  639. return SendMsg (SCI_GETSELALPHA, 0, 0);
  640. }
  641.  
  642. // Set the alpha of the selection.
  643. void wxScintilla::SetSelAlpha (int alpha) {
  644. SendMsg (SCI_SETSELALPHA, alpha, 0);
  645. }
  646.  
  647. // Set the foreground colour of the selection and whether to use this setting.
  648. void wxScintilla::SetSelForeground (bool useSetting, const wxColour& fore) {
  649. SendMsg (SCI_SETSELFORE, useSetting, wxColourAsLong(fore));
  650. }
  651.  
  652. // Set the background colour of the selection and whether to use this setting.
  653. void wxScintilla::SetSelBackground (bool useSetting, const wxColour& back) {
  654. SendMsg (SCI_SETSELBACK, useSetting, wxColourAsLong(back));
  655. }
  656.  
  657. // Set the foreground colour of the caret.
  658. void wxScintilla::SetCaretForeground (const wxColour& fore) {
  659. SendMsg (SCI_SETCARETFORE, wxColourAsLong(fore), 0);
  660. }
  661.  
  662. // When key+modifier combination km is pressed perform msg.
  663. void wxScintilla::CmdKeyAssign (int key, int modifiers, int cmd) {
  664. SendMsg (SCI_ASSIGNCMDKEY, MAKELONG(key, modifiers), cmd);
  665. }
  666.  
  667. // When key+modifier combination km is pressed do nothing.
  668. void wxScintilla::CmdKeyClear (int key, int modifiers) {
  669. SendMsg (SCI_CLEARCMDKEY, MAKELONG(key, modifiers));
  670. }
  671.  
  672. // Drop all key mappings.
  673. void wxScintilla::CmdKeyClearAll() {
  674. SendMsg (SCI_CLEARALLCMDKEYS, 0, 0);
  675. }
  676.  
  677. // Set the styles for a segment of the document.
  678. void wxScintilla::SetStyleBytes (int length, char* styleBytes) {
  679. SendMsg (SCI_SETSTYLINGEX, length, (long)styleBytes);
  680. }
  681.  
  682. // Set a style to be visible or not.
  683. void wxScintilla::StyleSetVisible (int style, bool visible) {
  684. SendMsg (SCI_STYLESETVISIBLE, style, visible);
  685. }
  686.  
  687. // Get the time in milliseconds that the caret is on and off.
  688. int wxScintilla::GetCaretPeriod() {
  689. return SendMsg (SCI_GETCARETPERIOD, 0, 0);
  690. }
  691.  
  692. // Get the time in milliseconds that the caret is on and off. 0 = steady on.
  693. void wxScintilla::SetCaretPeriod (int milliseconds) {
  694. SendMsg (SCI_SETCARETPERIOD, milliseconds, 0);
  695. }
  696.  
  697. // Set the set of characters making up words for when moving or selecting by word.
  698. // First sets deaults like SetCharsDefault.
  699. void wxScintilla::SetWordChars (const wxString& characters) {
  700. SendMsg (SCI_SETWORDCHARS, 0, (long)(const char*)wx2sci(characters));
  701. }
  702.  
  703. // Start a sequence of actions that is undone and redone as a unit.
  704. // May be nested.
  705. void wxScintilla::BeginUndoAction() {
  706. SendMsg (SCI_BEGINUNDOACTION, 0, 0);
  707. }
  708.  
  709. // End a sequence of actions that is undone and redone as a unit.
  710. void wxScintilla::EndUndoAction() {
  711. SendMsg (SCI_ENDUNDOACTION, 0, 0);
  712. }
  713.  
  714. // Set an indicator to plain, squiggle or TT.
  715. void wxScintilla::IndicatorSetStyle (int indic, int style) {
  716. SendMsg (SCI_INDICSETSTYLE, indic, style);
  717. }
  718.  
  719. // Retrieve the style of an indicator.
  720. int wxScintilla::IndicatorGetStyle (int indic) {
  721. return SendMsg (SCI_INDICGETSTYLE, indic, 0);
  722. }
  723.  
  724. // Set the foreground colour of an indicator.
  725. void wxScintilla::IndicatorSetForeground (int indic, const wxColour& fore) {
  726. SendMsg (SCI_INDICSETFORE, indic, wxColourAsLong(fore));
  727. }
  728.  
  729. // Retrieve the foreground colour of an indicator.
  730. wxColour wxScintilla::IndicatorGetForeground (int indic) {
  731. long colour = SendMsg (SCI_INDICGETFORE, indic, 0);
  732. return wxColourFromLong(colour);
  733. }
  734.  
  735. // Set the foreground colour of all whitespace and whether to use this setting.
  736. void wxScintilla::SetWhitespaceForeground (bool useSetting, const wxColour& fore) {
  737. SendMsg (SCI_SETWHITESPACEFORE, useSetting, wxColourAsLong(fore));
  738. }
  739.  
  740. // Set the background colour of all whitespace and whether to use this setting.
  741. void wxScintilla::SetWhitespaceBackground (bool useSetting, const wxColour& back) {
  742. SendMsg (SCI_SETWHITESPACEBACK, useSetting, wxColourAsLong(back));
  743. }
  744.  
  745. // Divide each styling byte into lexical class bits (default: 5) and indicator
  746. // bits (default: 3). If a lexer requires more than 32 lexical states, then this
  747. // is used to expand the possible states.
  748. void wxScintilla::SetStyleBits (int bits) {
  749. SendMsg (SCI_SETSTYLEBITS, bits, 0);
  750. }
  751.  
  752. // Retrieve number of bits in style bytes used to hold the lexical state.
  753. int wxScintilla::GetStyleBits() {
  754. return SendMsg (SCI_GETSTYLEBITS, 0, 0);
  755. }
  756.  
  757. // Used to hold extra styling information for each line.
  758. void wxScintilla::SetLineState (int line, int state) {
  759. SendMsg (SCI_SETLINESTATE, line, state);
  760. }
  761.  
  762. // Retrieve the extra styling information for a line.
  763. int wxScintilla::GetLineState (int line) {
  764. return SendMsg (SCI_GETLINESTATE, line, 0);
  765. }
  766.  
  767. // Retrieve the last line number that has line state.
  768. int wxScintilla::GetMaxLineState() {
  769. return SendMsg (SCI_GETMAXLINESTATE, 0, 0);
  770. }
  771.  
  772. // Is the background of the line containing the caret in a different colour?
  773. bool wxScintilla::GetCaretLineVisible() {
  774. return SendMsg (SCI_GETCARETLINEVISIBLE, 0, 0) != 0;
  775. }
  776.  
  777. // Display the background of the line containing the caret in a different colour.
  778. void wxScintilla::SetCaretLineVisible (bool show) {
  779. SendMsg (SCI_SETCARETLINEVISIBLE, show, 0);
  780. }
  781.  
  782. // Get the colour of the background of the line containing the caret.
  783. wxColour wxScintilla::GetCaretLineBackground() {
  784. long colour = SendMsg (SCI_GETCARETLINEBACK, 0, 0);
  785. return wxColourFromLong (colour);
  786. }
  787.  
  788. // Set the colour of the background of the line containing the caret.
  789. void wxScintilla::SetCaretLineBackground (const wxColour& back) {
  790. SendMsg (SCI_SETCARETLINEBACK, wxColourAsLong(back), 0);
  791. }
  792.  
  793. // Set a style to be changeable or not (read only).
  794. // Experimental feature, currently buggy.
  795. void wxScintilla::StyleSetChangeable (int style, bool changeable) {
  796. SendMsg (SCI_STYLESETCHANGEABLE, style, changeable);
  797. }
  798.  
  799. // Display a auto-completion list.
  800. // The lenEntered parameter indicates how many characters before
  801. // the caret should be used to provide context.
  802. void wxScintilla::AutoCompShow (int lenEntered, const wxString& itemList) {
  803. SendMsg (SCI_AUTOCSHOW, lenEntered, (long)(const char*)wx2sci(itemList));
  804. }
  805.  
  806. // Remove the auto-completion list from the screen.
  807. void wxScintilla::AutoCompCancel() {
  808. SendMsg (SCI_AUTOCCANCEL, 0, 0);
  809. }
  810.  
  811. // Is there an auto-completion list visible?
  812. bool wxScintilla::AutoCompActive() {
  813. return SendMsg (SCI_AUTOCACTIVE, 0, 0) != 0;
  814. }
  815.  
  816. // Retrieve the position of the caret when the auto-completion list was displayed.
  817. int wxScintilla::AutoCompPosStart() {
  818. return SendMsg (SCI_AUTOCPOSSTART, 0, 0);
  819. }
  820.  
  821. // User has selected an item so remove the list and insert the selection.
  822. void wxScintilla::AutoCompComplete() {
  823. SendMsg (SCI_AUTOCCOMPLETE, 0, 0);
  824. }
  825.  
  826. // Define a set of character that when typed cancel the auto-completion list.
  827. void wxScintilla::AutoCompStops (const wxString& characterSet) {
  828. SendMsg (SCI_AUTOCSTOPS, 0, (long)(const char*)wx2sci(characterSet));
  829. }
  830.  
  831. // Change the separator character in the string setting up an auto-completion list.
  832. // Default is space but can be changed if items contain space.
  833. void wxScintilla::AutoCompSetSeparator (int separatorCharacter) {
  834. SendMsg (SCI_AUTOCSETSEPARATOR, separatorCharacter, 0);
  835. }
  836.  
  837. // Retrieve the auto-completion list separator character.
  838. int wxScintilla::AutoCompGetSeparator() {
  839. return SendMsg (SCI_AUTOCGETSEPARATOR, 0, 0);
  840. }
  841.  
  842. // Select the item in the auto-completion list that starts with a string.
  843. void wxScintilla::AutoCompSelect (const wxString& text) {
  844. SendMsg (SCI_AUTOCSELECT, 0, (long)(const char*)wx2sci(text));
  845. }
  846.  
  847. // Should the auto-completion list be cancelled if the user backspaces to a
  848. // position before where the box was created.
  849. void wxScintilla::AutoCompSetCancelAtStart (bool cancel) {
  850. SendMsg (SCI_AUTOCSETCANCELATSTART, cancel, 0);
  851. }
  852.  
  853. // Retrieve whether auto-completion cancelled by backspacing before start.
  854. bool wxScintilla::AutoCompGetCancelAtStart() {
  855. return SendMsg (SCI_AUTOCGETCANCELATSTART, 0, 0) != 0;
  856. }
  857.  
  858. // Define a set of characters that when typed will cause the autocompletion to
  859. // choose the selected item.
  860. void wxScintilla::AutoCompSetFillUps (const wxString& characterSet) {
  861. SendMsg (SCI_AUTOCSETFILLUPS, 0, (long)(const char*)wx2sci(characterSet));
  862. }
  863.  
  864. // Should a single item auto-completion list automatically choose the item.
  865. void wxScintilla::AutoCompSetChooseSingle (bool chooseSingle) {
  866. SendMsg (SCI_AUTOCSETCHOOSESINGLE, chooseSingle, 0);
  867. }
  868.  
  869. // Retrieve whether a single item auto-completion list automatically choose the item.
  870. bool wxScintilla::AutoCompGetChooseSingle() {
  871. return SendMsg (SCI_AUTOCGETCHOOSESINGLE, 0, 0) != 0;
  872. }
  873.  
  874. // Set whether case is significant when performing auto-completion searches.
  875. void wxScintilla::AutoCompSetIgnoreCase (bool ignoreCase) {
  876. SendMsg (SCI_AUTOCSETIGNORECASE, ignoreCase, 0);
  877. }
  878.  
  879. // Retrieve state of ignore case flag.
  880. bool wxScintilla::AutoCompGetIgnoreCase() {
  881. return SendMsg (SCI_AUTOCGETIGNORECASE, 0, 0) != 0;
  882. }
  883.  
  884. // Display a list of strings and send notification when user chooses one.
  885. void wxScintilla::UserListShow (int listType, const wxString& itemList) {
  886. SendMsg (SCI_USERLISTSHOW, listType, (long)(const char*)wx2sci(itemList));
  887. }
  888.  
  889. // Set whether or not autocompletion is hidden automatically when nothing matches.
  890. void wxScintilla::AutoCompSetAutoHide (bool autoHide) {
  891. SendMsg (SCI_AUTOCSETAUTOHIDE, autoHide, 0);
  892. }
  893.  
  894. // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
  895. bool wxScintilla::AutoCompGetAutoHide() {
  896. return SendMsg (SCI_AUTOCGETAUTOHIDE, 0, 0) != 0;
  897. }
  898.  
  899. // Set whether or not autocompletion deletes any word characters
  900. // after the inserted text upon completion.
  901. void wxScintilla::AutoCompSetDropRestOfWord (bool dropRestOfWord) {
  902. SendMsg (SCI_AUTOCSETDROPRESTOFWORD, dropRestOfWord, 0);
  903. }
  904.  
  905. // Retrieve whether or not autocompletion deletes any word characters
  906. // after the inserted text upon completion.
  907. bool wxScintilla::AutoCompGetDropRestOfWord() {
  908. return SendMsg (SCI_AUTOCGETDROPRESTOFWORD, 0, 0) != 0;
  909. }
  910.  
  911. // Register an image for use in autocompletion lists.
  912. void wxScintilla::RegisterImage (int type, const wxBitmap& bmp) {
  913. // convert bmp to a xpm in a string
  914. wxMemoryOutputStream strm;
  915. wxImage img = bmp.ConvertToImage();
  916. #if wxCHECK_VERSION(2, 5, 0)
  917. if (img.HasAlpha()) img.ConvertAlphaToMask();
  918. #endif
  919. img.SaveFile(strm, wxBITMAP_TYPE_XPM);
  920. size_t len = strm.GetSize();
  921. char* buff = new char[len+1];
  922. strm.CopyTo(buff, len);
  923. buff[len] = 0;
  924. SendMsg(SCI_REGISTERIMAGE, type, (long)buff);
  925. delete [] buff;
  926. }
  927.  
  928. // Clear all the registered images.
  929. void wxScintilla::ClearRegisteredImages() {
  930. SendMsg (SCI_CLEARREGISTEREDIMAGES, 0, 0);
  931. }
  932.  
  933. // Retrieve the auto-completion list type-separator character.
  934. int wxScintilla::AutoCompGetTypeSeparator() {
  935. return SendMsg (SCI_AUTOCGETTYPESEPARATOR, 0, 0);
  936. }
  937.  
  938. // Change the type-separator character in the string setting up an auto-completion list.
  939. // Default is '?' but can be changed if items contain '?'.
  940. void wxScintilla::AutoCompSetTypeSeparator (int separatorCharacter) {
  941. SendMsg (SCI_AUTOCSETTYPESEPARATOR, separatorCharacter, 0);
  942. }
  943.  
  944. // Set the maximum width, in characters, of auto-completion and user lists.
  945. // Set to 0 to autosize to fit longest item, which is the default.
  946. void wxScintilla::AutoCompSetMaxWidth (int characterCount) {
  947. SendMsg (SCI_AUTOCSETMAXWIDTH, characterCount, 0);
  948. }
  949.  
  950. // Get the maximum width, in characters, of auto-completion and user lists.
  951. int wxScintilla::AutoCompGetMaxWidth() {
  952. return SendMsg (SCI_AUTOCGETMAXWIDTH, 0, 0);
  953. }
  954.  
  955. // Set the maximum height, in rows, of auto-completion and user lists.
  956. // The default is 5 rows.
  957. void wxScintilla::AutoCompSetMaxHeight (int rowCount) {
  958. SendMsg (SCI_AUTOCSETMAXHEIGHT, rowCount, 0);
  959. }
  960.  
  961. // Set the maximum height, in rows, of auto-completion and user lists.
  962. int wxScintilla::AutoCompGetMaxHeight() {
  963. return SendMsg (SCI_AUTOCGETMAXHEIGHT, 0, 0);
  964. }
  965.  
  966. // Set the number of spaces used for one level of indentation.
  967. void wxScintilla::SetIndent (int indentSize) {
  968. SendMsg (SCI_SETINDENT, indentSize, 0);
  969. }
  970.  
  971. // Retrieve indentation size.
  972. int wxScintilla::GetIndent() {
  973. return SendMsg (SCI_GETINDENT, 0, 0);
  974. }
  975.  
  976. // Indentation will only use space characters if useTabs is false, otherwise
  977. // it will use a combination of tabs and spaces.
  978. void wxScintilla::SetUseTabs (bool useTabs) {
  979. SendMsg (SCI_SETUSETABS, useTabs, 0);
  980. }
  981.  
  982. // Retrieve whether tabs will be used in indentation.
  983. bool wxScintilla::GetUseTabs() {
  984. return SendMsg (SCI_GETUSETABS, 0, 0) != 0;
  985. }
  986.  
  987. // Change the indentation of a line to a number of columns.
  988. void wxScintilla::SetLineIndentation (int line, int indentSize) {
  989. SendMsg (SCI_SETLINEINDENTATION, line, indentSize);
  990. }
  991.  
  992. // Retrieve the number of columns that a line is indented.
  993. int wxScintilla::GetLineIndentation (int line) {
  994. return SendMsg (SCI_GETLINEINDENTATION, line, 0);
  995. }
  996.  
  997. // Retrieve the position before the first non indentation character on a line.
  998. int wxScintilla::GetLineIndentPosition (int line) {
  999. return SendMsg (SCI_GETLINEINDENTPOSITION, line, 0);
  1000. }
  1001.  
  1002. // Retrieve the column number of a position, taking tab width into account.
  1003. int wxScintilla::GetColumn (int pos) {
  1004. return SendMsg (SCI_GETCOLUMN, pos, 0);
  1005. }
  1006.  
  1007. // Show or hide the horizontal scroll bar.
  1008. void wxScintilla::SetUseHorizontalScrollBar (bool show) {
  1009. SendMsg (SCI_SETHSCROLLBAR, show, 0);
  1010. }
  1011.  
  1012. // Is the horizontal scroll bar visible?
  1013. bool wxScintilla::GetUseHorizontalScrollBar() {
  1014. return SendMsg (SCI_GETHSCROLLBAR, 0, 0) != 0;
  1015. }
  1016.  
  1017. // Show or hide indentation guides.
  1018. void wxScintilla::SetIndentationGuides (bool show) {
  1019. SendMsg (SCI_SETINDENTATIONGUIDES, show, 0);
  1020. }
  1021.  
  1022. // Are the indentation guides visible?
  1023. bool wxScintilla::GetIndentationGuides() {
  1024. return SendMsg (SCI_GETINDENTATIONGUIDES, 0, 0) != 0;
  1025. }
  1026.  
  1027. // Set the highlighted indentation guide column.
  1028. // 0 = no highlighted guide.
  1029. void wxScintilla::SetHighlightGuide (int column) {
  1030. SendMsg (SCI_SETHIGHLIGHTGUIDE, column, 0);
  1031. }
  1032.  
  1033. // Get the highlighted indentation guide column.
  1034. int wxScintilla::GetHighlightGuide() {
  1035. return SendMsg (SCI_GETHIGHLIGHTGUIDE, 0, 0);
  1036. }
  1037.  
  1038. // Get the position after the last visible characters on a line.
  1039. int wxScintilla::GetLineEndPosition (int line) {
  1040. return SendMsg (SCI_GETLINEENDPOSITION, line, 0);
  1041. }
  1042.  
  1043. // Get the code page used to interpret the bytes of the document as characters.
  1044. int wxScintilla::GetCodePage() {
  1045. return SendMsg (SCI_GETCODEPAGE, 0, 0);
  1046. }
  1047.  
  1048. // Get the foreground colour of the caret.
  1049. wxColour wxScintilla::GetCaretForeground() {
  1050. long colour = SendMsg (SCI_GETCARETFORE, 0, 0);
  1051. return wxColourFromLong(colour);
  1052. }
  1053.  
  1054. // Get use palette (SCI_GETUSEPALETTE) not supported
  1055.  
  1056. // In read-only mode?
  1057. bool wxScintilla::GetReadOnly() {
  1058. return SendMsg (SCI_GETREADONLY, 0, 0) != 0;
  1059. }
  1060.  
  1061. // Sets the position of the caret.
  1062. void wxScintilla::SetCurrentPos (int pos) {
  1063. SendMsg (SCI_SETCURRENTPOS, pos, 0);
  1064. }
  1065.  
  1066. // Sets the position that starts the selection - this becomes the anchor.
  1067. void wxScintilla::SetSelectionStart (int pos) {
  1068. SendMsg (SCI_SETSELECTIONSTART, pos, 0);
  1069. }
  1070.  
  1071. // Returns the position at the start of the selection.
  1072. int wxScintilla::GetSelectionStart() {
  1073. return SendMsg (SCI_GETSELECTIONSTART, 0, 0);
  1074. }
  1075.  
  1076. // Sets the position that ends the selection - this becomes the currentPosition.
  1077. void wxScintilla::SetSelectionEnd (int pos) {
  1078. SendMsg (SCI_SETSELECTIONEND, pos, 0);
  1079. }
  1080.  
  1081. // Returns the position at the end of the selection.
  1082. int wxScintilla::GetSelectionEnd() {
  1083. return SendMsg (SCI_GETSELECTIONEND, 0, 0);
  1084. }
  1085.  
  1086. // Sets the print magnification added to the point size of each style for printing.
  1087. void wxScintilla::SetPrintMagnification (int magnification) {
  1088. SendMsg (SCI_SETPRINTMAGNIFICATION, magnification, 0);
  1089. }
  1090.  
  1091. // Returns the print magnification.
  1092. int wxScintilla::GetPrintMagnification() {
  1093. return SendMsg (SCI_GETPRINTMAGNIFICATION, 0, 0);
  1094. }
  1095.  
  1096. // Modify colours when printing for clearer printed text.
  1097. void wxScintilla::SetPrintColourMode (int mode) {
  1098. SendMsg (SCI_SETPRINTCOLOURMODE, mode, 0);
  1099. }
  1100.  
  1101. // Returns the print colour mode.
  1102. int wxScintilla::GetPrintColourMode() {
  1103. return SendMsg (SCI_GETPRINTCOLOURMODE, 0, 0);
  1104. }
  1105.  
  1106. // Find some text in the document.
  1107. int wxScintilla::FindText (int minPos, int maxPos, const wxString& text, int flags, int* lengthFound) {
  1108. TextToFind ft;
  1109. ft.chrg.cpMin = minPos;
  1110. ft.chrg.cpMax = maxPos;
  1111. wxWX2MBbuf buf = (wxWX2MBbuf)wx2sci(text);
  1112. ft.lpstrText = (char*)(const char*)buf;
  1113. int ret = SendMsg (SCI_FINDTEXT, flags, (long)&ft);
  1114. if (lengthFound) *lengthFound = ft.chrgText.cpMax - ft.chrgText.cpMin;
  1115. return ret;
  1116. }
  1117.  
  1118. // On Windows, will draw the document into a display context such as a printer.
  1119. int wxScintilla::FormatRange (bool doDraw, int startPos, int endPos,
  1120. wxDC* draw, wxDC* target, wxRect renderRect, wxRect pageRect) {
  1121. RangeToFormat fr;
  1122. if (endPos < startPos) {
  1123. int temp = startPos;
  1124. startPos = endPos;
  1125. endPos = temp;
  1126. }
  1127. fr.hdc = draw;
  1128. fr.hdcTarget = target;
  1129. fr.rc.top = renderRect.GetTop();
  1130. fr.rc.left = renderRect.GetLeft();
  1131. fr.rc.right = renderRect.GetRight();
  1132. fr.rc.bottom = renderRect.GetBottom();
  1133. fr.rcPage.top = pageRect.GetTop();
  1134. fr.rcPage.left = pageRect.GetLeft();
  1135. fr.rcPage.right = pageRect.GetRight();
  1136. fr.rcPage.bottom = pageRect.GetBottom();
  1137. fr.chrg.cpMin = startPos;
  1138. fr.chrg.cpMax = endPos;
  1139. return SendMsg (SCI_FORMATRANGE, doDraw, (long)&fr);
  1140. }
  1141.  
  1142. // Retrieve the display line at the top of the display.
  1143. int wxScintilla::GetFirstVisibleLine() {
  1144. return SendMsg (SCI_GETFIRSTVISIBLELINE, 0, 0);
  1145. }
  1146.  
  1147. // Retrieve the contents of a line.
  1148. wxString wxScintilla::GetLine (int line) {
  1149. int len = LineLength(line);
  1150. if (!len) return wxEmptyString;
  1151. wxMemoryBuffer mbuf(len+1);
  1152. char* buf = (char*)mbuf.GetWriteBuf(len+1);
  1153. SendMsg (SCI_GETLINE, line, (long)buf);
  1154. mbuf.UngetWriteBuf(len);
  1155. mbuf.AppendByte(0);
  1156. return sci2wx(buf);
  1157. }
  1158.  
  1159. // Returns the number of lines in the document. There is always at least one.
  1160. int wxScintilla::GetLineCount() {
  1161. return SendMsg (SCI_GETLINECOUNT, 0, 0);
  1162. }
  1163.  
  1164. // Sets the size in pixels of the left margin.
  1165. void wxScintilla::SetMarginLeft (int pixels) {
  1166. SendMsg (SCI_SETMARGINLEFT, 0, pixels);
  1167. }
  1168.  
  1169. // Returns the size in pixels of the left margin.
  1170. int wxScintilla::GetMarginLeft() {
  1171. return SendMsg (SCI_GETMARGINLEFT, 0, 0);
  1172. }
  1173.  
  1174. // Sets the size in pixels of the right margin.
  1175. void wxScintilla::SetMarginRight (int pixels) {
  1176. SendMsg (SCI_SETMARGINRIGHT, 0, pixels);
  1177. }
  1178.  
  1179. // Returns the size in pixels of the right margin.
  1180. int wxScintilla::GetMarginRight() {
  1181. return SendMsg (SCI_GETMARGINRIGHT, 0, 0);
  1182. }
  1183.  
  1184. // Is the document different from when it was last saved?
  1185. bool wxScintilla::GetModify() {
  1186. return SendMsg (SCI_GETMODIFY, 0, 0) != 0;
  1187. }
  1188.  
  1189. // Select a range of text.
  1190. void wxScintilla::SetSelection (int startPos, int endPos) {
  1191. SendMsg (SCI_SETSEL, startPos, endPos);
  1192. }
  1193.  
  1194. // Retrieve the selected text.
  1195. wxString wxScintilla::GetSelectedText() {
  1196. int start;
  1197. int end;
  1198. GetSelection(&start, &end);
  1199. int len = end - start;
  1200. if (!len) return wxEmptyString;
  1201. wxMemoryBuffer mbuf(len+2);
  1202. char* buf = (char*)mbuf.GetWriteBuf(len+1);
  1203. SendMsg (SCI_GETSELTEXT, 0, (long)buf);
  1204. mbuf.UngetWriteBuf(len);
  1205. mbuf.AppendByte(0);
  1206. return sci2wx(buf);
  1207. }
  1208.  
  1209. // Retrieve a range of text.
  1210. wxString wxScintilla::GetTextRange (int startPos, int endPos) {
  1211. if (endPos < startPos) {
  1212. int temp = startPos;
  1213. startPos = endPos;
  1214. endPos = temp;
  1215. }
  1216. int len = endPos - startPos;
  1217. if (!len) return wxEmptyString;
  1218. wxMemoryBuffer mbuf(len+1);
  1219. char* buf = (char*)mbuf.GetWriteBuf(len);
  1220. TextRange tr;
  1221. tr.lpstrText = buf;
  1222. tr.chrg.cpMin = startPos;
  1223. tr.chrg.cpMax = endPos;
  1224. SendMsg (SCI_GETTEXTRANGE, 0, (long)&tr);
  1225. mbuf.UngetWriteBuf(len);
  1226. mbuf.AppendByte(0);
  1227. return sci2wx(buf);
  1228. }
  1229.  
  1230. // Draw the selection in normal style or with selection highlighted.
  1231. void wxScintilla::HideSelection (bool hide) {
  1232. SendMsg (SCI_HIDESELECTION, hide, 0);
  1233. }
  1234.  
  1235. // Retrieve the point in the window where a position is displayed.
  1236. wxPoint wxScintilla::PointFromPosition (int pos) {
  1237. int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
  1238. int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
  1239. return wxPoint (x, y);
  1240. }
  1241.  
  1242. // Retrieve the line containing a position.
  1243. int wxScintilla::LineFromPosition (int pos) {
  1244. return SendMsg (SCI_LINEFROMPOSITION, pos, 0);
  1245. }
  1246.  
  1247. // Retrieve the position at the start of a line.
  1248. int wxScintilla::PositionFromLine (int line) {
  1249. return SendMsg (SCI_POSITIONFROMLINE, line, 0);
  1250. }
  1251.  
  1252. // Scroll horizontally and vertically.
  1253. void wxScintilla::LineScroll (int columns, int lines) {
  1254. SendMsg (SCI_LINESCROLL, columns, lines);
  1255. }
  1256.  
  1257. // Ensure the caret is visible.
  1258. void wxScintilla::EnsureCaretVisible() {
  1259. SendMsg (SCI_SCROLLCARET, 0, 0);
  1260. }
  1261.  
  1262. // Replace the selected text with the argument text.
  1263. void wxScintilla::ReplaceSelection (const wxString& text) {
  1264. SendMsg (SCI_REPLACESEL, 0, (long)(const char*)wx2sci(text));
  1265. }
  1266.  
  1267. // Set to read only or read write.
  1268. void wxScintilla::SetReadOnly (bool readOnly) {
  1269. SendMsg (SCI_SETREADONLY, readOnly, 0);
  1270. }
  1271.  
  1272. // Will a paste succeed?
  1273. bool wxScintilla::CanPaste() {
  1274. return SendMsg (SCI_CANPASTE, 0, 0) != 0;
  1275. }
  1276.  
  1277. // Are there any undoable actions in the undo history?
  1278. bool wxScintilla::CanUndo() {
  1279. return SendMsg (SCI_CANUNDO, 0, 0) != 0;
  1280. }
  1281.  
  1282. // Delete the undo history.
  1283. void wxScintilla::EmptyUndoBuffer() {
  1284. SendMsg (SCI_EMPTYUNDOBUFFER, 0, 0);
  1285. }
  1286.  
  1287. // Undo one action in the undo history.
  1288. void wxScintilla::Undo() {
  1289. SendMsg (SCI_UNDO, 0, 0);
  1290. }
  1291.  
  1292. // Cut the selection to the clipboard.
  1293. void wxScintilla::Cut() {
  1294. SendMsg (SCI_CUT, 0, 0);
  1295. }
  1296.  
  1297. // Copy the selection to the clipboard.
  1298. void wxScintilla::Copy() {
  1299. SendMsg (SCI_COPY, 0, 0);
  1300. }
  1301.  
  1302. // Paste the contents of the clipboard into the document replacing the selection.
  1303. void wxScintilla::Paste() {
  1304. SendMsg (SCI_PASTE, 0, 0);
  1305. }
  1306.  
  1307. // Clear the selection.
  1308. void wxScintilla::Clear() {
  1309. SendMsg (SCI_CLEAR, 0, 0);
  1310. }
  1311.  
  1312. // Replace the contents of the document with the argument text.
  1313. void wxScintilla::SetText (const wxString& text) {
  1314. SendMsg(SCI_SETTEXT, 0, (long)(const char*)wx2sci(text));
  1315. }
  1316.  
  1317. // Retrieve all the text in the document.
  1318. wxString wxScintilla::GetText() {
  1319. int len = GetTextLength();
  1320. wxMemoryBuffer mbuf(len+1); // leave room for the null...
  1321. char* buf = (char*)mbuf.GetWriteBuf(len+1);
  1322. SendMsg (SCI_GETTEXT, len+1, (long)buf);
  1323. mbuf.UngetWriteBuf(len);
  1324. mbuf.AppendByte(0);
  1325. return sci2wx(buf);
  1326. }
  1327.  
  1328. // Retrieve the number of characters in the document.
  1329. int wxScintilla::GetTextLength() {
  1330. return SendMsg (SCI_GETTEXTLENGTH, 0, 0);
  1331. }
  1332.  
  1333. // Set to overtype (true) or insert mode.
  1334. void wxScintilla::SetOvertype (bool overtype) {
  1335. SendMsg (SCI_SETOVERTYPE, overtype, 0);
  1336. }
  1337.  
  1338. // Returns true if overtype mode is active otherwise false is returned.
  1339. bool wxScintilla::GetOvertype() {
  1340. return SendMsg (SCI_GETOVERTYPE, 0, 0) != 0;
  1341. }
  1342.  
  1343. // Set the width of the insert mode caret.
  1344. void wxScintilla::SetCaretWidth (int pixels) {
  1345. SendMsg (SCI_SETCARETWIDTH, pixels, 0);
  1346. }
  1347.  
  1348. // Returns the width of the insert mode caret.
  1349. int wxScintilla::GetCaretWidth() {
  1350. return SendMsg (SCI_GETCARETWIDTH, 0, 0);
  1351. }
  1352.  
  1353. // Sets the position that starts the target which is used for updating the
  1354. // document without affecting the scroll position.
  1355. void wxScintilla::SetTargetStart (int pos) {
  1356. SendMsg (SCI_SETTARGETSTART, pos, 0);
  1357. }
  1358.  
  1359. // Get the position that starts the target.
  1360. int wxScintilla::GetTargetStart() {
  1361. return SendMsg (SCI_GETTARGETSTART, 0, 0);
  1362. }
  1363.  
  1364. // Sets the position that ends the target which is used for updating the
  1365. // document without affecting the scroll position.
  1366. void wxScintilla::SetTargetEnd (int pos) {
  1367. SendMsg (SCI_SETTARGETEND, pos, 0);
  1368. }
  1369.  
  1370. // Get the position that ends the target.
  1371. int wxScintilla::GetTargetEnd() {
  1372. return SendMsg (SCI_GETTARGETEND, 0, 0);
  1373. }
  1374.  
  1375. // Replace the target text with the argument text.
  1376. // Text is counted so it can contain NULs.
  1377. // Returns the length of the replacement text.
  1378. int wxScintilla::ReplaceTarget (const wxString& text) {
  1379. wxWX2MBbuf buf = (wxWX2MBbuf)wx2sci(text);
  1380. return SendMsg (SCI_REPLACETARGET, strlen(buf), (long)(const char*)buf);
  1381. }
  1382.  
  1383. // Replace the target text with the argument text after \d processing.
  1384. // Text is counted so it can contain NULs.
  1385. // Looks for \d where d is between 1 and 9 and replaces these with the strings
  1386. // matched in the last search operation which were surrounded by \( and \).
  1387. // Returns the length of the replacement text including any change
  1388. // caused by processing the \d patterns.
  1389. int wxScintilla::ReplaceTargetRE (const wxString& text) {
  1390. wxWX2MBbuf buf = (wxWX2MBbuf)wx2sci(text);
  1391. return SendMsg (SCI_REPLACETARGETRE, strlen(buf), (long)(const char*)buf);
  1392. }
  1393.  
  1394. // Search for a counted string in the target and set the target to the found
  1395. // range. Text is counted so it can contain NULs.
  1396. // Returns length of range or -1 for failure in which case target is not moved.
  1397. int wxScintilla::SearchInTarget (const wxString& text) {
  1398. wxWX2MBbuf buf = (wxWX2MBbuf)wx2sci(text);
  1399. return SendMsg (SCI_SEARCHINTARGET, strlen(buf), (long)(const char*)buf);
  1400. }
  1401.  
  1402. // Set the search flags used by SearchInTarget.
  1403. void wxScintilla::SetSearchFlags (int flags) {
  1404. SendMsg (SCI_SETSEARCHFLAGS, flags, 0);
  1405. }
  1406.  
  1407. // Get the search flags used by SearchInTarget.
  1408. int wxScintilla::GetSearchFlags() {
  1409. return SendMsg (SCI_GETSEARCHFLAGS, 0, 0);
  1410. }
  1411.  
  1412. // Show a call tip containing a definition near position pos.
  1413. void wxScintilla::CallTipShow (int pos, const wxString& definition) {
  1414. SendMsg (SCI_CALLTIPSHOW, pos, (long)(const char*)wx2sci(definition));
  1415. }
  1416.  
  1417. // Remove the call tip from the screen.
  1418. void wxScintilla::CallTipCancel() {
  1419. SendMsg (SCI_CALLTIPCANCEL, 0, 0);
  1420. }
  1421.  
  1422. // Is there an active call tip?
  1423. bool wxScintilla::CallTipActive() {
  1424. return SendMsg (SCI_CALLTIPACTIVE, 0, 0) != 0;
  1425. }
  1426.  
  1427. // Retrieve the position where the caret was before displaying the call tip.
  1428. int wxScintilla::CallTipPosAtStart() {
  1429. return SendMsg (SCI_CALLTIPPOSSTART, 0, 0);
  1430. }
  1431.  
  1432. // Highlight a segment of the definition.
  1433. void wxScintilla::CallTipSetHighlight (int startPos, int endPos) {
  1434. SendMsg (SCI_CALLTIPSETHLT, startPos, endPos);
  1435. }
  1436.  
  1437. // Set the background colour for the call tip.
  1438. void wxScintilla::CallTipSetBackground (const wxColour& back) {
  1439. SendMsg (SCI_CALLTIPSETBACK, wxColourAsLong(back), 0);
  1440. }
  1441.  
  1442. // Set the foreground colour for the call tip.
  1443. void wxScintilla::CallTipSetForeground (const wxColour& fore) {
  1444. SendMsg (SCI_CALLTIPSETFORE, wxColourAsLong(fore), 0);
  1445. }
  1446.  
  1447. // Set the foreground colour for the highlighted part of the call tip.
  1448. void wxScintilla::CallTipSetForegroundHighlight (const wxColour& fore) {
  1449. SendMsg (SCI_CALLTIPSETFOREHLT, wxColourAsLong(fore), 0);
  1450. }
  1451.  
  1452. // Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
  1453. void wxScintilla::CallTipUseStyle (int tabSize) {
  1454. SendMsg (SCI_CALLTIPUSESTYLE, tabSize, 0);
  1455. }
  1456.  
  1457. // Find the display line of a document line taking hidden lines into account.
  1458. int wxScintilla::VisibleFromDocLine (int line) {
  1459. return SendMsg (SCI_VISIBLEFROMDOCLINE, line, 0);
  1460. }
  1461.  
  1462. // Find the document line of a display line taking hidden lines into account.
  1463. int wxScintilla::DocLineFromVisible (int lineDisplay) {
  1464. return SendMsg (SCI_DOCLINEFROMVISIBLE, lineDisplay, 0);
  1465. }
  1466.  
  1467. // The number of display lines needed to wrap a document line
  1468. int wxScintilla::WrapCount (int line) {
  1469. return SendMsg (SCI_WRAPCOUNT, line, 0);
  1470. }
  1471.  
  1472. // Set the fold level of a line.
  1473. // This encodes an integer level along with flags indicating whether the
  1474. // line is a header and whether it is effectively white space.
  1475. void wxScintilla::SetFoldLevel (int line, int level) {
  1476. SendMsg (SCI_SETFOLDLEVEL, line, level);
  1477. }
  1478.  
  1479. // Retrieve the fold level of a line.
  1480. int wxScintilla::GetFoldLevel (int line) {
  1481. return SendMsg (SCI_GETFOLDLEVEL, line, 0);
  1482. }
  1483.  
  1484. // Find the last child line of a header line.
  1485. int wxScintilla::GetLastChild (int line, int level) {
  1486. return SendMsg (SCI_GETLASTCHILD, line, level);
  1487. }
  1488.  
  1489. // Find the parent line of a child line.
  1490. int wxScintilla::GetFoldParent (int line) {
  1491. return SendMsg (SCI_GETFOLDPARENT, line, 0);
  1492. }
  1493.  
  1494. // Make a range of lines visible.
  1495. void wxScintilla::ShowLines (int lineStart, int lineEnd) {
  1496. SendMsg (SCI_SHOWLINES, lineStart, lineEnd);
  1497. }
  1498.  
  1499. // Make a range of lines invisible.
  1500. void wxScintilla::HideLines (int lineStart, int lineEnd) {
  1501. SendMsg (SCI_HIDELINES, lineStart, lineEnd);
  1502. }
  1503.  
  1504. // Is a line visible?
  1505. bool wxScintilla::GetLineVisible (int line) {
  1506. return SendMsg (SCI_GETLINEVISIBLE, line, 0) != 0;
  1507. }
  1508.  
  1509. // Show the children of a header line.
  1510. void wxScintilla::SetFoldExpanded (int line, bool expanded) {
  1511. SendMsg (SCI_SETFOLDEXPANDED, line, expanded);
  1512. }
  1513.  
  1514. // Is a header line expanded?
  1515. bool wxScintilla::GetFoldExpanded (int line) {
  1516. return SendMsg (SCI_GETFOLDEXPANDED, line, 0) != 0;
  1517. }
  1518.  
  1519. // Switch a header line between expanded and contracted.
  1520. void wxScintilla::ToggleFold (int line) {
  1521. SendMsg (SCI_TOGGLEFOLD, line, 0);
  1522. }
  1523.  
  1524. // Ensure a particular line is visible by expanding any header line hiding it.
  1525. void wxScintilla::EnsureVisible (int line) {
  1526. SendMsg (SCI_ENSUREVISIBLE, line, 0);
  1527. }
  1528.  
  1529. // Set some style options for folding.
  1530. void wxScintilla::SetFoldFlags (int flags) {
  1531. SendMsg(SCI_SETFOLDFLAGS, flags, 0);
  1532. }
  1533.  
  1534. // Ensure a particular line is visible by expanding any header line hiding it.
  1535. // Use the currently set visibility policy to determine which range to display.
  1536. void wxScintilla::EnsureVisibleEnforcePolicy (int line) {
  1537. SendMsg (SCI_ENSUREVISIBLEENFORCEPOLICY, line, 0);
  1538. }
  1539.  
  1540. // Sets whether a tab pressed when caret is within indentation indents.
  1541. void wxScintilla::SetTabIndents (bool tabIndents) {
  1542. SendMsg (SCI_SETTABINDENTS, tabIndents, 0);
  1543. }
  1544.  
  1545. // Does a tab pressed when caret is within indentation indent?
  1546. bool wxScintilla::GetTabIndents() {
  1547. return SendMsg (SCI_GETTABINDENTS, 0, 0) != 0;
  1548. }
  1549.  
  1550. // Sets whether a backspace pressed when caret is within indentation unindents.
  1551. void wxScintilla::SetBackSpaceUnIndents (bool bsUnIndents) {
  1552. SendMsg (SCI_SETBACKSPACEUNINDENTS, bsUnIndents, 0);
  1553. }
  1554.  
  1555. // Does a backspace pressed when caret is within indentation unindent?
  1556. bool wxScintilla::GetBackSpaceUnIndents() {
  1557. return SendMsg (SCI_GETBACKSPACEUNINDENTS, 0, 0) != 0;
  1558. }
  1559.  
  1560. // Sets the time the mouse must sit still to generate a mouse dwell event.
  1561. void wxScintilla::SetMouseDwellTime (int periodMilliseconds) {
  1562. SendMsg (SCI_SETMOUSEDWELLTIME, periodMilliseconds, 0);
  1563. }
  1564.  
  1565. // Retrieve the time the mouse must sit still to generate a mouse dwell event.
  1566. int wxScintilla::GetMouseDwellTime() {
  1567. return SendMsg (SCI_GETMOUSEDWELLTIME, 0, 0);
  1568. }
  1569.  
  1570. // Get position of start of word.
  1571. int wxScintilla::WordStartPosition (int pos, bool onlyWordCharacters) {
  1572. return SendMsg (SCI_WORDSTARTPOSITION, pos, onlyWordCharacters);
  1573. }
  1574.  
  1575. // Get position of end of word.
  1576. int wxScintilla::WordEndPosition (int pos, bool onlyWordCharacters) {
  1577. return SendMsg (SCI_WORDENDPOSITION, pos, onlyWordCharacters);
  1578. }
  1579.  
  1580. // Sets whether text is word wrapped.
  1581. void wxScintilla::SetWrapMode (int mode) {
  1582. SendMsg (SCI_SETWRAPMODE, mode, 0);
  1583. }
  1584.  
  1585. // Retrieve whether text is word wrapped.
  1586. int wxScintilla::GetWrapMode() {
  1587. return SendMsg (SCI_GETWRAPMODE, 0, 0);
  1588. }
  1589.  
  1590. // Set the display mode of visual flags for wrapped lines.
  1591. void wxScintilla::SetWrapVisualFlags (int wrapVisualFlags) {
  1592. SendMsg (SCI_SETWRAPVISUALFLAGS, wrapVisualFlags, 0);
  1593. }
  1594.  
  1595. // Retrive the display mode of visual flags for wrapped lines.
  1596. int wxScintilla::GetWrapVisualFlags() {
  1597. return SendMsg (SCI_GETWRAPVISUALFLAGS, 0, 0);
  1598. }
  1599.  
  1600. // Set the location of visual flags for wrapped lines.
  1601. void wxScintilla::SetWrapVisualFlagsLocation (int wrapVisualFlagsLocation) {
  1602. SendMsg (SCI_SETWRAPVISUALFLAGSLOCATION, wrapVisualFlagsLocation, 0);
  1603. }
  1604.  
  1605. // Retrive the location of visual flags for wrapped lines.
  1606. int wxScintilla::GetWrapVisualFlagsLocation() {
  1607. return SendMsg (SCI_GETWRAPVISUALFLAGSLOCATION, 0, 0);
  1608. }
  1609.  
  1610. // Set the start indent for wrapped lines.
  1611. void wxScintilla::SetWrapStartIndent (int indent) {
  1612. SendMsg (SCI_SETWRAPSTARTINDENT, indent, 0);
  1613. }
  1614.  
  1615. // Retrive the start indent for wrapped lines.
  1616. int wxScintilla::GetWrapStartIndent() {
  1617. return SendMsg (SCI_GETWRAPSTARTINDENT, 0, 0);
  1618. }
  1619.  
  1620. // Sets the degree of caching of layout information.
  1621. void wxScintilla::SetLayoutCache (int mode) {
  1622. SendMsg (SCI_SETLAYOUTCACHE, mode, 0);
  1623. }
  1624.  
  1625. // Retrieve the degree of caching of layout information.
  1626. int wxScintilla::GetLayoutCache() {
  1627. return SendMsg (SCI_GETLAYOUTCACHE, 0, 0);
  1628. }
  1629.  
  1630. // Sets the document width assumed for scrolling.
  1631. void wxScintilla::SetScrollWidth (int pixels) {
  1632. SendMsg (SCI_SETSCROLLWIDTH, pixels, 0);
  1633. }
  1634.  
  1635. // Retrieve the document width assumed for scrolling.
  1636. int wxScintilla::GetScrollWidth() {
  1637. return SendMsg (SCI_GETSCROLLWIDTH, 0, 0);
  1638. }
  1639.  
  1640. // Measure the pixel width of some text in a particular style.
  1641. // NUL terminated text argument.
  1642. // Does not handle tab or control characters.
  1643. int wxScintilla::TextWidth (int style, const wxString& text) {
  1644. return SendMsg (SCI_TEXTWIDTH, style, (long)(const char*)wx2sci(text));
  1645. }
  1646.  
  1647. // Sets the scroll range so that maximum scroll position has
  1648. // the last line at the bottom of the view (default).
  1649. // Setting this to false allows scrolling one page below the last line.
  1650. void wxScintilla::SetEndAtLastLine (bool endAtLastLine) {
  1651. SendMsg (SCI_SETENDATLASTLINE, endAtLastLine, 0);
  1652. }
  1653.  
  1654. // Retrieve whether the maximum scroll position has the last
  1655. // line at the bottom of the view.
  1656. bool wxScintilla::GetEndAtLastLine() {
  1657. return SendMsg (SCI_GETENDATLASTLINE, 0, 0) != 0;
  1658. }
  1659.  
  1660. // Retrieve the height of a particular line of text in pixels.
  1661. int wxScintilla::TextHeight (int line) {
  1662. return SendMsg (SCI_TEXTHEIGHT, line, 0);
  1663. }
  1664.  
  1665. // Show or hide the vertical scroll bar.
  1666. void wxScintilla::SetUseVerticalScrollBar (bool show) {
  1667. SendMsg (SCI_SETVSCROLLBAR, show, 0);
  1668. }
  1669.  
  1670. // Is the vertical scroll bar visible?
  1671. bool wxScintilla::GetUseVerticalScrollBar() {
  1672. return SendMsg (SCI_GETVSCROLLBAR, 0, 0) != 0;
  1673. }
  1674.  
  1675. // Add text to the document at current position.
  1676. void wxScintilla::AppendText (const wxString& text) {
  1677. wxWX2MBbuf buf = (wxWX2MBbuf)wx2sci(text);
  1678. SendMsg (SCI_APPENDTEXT, strlen(buf), (long)(const char*)buf);
  1679. }
  1680.  
  1681. // Append a string to the end of the document without changing the selection.
  1682. void wxScintilla::AppendText (int length, const wxString& text) {
  1683. SendMsg (SCI_APPENDTEXT, length, (long)(const char*)wx2sci(text));
  1684. }
  1685.  
  1686. // Is drawing done in two phases with backgrounds drawn before foregrounds?
  1687. bool wxScintilla::GetTwoPhaseDraw() {
  1688. return SendMsg (SCI_GETTWOPHASEDRAW, 0, 0) != 0;
  1689. }
  1690.  
  1691. // In twoPhaseDraw mode, drawing is performed in two phases, first the background
  1692. // and then the foreground. This avoids chopping off characters that overlap the next run.
  1693. void wxScintilla::SetTwoPhaseDraw (bool twoPhase) {
  1694. SendMsg (SCI_SETTWOPHASEDRAW, twoPhase, 0);
  1695. }
  1696.  
  1697. // Make the target range start and end be the same as the selection range start and end.
  1698. void wxScintilla::TargetFromSelection() {
  1699. SendMsg (SCI_TARGETFROMSELECTION, 0, 0);
  1700. }
  1701.  
  1702. // Join the lines in the target.
  1703. void wxScintilla::LinesJoin() {
  1704. SendMsg (SCI_LINESJOIN, 0, 0);
  1705. }
  1706.  
  1707. // Split the lines in the target into lines that are less wide than pixel where possible.
  1708. void wxScintilla::LinesSplit (int pixels) {
  1709. SendMsg (SCI_LINESSPLIT, pixels, 0);
  1710. }
  1711.  
  1712. // Set the colours used as a chequerboard pattern in the fold margin
  1713. void wxScintilla::SetFoldMarginColour (bool useSetting, const wxColour& back) {
  1714. SendMsg (SCI_SETFOLDMARGINCOLOUR, useSetting, wxColourAsLong(back));
  1715. }
  1716. void wxScintilla::SetFoldMarginHiColour (bool useSetting, const wxColour& fore) {
  1717. SendMsg (SCI_SETFOLDMARGINHICOLOUR, useSetting, wxColourAsLong(fore));
  1718. }
  1719.  
  1720. // Move caret down one line.
  1721. void wxScintilla::LineDown() {
  1722. SendMsg (SCI_LINEDOWN, 0, 0);
  1723. }
  1724.  
  1725. // Move caret down one line extending selection to new caret position.
  1726. void wxScintilla::LineDownExtend() {
  1727. SendMsg (SCI_LINEDOWNEXTEND, 0, 0);
  1728. }
  1729.  
  1730. // Move caret up one line.
  1731. void wxScintilla::LineUp() {
  1732. SendMsg (SCI_LINEUP, 0, 0);
  1733. }
  1734.  
  1735. // Move caret up one line extending selection to new caret position.
  1736. void wxScintilla::LineUpExtend() {
  1737. SendMsg (SCI_LINEUPEXTEND, 0, 0);
  1738. }
  1739.  
  1740. // Move caret left one character.
  1741. void wxScintilla::CharLeft() {
  1742. SendMsg (SCI_CHARLEFT, 0, 0);
  1743. }
  1744.  
  1745. // Move caret left one character extending selection to new caret position.
  1746. void wxScintilla::CharLeftExtend() {
  1747. SendMsg (SCI_CHARLEFTEXTEND, 0, 0);
  1748. }
  1749.  
  1750. // Move caret right one character.
  1751. void wxScintilla::CharRight() {
  1752. SendMsg (SCI_CHARRIGHT, 0, 0);
  1753. }
  1754.  
  1755. // Move caret right one character extending selection to new caret position.
  1756. void wxScintilla::CharRightExtend() {
  1757. SendMsg (SCI_CHARRIGHTEXTEND, 0, 0);
  1758. }
  1759.  
  1760. // Move caret left one word.
  1761. void wxScintilla::WordLeft() {
  1762. SendMsg (SCI_WORDLEFT, 0, 0);
  1763. }
  1764.  
  1765. // Move caret left one word extending selection to new caret position.
  1766. void wxScintilla::WordLeftExtend() {
  1767. SendMsg (SCI_WORDLEFTEXTEND, 0, 0);
  1768. }
  1769.  
  1770. // Move caret right one word.
  1771. void wxScintilla::WordRight() {
  1772. SendMsg (SCI_WORDRIGHT, 0, 0);
  1773. }
  1774.  
  1775. // Move caret right one word extending selection to new caret position.
  1776. void wxScintilla::WordRightExtend() {
  1777. SendMsg (SCI_WORDRIGHTEXTEND, 0, 0);
  1778. }
  1779.  
  1780. // Move caret to first position on line.
  1781. void wxScintilla::Home() {
  1782. SendMsg (SCI_HOME, 0, 0);
  1783. }
  1784.  
  1785. // Move caret to first position on line extending selection to new caret position.
  1786. void wxScintilla::HomeExtend() {
  1787. SendMsg (SCI_HOMEEXTEND, 0, 0);
  1788. }
  1789.  
  1790. // Move caret to last position on line.
  1791. void wxScintilla::LineEnd() {
  1792. SendMsg (SCI_LINEEND, 0, 0);
  1793. }
  1794.  
  1795. // Move caret to last position on line extending selection to new caret position.
  1796. void wxScintilla::LineEndExtend() {
  1797. SendMsg (SCI_LINEENDEXTEND, 0, 0);
  1798. }
  1799.  
  1800. // Move caret to first position in document.
  1801. void wxScintilla::DocumentStart() {
  1802. SendMsg (SCI_DOCUMENTSTART, 0, 0);
  1803. }
  1804.  
  1805. // Move caret to first position in document extending selection to new caret position.
  1806. void wxScintilla::DocumentStartExtend() {
  1807. SendMsg (SCI_DOCUMENTSTARTEXTEND, 0, 0);
  1808. }
  1809.  
  1810. // Move caret to last position in document.
  1811. void wxScintilla::DocumentEnd() {
  1812. SendMsg (SCI_DOCUMENTEND, 0, 0);
  1813. }
  1814.  
  1815. // Move caret to last position in document extending selection to new caret position.
  1816. void wxScintilla::DocumentEndExtend() {
  1817. SendMsg (SCI_DOCUMENTENDEXTEND, 0, 0);
  1818. }
  1819.  
  1820. // Move caret one page up.
  1821. void wxScintilla::PageUp() {
  1822. SendMsg (SCI_PAGEUP, 0, 0);
  1823. }
  1824.  
  1825. // Move caret one page up extending selection to new caret position.
  1826. void wxScintilla::PageUpExtend() {
  1827. SendMsg (SCI_PAGEUPEXTEND, 0, 0);
  1828. }
  1829.  
  1830. // Move caret one page down.
  1831. void wxScintilla::PageDown() {
  1832. SendMsg (SCI_PAGEDOWN, 0, 0);
  1833. }
  1834.  
  1835. // Move caret one page down extending selection to new caret position.
  1836. void wxScintilla::PageDownExtend() {
  1837. SendMsg (SCI_PAGEDOWNEXTEND, 0, 0);
  1838. }
  1839.  
  1840. // Switch from insert to overtype mode or the reverse.
  1841. void wxScintilla::EditToggleOvertype() {
  1842. SendMsg (SCI_EDITTOGGLEOVERTYPE, 0, 0);
  1843. }
  1844.  
  1845. // Cancel any modes such as call tip or auto-completion list display.
  1846. void wxScintilla::Cancel() {
  1847. SendMsg (SCI_CANCEL, 0, 0);
  1848. }
  1849.  
  1850. // Delete the selection or if no selection, the character before the caret.
  1851. void wxScintilla::DeleteBack() {
  1852. SendMsg (SCI_DELETEBACK, 0, 0);
  1853. }
  1854.  
  1855. // If selection is empty or all on one line replace the selection with a tab character.
  1856. // If more than one line selected, indent the lines.
  1857. void wxScintilla::Tab() {
  1858. SendMsg (SCI_TAB, 0, 0);
  1859. }
  1860.  
  1861. // Dedent the selected lines.
  1862. void wxScintilla::BackTab() {
  1863. SendMsg (SCI_BACKTAB, 0, 0);
  1864. }
  1865.  
  1866. // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
  1867. void wxScintilla::NewLine() {
  1868. SendMsg (SCI_NEWLINE, 0, 0);
  1869. }
  1870.  
  1871. // Insert a Form Feed character.
  1872. void wxScintilla::FormFeed() {
  1873. SendMsg (SCI_FORMFEED, 0, 0);
  1874. }
  1875.  
  1876. // Move caret to before first visible character on line.
  1877. // If already there move to first character on line.
  1878. void wxScintilla::VCHome() {
  1879. SendMsg (SCI_VCHOME, 0, 0);
  1880. }
  1881.  
  1882. // Like VCHome but extending selection to new caret position.
  1883. void wxScintilla::VCHomeExtend() {
  1884. SendMsg (SCI_VCHOMEEXTEND, 0, 0);
  1885. }
  1886.  
  1887. // Magnify the displayed text by increasing the sizes by 1 point.
  1888. void wxScintilla::ZoomIn() {
  1889. SendMsg (SCI_ZOOMIN, 0, 0);
  1890. }
  1891.  
  1892. // Make the displayed text smaller by decreasing the sizes by 1 point.
  1893. void wxScintilla::ZoomOut() {
  1894. SendMsg (SCI_ZOOMOUT, 0, 0);
  1895. }
  1896.  
  1897. // Delete the word to the left of the caret.
  1898. void wxScintilla::DelWordLeft() {
  1899. SendMsg (SCI_DELWORDLEFT, 0, 0);
  1900. }
  1901.  
  1902. // Delete the word to the right of the caret.
  1903. void wxScintilla::DelWordRight() {
  1904. SendMsg (SCI_DELWORDRIGHT, 0, 0);
  1905. }
  1906.  
  1907. // Cut the line containing the caret.
  1908. void wxScintilla::LineCut() {
  1909. SendMsg (SCI_LINECUT, 0, 0);
  1910. }
  1911.  
  1912. // Delete the line containing the caret.
  1913. void wxScintilla::LineDelete() {
  1914. SendMsg (SCI_LINEDELETE, 0, 0);
  1915. }
  1916.  
  1917. // Switch the current line with the previous.
  1918. void wxScintilla::LineTranspose() {
  1919. SendMsg (SCI_LINETRANSPOSE, 0, 0);
  1920. }
  1921.  
  1922. // Duplicate the current line.
  1923. void wxScintilla::LineDuplicate() {
  1924. SendMsg (SCI_LINEDUPLICATE, 0, 0);
  1925. }
  1926.  
  1927. // Transform the selection to lower case.
  1928. void wxScintilla::LowerCase() {
  1929. SendMsg (SCI_LOWERCASE, 0, 0);
  1930. }
  1931.  
  1932. // Transform the selection to upper case.
  1933. void wxScintilla::UpperCase() {
  1934. SendMsg (SCI_UPPERCASE, 0, 0);
  1935. }
  1936.  
  1937. // Scroll the document down, keeping the caret visible.
  1938. void wxScintilla::LineScrollDown() {
  1939. SendMsg (SCI_LINESCROLLDOWN, 0, 0);
  1940. }
  1941.  
  1942. // Scroll the document up, keeping the caret visible.
  1943. void wxScintilla::LineScrollUp() {
  1944. SendMsg (SCI_LINESCROLLUP, 0, 0);
  1945. }
  1946.  
  1947. // Delete the selection or if no selection, the character before the caret.
  1948. // Will not delete the character before at the start of a line.
  1949. void wxScintilla::DeleteBackNotLine() {
  1950. SendMsg (SCI_DELETEBACKNOTLINE, 0, 0);
  1951. }
  1952.  
  1953. // Move caret to first position on display line.
  1954. void wxScintilla::HomeDisplay() {
  1955. SendMsg (SCI_HOMEDISPLAY, 0, 0);
  1956. }
  1957.  
  1958. // Move caret to first position on display line extending selection to
  1959. // new caret position.
  1960. void wxScintilla::HomeDisplayExtend() {
  1961. SendMsg (SCI_HOMEDISPLAYEXTEND, 0, 0);
  1962. }
  1963.  
  1964. // Move caret to last position on display line.
  1965. void wxScintilla::LineEndDisplay() {
  1966. SendMsg (SCI_LINEENDDISPLAY, 0, 0);
  1967. }
  1968.  
  1969. // Move caret to last position on display line extending selection to new
  1970. // caret position.
  1971. void wxScintilla::LineEndDisplayExtend() {
  1972. SendMsg (SCI_LINEENDDISPLAYEXTEND, 0, 0);
  1973. }
  1974.  
  1975. // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
  1976. // except they behave differently when word-wrap is enabled:
  1977. // They go first to the start / end of the display line, like (Home|LineEnd)Display
  1978. // The difference is that, the cursor is already at the point, it goes on to the start
  1979. // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
  1980. void wxScintilla::HomeWrap() {
  1981. SendMsg (SCI_HOMEWRAP, 0, 0);
  1982. }
  1983. void wxScintilla::HomeWrapExtend() {
  1984. SendMsg (SCI_HOMEWRAPEXTEND, 0, 0);
  1985. }
  1986. void wxScintilla::LineEndWrap() {
  1987. SendMsg (SCI_LINEENDWRAP, 0, 0);
  1988. }
  1989. void wxScintilla::LineEndWrapExtend() {
  1990. SendMsg (SCI_LINEENDWRAPEXTEND, 0, 0);
  1991. }
  1992. void wxScintilla::VCHomeWrap() {
  1993. SendMsg (SCI_VCHOMEWRAP, 0, 0);
  1994. }
  1995. void wxScintilla::VCHomeWrapExtend() {
  1996. SendMsg (SCI_VCHOMEWRAPEXTEND, 0, 0);
  1997. }
  1998.  
  1999. // Copy the line containing the caret.
  2000. void wxScintilla::LineCopy() {
  2001. SendMsg (SCI_LINECOPY, 0, 0);
  2002. }
  2003.  
  2004. // Move the caret inside current view if it's not there already.
  2005. void wxScintilla::MoveCaretInsideView() {
  2006. SendMsg (SCI_MOVECARETINSIDEVIEW, 0, 0);
  2007. }
  2008.  
  2009. // How many characters are on a line, not including end of line characters?
  2010. int wxScintilla::LineLength (int line) {
  2011. return SendMsg (SCI_LINELENGTH, line, 0);
  2012. }
  2013.  
  2014. // Highlight the characters at two positions.
  2015. void wxScintilla::BraceHighlight (int pos1, int pos2) {
  2016. SendMsg (SCI_BRACEHIGHLIGHT, pos1, pos2);
  2017. }
  2018.  
  2019. // Highlight the character at a position indicating there is no matching brace.
  2020. void wxScintilla::BraceBadLight (int pos) {
  2021. SendMsg (SCI_BRACEBADLIGHT, pos, 0);
  2022. }
  2023.  
  2024. // Find the position of a matching brace or INVALID_POSITION if no match.
  2025. int wxScintilla::BraceMatch (int pos) {
  2026. return SendMsg (SCI_BRACEMATCH, pos, 0);
  2027. }
  2028.  
  2029. // Are the end of line characters visible?
  2030. bool wxScintilla::GetViewEOL() {
  2031. return SendMsg (SCI_GETVIEWEOL, 0, 0) != 0;
  2032. }
  2033.  
  2034. // Make the end of line characters visible or invisible.
  2035. void wxScintilla::SetViewEOL (bool visible) {
  2036. SendMsg (SCI_SETVIEWEOL, visible, 0);
  2037. }
  2038.  
  2039. // Retrieve a pointer to the document object.
  2040. void* wxScintilla::GetDocPointer() {
  2041. return (void*)SendMsg (SCI_GETDOCPOINTER);
  2042. }
  2043.  
  2044. // Change the document object used.
  2045. void wxScintilla::SetDocPointer (void* docPointer) {
  2046. SendMsg (SCI_SETDOCPOINTER, 0, (long)docPointer);
  2047. }
  2048.  
  2049. // Set which document modification events are sent to the container.
  2050. void wxScintilla::SetModEventMask (int mask) {
  2051. SendMsg (SCI_SETMODEVENTMASK, mask, 0);
  2052. }
  2053.  
  2054. // Retrieve the column number which text should be kept within.
  2055. int wxScintilla::GetEdgeColumn() {
  2056. return SendMsg (SCI_GETEDGECOLUMN, 0, 0);
  2057. }
  2058.  
  2059. // Set the column number of the edge.
  2060. // If text goes past the edge then it is highlighted.
  2061. void wxScintilla::SetEdgeColumn (int column) {
  2062. SendMsg (SCI_SETEDGECOLUMN, column, 0);
  2063. }
  2064.  
  2065. // Retrieve the edge highlight mode.
  2066. int wxScintilla::GetEdgeMode() {
  2067. return SendMsg (SCI_GETEDGEMODE, 0, 0);
  2068. }
  2069.  
  2070. // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
  2071. // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
  2072. void wxScintilla::SetEdgeMode (int mode) {
  2073. SendMsg (SCI_SETEDGEMODE, mode, 0);
  2074. }
  2075.  
  2076. // Retrieve the colour used in edge indication.
  2077. wxColour wxScintilla::GetEdgeColour() {
  2078. long colour = SendMsg (SCI_GETEDGECOLOUR, 0, 0);
  2079. return wxColourFromLong(colour);
  2080. }
  2081.  
  2082. // Change the colour used in edge indication.
  2083. void wxScintilla::SetEdgeColour (const wxColour& colour) {
  2084. SendMsg (SCI_SETEDGECOLOUR, wxColourAsLong(colour), 0);
  2085. }
  2086.  
  2087. // Sets the current caret position to be the search anchor.
  2088. void wxScintilla::SearchAnchor() {
  2089. SendMsg (SCI_SEARCHANCHOR, 0, 0);
  2090. }
  2091.  
  2092. // Find some text starting at the search anchor.
  2093. // Does not ensure the selection is visible.
  2094. int wxScintilla::SearchNext (int flags, const wxString& text) {
  2095. return SendMsg (SCI_SEARCHNEXT, flags, (long)(const char*)wx2sci(text));
  2096. }
  2097.  
  2098. // Find some text starting at the search anchor and moving backwards.
  2099. // Does not ensure the selection is visible.
  2100. int wxScintilla::SearchPrev (int flags, const wxString& text) {
  2101. return SendMsg (SCI_SEARCHPREV, flags, (long)(const char*)wx2sci(text));
  2102. }
  2103.  
  2104. // Retrieves the number of lines completely visible.
  2105. int wxScintilla::LinesOnScreen() {
  2106. return SendMsg (SCI_LINESONSCREEN, 0, 0);
  2107. }
  2108.  
  2109. // Set whether a pop up menu is displayed automatically when the user presses
  2110. // the wrong mouse button.
  2111. void wxScintilla::UsePopUp (bool allowPopUp) {
  2112. SendMsg (SCI_USEPOPUP, allowPopUp, 0);
  2113. }
  2114.  
  2115. // Is the selection rectangular? The alternative is the more common stream selection.
  2116. bool wxScintilla::SelectionIsRectangle() {
  2117. return SendMsg (SCI_SELECTIONISRECTANGLE, 0, 0) != 0;
  2118. }
  2119.  
  2120. // Set the zoom level. This number of points is added to the size of all fonts.
  2121. // It may be positive to magnify or negative to reduce.
  2122. void wxScintilla::SetZoom (int zoom) {
  2123. SendMsg (SCI_SETZOOM, zoom, 0);
  2124. }
  2125.  
  2126. // Retrieve the zoom level.
  2127. int wxScintilla::GetZoom() {
  2128. return SendMsg (SCI_GETZOOM, 0, 0);
  2129. }
  2130.  
  2131. // Create a new document object.
  2132. // Starts with reference count of 1 and not selected into editor.
  2133. void* wxScintilla::CreateDocument() {
  2134. return (void*)SendMsg (SCI_CREATEDOCUMENT, 0, 0);
  2135. }
  2136.  
  2137. // Extend life of document.
  2138. void wxScintilla::AddRefDocument (void* docPointer) {
  2139. SendMsg (SCI_ADDREFDOCUMENT, 0, (long)docPointer);
  2140. }
  2141.  
  2142. // Release a reference to the document, deleting document if it fades to black.
  2143. void wxScintilla::ReleaseDocument (void* docPointer) {
  2144. SendMsg (SCI_RELEASEDOCUMENT, 0, (long)docPointer);
  2145. }
  2146.  
  2147. // Get which document modification events are sent to the container.
  2148. int wxScintilla::GetModEventMask() {
  2149. return SendMsg (SCI_GETMODEVENTMASK, 0, 0);
  2150. }
  2151.  
  2152. // Change internal focus flag.
  2153. void wxScintilla::SetSCIFocus (bool focus) {
  2154. SendMsg (SCI_SETFOCUS, focus, 0);
  2155. }
  2156.  
  2157. // Get internal focus flag.
  2158. bool wxScintilla::GetSCIFocus() {
  2159. return SendMsg (SCI_GETFOCUS, 0, 0) != 0;
  2160. }
  2161.  
  2162. // Change error status - 0 = OK.
  2163. void wxScintilla::SetStatus (int status) {
  2164. SendMsg (SCI_SETSTATUS, status, 0);
  2165. }
  2166.  
  2167. // Get error status.
  2168. int wxScintilla::GetStatus() {
  2169. return SendMsg (SCI_GETSTATUS, 0, 0);
  2170. }
  2171.  
  2172. // Set whether the mouse is captured when its button is pressed.
  2173. void wxScintilla::SetMouseDownCaptures (bool captures) {
  2174. SendMsg (SCI_SETMOUSEDOWNCAPTURES, captures, 0);
  2175. }
  2176.  
  2177. // Get whether mouse gets captured.
  2178. bool wxScintilla::GetMouseDownCaptures() {
  2179. return SendMsg (SCI_GETMOUSEDOWNCAPTURES, 0, 0) != 0;
  2180. }
  2181.  
  2182. // Sets the cursor to one of the SC_CURSOR* values.
  2183. void wxScintilla::SetCursorType (int cursorType) {
  2184. SendMsg(SCI_SETCURSOR, cursorType, 0);
  2185. }
  2186.  
  2187. // Get cursor type.
  2188. int wxScintilla::GetCursorType() {
  2189. return SendMsg (SCI_GETCURSOR, 0, 0);
  2190. }
  2191.  
  2192. // Change the way control characters are displayed:
  2193. // If symbol is < 32, keep the drawn way, else, use the given character.
  2194. void wxScintilla::SetControlCharSymbol (int symbol) {
  2195. SendMsg (SCI_SETCONTROLCHARSYMBOL, symbol, 0);
  2196. }
  2197.  
  2198. // Get the way control characters are displayed.
  2199. int wxScintilla::GetControlCharSymbol() {
  2200. return SendMsg (SCI_GETCONTROLCHARSYMBOL, 0, 0);
  2201. }
  2202.  
  2203. // Move to the previous change in capitalisation.
  2204. void wxScintilla::WordPartLeft() {
  2205. SendMsg (SCI_WORDPARTLEFT, 0, 0);
  2206. }
  2207.  
  2208. // Move to the previous change in capitalisation extending selection
  2209. // to new caret position.
  2210. void wxScintilla::WordPartLeftExtend() {
  2211. SendMsg (SCI_WORDPARTLEFTEXTEND, 0, 0);
  2212. }
  2213.  
  2214. // Move to the change next in capitalisation.
  2215. void wxScintilla::WordPartRight() {
  2216. SendMsg (SCI_WORDPARTRIGHT, 0, 0);
  2217. }
  2218.  
  2219. // Move to the next change in capitalisation extending selection
  2220. // to new caret position.
  2221. void wxScintilla::WordPartRightExtend() {
  2222. SendMsg (SCI_WORDPARTRIGHTEXTEND, 0, 0);
  2223. }
  2224.  
  2225. // Set the way the display area is determined when a particular line
  2226. // is to be moved to by Find, FindNext, GotoLine, etc.
  2227. void wxScintilla::SetVisiblePolicy (int visiblePolicy, int visibleSlop) {
  2228. SendMsg (SCI_SETVISIBLEPOLICY, visiblePolicy, visibleSlop);
  2229. }
  2230.  
  2231. // Delete back from the current position to the start of the line.
  2232. void wxScintilla::DelLineLeft() {
  2233. SendMsg (SCI_DELLINELEFT, 0, 0);
  2234. }
  2235.  
  2236. // Delete forwards from the current position to the end of the line.
  2237. void wxScintilla::DelLineRight() {
  2238. SendMsg (SCI_DELLINERIGHT, 0, 0);
  2239. }
  2240.  
  2241. // Get and Set the xOffset (ie, horizonal scroll position).
  2242. void wxScintilla::SetXOffset (int newOffset) {
  2243. SendMsg (SCI_SETXOFFSET, newOffset, 0);
  2244. }
  2245. int wxScintilla::GetXOffset() {
  2246. return SendMsg (SCI_GETXOFFSET, 0, 0);
  2247. }
  2248.  
  2249. // Set the last x chosen value to be the caret x position.
  2250. void wxScintilla::ChooseCaretX() {
  2251. SendMsg (SCI_CHOOSECARETX, 0, 0);
  2252. }
  2253.  
  2254. // Set the focus to this Scintilla widget (GTK+ specific)
  2255. // Grab focus (SCI_GRABFOCUS) not supported
  2256.  
  2257. // Set the way the caret is kept visible when going sideway.
  2258. // The exclusion zone is given in pixels.
  2259. void wxScintilla::SetXCaretPolicy (int caretPolicy, int caretSlop) {
  2260. SendMsg (SCI_SETXCARETPOLICY, caretPolicy, caretSlop);
  2261. }
  2262.  
  2263. // Set the way the line the caret is on is kept visible.
  2264. // The exclusion zone is given in lines.
  2265. void wxScintilla::SetYCaretPolicy (int caretPolicy, int caretSlop) {
  2266. SendMsg (SCI_SETYCARETPOLICY, caretPolicy, caretSlop);
  2267. }
  2268.  
  2269. // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
  2270. void wxScintilla::SetPrintWrapMode (int mode) {
  2271. SendMsg (SCI_SETPRINTWRAPMODE, mode, 0);
  2272. }
  2273.  
  2274. // Is printing line wrapped?
  2275. int wxScintilla::GetPrintWrapMode() {
  2276. return SendMsg (SCI_GETPRINTWRAPMODE, 0, 0);
  2277. }
  2278.  
  2279. // Set a fore colour for active hotspots.
  2280. void wxScintilla::SetHotspotActiveForeground (bool useSetting, const wxColour& fore) {
  2281. SendMsg (SCI_SETHOTSPOTACTIVEFORE, useSetting, wxColourAsLong(fore));
  2282. }
  2283.  
  2284. // Set a back colour for active hotspots.
  2285. void wxScintilla::SetHotspotActiveBackground (bool useSetting, const wxColour& back) {
  2286. SendMsg (SCI_SETHOTSPOTACTIVEBACK, useSetting, wxColourAsLong(back));
  2287. }
  2288.  
  2289. // Enable / Disable underlining active hotspots.
  2290. void wxScintilla::SetHotspotActiveUnderline (bool underline) {
  2291. SendMsg (SCI_SETHOTSPOTACTIVEUNDERLINE, underline, 0);
  2292. }
  2293.  
  2294. // Limit hotspots to single line so hotspots on two lines don't merge.
  2295. void wxScintilla::SetHotspotSingleLine (bool singleLine) {
  2296. SendMsg(SCI_SETHOTSPOTSINGLELINE, singleLine, 0);
  2297. }
  2298.  
  2299. // Move caret between paragraphs (delimited by empty lines).
  2300. void wxScintilla::ParaDown() {
  2301. SendMsg (SCI_PARADOWN, 0, 0);
  2302. }
  2303. void wxScintilla::ParaDownExtend() {
  2304. SendMsg (SCI_PARADOWNEXTEND, 0, 0);
  2305. }
  2306. void wxScintilla::ParaUp() {
  2307. SendMsg (SCI_PARAUP, 0, 0);
  2308. }
  2309. void wxScintilla::ParaUpExtend() {
  2310. SendMsg (SCI_PARAUPEXTEND, 0, 0);
  2311. }
  2312.  
  2313. // Given a valid document position, return the previous position taking code
  2314. // page into account. Returns 0 if passed 0.
  2315. int wxScintilla::PositionBefore (int pos) {
  2316. return SendMsg (SCI_POSITIONBEFORE, pos, 0);
  2317. }
  2318.  
  2319. // Given a valid document position, return the next position taking code
  2320. // page into account. Maximum value returned is the last position in the document.
  2321. int wxScintilla::PositionAfter (int pos) {
  2322. return SendMsg (SCI_POSITIONAFTER, pos, 0);
  2323. }
  2324.  
  2325. // Copy a range of text to the clipboard. Positions are clipped into the document.
  2326. void wxScintilla::CopyRange (int startPos, int endPos) {
  2327. SendMsg (SCI_COPYRANGE, startPos, endPos);
  2328. }
  2329.  
  2330. // Copy argument text to the clipboard.
  2331. void wxScintilla::CopyText (int length, const wxString& text) {
  2332. SendMsg (SCI_COPYTEXT, length, (long)(const char*)wx2sci(text));
  2333. }
  2334.  
  2335. // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
  2336. // by lines (SC_SEL_LINES).
  2337. void wxScintilla::SetSelectionMode (int mode) {
  2338. SendMsg (SCI_SETSELECTIONMODE, mode, 0);
  2339. }
  2340.  
  2341. // Get the mode of the current selection.
  2342. int wxScintilla::GetSelectionMode() {
  2343. return SendMsg (SCI_GETSELECTIONMODE, 0, 0);
  2344. }
  2345.  
  2346. // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
  2347. int wxScintilla::GetLineSelStartPosition (int line) {
  2348. return SendMsg (SCI_GETLINESELSTARTPOSITION, line, 0);
  2349. }
  2350.  
  2351. // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
  2352. int wxScintilla::GetLineSelEndPosition (int line) {
  2353. return SendMsg (SCI_GETLINESELENDPOSITION, line, 0);
  2354. }
  2355.  
  2356. // Move caret down one line, extending rectangular selection to new caret position.
  2357. void wxScintilla::LineDownRectExtend() {
  2358. SendMsg (SCI_LINEDOWNRECTEXTEND, 0, 0);
  2359. }
  2360.  
  2361. // Move caret up one line, extending rectangular selection to new caret position.
  2362. void wxScintilla::LineUpRectExtend() {
  2363. SendMsg (SCI_LINEUPRECTEXTEND, 0, 0);
  2364. }
  2365.  
  2366. // Move caret left one character, extending rectangular selection to new caret position.
  2367. void wxScintilla::CharLeftRectExtend() {
  2368. SendMsg (SCI_CHARLEFTRECTEXTEND, 0, 0);
  2369. }
  2370.  
  2371. // Move caret right one character, extending rectangular selection to new caret position.
  2372. void wxScintilla::CharRightRectExtend() {
  2373. SendMsg (SCI_CHARRIGHTRECTEXTEND, 0, 0);
  2374. }
  2375.  
  2376. // Move caret to first position on line, extending rectangular selection to new caret position.
  2377. void wxScintilla::HomeRectExtend() {
  2378. SendMsg (SCI_HOMERECTEXTEND, 0, 0);
  2379. }
  2380.  
  2381. // Move caret to before first visible character on line.
  2382. // If already there move to first character on line.
  2383. // In either case, extend rectangular selection to new caret position.
  2384. void wxScintilla::VCHomeRectExtend() {
  2385. SendMsg (SCI_VCHOMERECTEXTEND, 0, 0);
  2386. }
  2387.  
  2388. // Move caret to last position on line, extending rectangular selection to new caret position.
  2389. void wxScintilla::LineEndRectExtend() {
  2390. SendMsg (SCI_LINEENDRECTEXTEND, 0, 0);
  2391. }
  2392.  
  2393. // Move caret one page up, extending rectangular selection to new caret position.
  2394. void wxScintilla::PageUpRectExtend() {
  2395. SendMsg (SCI_PAGEUPRECTEXTEND, 0, 0);
  2396. }
  2397.  
  2398. // Move caret one page down, extending rectangular selection to new caret position.
  2399. void wxScintilla::PageDownRectExtend() {
  2400. SendMsg (SCI_PAGEDOWNRECTEXTEND, 0, 0);
  2401. }
  2402.  
  2403. // Move caret to top of page, or one page up if already at top of page.
  2404. void wxScintilla::StutteredPageUp() {
  2405. SendMsg (SCI_STUTTEREDPAGEUP, 0, 0);
  2406. }
  2407.  
  2408. // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
  2409. void wxScintilla::StutteredPageUpExtend() {
  2410. SendMsg (SCI_STUTTEREDPAGEUPEXTEND, 0, 0);
  2411. }
  2412.  
  2413. // Move caret to bottom of page, or one page down if already at bottom of page.
  2414. void wxScintilla::StutteredPageDown() {
  2415. SendMsg (SCI_STUTTEREDPAGEDOWN, 0, 0);
  2416. }
  2417.  
  2418. // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
  2419. void wxScintilla::StutteredPageDownExtend() {
  2420. SendMsg (SCI_STUTTEREDPAGEDOWNEXTEND, 0, 0);
  2421. }
  2422.  
  2423. // Move caret left one word, position cursor at end of word.
  2424. void wxScintilla::WordLeftEnd() {
  2425. SendMsg (SCI_WORDLEFTEND, 0, 0);
  2426. }
  2427.  
  2428. // Move caret left one word, position cursor at end of word, extending selection to new caret position.
  2429. void wxScintilla::WordLeftEndExtend() {
  2430. SendMsg (SCI_WORDLEFTENDEXTEND, 0, 0);
  2431. }
  2432.  
  2433. // Move caret right one word, position cursor at end of word.
  2434. void wxScintilla::WordRightEnd() {
  2435. SendMsg (SCI_WORDRIGHTEND, 0, 0);
  2436. }
  2437.  
  2438. // Move caret right one word, position cursor at end of word, extending selection to new caret position.
  2439. void wxScintilla::WordRightEndExtend() {
  2440. SendMsg (SCI_WORDRIGHTENDEXTEND, 0, 0);
  2441. }
  2442.  
  2443. // Set the set of characters making up whitespace for when moving or selecting by word.
  2444. // Should be called after SetWordChars.
  2445. void wxScintilla::SetWhitespaceChars (const wxString& characters) {
  2446. SendMsg (SCI_SETWHITESPACECHARS, 0, (long)(const char*)wx2sci(characters));
  2447. }
  2448.  
  2449. // Reset the set of characters for whitespace and word characters to the defaults.
  2450. void wxScintilla::SetCharsDefault() {
  2451. SendMsg (SCI_SETCHARSDEFAULT, 0, 0);
  2452. }
  2453.  
  2454. // Get currently selected item position in the auto-completion list
  2455. int wxScintilla::AutoCompGetCurrent() {
  2456. return SendMsg (SCI_AUTOCGETCURRENT, 0, 0);
  2457. }
  2458.  
  2459. // Enlarge the document to a particular size of text bytes.
  2460. void wxScintilla::Allocate (int bytes) {
  2461. SendMsg (SCI_ALLOCATE, bytes, 0);
  2462. }
  2463.  
  2464. // Target as UTF8 (SCI_TARGETASUTF8) not supported
  2465.  
  2466. // Set lenght for encode (SCI_SETLENGTHFORENCODE) not supported
  2467.  
  2468. // Set endoce from UTF8 (SCI_ENCODEDFROMUTF8) not supported
  2469.  
  2470. // Returns the position of a column on a line taking the width of tabs into account.
  2471. int wxScintilla::FindColumn (int line, int column) {
  2472. return SendMsg (SCI_ENCODEDFROMUTF8, line, column);
  2473. }
  2474.  
  2475. // Can the caret preferred x position only be changed by explicit movement commands?
  2476. bool wxScintilla::GetCaretSticky () {
  2477. return SendMsg (SCI_GETCARETSTICKY, 0, 0) != 0;
  2478. }
  2479.  
  2480. // Stop the caret preferred x position changing when the user types.
  2481. void wxScintilla::SetCaretSticky (bool useCaretStickyBehaviour) {
  2482. SendMsg (SCI_SETCARETSTICKY, useCaretStickyBehaviour, 0);
  2483. }
  2484.  
  2485. // Switch between sticky and non-sticky: meant to be bound to a key.
  2486. void wxScintilla::ToggleCaretSticky () {
  2487. SendMsg (SCI_TOGGLECARETSTICKY, 0, 0);
  2488. }
  2489.  
  2490. // Enable/Disable convert-on-paste for line endings.
  2491. void wxScintilla::SetPasteConvertEndings (bool convert) {
  2492. SendMsg (SCI_SETPASTECONVERTENDINGS, convert, 0);
  2493. }
  2494.  
  2495. // Get convert-on-paste setting.
  2496. bool wxScintilla::GetPasteConvertEndings () {
  2497. return SendMsg (SCI_GETPASTECONVERTENDINGS, 0, 0) != 0;
  2498. }
  2499.  
  2500. // Duplicate the selection. If selection empty duplicate the line containing the caret.
  2501. void wxScintilla::SelectionDuplicate () {
  2502. SendMsg (SCI_SELECTIONDUPLICATE, 0, 0);
  2503. }
  2504.  
  2505. // Get the background alpha of the caret line.
  2506. int wxScintilla::GetCaretLineBackroundAlpha () {
  2507. return SendMsg (SCI_GETCARETLINEBACKALPHA, 0, 0);
  2508. }
  2509.  
  2510. // Set background alpha of the caret line.
  2511. void wxScintilla::SetCaretLineBackgroundAlpha (int alpha) {
  2512. SendMsg (SCI_SETCARETLINEBACKALPHA, alpha, 0);
  2513. }
  2514.  
  2515. // Start notifying the container of all key presses and commands.
  2516. void wxScintilla::StartRecord () {
  2517. SendMsg (SCI_STARTRECORD, 0, 0);
  2518. }
  2519.  
  2520. // Stop notifying the container of all key presses and commands.
  2521. void wxScintilla::StopRecord () {
  2522. SendMsg (SCI_STOPRECORD, 0, 0);
  2523. }
  2524.  
  2525. // Set the lexing language of the document.
  2526. void wxScintilla::SetLexer (int lexer) {
  2527. SendMsg (SCI_SETLEXER, lexer, 0);
  2528. }
  2529.  
  2530. // Retrieve the lexing language of the document.
  2531. int wxScintilla::GetLexer () {
  2532. return SendMsg (SCI_GETLEXER, 0, 0);
  2533. }
  2534.  
  2535. // Colourise a segment of the document using the current lexing language.
  2536. void wxScintilla::Colourise (int startPos, int endPos) {
  2537. SendMsg (SCI_COLOURISE, startPos, endPos);
  2538. }
  2539.  
  2540. // Set up a value that may be used by a lexer for some optional feature.
  2541. void wxScintilla::SetProperty (const wxString& key, const wxString& value) {
  2542. SendMsg (SCI_SETPROPERTY, (long)(const char*)wx2sci(key), (long)(const char*)wx2sci(value));
  2543. }
  2544.  
  2545. // Retrieve a value that may be used by a lexer for some optional feature.
  2546. wxString wxScintilla::GetProperty (const wxString& key) {
  2547. int len = SendMsg (SCI_GETPROPERTY, (long)(const char*)wx2sci(key), (long)NULL);
  2548. if (!len) return wxEmptyString;
  2549. wxMemoryBuffer mbuf (len+1);
  2550. char* buf = (char*)mbuf.GetWriteBuf (len+1);
  2551. SendMsg (SCI_GETPROPERTY, (long)(const char*)wx2sci(key), (long)buf);
  2552. mbuf.UngetWriteBuf (len);
  2553. mbuf.AppendByte (0);
  2554. return sci2wx(buf);
  2555. }
  2556. wxString wxScintilla::GetPropertyExpanded (const wxString& key) {
  2557. int len = SendMsg (SCI_GETPROPERTYEXPANDED, (long)(const char*)wx2sci(key), (long)NULL);
  2558. if (!len) return wxEmptyString;
  2559. wxMemoryBuffer mbuf(len+1);
  2560. char* buf = (char*)mbuf.GetWriteBuf(len+1);
  2561. SendMsg (SCI_GETPROPERTYEXPANDED, (long)(const char*)wx2sci(key), (long)buf);
  2562. mbuf.UngetWriteBuf (len);
  2563. mbuf.AppendByte(0);
  2564. return sci2wx(buf);
  2565. }
  2566. int wxScintilla::GetPropertyInt (const wxString& key) {
  2567. return SendMsg (SCI_GETPROPERTYINT, (long)(const char*)wx2sci(key), 0);
  2568. }
  2569.  
  2570. // Retrieve the number of bits the current lexer needs for styling.
  2571. int wxScintilla::GetStyleBitsNeeded () {
  2572. return SendMsg (SCI_GETSTYLEBITSNEEDED, 0, 0);
  2573. }
  2574.  
  2575. // Set up the key words used by the lexer.
  2576. void wxScintilla::SetKeyWords (int keywordSet, const wxString& keyWords) {
  2577. SendMsg (SCI_SETKEYWORDS, keywordSet, (long)(const char*)wx2sci(keyWords));
  2578. }
  2579.  
  2580. // Set the lexing language of the document based on string name.
  2581. void wxScintilla::SetLexerLanguage (const wxString& language) {
  2582. SendMsg (SCI_SETLEXERLANGUAGE, 0, (long)(const char*)wx2sci(language));
  2583. }
  2584.  
  2585. // END of generated section
  2586. //----------------------------------------------------------------------
  2587.  
  2588.  
  2589. // Returns the line number of the line with the caret.
  2590. int wxScintilla::GetCurrentLine () {
  2591. int line = LineFromPosition (GetCurrentPos());
  2592. return line;
  2593. }
  2594.  
  2595.  
  2596. // Extract style settings from a spec-string which is composed of one or
  2597. // more of the following comma separated elements:
  2598. //
  2599. // bold turns on bold
  2600. // italic turns on italics
  2601. // fore:[name or #RRGGBB] sets the foreground colour
  2602. // back:[name or #RRGGBB] sets the background colour
  2603. // face:[facename] sets the font face name to use
  2604. // size:[num] sets the font size in points
  2605. // eol turns on eol filling
  2606. // underline turns on underlining
  2607. //
  2608. void wxScintilla::StyleSetSpec (int styleNum, const wxString& spec) {
  2609.  
  2610. wxStringTokenizer tkz (spec, _T(","));
  2611. while (tkz.HasMoreTokens()) {
  2612. wxString token = tkz.GetNextToken();
  2613.  
  2614. wxString option = token.BeforeFirst (':');
  2615. wxString val = token.AfterFirst (':');
  2616.  
  2617. if (option == _T("bold"))
  2618. StyleSetBold (styleNum, true);
  2619.  
  2620. else if (option == _T("italic"))
  2621. StyleSetItalic (styleNum, true);
  2622.  
  2623. else if (option == _T("underline"))
  2624. StyleSetUnderline (styleNum, true);
  2625.  
  2626. else if (option == _T("eol"))
  2627. StyleSetEOLFilled (styleNum, true);
  2628.  
  2629. else if (option == _T("size")) {
  2630. long points;
  2631. if (val.ToLong (&points))
  2632. StyleSetSize (styleNum, points);
  2633. }
  2634.  
  2635. else if (option == _T("face"))
  2636. StyleSetFaceName (styleNum, val);
  2637.  
  2638. else if (option == _T("fore"))
  2639. StyleSetForeground (styleNum, wxColourFromSpec (val));
  2640.  
  2641. else if (option == _T("back"))
  2642. StyleSetBackground (styleNum, wxColourFromSpec (val));
  2643. }
  2644. }
  2645.  
  2646.  
  2647. // Set style size, face, bold, italic, and underline attributes from
  2648. // a wxFont's attributes.
  2649. void wxScintilla::StyleSetFont (int styleNum, wxFont& font) {
  2650. #ifdef __WXGTK__
  2651. // Ensure that the native font is initialized
  2652. int x, y;
  2653. GetTextExtent (_T("X"), &x, &y, NULL, NULL, &font);
  2654. #endif
  2655. int size = font.GetPointSize();
  2656. wxString faceName = font.GetFaceName();
  2657. bool bold = font.GetWeight() == wxBOLD;
  2658. bool italic = font.GetStyle() == wxITALIC;
  2659. bool under = font.GetUnderlined();
  2660. wxFontEncoding encoding = font.GetEncoding();
  2661.  
  2662. StyleSetFontAttr (styleNum, size, faceName, bold, italic, under, encoding);
  2663. }
  2664.  
  2665. // Set all font style attributes at once.
  2666. void wxScintilla::StyleSetFontAttr (int styleNum, int size, const wxString& faceName,
  2667. bool bold, bool italic, bool underline,
  2668. wxFontEncoding encoding) {
  2669. StyleSetSize (styleNum, size);
  2670. StyleSetFaceName (styleNum, faceName);
  2671. StyleSetBold (styleNum, bold);
  2672. StyleSetItalic (styleNum, italic);
  2673. StyleSetUnderline (styleNum, underline);
  2674. StyleSetFontEncoding (styleNum, encoding);
  2675. }
  2676.  
  2677. // Set the character set of the font in a style.
  2678. void wxScintilla::StyleSetCharacterSet (int style, int characterSet) {
  2679. wxFontEncoding encoding;
  2680.  
  2681. // Translate the Scintilla characterSet to a wxFontEncoding
  2682. switch (characterSet) {
  2683. default:
  2684. case wxSCI_CHARSET_ANSI:
  2685. case wxSCI_CHARSET_DEFAULT:
  2686. encoding = wxFONTENCODING_DEFAULT;
  2687. break;
  2688. case wxSCI_CHARSET_BALTIC:
  2689. encoding = wxFONTENCODING_ISO8859_13;
  2690. break;
  2691. case wxSCI_CHARSET_CHINESEBIG5:
  2692. encoding = wxFONTENCODING_CP950;
  2693. break;
  2694. case wxSCI_CHARSET_EASTEUROPE:
  2695. encoding = wxFONTENCODING_ISO8859_2;
  2696. break;
  2697. case wxSCI_CHARSET_GB2312:
  2698. encoding = wxFONTENCODING_CP936;
  2699. break;
  2700. case wxSCI_CHARSET_GREEK:
  2701. encoding = wxFONTENCODING_ISO8859_7;
  2702. break;
  2703. case wxSCI_CHARSET_HANGUL:
  2704. encoding = wxFONTENCODING_CP949;
  2705. break;
  2706. case wxSCI_CHARSET_MAC:
  2707. encoding = wxFONTENCODING_DEFAULT;
  2708. break;
  2709. case wxSCI_CHARSET_OEM:
  2710. encoding = wxFONTENCODING_DEFAULT;
  2711. break;
  2712. case wxSCI_CHARSET_RUSSIAN:
  2713. encoding = wxFONTENCODING_KOI8;
  2714. break;
  2715. case wxSCI_CHARSET_SHIFTJIS:
  2716. encoding = wxFONTENCODING_CP932;
  2717. break;
  2718. case wxSCI_CHARSET_SYMBOL:
  2719. encoding = wxFONTENCODING_DEFAULT;
  2720. break;
  2721. case wxSCI_CHARSET_TURKISH:
  2722. encoding = wxFONTENCODING_ISO8859_9;
  2723. break;
  2724. case wxSCI_CHARSET_JOHAB:
  2725. encoding = wxFONTENCODING_DEFAULT;
  2726. break;
  2727. case wxSCI_CHARSET_HEBREW:
  2728. encoding = wxFONTENCODING_ISO8859_8;
  2729. break;
  2730. case wxSCI_CHARSET_ARABIC:
  2731. encoding = wxFONTENCODING_ISO8859_6;
  2732. break;
  2733. case wxSCI_CHARSET_VIETNAMESE:
  2734. encoding = wxFONTENCODING_DEFAULT;
  2735. break;
  2736. case wxSCI_CHARSET_THAI:
  2737. encoding = wxFONTENCODING_ISO8859_11;
  2738. break;
  2739. case wxSCI_CHARSET_CYRILLIC:
  2740. encoding = wxFONTENCODING_ISO8859_5;
  2741. break;
  2742. case wxSCI_CHARSET_8859_15:
  2743. encoding = wxFONTENCODING_ISO8859_15;
  2744. break;
  2745. }
  2746.  
  2747. // We just have Scintilla track the wxFontEncoding for us. It gets used
  2748. // in Font::Create in PlatWX.cpp. We add one to the value so that the
  2749. // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
  2750. // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
  2751. // to wxFONENCODING_DEFAULT in Font::Create.
  2752. SendMsg (SCI_STYLESETCHARACTERSET, style, encoding+1);
  2753. }
  2754.  
  2755. // Set the font encoding to be used by a style.
  2756. void wxScintilla::StyleSetFontEncoding(int style, wxFontEncoding encoding) {
  2757. SendMsg (SCI_STYLESETCHARACTERSET, style, encoding+1);
  2758. }
  2759.  
  2760. // Perform one of the operations defined by the wxSCI_CMD_* constants.
  2761. void wxScintilla::CmdKeyExecute (int cmd) {
  2762. SendMsg (cmd);
  2763. }
  2764.  
  2765.  
  2766. // Set the left and right margin in the edit area, measured in pixels.
  2767. void wxScintilla::SetMargins (int left, int right) {
  2768. SetMarginLeft (left);
  2769. SetMarginRight (right);
  2770. }
  2771.  
  2772.  
  2773. // Retrieve the start and end positions of the current selection.
  2774. void wxScintilla::GetSelection (int* startPos, int* endPos) {
  2775. if (startPos != NULL) *startPos = SendMsg (SCI_GETSELECTIONSTART);
  2776. if (endPos != NULL) *endPos = SendMsg (SCI_GETSELECTIONEND);
  2777. }
  2778.  
  2779.  
  2780. // Scroll enough to make the given line visible
  2781. void wxScintilla::ScrollToLine (int line) {
  2782. m_swx->DoScrollToLine (line);
  2783. }
  2784.  
  2785.  
  2786. // Scroll enough to make the given column visible
  2787. void wxScintilla::ScrollToColumn (int column) {
  2788. m_swx->DoScrollToColumn (column);
  2789. }
  2790.  
  2791.  
  2792. bool wxScintilla::SaveFile (const wxString& filename) {
  2793. wxFile file (filename, wxFile::write);
  2794. if (!file.IsOpened()) return false;
  2795.  
  2796. bool success = file.Write (GetText(), *wxConvCurrent);
  2797. if (success) {
  2798. SetSavePoint();
  2799. }
  2800.  
  2801. return success;
  2802. }
  2803.  
  2804. bool wxScintilla::LoadFile (const wxString& filename) {
  2805. wxFile file (filename, wxFile::read);
  2806. if (!file.IsOpened()) return false;
  2807.  
  2808. // get the file size (assume it is not huge file...)
  2809. size_t len = file.Length();
  2810.  
  2811. bool success = false;
  2812. if (len > 0) {
  2813. #if wxUSE_UNICODE
  2814. wxMemoryBuffer buffer (len+1);
  2815. success = (file.Read (buffer.GetData(), len) == (int)len);
  2816. if (success) {
  2817. ((char*)buffer.GetData())[len] = 0;
  2818. SetText (wxString (buffer, *wxConvCurrent, len));
  2819. }
  2820. #else
  2821. wxString buffer;
  2822. success = (file.Read (wxStringBuffer (buffer, len), len) == (int)len);
  2823. if (success) {
  2824. SetText (buffer);
  2825. }
  2826. #endif
  2827. }else if (len == 0) {
  2828. success = true; // empty file is ok
  2829. SetText (wxEmptyString);
  2830. }else{
  2831. success = false; // len == wxInvalidOffset
  2832. }
  2833.  
  2834. if (success) {
  2835. EmptyUndoBuffer();
  2836. SetSavePoint();
  2837. }
  2838.  
  2839. return success;
  2840. }
  2841.  
  2842.  
  2843. #if SCI_USE_DND
  2844. wxDragResult wxScintilla::DoDragOver (wxCoord x, wxCoord y, wxDragResult def) {
  2845. return m_swx->DoDragOver (x, y, def);
  2846. }
  2847.  
  2848. bool wxScintilla::DoDropText (long x, long y, const wxString& data) {
  2849. return m_swx->DoDropText (x, y, data);
  2850. }
  2851.  
  2852. wxDragResult wxScintilla::DoDragEnter (wxCoord x, wxCoord y, wxDragResult def) {
  2853. return m_swx->DoDragOver (x, y, def);
  2854. }
  2855.  
  2856. void wxScintilla::DoDragLeave () {
  2857. m_swx->DoDragLeave ();
  2858. }
  2859. #endif
  2860.  
  2861.  
  2862. void wxScintilla::SetUseAntiAliasing (bool useAA) {
  2863. m_swx->SetUseAntiAliasing (useAA);
  2864. }
  2865.  
  2866. bool wxScintilla::GetUseAntiAliasing() {
  2867. return m_swx->GetUseAntiAliasing();
  2868. }
  2869.  
  2870. #if wxCHECK_VERSION(2, 5, 0)
  2871. // Raw text handling for UTF-8
  2872. void wxScintilla::AddTextRaw (const char* text) {
  2873. SendMsg (SCI_ADDTEXT, strlen(text), (long)text);
  2874. }
  2875.  
  2876. void wxScintilla::InsertTextRaw (int pos, const char* text) {
  2877. SendMsg (SCI_INSERTTEXT, pos, (long)text);
  2878. }
  2879.  
  2880. wxCharBuffer wxScintilla::GetCurLineRaw (int* linePos) {
  2881. int len = LineLength (GetCurrentLine());
  2882. if (!len) {
  2883. if (linePos) *linePos = 0;
  2884. wxCharBuffer empty;
  2885. return empty;
  2886. }
  2887. wxCharBuffer buf(len);
  2888. int pos = SendMsg (SCI_GETCURLINE, len, (long)buf.data());
  2889. if (linePos) *linePos = pos;
  2890. return buf;
  2891. }
  2892.  
  2893. wxCharBuffer wxScintilla::GetLineRaw (int line) {
  2894. int len = LineLength (line);
  2895. if (!len) {
  2896. wxCharBuffer empty;
  2897. return empty;
  2898. }
  2899. wxCharBuffer buf(len);
  2900. SendMsg (SCI_GETLINE, line, (long)buf.data());
  2901. return buf;
  2902. }
  2903.  
  2904. wxCharBuffer wxScintilla::GetSelectedTextRaw() {
  2905. int start;
  2906. int end;
  2907. GetSelection (&start, &end);
  2908. int len = end - start;
  2909. if (!len) {
  2910. wxCharBuffer empty;
  2911. return empty;
  2912. }
  2913. wxCharBuffer buf(len);
  2914. SendMsg (SCI_GETSELTEXT, 0, (long)buf.data());
  2915. return buf;
  2916. }
  2917.  
  2918. wxCharBuffer wxScintilla::GetTextRangeRaw (int startPos, int endPos) {
  2919. if (endPos < startPos) {
  2920. int temp = startPos;
  2921. startPos = endPos;
  2922. endPos = temp;
  2923. }
  2924. int len = endPos - startPos;
  2925. if (!len) {
  2926. wxCharBuffer empty;
  2927. return empty;
  2928. }
  2929. wxCharBuffer buf(len);
  2930. TextRange tr;
  2931. tr.lpstrText = buf.data();
  2932. tr.chrg.cpMin = startPos;
  2933. tr.chrg.cpMax = endPos;
  2934. SendMsg (SCI_GETTEXTRANGE, 0, (long)&tr);
  2935. return buf;
  2936. }
  2937.  
  2938. void wxScintilla::SetTextRaw (const char* text) {
  2939. SendMsg (SCI_SETTEXT, 0, (long)text);
  2940. }
  2941.  
  2942. wxCharBuffer wxScintilla::GetTextRaw() {
  2943. int len = GetTextLength();
  2944. wxCharBuffer buf(len);
  2945. SendMsg (SCI_GETTEXT, len, (long)buf.data());
  2946. return buf;
  2947. }
  2948.  
  2949. void wxScintilla::AppendTextRaw (const char* text) {
  2950. SendMsg (SCI_APPENDTEXT, strlen(text), (long)text);
  2951. }
  2952. #endif
  2953.  
  2954.  
  2955. //----------------------------------------------------------------------
  2956. // Event handlers
  2957.  
  2958. void wxScintilla::OnPaint (wxPaintEvent& WXUNUSED(evt)) {
  2959. wxPaintDC dc(this);
  2960. m_swx->DoPaint (&dc, GetUpdateRegion().GetBox());
  2961. }
  2962.  
  2963. void wxScintilla::OnScrollWin (wxScrollWinEvent& evt) {
  2964. if (evt.GetOrientation() == wxHORIZONTAL)
  2965. m_swx->DoHScroll (evt.GetEventType(), evt.GetPosition());
  2966. else
  2967. m_swx->DoVScroll (evt.GetEventType(), evt.GetPosition());
  2968. }
  2969.  
  2970. void wxScintilla::OnScroll (wxScrollEvent& evt) {
  2971. wxScrollBar* sb = wxDynamicCast (evt.GetEventObject(), wxScrollBar);
  2972. if (sb) {
  2973. if (sb->IsVertical())
  2974. m_swx->DoVScroll (evt.GetEventType(), evt.GetPosition());
  2975. else
  2976. m_swx->DoHScroll (evt.GetEventType(), evt.GetPosition());
  2977. }
  2978. }
  2979.  
  2980. void wxScintilla::OnSize (wxSizeEvent& WXUNUSED(evt)) {
  2981. if (m_swx) {
  2982. wxSize sz = GetClientSize();
  2983. m_swx->DoSize (sz.x, sz.y);
  2984. }
  2985. }
  2986.  
  2987. void wxScintilla::OnMouseLeftDown (wxMouseEvent& evt) {
  2988. SetFocus();
  2989. wxPoint pt = evt.GetPosition();
  2990. m_swx->DoLeftButtonDown (Point(pt.x, pt.y), m_stopWatch.Time(),
  2991. evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
  2992. }
  2993.  
  2994. void wxScintilla::OnMouseMove (wxMouseEvent& evt) {
  2995. wxPoint pt = evt.GetPosition();
  2996. m_swx->DoLeftButtonMove (Point(pt.x, pt.y));
  2997. }
  2998.  
  2999. void wxScintilla::OnMouseLeftUp (wxMouseEvent& evt) {
  3000. wxPoint pt = evt.GetPosition();
  3001. m_swx->DoLeftButtonUp (Point(pt.x, pt.y), m_stopWatch.Time(),
  3002. evt.ControlDown());
  3003. }
  3004.  
  3005.  
  3006. void wxScintilla::OnMouseRightUp (wxMouseEvent& evt) {
  3007. wxPoint pt = evt.GetPosition();
  3008. m_swx->DoContextMenu (Point(pt.x, pt.y));
  3009. }
  3010.  
  3011.  
  3012. void wxScintilla::OnMouseMiddleUp (wxMouseEvent& evt) {
  3013. wxPoint pt = evt.GetPosition();
  3014. m_swx->DoMiddleButtonUp (Point(pt.x, pt.y));
  3015. }
  3016.  
  3017. void wxScintilla::OnContextMenu (wxContextMenuEvent& evt) {
  3018. wxPoint pt = evt.GetPosition();
  3019. ScreenToClient (&pt.x, &pt.y);
  3020. /*
  3021. Show context menu at event point if it's within the window,
  3022. or at caret location if not
  3023. */
  3024. wxHitTest ht = this->HitTest(pt);
  3025. if (ht != wxHT_WINDOW_INSIDE) {
  3026. pt = this->PointFromPosition (this->GetCurrentPos());
  3027. }
  3028. m_swx->DoContextMenu (Point(pt.x, pt.y));
  3029. }
  3030.  
  3031. void wxScintilla::OnMouseWheel (wxMouseEvent& evt) {
  3032. m_swx->DoMouseWheel (evt.GetWheelRotation(),
  3033. evt.GetWheelDelta(),
  3034. evt.GetLinesPerAction(),
  3035. evt.ControlDown(),
  3036. evt.IsPageScroll());
  3037. }
  3038.  
  3039.  
  3040. void wxScintilla::OnChar (wxKeyEvent& evt) {
  3041. // On (some?) non-US keyboards the AltGr key is required to enter some
  3042. // common characters. It comes to us as both Alt and Ctrl down so we need
  3043. // to let the char through in that case, otherwise if only ctrl or only
  3044. // alt let's skip it.
  3045. bool ctrl = evt.ControlDown();
  3046. #ifdef __WXMAC__
  3047. // On the Mac the Alt key is just a modifier key (like Shift) so we need
  3048. // to allow the char events to be processed when Alt is pressed.
  3049. // TODO: Should we check MetaDown instead in this case?
  3050. bool alt = false;
  3051. #else
  3052. bool alt = evt.AltDown();
  3053. #endif
  3054. bool skip = ((ctrl || alt) && ! (ctrl && alt));
  3055.  
  3056. if (!m_lastKeyDownConsumed && !skip) {
  3057. #if wxUSE_UNICODE
  3058. #if !wxCHECK_VERSION(2, 5, 0)
  3059. int key = evt.m_rawCode;
  3060. #else
  3061. int key = evt.GetUnicodeKey();
  3062. #endif
  3063. bool keyOk = true;
  3064.  
  3065. // if the unicode key code is not really a unicode character (it may
  3066. // be a function key or etc., the platforms appear to always give us a
  3067. // small value in this case) then fallback to the ascii key code but
  3068. // don't do anything for function keys or etc.
  3069. if (key <= 127) {
  3070. key = evt.GetKeyCode();
  3071. keyOk = (key <= 127);
  3072. }
  3073. if (keyOk) {
  3074. m_swx->DoAddChar (key);
  3075. return;
  3076. }
  3077. #else
  3078. int key = evt.GetKeyCode();
  3079. #if !wxCHECK_VERSION(2, 5, 0)
  3080. if ( (key <= WXK_START || key > WXK_NUMPAD_DIVIDE)) {
  3081. #else
  3082. if ( (key <= WXK_START || key > WXK_COMMAND)) {
  3083. #endif
  3084. m_swx->DoAddChar (key);
  3085. return;
  3086. }
  3087. #endif
  3088. }
  3089. evt.Skip();
  3090. }
  3091.  
  3092. void wxScintilla::OnKeyDown (wxKeyEvent& evt) {
  3093. int processed = m_swx->DoKeyDown (evt, &m_lastKeyDownConsumed);
  3094. if (!processed && !m_lastKeyDownConsumed) {
  3095. evt.Skip();
  3096. }
  3097. }
  3098.  
  3099. void wxScintilla::OnLoseFocus (wxFocusEvent& evt) {
  3100. m_swx->DoLoseFocus();
  3101. evt.Skip();
  3102. }
  3103.  
  3104.  
  3105. void wxScintilla::OnGainFocus (wxFocusEvent& evt) {
  3106. m_swx->DoGainFocus();
  3107. evt.Skip();
  3108. }
  3109.  
  3110.  
  3111. void wxScintilla::OnSysColourChanged (wxSysColourChangedEvent& WXUNUSED(evt)) {
  3112. m_swx->DoSysColourChange();
  3113. }
  3114.  
  3115.  
  3116. void wxScintilla::OnEraseBackground (wxEraseEvent& WXUNUSED(evt)) {
  3117. // do nothing to help avoid flashing
  3118. }
  3119.  
  3120.  
  3121.  
  3122. void wxScintilla::OnMenu (wxCommandEvent& evt) {
  3123. m_swx->DoCommand (evt.GetId());
  3124. }
  3125.  
  3126.  
  3127. void wxScintilla::OnListBox (wxCommandEvent& WXUNUSED(evt)) {
  3128. m_swx->DoOnListBox ();
  3129. }
  3130.  
  3131.  
  3132. void wxScintilla::OnIdle (wxIdleEvent& evt) {
  3133. m_swx->DoOnIdle (evt);
  3134. }
  3135.  
  3136.  
  3137. wxSize wxScintilla::DoGetBestSize() const
  3138. {
  3139. // What would be the best size for a wxSintilla?
  3140. // Just give a reasonable minimum until something else can be figured out.
  3141. return wxSize(600,440);
  3142. }
  3143.  
  3144.  
  3145. //----------------------------------------------------------------------
  3146. // Turn notifications from Scintilla into events
  3147.  
  3148.  
  3149. void wxScintilla::NotifyChange() {
  3150. wxScintillaEvent evt (wxEVT_SCI_CHANGE, GetId());
  3151. evt.SetEventObject (this);
  3152. GetEventHandler()->ProcessEvent(evt);
  3153. }
  3154.  
  3155. static void SetEventText (wxScintillaEvent& evt, const char* text, size_t length) {
  3156. if(!text) return;
  3157. evt.SetText(sci2wx(text, length));
  3158. }
  3159.  
  3160. void wxScintilla::NotifyParent (SCNotification* _scn) {
  3161. SCNotification& scn = *_scn;
  3162. wxScintillaEvent evt (0, GetId());
  3163. evt.SetEventObject (this);
  3164. evt.SetPosition (scn.position);
  3165. evt.SetKey (scn.ch);
  3166. evt.SetModifiers (scn.modifiers);
  3167.  
  3168. switch (scn.nmhdr.code) {
  3169. case SCN_STYLENEEDED:
  3170. evt.SetEventType (wxEVT_SCI_STYLENEEDED);
  3171. break;
  3172.  
  3173. case SCN_CHARADDED:
  3174. evt.SetEventType (wxEVT_SCI_CHARADDED);
  3175. break;
  3176.  
  3177. case SCN_SAVEPOINTREACHED:
  3178. evt.SetEventType (wxEVT_SCI_SAVEPOINTREACHED);
  3179. break;
  3180.  
  3181. case SCN_SAVEPOINTLEFT:
  3182. evt.SetEventType (wxEVT_SCI_SAVEPOINTLEFT);
  3183. break;
  3184.  
  3185. case SCN_MODIFYATTEMPTRO:
  3186. evt.SetEventType (wxEVT_SCI_ROMODIFYATTEMPT);
  3187. break;
  3188.  
  3189. case SCN_KEY:
  3190. evt.SetEventType (wxEVT_SCI_KEY);
  3191. break;
  3192.  
  3193. case SCN_DOUBLECLICK:
  3194. evt.SetEventType (wxEVT_SCI_DOUBLECLICK);
  3195. break;
  3196.  
  3197. case SCN_UPDATEUI:
  3198. evt.SetEventType (wxEVT_SCI_UPDATEUI);
  3199. break;
  3200.  
  3201. case SCN_MODIFIED:
  3202. evt.SetEventType (wxEVT_SCI_MODIFIED);
  3203. evt.SetModificationType (scn.modificationType);
  3204. SetEventText (evt, scn.text, scn.length);
  3205. evt.SetLength (scn.length);
  3206. evt.SetLinesAdded (scn.linesAdded);
  3207. evt.SetLine (scn.line);
  3208. evt.SetFoldLevelNow (scn.foldLevelNow);
  3209. evt.SetFoldLevelPrev (scn.foldLevelPrev);
  3210. break;
  3211.  
  3212. case SCN_MACRORECORD:
  3213. evt.SetEventType (wxEVT_SCI_MACRORECORD);
  3214. evt.SetMessage (scn.message);
  3215. evt.SetWParam (scn.wParam);
  3216. evt.SetLParam (scn.lParam);
  3217. break;
  3218.  
  3219. case SCN_MARGINCLICK:
  3220. evt.SetEventType (wxEVT_SCI_MARGINCLICK);
  3221. evt.SetMargin (scn.margin);
  3222. break;
  3223.  
  3224. case SCN_NEEDSHOWN:
  3225. evt.SetEventType (wxEVT_SCI_NEEDSHOWN);
  3226. evt.SetLength (scn.length);
  3227. break;
  3228.  
  3229. case SCN_PAINTED:
  3230. evt.SetEventType (wxEVT_SCI_PAINTED);
  3231. break;
  3232.  
  3233. case SCN_USERLISTSELECTION:
  3234. evt.SetEventType (wxEVT_SCI_USERLISTSELECTION);
  3235. evt.SetListType (scn.listType);
  3236. SetEventText (evt, scn.text, strlen(scn.text));
  3237. break;
  3238.  
  3239. case SCN_URIDROPPED:
  3240. evt.SetEventType (wxEVT_SCI_URIDROPPED);
  3241. SetEventText (evt, scn.text, strlen(scn.text));
  3242. break;
  3243.  
  3244. case SCN_DWELLSTART:
  3245. evt.SetEventType (wxEVT_SCI_DWELLSTART);
  3246. evt.SetX (scn.x);
  3247. evt.SetY (scn.y);
  3248. break;
  3249.  
  3250. case SCN_DWELLEND:
  3251. evt.SetEventType (wxEVT_SCI_DWELLEND);
  3252. evt.SetX (scn.x);
  3253. evt.SetY (scn.y);
  3254. break;
  3255.  
  3256. case SCN_ZOOM:
  3257. evt.SetEventType (wxEVT_SCI_ZOOM);
  3258. break;
  3259.  
  3260. case SCN_HOTSPOTCLICK:
  3261. evt.SetEventType (wxEVT_SCI_HOTSPOT_CLICK);
  3262. break;
  3263.  
  3264. case SCN_HOTSPOTDOUBLECLICK:
  3265. evt.SetEventType (wxEVT_SCI_HOTSPOT_DCLICK);
  3266. break;
  3267.  
  3268. case SCN_CALLTIPCLICK:
  3269. evt.SetEventType (wxEVT_SCI_CALLTIP_CLICK);
  3270. break;
  3271.  
  3272. case SCN_AUTOCSELECTION:
  3273. evt.SetEventType (wxEVT_SCI_AUTOCOMP_SELECTION);
  3274. break;
  3275.  
  3276. default:
  3277. return;
  3278. }
  3279.  
  3280. GetEventHandler()->ProcessEvent (evt);
  3281. }
  3282.  
  3283.  
  3284. //----------------------------------------------------------------------
  3285. //----------------------------------------------------------------------
  3286. //----------------------------------------------------------------------
  3287.  
  3288. wxScintillaEvent::wxScintillaEvent (wxEventType commandType, int id)
  3289. : wxCommandEvent (commandType, id) {
  3290. m_position = 0;
  3291. m_key = 0;
  3292. m_modifiers = 0;
  3293. m_modificationType = 0;
  3294. m_length = 0;
  3295. m_linesAdded = 0;
  3296. m_line = 0;
  3297. m_foldLevelNow = 0;
  3298. m_foldLevelPrev = 0;
  3299. m_margin = 0;
  3300. m_message = 0;
  3301. m_wParam = 0;
  3302. m_lParam = 0;
  3303. m_listType = 0;
  3304. m_x = 0;
  3305. m_y = 0;
  3306. m_dragAllowMove = FALSE;
  3307. #if wxUSE_DRAG_AND_DROP
  3308. m_dragResult = wxDragNone;
  3309. #endif
  3310. }
  3311.  
  3312. bool wxScintillaEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
  3313. bool wxScintillaEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
  3314. bool wxScintillaEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
  3315.  
  3316.  
  3317. wxScintillaEvent::wxScintillaEvent (const wxScintillaEvent& event)
  3318. : wxCommandEvent(event) {
  3319. m_position = event.m_position;
  3320. m_key = event.m_key;
  3321. m_modifiers = event.m_modifiers;
  3322. m_modificationType = event.m_modificationType;
  3323. m_text = event.m_text;
  3324. m_length = event.m_length;
  3325. m_linesAdded = event.m_linesAdded;
  3326. m_line = event.m_line;
  3327. m_foldLevelNow = event.m_foldLevelNow;
  3328. m_foldLevelPrev = event.m_foldLevelPrev;
  3329. m_margin = event.m_margin;
  3330. m_message = event.m_message;
  3331. m_wParam = event.m_wParam;
  3332. m_lParam = event.m_lParam;
  3333. m_listType = event.m_listType;
  3334. m_x = event.m_x;
  3335. m_y = event.m_y;
  3336. m_dragText = event.m_dragText;
  3337. m_dragAllowMove = event.m_dragAllowMove;
  3338. #if wxUSE_DRAG_AND_DROP
  3339. m_dragResult = event.m_dragResult;
  3340. #endif
  3341. }
  3342.  
  3343. //----------------------------------------------------------------------
  3344. //----------------------------------------------------------------------
  3345.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement