mostly cosmetic fixes, mainly discovered by 'clang --analyze'

reordering of Resource-related stuff was because of

   "error: explicit specialization of 'getString' after instantiation"

complaints.
This commit is contained in:
Mathias Gumz 2010-05-23 12:25:47 +02:00
parent ff9c68e247
commit fbcdd34b22
9 changed files with 222 additions and 216 deletions

View file

@ -68,7 +68,7 @@ TextureRender::TextureRender(ImageControl &imgctrl,
XColor *_colors, size_t num_colors): XColor *_colors, size_t num_colors):
control(imgctrl), control(imgctrl),
colors(_colors), colors(_colors),
ncolors(ncolors), ncolors(static_cast<int>(num_colors)),
cpc(imgctrl.colorsPerChannel()), cpc(imgctrl.colorsPerChannel()),
cpccpc(cpc * cpc), cpccpc(cpc * cpc),
red(0), green(0), blue(0), red(0), green(0), blue(0),

View file

@ -160,7 +160,7 @@ bool FbWinFrame::setTabMode(TabMode tabmode) {
// reconfigure(); // reconfigure();
} }
return true; return ret;
} }
void FbWinFrame::hide() { void FbWinFrame::hide() {

View file

@ -189,8 +189,10 @@ void IconButton::refreshEverything(bool setup) {
unsigned int w = width(); unsigned int w = width();
unsigned int h = height(); unsigned int h = height();
FbTk::translateSize(orientation(), w, h); FbTk::translateSize(orientation(), w, h);
int iconx = 1, icony = 1; int iconx = 1;
unsigned int neww = w, newh = h; int icony = 1;
unsigned int neww;
unsigned int newh = h;
if (newh > 2*static_cast<unsigned>(icony)) if (newh > 2*static_cast<unsigned>(icony))
newh -= 2*icony; newh -= 2*icony;
else else

View file

@ -458,7 +458,7 @@ bool Keys::addBinding(const string &linebuffer) {
} else if (extractKeyFromString(arg, "move", key)) { } else if (extractKeyFromString(arg, "move", key)) {
type = MotionNotify; 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; type = KeyPress;
// keycode covers the following three two-byte cases: // keycode covers the following three two-byte cases:

View file

@ -48,85 +48,6 @@ using namespace FbTk;
//----------------------------------------------------------------- //-----------------------------------------------------------------
namespace FbTk { namespace FbTk {
template<>
void FbTk::Resource<int>::
setFromString(const char* strval) {
int val;
if (sscanf(strval, "%d", &val)==1)
*this = val;
}
template<>
void FbTk::Resource<string>::
setFromString(const char *strval) {
*this = strval;
}
template<>
void FbTk::Resource<bool>::
setFromString(char const *strval) {
*this = (bool)!strcasecmp(strval, "true");
}
template<>
void FbTk::Resource<vector<WinButton::Type> >::
setFromString(char const *strval) {
vector<string> 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<Fluxbox::TabsAttachArea>::
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<unsigned int>::
setFromString(const char *strval) {
if (sscanf(strval, "%ul", &m_value) != 1)
setDefaultValue();
}
template<>
void FbTk::Resource<long long>::
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<bool>::
getString() const {
return string(**this == true ? "true" : "false");
}
template<> template<>
string FbTk::Resource<int>:: string FbTk::Resource<int>::
getString() const { getString() const {
@ -135,10 +56,37 @@ getString() const {
return string(strval); return string(strval);
} }
template<>
void FbTk::Resource<int>::
setFromString(const char* strval) {
int val;
if (sscanf(strval, "%d", &val)==1)
*this = val;
}
template<> template<>
string FbTk::Resource<string>:: string FbTk::Resource<string>::
getString() const { return **this; } getString() const { return **this; }
template<>
void FbTk::Resource<string>::
setFromString(const char *strval) {
*this = strval;
}
template<>
string FbTk::Resource<bool>::
getString() const {
return string(**this == true ? "true" : "false");
}
template<>
void FbTk::Resource<bool>::
setFromString(char const *strval) {
*this = (bool)!strcasecmp(strval, "true");
}
template<> template<>
string FbTk::Resource<vector<WinButton::Type> >:: string FbTk::Resource<vector<WinButton::Type> >::
@ -173,6 +121,34 @@ getString() const {
return retval; return retval;
} }
template<>
void FbTk::Resource<vector<WinButton::Type> >::
setFromString(char const *strval) {
vector<string> 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<> template<>
string FbTk::Resource<Fluxbox::TabsAttachArea>:: string FbTk::Resource<Fluxbox::TabsAttachArea>::
getString() const { getString() const {
@ -182,6 +158,15 @@ getString() const {
return "Window"; return "Window";
} }
template<>
void FbTk::Resource<Fluxbox::TabsAttachArea>::
setFromString(char const *strval) {
if (strcasecmp(strval, "Titlebar")==0)
m_value= Fluxbox::ATTACH_AREA_TITLEBAR;
else
m_value= Fluxbox::ATTACH_AREA_WINDOW;
}
template<> template<>
string FbTk::Resource<unsigned int>:: string FbTk::Resource<unsigned int>::
getString() const { getString() const {
@ -190,6 +175,14 @@ getString() const {
return string(tmpstr); return string(tmpstr);
} }
template<>
void FbTk::Resource<unsigned int>::
setFromString(const char *strval) {
if (sscanf(strval, "%ul", &m_value) != 1)
setDefaultValue();
}
template<> template<>
string FbTk::Resource<long long>:: string FbTk::Resource<long long>::
getString() const { getString() const {
@ -198,6 +191,20 @@ getString() const {
return string(tmpstr); return string(tmpstr);
} }
template<>
void FbTk::Resource<long long>::
setFromString(const char *strval) {
if (sscanf(strval, "%lld", &m_value) != 1)
setDefaultValue();
}
template<>
string FbTk::Resource<Layer>::
getString() const {
return ::Layer::getString(m_value.getNum());
}
template<> template<>
void FbTk::Resource<Layer>:: void FbTk::Resource<Layer>::
setFromString(const char *strval) { setFromString(const char *strval) {
@ -209,11 +216,12 @@ setFromString(const char *strval) {
setDefaultValue(); setDefaultValue();
} }
template<> template<>
string FbTk::Resource<Layer>:: string FbTk::Resource<long>::
getString() const { getString() const {
return ::Layer::getString(m_value.getNum()); char tmpstr[128];
sprintf(tmpstr, "%ld", m_value);
return string(tmpstr);
} }
template<> template<>
@ -223,11 +231,4 @@ setFromString(const char *strval) {
setDefaultValue(); setDefaultValue();
} }
template<>
string FbTk::Resource<long>::
getString() const {
char tmpstr[128];
sprintf(tmpstr, "%ld", m_value);
return string(tmpstr);
}
} // end namespace FbTk } // end namespace FbTk

View file

@ -208,37 +208,6 @@ private:
namespace FbTk { namespace FbTk {
template<>
void FbTk::Resource<FbWinFrame::TabPlacement>::
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<> template<>
string FbTk::Resource<FbWinFrame::TabPlacement>:: string FbTk::Resource<FbWinFrame::TabPlacement>::
getString() const { getString() const {
@ -283,6 +252,38 @@ getString() const {
//default string //default string
return string("TopLeft"); return string("TopLeft");
} }
template<>
void FbTk::Resource<FbWinFrame::TabPlacement>::
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 } // end namespace FbTk

View file

@ -133,24 +133,6 @@ bool ScreenPlacement::placeWindow(const FluxboxWindow &win, int head,
////////////////////// Placement Resources ////////////////////// Placement Resources
namespace FbTk { namespace FbTk {
template <>
void FbTk::Resource<ScreenPlacement::PlacementPolicy>::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 <> template <>
std::string FbTk::Resource<ScreenPlacement::PlacementPolicy>::getString() const { std::string FbTk::Resource<ScreenPlacement::PlacementPolicy>::getString() const {
switch (*(*this)) { switch (*(*this)) {
@ -172,16 +154,24 @@ std::string FbTk::Resource<ScreenPlacement::PlacementPolicy>::getString() const
} }
template <> template <>
void FbTk::Resource<ScreenPlacement::RowDirection>::setFromString(const char *str) { void FbTk::Resource<ScreenPlacement::PlacementPolicy>::setFromString(const char *str) {
if (strcasecmp("LeftToRight", str) == 0) if (strcasecmp("RowSmartPlacement", str) == 0)
*(*this) = ScreenPlacement::LEFTRIGHT; *(*this) = ScreenPlacement::ROWSMARTPLACEMENT;
else if (strcasecmp("RightToLeft", str) == 0) else if (strcasecmp("ColSmartPlacement", str) == 0)
*(*this) = ScreenPlacement::RIGHTLEFT; *(*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 else
setDefaultValue(); setDefaultValue();
} }
template <> template <>
std::string FbTk::Resource<ScreenPlacement::RowDirection>::getString() const { std::string FbTk::Resource<ScreenPlacement::RowDirection>::getString() const {
switch (*(*this)) { switch (*(*this)) {
@ -196,14 +186,13 @@ std::string FbTk::Resource<ScreenPlacement::RowDirection>::getString() const {
template <> template <>
void FbTk::Resource<ScreenPlacement::ColumnDirection>::setFromString(const char *str) { void FbTk::Resource<ScreenPlacement::RowDirection>::setFromString(const char *str) {
if (strcasecmp("TopToBottom", str) == 0) if (strcasecmp("LeftToRight", str) == 0)
*(*this) = ScreenPlacement::TOPBOTTOM; *(*this) = ScreenPlacement::LEFTRIGHT;
else if (strcasecmp("BottomToTop", str) == 0) else if (strcasecmp("RightToLeft", str) == 0)
*(*this) = ScreenPlacement::BOTTOMTOP; *(*this) = ScreenPlacement::RIGHTLEFT;
else else
setDefaultValue(); setDefaultValue();
} }
template <> template <>
@ -217,4 +206,16 @@ std::string FbTk::Resource<ScreenPlacement::ColumnDirection>::getString() const
return "TopToBottom"; return "TopToBottom";
} }
template <>
void FbTk::Resource<ScreenPlacement::ColumnDirection>::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 } // end namespace FbTk

View file

@ -89,36 +89,6 @@ using std::dec;
namespace FbTk { namespace FbTk {
template<>
void FbTk::Resource<Slit::Placement>::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<> template<>
string FbTk::Resource<Slit::Placement>::getString() const { string FbTk::Resource<Slit::Placement>::getString() const {
switch (m_value) { switch (m_value) {
@ -163,6 +133,36 @@ string FbTk::Resource<Slit::Placement>::getString() const {
return string("RightBottom"); return string("RightBottom");
} }
template<>
void FbTk::Resource<Slit::Placement>::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 } // end namespace FbTk
namespace { namespace {

View file

@ -79,37 +79,6 @@ using std::list;
namespace FbTk { namespace FbTk {
template<>
void FbTk::Resource<Toolbar::Placement>::
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<> template<>
string FbTk::Resource<Toolbar::Placement>:: string FbTk::Resource<Toolbar::Placement>::
getString() const { getString() const {
@ -154,6 +123,38 @@ getString() const {
//default string //default string
return string("BottomCenter"); return string("BottomCenter");
} }
template<>
void FbTk::Resource<Toolbar::Placement>::
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 } // end namespace FbTk
namespace { namespace {