CComponentsText: add bool as return value for setTextFromFile()

This commit is contained in:
2013-04-24 00:43:55 +02:00
parent 3e0636a617
commit cc63773920
2 changed files with 6 additions and 4 deletions

View File

@@ -213,7 +213,7 @@ class CComponentsText : public CComponentsItem
virtual void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); virtual void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual void setText(const int digit, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); virtual void setText(const int digit, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual void setTextFromFile(const std::string& path_to_textfile, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL); virtual bool setTextFromFile(const std::string& path_to_textfile, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
virtual void removeLineBreaks(std::string& str); virtual void removeLineBreaks(std::string& str);
//get a Text Box object, so it's possible to get access directly to its methods //get a Text Box object, so it's possible to get access directly to its methods

View File

@@ -191,8 +191,8 @@ void CComponentsText::setText(const int digit, const int mode, Font* font_text)
#endif #endif
} }
//set text lines directly from a file //set text lines directly from a file, returns true on succsess
void CComponentsText::setTextFromFile(const string& path_to_textfile, const int mode, Font* font_text) bool CComponentsText::setTextFromFile(const string& path_to_textfile, const int mode, Font* font_text)
{ {
string file = path_to_textfile; string file = path_to_textfile;
string txt = ""; string txt = "";
@@ -200,7 +200,7 @@ void CComponentsText::setTextFromFile(const string& path_to_textfile, const int
ifstream in (file.c_str(), ios::in); ifstream in (file.c_str(), ios::in);
if (!in){ if (!in){
printf("[CComponentsText] [%s - %d] error while open %s -> %s\n", __FUNCTION__, __LINE__, file.c_str(), strerror(errno)); printf("[CComponentsText] [%s - %d] error while open %s -> %s\n", __FUNCTION__, __LINE__, file.c_str(), strerror(errno));
return; return false;
} }
string line; string line;
@@ -210,6 +210,8 @@ void CComponentsText::setTextFromFile(const string& path_to_textfile, const int
in.close(); in.close();
setText(txt, mode, font_text); setText(txt, mode, font_text);
return true;
} }
void CComponentsText::paintText(bool do_save_bg) void CComponentsText::paintText(bool do_save_bg)