]> git.saurik.com Git - wxWidgets.git/blobdiff - interface/wx/textentry.h
Document wxWindow::Close() return value.
[wxWidgets.git] / interface / wx / textentry.h
index 330b00efa1d30b257cd8799c38497a7fbc55d29c..790f08242f8e38a2fcadb4061298bce48566a5e7 100644 (file)
@@ -8,6 +8,13 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
+
+/**
+    wxTextPos is a position in the text
+*/
+typedef long wxTextPos;
+
+
 /**
     @class wxTextEntry
 
 /**
     @class wxTextEntry
 
@@ -204,19 +211,28 @@ public:
 
         This is defined as the zero based index of the character position to
         the right of the insertion point. For example, if the insertion point
 
         This is defined as the zero based index of the character position to
         the right of the insertion point. For example, if the insertion point
-        is at the end of the single-line text control, it is equal to both
-        GetLastPosition() and @c "GetValue().Length()" (but notice that the latter
-        equality is not necessarily true for multiline edit controls which may
-        use multiple new line characters).
+        is at the end of the single-line text control, it is equal to
+        GetLastPosition().
+
+        Notice that insertion position is, in general, different from the index
+        of the character the cursor position at in the string returned by
+        GetValue(). While this is always the case for the single line controls,
+        multi-line controls can use two characters @c "\\r\\n" as line
+        separator (this is notably the case under MSW) meaning that indices in
+        the control and its string value are offset by 1 for every line.
 
 
-        The following code snippet safely returns the character at the insertion
-        point or the zero character if the point is at the end of the control.
+        Hence to correctly get the character at the current cursor position,
+        taking into account that there can be none if the cursor is at the end
+        of the string, you could do the following:
 
         @code
 
         @code
-        char GetCurrentChar(wxTextCtrl *tc) {
-            if (tc->GetInsertionPoint() == tc->GetLastPosition())
-            return '\0';
-            return tc->GetValue[tc->GetInsertionPoint()];
+        wxString GetCurrentChar(wxTextCtrl *tc)
+        {
+            long pos = tc->GetInsertionPoint();
+            if ( pos == tc->GetLastPosition() )
+                return wxString();
+
+            return tc->GetRange(pos, pos + 1);
         }
         @endcode
     */
         }
         @endcode
     */
@@ -440,6 +456,10 @@ public:
             currently you should avoid calling methods such as WriteText() or
             Replace() when using hints and the text control is empty.
 
             currently you should avoid calling methods such as WriteText() or
             Replace() when using hints and the text control is empty.
 
+        @remarks Hints can only be used for single line text controls,
+            native multi-line text controls don't support hints under any
+            platform and hence wxWidgets doesn't provide them neither.
+
         @since 2.9.0
      */
     virtual bool SetHint(const wxString& hint);
         @since 2.9.0
      */
     virtual bool SetHint(const wxString& hint);