Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: widgets/EAButton.cpp
- Revision:
- 7:6cf21b018420
- Parent:
- 3:24fbf4dbd7e5
--- a/widgets/EAButton.cpp	Thu May 06 23:32:14 2010 +0000
+++ b/widgets/EAButton.cpp	Mon Nov 01 13:07:40 2010 +0000
@@ -39,47 +39,21 @@
     {
         _manager.deleteHitBox(_box);
         _box = NULL;
-    }
-    
-    if (_text != NULL)
-    {
-        delete[] _text;
-        _text = NULL;
-    }    
+    }   
 }
 
 void EAButton::paint(EALCD& lcd)
 {
     lcd.drawFilledRect(x(), y(), width(), height());
-    if (_text != NULL)
+    if (_text.empty() == false)
     {
         lcd.drawText(x()+10, y()+10, _text);
     }
 }
 
-bool EAButton::setText(char* text)
-{
-    if (text == NULL)
-    {
-        // Invalid text passed in.
-        return false;
-    }
-    
-    // Store the text for later
-    int textLen = strlen(text);
-    
-    // If already have some text then clear to load the new text.
-    if (_text != NULL)
-    {
-        delete[] _text;
-        _text = NULL;
-    }
-    
-    // Now allocate enough space to hold text. Note +1 for null character.
-    _text = new char[textLen+1];
-    
-    // Now copy over passed in text to text variable.
-    strcpy(_text, text);
+bool EAButton::setText(const std::string& text)
+{   
+    _text = text;
     
     return true;
 }