]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/stattext.cpp
xti additions / changes, trying to reduce dependencies
[wxWidgets.git] / src / msw / stattext.cpp
index 6a2056e2afd2f838da72701f0df655df317600cb..83b4a2818839cdd68b49f1c64571e39f2b3187af 100644 (file)
@@ -5,11 +5,11 @@
 // Modified by:
 // Created:     04/01/98
 // RCS-ID:      $Id$
-// Copyright:   (c) Julian Smart and Markus Holzem
-// Licence:     wxWindows license
+// Copyright:   (c) Julian Smart
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
 #pragma implementation "stattext.h"
 #endif
 
 #include "wx/msw/private.h"
 #include <stdio.h>
 
+#if wxUSE_EXTENDED_RTTI
+IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticText, wxControl,"wx/stattext.h")
+
+WX_BEGIN_PROPERTIES_TABLE(wxStaticText)
+       WX_PROPERTY( Label,wxString, SetLabel, GetLabel, wxEmptyString )
+WX_END_PROPERTIES_TABLE()
+
+WX_BEGIN_HANDLERS_TABLE(wxStaticText)
+WX_END_HANDLERS_TABLE()
+
+WX_CONSTRUCTOR_6( wxStaticText , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle ) 
+#else
 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
+#endif
 
 bool wxStaticText::Create(wxWindow *parent,
                           wxWindowID id,
@@ -51,6 +64,11 @@ bool wxStaticText::Create(wxWindow *parent,
     return TRUE;
 }
 
+wxBorder wxStaticText::GetDefaultBorder() const
+{
+    return wxBORDER_NONE;
+}
+
 WXDWORD wxStaticText::MSWGetStyle(long style, WXDWORD *exstyle) const
 {
     WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle);
@@ -76,10 +94,15 @@ wxSize wxStaticText::DoGetBestSize() const
     int widthTextMax = 0, widthLine,
         heightTextTotal = 0, heightLineDefault = 0, heightLine = 0;
 
+    bool lastWasAmpersand = FALSE;
+
     wxString curLine;
-    for ( const wxChar *pc = text; ; pc++ ) {
-        if ( *pc == wxT('\n') || *pc == wxT('\0') ) {
-            if ( !curLine ) {
+    for ( const wxChar *pc = text; ; pc++ )
+    {
+        if ( *pc == wxT('\n') || *pc == wxT('\0') )
+        {
+            if ( !curLine )
+            {
                 // we can't use GetTextExtent - it will return 0 for both width
                 // and height and an empty line should count in height
                 // calculation
@@ -90,22 +113,44 @@ wxSize wxStaticText::DoGetBestSize() const
 
                 heightTextTotal += heightLineDefault;
             }
-            else {
+            else
+            {
                 GetTextExtent(curLine, &widthLine, &heightLine);
                 if ( widthLine > widthTextMax )
                     widthTextMax = widthLine;
                 heightTextTotal += heightLine;
             }
 
-            if ( *pc == wxT('\n') ) {
+            if ( *pc == wxT('\n') )
+            {
                curLine.Empty();
             }
-            else {
+            else
+            {
                // the end of string
                break;
             }
         }
-        else {
+        else
+        {
+            // we shouldn't take into account the '&' which just introduces the
+            // mnemonic characters and so are not shown on the screen -- except
+            // when it is preceded by another '&' in which case it stands for a
+            // literal ampersand
+            if ( *pc == _T('&') )
+            {
+                if ( !lastWasAmpersand )
+                {
+                    lastWasAmpersand = TRUE;
+
+                    // skip the statement adding pc to curLine below
+                    continue;
+                }
+
+                // it is a literal ampersand
+                lastWasAmpersand = FALSE;
+            }
+
             curLine += *pc;
         }
     }