X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=otk%2Fstyle.cc;h=a3d21788d5fb8871e36e2af2ccec68997be73e40;hb=24924367f9486b29b8b9fd024781ccb5f9e0e276;hp=6349a6bcf4a23694222f3663e0794b14b37765b6;hpb=fb0dd6cf9a839f9990ac877bf1b3d469d883b463;p=chaz%2Fopenbox diff --git a/otk/style.cc b/otk/style.cc index 6349a6bc..a3d21788 100644 --- a/otk/style.cc +++ b/otk/style.cc @@ -1,10 +1,13 @@ -#ifdef HAVE_CONFIG_H -#include "../config.h" -#endif // HAVE_CONFIG_H +// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- + +#ifdef HAVE_CONFIG_H +# include "../config.h" +#endif #include -#include "display.hh" +#include +#include "display.hh" #include "util.hh" #include "style.hh" @@ -155,32 +158,6 @@ void Style::load(const Configuration &style) { } -void Style::doJustify(const std::string &text, int &start_pos, - unsigned int max_length, - unsigned int modifier) const { - size_t text_len = text.size(); - unsigned int length; - - do { - length = font->measureString(std::string(text, 0, text_len)) + modifier; - } while (length > max_length && text_len-- > 0); - - switch (justify) { - case RightJustify: - start_pos += max_length - length; - break; - - case CenterJustify: - start_pos += (max_length - length) / 2; - break; - - case LeftJustify: - default: - break; - } -} - - void Style::readDatabaseMask(const std::string &rname, PixmapMask &pixmapMask, const Configuration &style) { Window root_window = OBDisplay::screenInfo(screen_number)->getRootWindow(); @@ -256,54 +233,29 @@ BColor Style::readDatabaseColor(const std::string &rname, BFont *Style::readDatabaseFont(const std::string &rbasename, - const Configuration &style) { - std::string fontname; + const Configuration &style) { + std::string fontstring, s; - std::string s; + // XXX: load all this font stuff from the style... - int i; - if (style.getValue(rbasename + "xft.font", s) && - style.getValue(rbasename + "xft.size", i)) { - std::string family = s; - bool bold = False; - bool italic = False; - bool dropShadow = False; - - if (style.getValue(rbasename + "xft.flags", s)) { - if (s.find("bold") != std::string::npos) - bold = True; - if (s.find("italic") != std::string::npos) - italic = True; - if (s.find("shadow") != std::string::npos) - dropShadow = True; - } + bool dropShadow = True; - unsigned char offset = 1; - if (style.getValue(rbasename + "xft.shadow.offset", s)) { - offset = atoi(s.c_str()); //doesn't detect errors - if (offset > CHAR_MAX) - offset = 1; - } - - unsigned char tint = 0x40; - if (style.getValue(rbasename + "xft.shadow.tint", s)) { - tint = atoi(s.c_str()); - } + unsigned char offset = 1; + if (style.getValue(rbasename + "xft.shadow.offset", s)) { + offset = atoi(s.c_str()); //doesn't detect errors + if (offset > CHAR_MAX) + offset = 1; + } - - BFont *b = new BFont(screen_number, family, i, bold, italic, - dropShadow && shadow_fonts, - offset, tint, aa_fonts); - if (b->valid()) - return b; - delete b; + unsigned char tint = 0x40; + if (style.getValue(rbasename + "xft.shadow.tint", s)) { + tint = atoi(s.c_str()); } - if (style.getValue(rbasename + "xft.font", s)) - printf("Unable to load font \"%s\". Exiting\n", s.c_str()); - else - printf("Font not defined by style. Exiting\n"); - exit(2); // can't continue without a font + fontstring = "Arial,Sans-8:bold"; + + // if this fails, it ::exit()'s + return new BFont(screen_number, fontstring, dropShadow, offset, tint); } }