diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc index 73c1a949..116142d6 100644 --- a/src/FbTk/TextureRender.cc +++ b/src/FbTk/TextureRender.cc @@ -68,7 +68,7 @@ TextureRender::TextureRender(ImageControl &imgctrl, XColor *_colors, size_t num_colors): control(imgctrl), colors(_colors), - ncolors(ncolors), + ncolors(static_cast(num_colors)), cpc(imgctrl.colorsPerChannel()), cpccpc(cpc * cpc), red(0), green(0), blue(0), diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 29752529..b311be65 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -160,7 +160,7 @@ bool FbWinFrame::setTabMode(TabMode tabmode) { // reconfigure(); } - return true; + return ret; } void FbWinFrame::hide() { diff --git a/src/IconButton.cc b/src/IconButton.cc index 320918c2..0a506613 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -189,8 +189,10 @@ void IconButton::refreshEverything(bool setup) { unsigned int w = width(); unsigned int h = height(); FbTk::translateSize(orientation(), w, h); - int iconx = 1, icony = 1; - unsigned int neww = w, newh = h; + int iconx = 1; + int icony = 1; + unsigned int neww; + unsigned int newh = h; if (newh > 2*static_cast(icony)) newh -= 2*icony; else diff --git a/src/Keys.cc b/src/Keys.cc index f03dc01d..2b646562 100644 --- a/src/Keys.cc +++ b/src/Keys.cc @@ -458,7 +458,7 @@ bool Keys::addBinding(const string &linebuffer) { } else if (extractKeyFromString(arg, "move", key)) { type = MotionNotify; - } else if (key = FbTk::KeyUtil::getKey(val[argc].c_str())) { // convert from string symbol + } else if ((key = FbTk::KeyUtil::getKey(val[argc].c_str()))) { // convert from string symbol type = KeyPress; // keycode covers the following three two-byte cases: diff --git a/src/Resources.cc b/src/Resources.cc index 60c74613..734cd754 100644 --- a/src/Resources.cc +++ b/src/Resources.cc @@ -48,85 +48,6 @@ using namespace FbTk; //----------------------------------------------------------------- namespace FbTk { -template<> -void FbTk::Resource:: -setFromString(const char* strval) { - int val; - if (sscanf(strval, "%d", &val)==1) - *this = val; -} - -template<> -void FbTk::Resource:: -setFromString(const char *strval) { - *this = strval; -} - -template<> -void FbTk::Resource:: -setFromString(char const *strval) { - *this = (bool)!strcasecmp(strval, "true"); -} - -template<> -void FbTk::Resource >:: -setFromString(char const *strval) { - vector val; - StringUtil::stringtok(val, strval); - //clear old values - m_value.clear(); - - std::string v; - for (size_t i = 0; i < val.size(); i++) { - v = FbTk::StringUtil::toLower(val[i]); - if (v == "maximize") - m_value.push_back(WinButton::MAXIMIZE); - else if (v == "minimize") - m_value.push_back(WinButton::MINIMIZE); - else if (v == "shade") - m_value.push_back(WinButton::SHADE); - else if (v == "stick") - m_value.push_back(WinButton::STICK); - else if (v == "menuIcon") - m_value.push_back(WinButton::MENUICON); - else if (v == "close") - m_value.push_back(WinButton::CLOSE); - } -} - -template<> -void FbTk::Resource:: -setFromString(char const *strval) { - if (strcasecmp(strval, "Titlebar")==0) - m_value= Fluxbox::ATTACH_AREA_TITLEBAR; - else - m_value= Fluxbox::ATTACH_AREA_WINDOW; -} - -template<> -void FbTk::Resource:: -setFromString(const char *strval) { - if (sscanf(strval, "%ul", &m_value) != 1) - setDefaultValue(); -} - -template<> -void FbTk::Resource:: -setFromString(const char *strval) { - if (sscanf(strval, "%lld", &m_value) != 1) - setDefaultValue(); -} - - -//----------------------------------------------------------------- -//---- manipulators for int, bool, and some enums with Resource --- -//----------------------------------------------------------------- -template<> -string FbTk::Resource:: -getString() const { - return string(**this == true ? "true" : "false"); -} - template<> string FbTk::Resource:: getString() const { @@ -135,10 +56,37 @@ getString() const { return string(strval); } +template<> +void FbTk::Resource:: +setFromString(const char* strval) { + int val; + if (sscanf(strval, "%d", &val)==1) + *this = val; +} + template<> string FbTk::Resource:: getString() const { return **this; } +template<> +void FbTk::Resource:: +setFromString(const char *strval) { + *this = strval; +} + + +template<> +string FbTk::Resource:: +getString() const { + return string(**this == true ? "true" : "false"); +} + +template<> +void FbTk::Resource:: +setFromString(char const *strval) { + *this = (bool)!strcasecmp(strval, "true"); +} + template<> string FbTk::Resource >:: @@ -173,6 +121,34 @@ getString() const { return retval; } + + +template<> +void FbTk::Resource >:: +setFromString(char const *strval) { + vector val; + StringUtil::stringtok(val, strval); + //clear old values + m_value.clear(); + + std::string v; + for (size_t i = 0; i < val.size(); i++) { + v = FbTk::StringUtil::toLower(val[i]); + if (v == "maximize") + m_value.push_back(WinButton::MAXIMIZE); + else if (v == "minimize") + m_value.push_back(WinButton::MINIMIZE); + else if (v == "shade") + m_value.push_back(WinButton::SHADE); + else if (v == "stick") + m_value.push_back(WinButton::STICK); + else if (v == "menuIcon") + m_value.push_back(WinButton::MENUICON); + else if (v == "close") + m_value.push_back(WinButton::CLOSE); + } +} + template<> string FbTk::Resource:: getString() const { @@ -182,6 +158,15 @@ getString() const { return "Window"; } +template<> +void FbTk::Resource:: +setFromString(char const *strval) { + if (strcasecmp(strval, "Titlebar")==0) + m_value= Fluxbox::ATTACH_AREA_TITLEBAR; + else + m_value= Fluxbox::ATTACH_AREA_WINDOW; +} + template<> string FbTk::Resource:: getString() const { @@ -190,6 +175,14 @@ getString() const { return string(tmpstr); } +template<> +void FbTk::Resource:: +setFromString(const char *strval) { + if (sscanf(strval, "%ul", &m_value) != 1) + setDefaultValue(); +} + + template<> string FbTk::Resource:: getString() const { @@ -198,6 +191,20 @@ getString() const { return string(tmpstr); } +template<> +void FbTk::Resource:: +setFromString(const char *strval) { + if (sscanf(strval, "%lld", &m_value) != 1) + setDefaultValue(); +} + + +template<> +string FbTk::Resource:: +getString() const { + return ::Layer::getString(m_value.getNum()); +} + template<> void FbTk::Resource:: setFromString(const char *strval) { @@ -209,11 +216,12 @@ setFromString(const char *strval) { setDefaultValue(); } - template<> -string FbTk::Resource:: +string FbTk::Resource:: getString() const { - return ::Layer::getString(m_value.getNum()); + char tmpstr[128]; + sprintf(tmpstr, "%ld", m_value); + return string(tmpstr); } template<> @@ -223,11 +231,4 @@ setFromString(const char *strval) { setDefaultValue(); } -template<> -string FbTk::Resource:: -getString() const { - char tmpstr[128]; - sprintf(tmpstr, "%ld", m_value); - return string(tmpstr); -} } // end namespace FbTk diff --git a/src/Screen.cc b/src/Screen.cc index c2929d03..b712b81f 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -208,37 +208,6 @@ private: namespace FbTk { -template<> -void FbTk::Resource:: -setFromString(const char *strval) { - if (strcasecmp(strval, "TopLeft") == 0) - m_value = FbWinFrame::TOPLEFT; - else if (strcasecmp(strval, "BottomLeft") == 0) - m_value = FbWinFrame::BOTTOMLEFT; - else if (strcasecmp(strval, "Top") == 0) - m_value = FbWinFrame::TOP; - else if (strcasecmp(strval, "Bottom") == 0) - m_value = FbWinFrame::BOTTOM; - else if (strcasecmp(strval, "TopRight") == 0) - m_value = FbWinFrame::TOPRIGHT; - else if (strcasecmp(strval, "BottomRight") == 0) - m_value = FbWinFrame::BOTTOMRIGHT; - else if (strcasecmp(strval, "LeftTop") == 0) - m_value = FbWinFrame::LEFTTOP; - else if (strcasecmp(strval, "Left") == 0) - m_value = FbWinFrame::LEFT; - else if (strcasecmp(strval, "LeftBottom") == 0) - m_value = FbWinFrame::LEFTBOTTOM; - else if (strcasecmp(strval, "RightTop") == 0) - m_value = FbWinFrame::RIGHTTOP; - else if (strcasecmp(strval, "Right") == 0) - m_value = FbWinFrame::RIGHT; - else if (strcasecmp(strval, "RightBottom") == 0) - m_value = FbWinFrame::RIGHTBOTTOM; - else - setDefaultValue(); -} - template<> string FbTk::Resource:: getString() const { @@ -283,6 +252,38 @@ getString() const { //default string return string("TopLeft"); } + +template<> +void FbTk::Resource:: +setFromString(const char *strval) { + if (strcasecmp(strval, "TopLeft") == 0) + m_value = FbWinFrame::TOPLEFT; + else if (strcasecmp(strval, "BottomLeft") == 0) + m_value = FbWinFrame::BOTTOMLEFT; + else if (strcasecmp(strval, "Top") == 0) + m_value = FbWinFrame::TOP; + else if (strcasecmp(strval, "Bottom") == 0) + m_value = FbWinFrame::BOTTOM; + else if (strcasecmp(strval, "TopRight") == 0) + m_value = FbWinFrame::TOPRIGHT; + else if (strcasecmp(strval, "BottomRight") == 0) + m_value = FbWinFrame::BOTTOMRIGHT; + else if (strcasecmp(strval, "LeftTop") == 0) + m_value = FbWinFrame::LEFTTOP; + else if (strcasecmp(strval, "Left") == 0) + m_value = FbWinFrame::LEFT; + else if (strcasecmp(strval, "LeftBottom") == 0) + m_value = FbWinFrame::LEFTBOTTOM; + else if (strcasecmp(strval, "RightTop") == 0) + m_value = FbWinFrame::RIGHTTOP; + else if (strcasecmp(strval, "Right") == 0) + m_value = FbWinFrame::RIGHT; + else if (strcasecmp(strval, "RightBottom") == 0) + m_value = FbWinFrame::RIGHTBOTTOM; + else + setDefaultValue(); +} + } // end namespace FbTk diff --git a/src/ScreenPlacement.cc b/src/ScreenPlacement.cc index a6179565..3e0c3777 100644 --- a/src/ScreenPlacement.cc +++ b/src/ScreenPlacement.cc @@ -132,24 +132,6 @@ bool ScreenPlacement::placeWindow(const FluxboxWindow &win, int head, ////////////////////// Placement Resources namespace FbTk { - -template <> -void FbTk::Resource::setFromString(const char *str) { - if (strcasecmp("RowSmartPlacement", str) == 0) - *(*this) = ScreenPlacement::ROWSMARTPLACEMENT; - else if (strcasecmp("ColSmartPlacement", str) == 0) - *(*this) = ScreenPlacement::COLSMARTPLACEMENT; - else if (strcasecmp("RowMinOverlapPlacement", str) == 0) - *(*this) = ScreenPlacement::ROWMINOVERLAPPLACEMENT; - else if (strcasecmp("ColMinOverlapPlacement", str) == 0) - *(*this) = ScreenPlacement::COLMINOVERLAPPLACEMENT; - else if (strcasecmp("UnderMousePlacement", str) == 0) - *(*this) = ScreenPlacement::UNDERMOUSEPLACEMENT; - else if (strcasecmp("CascadePlacement", str) == 0) - *(*this) = ScreenPlacement::CASCADEPLACEMENT; - else - setDefaultValue(); -} template <> std::string FbTk::Resource::getString() const { @@ -172,16 +154,24 @@ std::string FbTk::Resource::getString() const } template <> -void FbTk::Resource::setFromString(const char *str) { - if (strcasecmp("LeftToRight", str) == 0) - *(*this) = ScreenPlacement::LEFTRIGHT; - else if (strcasecmp("RightToLeft", str) == 0) - *(*this) = ScreenPlacement::RIGHTLEFT; +void FbTk::Resource::setFromString(const char *str) { + if (strcasecmp("RowSmartPlacement", str) == 0) + *(*this) = ScreenPlacement::ROWSMARTPLACEMENT; + else if (strcasecmp("ColSmartPlacement", str) == 0) + *(*this) = ScreenPlacement::COLSMARTPLACEMENT; + else if (strcasecmp("RowMinOverlapPlacement", str) == 0) + *(*this) = ScreenPlacement::ROWMINOVERLAPPLACEMENT; + else if (strcasecmp("ColMinOverlapPlacement", str) == 0) + *(*this) = ScreenPlacement::COLMINOVERLAPPLACEMENT; + else if (strcasecmp("UnderMousePlacement", str) == 0) + *(*this) = ScreenPlacement::UNDERMOUSEPLACEMENT; + else if (strcasecmp("CascadePlacement", str) == 0) + *(*this) = ScreenPlacement::CASCADEPLACEMENT; else setDefaultValue(); - } + template <> std::string FbTk::Resource::getString() const { switch (*(*this)) { @@ -196,14 +186,13 @@ std::string FbTk::Resource::getString() const { template <> -void FbTk::Resource::setFromString(const char *str) { - if (strcasecmp("TopToBottom", str) == 0) - *(*this) = ScreenPlacement::TOPBOTTOM; - else if (strcasecmp("BottomToTop", str) == 0) - *(*this) = ScreenPlacement::BOTTOMTOP; +void FbTk::Resource::setFromString(const char *str) { + if (strcasecmp("LeftToRight", str) == 0) + *(*this) = ScreenPlacement::LEFTRIGHT; + else if (strcasecmp("RightToLeft", str) == 0) + *(*this) = ScreenPlacement::RIGHTLEFT; else setDefaultValue(); - } template <> @@ -217,4 +206,16 @@ std::string FbTk::Resource::getString() const return "TopToBottom"; } + + +template <> +void FbTk::Resource::setFromString(const char *str) { + if (strcasecmp("TopToBottom", str) == 0) + *(*this) = ScreenPlacement::TOPBOTTOM; + else if (strcasecmp("BottomToTop", str) == 0) + *(*this) = ScreenPlacement::BOTTOMTOP; + else + setDefaultValue(); +} + } // end namespace FbTk diff --git a/src/Slit.cc b/src/Slit.cc index fb3da30c..7aaa0965 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -89,36 +89,6 @@ using std::dec; namespace FbTk { -template<> -void FbTk::Resource::setFromString(const char *strval) { - if (strcasecmp(strval, "TopLeft")==0) - m_value = Slit::TOPLEFT; - else if (strcasecmp(strval, "LeftCenter")==0) - m_value = Slit::LEFTCENTER; - else if (strcasecmp(strval, "BottomLeft")==0) - m_value = Slit::BOTTOMLEFT; - else if (strcasecmp(strval, "TopCenter")==0) - m_value = Slit::TOPCENTER; - else if (strcasecmp(strval, "BottomCenter")==0) - m_value = Slit::BOTTOMCENTER; - else if (strcasecmp(strval, "TopRight")==0) - m_value = Slit::TOPRIGHT; - else if (strcasecmp(strval, "RightCenter")==0) - m_value = Slit::RIGHTCENTER; - else if (strcasecmp(strval, "BottomRight")==0) - m_value = Slit::BOTTOMRIGHT; - else if (strcasecmp(strval, "LeftTop")==0) - m_value = Slit::LEFTTOP; - else if (strcasecmp(strval, "LeftBottom")==0) - m_value = Slit::LEFTBOTTOM; - else if (strcasecmp(strval, "RightTop")==0) - m_value = Slit::RIGHTTOP; - else if (strcasecmp(strval, "RightBottom")==0) - m_value = Slit::RIGHTBOTTOM; - else - setDefaultValue(); -} - template<> string FbTk::Resource::getString() const { switch (m_value) { @@ -163,6 +133,36 @@ string FbTk::Resource::getString() const { return string("RightBottom"); } +template<> +void FbTk::Resource::setFromString(const char *strval) { + if (strcasecmp(strval, "TopLeft")==0) + m_value = Slit::TOPLEFT; + else if (strcasecmp(strval, "LeftCenter")==0) + m_value = Slit::LEFTCENTER; + else if (strcasecmp(strval, "BottomLeft")==0) + m_value = Slit::BOTTOMLEFT; + else if (strcasecmp(strval, "TopCenter")==0) + m_value = Slit::TOPCENTER; + else if (strcasecmp(strval, "BottomCenter")==0) + m_value = Slit::BOTTOMCENTER; + else if (strcasecmp(strval, "TopRight")==0) + m_value = Slit::TOPRIGHT; + else if (strcasecmp(strval, "RightCenter")==0) + m_value = Slit::RIGHTCENTER; + else if (strcasecmp(strval, "BottomRight")==0) + m_value = Slit::BOTTOMRIGHT; + else if (strcasecmp(strval, "LeftTop")==0) + m_value = Slit::LEFTTOP; + else if (strcasecmp(strval, "LeftBottom")==0) + m_value = Slit::LEFTBOTTOM; + else if (strcasecmp(strval, "RightTop")==0) + m_value = Slit::RIGHTTOP; + else if (strcasecmp(strval, "RightBottom")==0) + m_value = Slit::RIGHTBOTTOM; + else + setDefaultValue(); +} + } // end namespace FbTk namespace { diff --git a/src/Toolbar.cc b/src/Toolbar.cc index e64d74ec..4ed765ae 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -79,37 +79,6 @@ using std::list; namespace FbTk { -template<> -void FbTk::Resource:: -setFromString(const char *strval) { - if (strcasecmp(strval, "TopLeft")==0) - m_value = Toolbar::TOPLEFT; - else if (strcasecmp(strval, "BottomLeft")==0) - m_value = Toolbar::BOTTOMLEFT; - else if (strcasecmp(strval, "TopCenter")==0) - m_value = Toolbar::TOPCENTER; - else if (strcasecmp(strval, "BottomCenter")==0) - m_value = Toolbar::BOTTOMCENTER; - else if (strcasecmp(strval, "TopRight")==0) - m_value = Toolbar::TOPRIGHT; - else if (strcasecmp(strval, "BottomRight")==0) - m_value = Toolbar::BOTTOMRIGHT; - else if (strcasecmp(strval, "LeftTop") == 0) - m_value = Toolbar::LEFTTOP; - else if (strcasecmp(strval, "LeftCenter") == 0) - m_value = Toolbar::LEFTCENTER; - else if (strcasecmp(strval, "LeftBottom") == 0) - m_value = Toolbar::LEFTBOTTOM; - else if (strcasecmp(strval, "RightTop") == 0) - m_value = Toolbar::RIGHTTOP; - else if (strcasecmp(strval, "RightCenter") == 0) - m_value = Toolbar::RIGHTCENTER; - else if (strcasecmp(strval, "RightBottom") == 0) - m_value = Toolbar::RIGHTBOTTOM; - else - setDefaultValue(); -} - template<> string FbTk::Resource:: getString() const { @@ -154,6 +123,38 @@ getString() const { //default string return string("BottomCenter"); } + +template<> +void FbTk::Resource:: +setFromString(const char *strval) { + if (strcasecmp(strval, "TopLeft")==0) + m_value = Toolbar::TOPLEFT; + else if (strcasecmp(strval, "BottomLeft")==0) + m_value = Toolbar::BOTTOMLEFT; + else if (strcasecmp(strval, "TopCenter")==0) + m_value = Toolbar::TOPCENTER; + else if (strcasecmp(strval, "BottomCenter")==0) + m_value = Toolbar::BOTTOMCENTER; + else if (strcasecmp(strval, "TopRight")==0) + m_value = Toolbar::TOPRIGHT; + else if (strcasecmp(strval, "BottomRight")==0) + m_value = Toolbar::BOTTOMRIGHT; + else if (strcasecmp(strval, "LeftTop") == 0) + m_value = Toolbar::LEFTTOP; + else if (strcasecmp(strval, "LeftCenter") == 0) + m_value = Toolbar::LEFTCENTER; + else if (strcasecmp(strval, "LeftBottom") == 0) + m_value = Toolbar::LEFTBOTTOM; + else if (strcasecmp(strval, "RightTop") == 0) + m_value = Toolbar::RIGHTTOP; + else if (strcasecmp(strval, "RightCenter") == 0) + m_value = Toolbar::RIGHTCENTER; + else if (strcasecmp(strval, "RightBottom") == 0) + m_value = Toolbar::RIGHTBOTTOM; + else + setDefaultValue(); +} + } // end namespace FbTk namespace {