]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/textctrl.cpp
wxID_PREFERENCES added for the preferences menu item
[wxWidgets.git] / src / msw / textctrl.cpp
index 1a4228d9a416cb81784da7af045c94511967e9a7..48067eca29445aa23359105c1033cc3c052c4a2b 100644 (file)
@@ -13,7 +13,7 @@
 // declarations
 // ============================================================================
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
     #pragma implementation "textctrl.h"
 #endif
 
@@ -116,11 +116,75 @@ IMPLEMENT_DYNAMIC_CLASS(wxRichEditModule, wxModule)
 // event tables and other macros
 // ----------------------------------------------------------------------------
 
+#if wxUSE_EXTENDED_RTTI
+WX_DEFINE_FLAGS( wxTextCtrlStyle )
+
+wxBEGIN_FLAGS( wxTextCtrlStyle )
+    // new style border flags, we put them first to
+    // use them for streaming out
+    wxFLAGS_MEMBER(wxBORDER_SIMPLE)
+    wxFLAGS_MEMBER(wxBORDER_SUNKEN)
+    wxFLAGS_MEMBER(wxBORDER_DOUBLE)
+    wxFLAGS_MEMBER(wxBORDER_RAISED)
+    wxFLAGS_MEMBER(wxBORDER_STATIC)
+    wxFLAGS_MEMBER(wxBORDER_NONE)
+    
+    // old style border flags
+    wxFLAGS_MEMBER(wxSIMPLE_BORDER)
+    wxFLAGS_MEMBER(wxSUNKEN_BORDER)
+    wxFLAGS_MEMBER(wxDOUBLE_BORDER)
+    wxFLAGS_MEMBER(wxRAISED_BORDER)
+    wxFLAGS_MEMBER(wxSTATIC_BORDER)
+    wxFLAGS_MEMBER(wxNO_BORDER)
+
+    // standard window styles
+    wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
+    wxFLAGS_MEMBER(wxCLIP_CHILDREN)
+    wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
+    wxFLAGS_MEMBER(wxWANTS_CHARS)
+    wxFLAGS_MEMBER(wxNO_FULL_REPAINT_ON_RESIZE)
+    wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
+    wxFLAGS_MEMBER(wxVSCROLL)
+    wxFLAGS_MEMBER(wxHSCROLL)
+
+    wxFLAGS_MEMBER(wxTE_PROCESS_ENTER)
+    wxFLAGS_MEMBER(wxTE_PROCESS_TAB)
+    wxFLAGS_MEMBER(wxTE_MULTILINE)
+    wxFLAGS_MEMBER(wxTE_PASSWORD)
+    wxFLAGS_MEMBER(wxTE_READONLY)
+    wxFLAGS_MEMBER(wxHSCROLL)
+    wxFLAGS_MEMBER(wxTE_RICH)
+    wxFLAGS_MEMBER(wxTE_RICH2)
+    wxFLAGS_MEMBER(wxTE_AUTO_URL)
+    wxFLAGS_MEMBER(wxTE_NOHIDESEL)
+    wxFLAGS_MEMBER(wxTE_LEFT)
+    wxFLAGS_MEMBER(wxTE_CENTRE)
+    wxFLAGS_MEMBER(wxTE_RIGHT)
+    wxFLAGS_MEMBER(wxTE_DONTWRAP)
+    wxFLAGS_MEMBER(wxTE_LINEWRAP)
+    wxFLAGS_MEMBER(wxTE_WORDWRAP)
+
+wxEND_FLAGS( wxTextCtrlStyle )
+
+IMPLEMENT_DYNAMIC_CLASS_XTI(wxTextCtrl, wxControl,"wx/textctrl.h")
+
+wxBEGIN_PROPERTIES_TABLE(wxTextCtrl)
+    wxEVENT_PROPERTY( TextUpdated , wxEVT_COMMAND_TEXT_UPDATED , wxCommandEvent ) 
+    wxEVENT_PROPERTY( TextEnter , wxEVT_COMMAND_TEXT_ENTER , wxCommandEvent )
+
+    wxPROPERTY( Font , wxFont , SetFont , GetFont  ,, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
+       wxPROPERTY( Value , wxString , SetValue, GetValue, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
+    wxPROPERTY_FLAGS( WindowStyle , wxTextCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
+wxEND_PROPERTIES_TABLE()
+
+wxBEGIN_HANDLERS_TABLE(wxTextCtrl)
+wxEND_HANDLERS_TABLE()
+
+wxCONSTRUCTOR_6( wxTextCtrl , wxWindow* , Parent , wxWindowID , Id , wxString , Value , wxPoint , Position , wxSize , Size , long , WindowStyle)
+#else
 IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
-/*
-       TODO PROPERTIES :
-               value
-*/
+#endif
+
 
 BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
     EVT_CHAR(wxTextCtrl::OnChar)
@@ -1212,8 +1276,28 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
         wxChar *buf = tmp;
 
         *(WORD *)buf = (WORD)len;
-        len = (size_t)::SendMessage(GetHwnd(), EM_GETLINE,
-                                    lineNo, (LPARAM)buf);
+        len = (size_t)::SendMessage(GetHwnd(), EM_GETLINE, lineNo, (LPARAM)buf);
+
+#if wxUSE_RICHEDIT
+        if ( IsRich() )
+        {
+            // remove the '\r' returned by the rich edit control, the user code
+            // should never see it
+            if ( buf[len - 2] == _T('\r') && buf[len - 1] == _T('\n') )
+            {
+                buf[len - 2] = _T('\n');
+                len--;
+            }
+        }
+#endif // wxUSE_RICHEDIT
+
+        // remove the '\n' at the end, if any (this is how this function is
+        // supposed to work according to the docs)
+        if ( buf[len - 1] == _T('\n') )
+        {
+            len--;
+        }
+
         buf[len] = 0;
         tmp.SetLength(len);
     }
@@ -1853,7 +1937,7 @@ bool wxTextCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
             }
             return TRUE;
     }
-    
+
     // not processed, leave it to the base class
     return wxTextCtrlBase::MSWOnNotify(idCtrl, lParam, result);
 }