From ec235918df48427817521d6df9fde4cbe56c82d7 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Thu, 28 Aug 2003 23:06:27 +0000 Subject: verbose setting on theme warnings --- src/FbTk/Theme.cc | 75 ++++++++++++++++++++++++++----------------------------- src/FbTk/Theme.hh | 9 ++++++- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc index 4afb7eb..ed7ba73 100644 --- a/src/FbTk/Theme.cc +++ b/src/FbTk/Theme.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Theme.cc,v 1.16 2003/08/28 15:46:13 fluxgen Exp $ +// $Id: Theme.cc,v 1.17 2003/08/28 23:06:27 fluxgen Exp $ #include "Theme.hh" @@ -78,16 +78,18 @@ void ThemeItem::setDefaultValue() { template <> void ThemeItem::setFromString(const char *str) { if (m_value.load(str) == false) { - cerr<<"FbTk::Theme: Error loading font "<< - ((m_value.isAntialias() || m_value.utf8()) ? "(" : "")<< + if (FbTk::ThemeManager::instance().verbose()) { + cerr<<"FbTk::Theme: Error loading font "<< + ((m_value.isAntialias() || m_value.utf8()) ? "(" : "")<< - (m_value.isAntialias() ? "antialias" : "")<< - (m_value.utf8() ? " utf8" : "")<< + (m_value.isAntialias() ? "antialias" : "")<< + (m_value.utf8() ? " utf8" : "")<< - ((m_value.isAntialias() || m_value.utf8()) ? ") " : "")<< - "for \""<::load() { std::auto_ptr pm(Image::load(pixmap_name, m_tm.screenNum())); if (pm.get() == 0) { - cerr<<"Resource("<pixmap().release(); @@ -175,7 +178,8 @@ void ThemeItem::setDefaultValue() { template <> void ThemeItem::setFromString(const char *str) { if (!m_value.setFromString(str, m_tm.screenNum())) { - cerr<<"FbTk::Theme: Error loading color value for \""< void ThemeItem::load() { } Theme::Theme(int screen_num):m_screen_num(screen_num) { - - if (!ThemeManager::instance().registerTheme(*this)) { - // should it be fatal or not? - cerr<<"FbTk::Theme Warning: Failed to register Theme"<display())) { + m_max_screens(ScreenCount(FbTk::App::instance()->display())), + m_verbose(false) { } @@ -255,8 +252,8 @@ void ThemeManager::loadTheme(Theme &tm) { if (!loadItem(*resource)) { // try fallback resource in theme if (!tm.fallback(*resource)) { - cerr<<"Failed to read theme item: "<name()<name()<setDefaultValue(); } } @@ -295,22 +292,22 @@ std::string ThemeManager::resourceValue(const std::string &name, const std::stri } /* -void ThemeManager::listItems() { - ThemeList::iterator it = m_themelist.begin(); - ThemeList::iterator it_end = m_themelist.end(); - for (; it != it_end; ++it) { - std::list::iterator item = (*it)->itemList().begin(); - std::list::iterator item_end = (*it)->itemList().end(); - for (; item != item_end; ++item) { - cerr<<(*item)->name()<<":"<)) { - cerr<<(*item)->name()<<".pixmap:"<name()<<".color:"<name()<<".colorTo:"<::iterator item = (*it)->itemList().begin(); + std::list::iterator item_end = (*it)->itemList().end(); + for (; item != item_end; ++item) { + cerr<<(*item)->name()<<":"<)) { + cerr<<(*item)->name()<<".pixmap:"<name()<<".color:"<name()<<".colorTo:"<, Theme and ThemeManager which is the base for any theme @@ -106,6 +106,8 @@ public: void remove(ThemeItem &item); virtual bool fallback(ThemeItem_base &base) { return false; } FbTk::Subject &reconfigSig() { return m_reconfig_sig; } + + private: const int m_screen_num; typedef std::list ItemList; @@ -121,11 +123,15 @@ private: class ThemeManager { public: static ThemeManager &instance(); + bool load(const std::string &filename); std::string resourceValue(const std::string &name, const std::string &altname); void loadTheme(Theme &tm); bool loadItem(ThemeItem_base &resource); bool loadItem(ThemeItem_base &resource, const std::string &name, const std::string &altname); + + bool verbose() const { return m_verbose; } + void setVerbose(bool value) { m_verbose = value; } private: ThemeManager(); ~ThemeManager() { } @@ -141,6 +147,7 @@ private: ThemeList m_themelist; const int m_max_screens; XrmDatabaseHelper m_database; + bool m_verbose; }; -- cgit v0.11.2