summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2002-08-08 23:07:24 +0000
committerDana Jansens <danakj@orodu.net>2002-08-08 23:07:24 +0000
commit01096f867493aed2efc2694c986811404288c1f1 (patch)
tree69be448dffccea605007a2c254c22ac6a2ac9d90 /util
parent2d5e1c55f132a0a834eb28146fe60c8e2ca8e665 (diff)
sync with blackbox-cvs
Diffstat (limited to 'util')
-rw-r--r--util/bsetroot.cc38
-rw-r--r--util/bsetroot.hh3
2 files changed, 34 insertions, 7 deletions
diff --git a/util/bsetroot.cc b/util/bsetroot.cc
index 6f8e122d..21cb3647 100644
--- a/util/bsetroot.cc
+++ b/util/bsetroot.cc
@@ -39,6 +39,8 @@ extern "C" {
#endif // HAVE_STDIO_H
}
+#include <cctype>
+
#include "../src/i18n.hh"
#include "../src/GCCache.hh"
#include "../src/Texture.hh"
@@ -51,8 +53,6 @@ I18n i18n;
bsetroot::bsetroot(int argc, char **argv, char *dpy_name)
: BaseDisplay(argv[0], dpy_name) {
- grad = fore = back = (char *) 0;
-
bool mod = False, sol = False, grd = False;
int mod_x = 0, mod_y = 0;
@@ -115,9 +115,12 @@ bsetroot::bsetroot(int argc, char **argv, char *dpy_name)
for (unsigned int s = 0; s < getNumberOfScreens(); ++s)
img_ctrl[s] = new BImageControl(this, getScreenInfo(s), True);
- if (sol && fore) solid();
- else if (mod && mod_x && mod_y && fore && back) modula(mod_x, mod_y);
- else if (grd && grad && fore && back) gradient();
+ if (sol && ! fore.empty())
+ solid();
+ else if (mod && mod_x && mod_y && ! (fore.empty() || back.empty()))
+ modula(mod_x, mod_y);
+ else if (grd && ! (grad.empty() || fore.empty() || back.empty()))
+ gradient();
else usage();
}
@@ -289,8 +292,31 @@ void bsetroot::modula(int x, int y) {
void bsetroot::gradient(void) {
+ /*
+ we have to be sure that neither raised nor sunken is specified otherwise
+ odd looking borders appear. So we convert to lowercase then look for
+ 'raised' or 'sunken' in the description and erase them. To be paranoid
+ the search is done in a loop.
+ */
+ std::string descr;
+ descr.reserve(grad.size());
+
+ std::string::const_iterator it = grad.begin(), end = grad.end();
+ for (; it != end; ++it)
+ descr += std::tolower(*it);
+
+ std::string::size_type pos;
+ while ((pos = descr.find("raised")) != std::string::npos)
+ descr.erase(pos, 6); // 6 is strlen raised
+
+ while ((pos = descr.find("sunken")) != std::string::npos)
+ descr.erase(pos, 6);
+
+ // now add on 'flat' to prevent the bevels from being added
+ descr += "flat";
+
for (unsigned int screen = 0; screen < getNumberOfScreens(); screen++) {
- BTexture texture(grad, this, screen, img_ctrl[screen]);
+ BTexture texture(descr, this, screen, img_ctrl[screen]);
const ScreenInfo *screen_info = getScreenInfo(screen);
texture.setColor(BColor(fore, this, screen));
diff --git a/util/bsetroot.hh b/util/bsetroot.hh
index 7e09ff26..23e5e3d9 100644
--- a/util/bsetroot.hh
+++ b/util/bsetroot.hh
@@ -27,12 +27,13 @@
#include "../src/BaseDisplay.hh"
#include "../src/Image.hh"
+#include <string>
class bsetroot : public BaseDisplay {
private:
BImageControl **img_ctrl;
- char *fore, *back, *grad;
+ std::string fore, back, grad;
// no copying!!
bsetroot(const bsetroot &);