]> git.saurik.com Git - wxWidgets.git/blobdiff - src/stc/gen_iface.py
SWIGged updates for wxMSW
[wxWidgets.git] / src / stc / gen_iface.py
index e198bdc6e0af7d48d44406324283e45e2d8d45bd..4c7d15bcca5b44982c001f0682e805202806a382 100644 (file)
@@ -86,6 +86,11 @@ methodOverrideMap = {
 
                        '''wxString %s(int startPos, int endPos) {
                           wxString text;
 
                        '''wxString %s(int startPos, int endPos) {
                           wxString text;
+                          if (endPos < startPos) {
+                              int temp = startPos;
+                              startPos = endPos;
+                              endPos = temp;
+                          }
                           int len = endPos - startPos;
                           if (!len) return "";
                           TextRange tr;
                           int len = endPos - startPos;
                           if (!len) return "";
                           TextRange tr;
@@ -108,15 +113,19 @@ methodOverrideMap = {
                            0),
 
     'GetCurLine' : (0,
                            0),
 
     'GetCurLine' : (0,
-                    'wxString %s(int* OUTPUT=NULL);',
+                    '#ifdef SWIG\n    wxString %s(int* OUTPUT);\n#else\n    wxString GetCurLine(int* linePos=NULL);\n#endif',
 
                     '''wxString %s(int* linePos) {
                        wxString text;
                        int len = LineLength(GetCurrentLine());
 
                     '''wxString %s(int* linePos) {
                        wxString text;
                        int len = LineLength(GetCurrentLine());
-                       if (!len) return "";
-                       char* buf = text.GetWriteBuf(len);
-
-                       int pos = SendMsg(%s, len, (long)buf);
+                       if (!len) {
+                           if (linePos)  *linePos = 0;
+                           return "";
+                       }
+                       // Need an extra byte because SCI_GETCURLINE writes a null to the string
+                       char* buf = text.GetWriteBuf(len+1);
+
+                       int pos = SendMsg(%s, len+1, (long)buf);
                        text.UngetWriteBuf(len);
                        if (linePos)  *linePos = pos;
 
                        text.UngetWriteBuf(len);
                        if (linePos)  *linePos = pos;
 
@@ -262,6 +271,11 @@ methodOverrideMap = {
                                 wxRect pageRect) {
                             RangeToFormat fr;
 
                                 wxRect pageRect) {
                             RangeToFormat fr;
 
+                            if (endPos < startPos) {
+                                int temp = startPos;
+                                startPos = endPos;
+                                endPos = temp;
+                            }
                             fr.hdc = draw;
                             fr.hdcTarget = target;
                             fr.rc.top = renderRect.GetTop();
                             fr.hdc = draw;
                             fr.hdcTarget = target;
                             fr.rc.top = renderRect.GetTop();
@@ -320,6 +334,11 @@ methodOverrideMap = {
 
                       '''wxString %s(int startPos, int endPos) {
                             wxString text;
 
                       '''wxString %s(int startPos, int endPos) {
                             wxString text;
+                            if (endPos < startPos) {
+                                int temp = startPos;
+                                startPos = endPos;
+                                endPos = temp;
+                            }
                             int   len  = endPos - startPos;
                             if (!len) return "";
                             char* buff = text.GetWriteBuf(len);
                             int   len  = endPos - startPos;
                             if (!len) return "";
                             char* buff = text.GetWriteBuf(len);
@@ -346,11 +365,11 @@ methodOverrideMap = {
 
                  '''wxString %s() {
                         wxString text;
 
                  '''wxString %s() {
                         wxString text;
-                        int   len  = GetTextLength()+1;
-                        char* buff = text.GetWriteBuf(len);
+                        int   len  = GetTextLength();
+                        char* buff = text.GetWriteBuf(len+1);  // leave room for the null...
 
 
-                        SendMsg(%s, len, (long)buff);
-                        text.UngetWriteBuf(len-1);
+                        SendMsg(%s, len+1, (long)buff);
+                        text.UngetWriteBuf(len);
                         return text;''',
 
                  ('Retrieve all the text in the document.', )),
                         return text;''',
 
                  ('Retrieve all the text in the document.', )),
@@ -474,6 +493,9 @@ methodOverrideMap = {
                          0),
 
     'GrabFocus' : (None, 0, 0, 0),
                          0),
 
     'GrabFocus' : (None, 0, 0, 0),
+    'SetFocus'  : ('SetSTCFocus', 0, 0, 0),
+    'GetFocus'  : ('GetSTCFocus', 0, 0, 0),
+
 
     '' : ('', 0, 0, 0),
 
 
     '' : ('', 0, 0, 0),