From 46ea237c383b6d305dfbea77c6bff54c7b73c2b3 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Tue, 19 Aug 2003 21:25:26 +0000 Subject: fixed load item --- src/FbTk/Theme.cc | 31 +++++++++++++++++++++---------- src/FbTk/Theme.hh | 8 ++++++-- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc index 0121eb5..6467fc7 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.11 2003/08/13 09:24:02 fluxgen Exp $ +// $Id: Theme.cc,v 1.12 2003/08/19 21:25:26 fluxgen Exp $ #include "Theme.hh" @@ -245,24 +245,35 @@ void ThemeManager::loadTheme(Theme &tm) { std::list::iterator i_end = tm.itemList().end(); for (; i != i_end; ++i) { ThemeItem_base *resource = *i; - loadItem(*resource); + if (!loadItem(*resource)) { + // try fallback resource in theme + if (!tm.fallback(*resource)) { + cerr<<"Failed to read theme item: "<name()<setDefaultValue(); + } + } } // send reconfiguration signal to theme and listeners } -void ThemeManager::loadItem(ThemeItem_base &resource) { +bool ThemeManager::loadItem(ThemeItem_base &resource) { + return loadItem(resource, resource.name(), resource.altName()); +} + +/// handles resource item loading with specific name/altname +bool ThemeManager::loadItem(ThemeItem_base &resource, const std::string &name, const std::string &alt_name) { XrmValue value; char *value_type; - if (XrmGetResource(*m_database, resource.name().c_str(), - resource.altName().c_str(), &value_type, &value)) { + if (XrmGetResource(*m_database, name.c_str(), + alt_name.c_str(), &value_type, &value)) { resource.setFromString(value.addr); resource.load(); // load additional stuff by the ThemeItem - } else { - cerr<<"Failed to read theme item: "<, Theme and ThemeManager which is the base for any theme @@ -80,6 +80,8 @@ public: inline T *operator->() { return &m_value; } inline const T *operator->() const { return &m_value; } /**@}*/ + + FbTk::Theme &theme() { return m_tm; } private: T m_value; @@ -102,6 +104,7 @@ public: /// remove ThemeItem template 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; @@ -121,7 +124,8 @@ public: bool load(const std::string &filename); std::string resourceValue(const std::string &name, const std::string &altname); void loadTheme(Theme &tm); - void loadItem(ThemeItem_base &resource); + bool loadItem(ThemeItem_base &resource); + bool loadItem(ThemeItem_base &resource, const std::string &name, const std::string &altname); private: ThemeManager(); ~ThemeManager() { } -- cgit v0.11.2