]> Dogcows Code - chaz/openbox/commitdiff
remove userstring
authorDana Jansens <danakj@orodu.net>
Sun, 12 Jan 2003 23:55:30 +0000 (23:55 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 12 Jan 2003 23:55:30 +0000 (23:55 +0000)
otk/Makefile.am
otk/focuslabel.cc
otk/focuslabel.hh
otk/font.cc
otk/font.hh
otk/label.cc
otk/label.hh
otk/property.cc
otk/property.hh
otk/userstring.hh [deleted file]

index 2ee73c108c6301e8c56c7715d26d5b7b2658f700..dc84e0e273d783e1ea661a31014fb9074c4d8874 100644 (file)
@@ -12,7 +12,7 @@ libotk_la_SOURCES= color.cc display.cc font.cc gccache.cc image.cc \
                   property.cc imagecontrol.cc rect.cc screeninfo.cc \
                   texture.cc timer.cc timerqueuemanager.cc style.cc \
                   configuration.cc util.cc widget.cc focuswidget.cc \
-                  button.cc eventhandler.cc eventdispatcher.cc \
+                  button.cc eventhandler.cc eventdispatcher.cc ustring.cc \
                   label.cc focuslabel.cc application.cc appwidget.cc
 #                  otk_wrap.cc
 
index e82fa1ed75c4b8fb05f18e34d02f284d33aa159c..397a2cac8928b0e113b37fb2b159c8a47980e644 100644 (file)
@@ -41,7 +41,7 @@ void FocusLabel::update(void)
                           : style()->getTextUnfocus());
     unsigned int sidemargin = style()->getBevelWidth() * 2;
 
-    userstring t = _text; // the actual text to draw
+    std::string t = _text; // the actual text to draw
     int x = sidemargin;    // x coord for the text
 
     // find a string that will fit inside the area for text
index b3db60747063f3c4712d2d8d668d1d90480a6d0e..54a7f06f078ba177e6291c6fab17db95b26ba6d3 100644 (file)
@@ -4,7 +4,6 @@
 
 #include "focuswidget.hh"
 #include "font.hh"
-#include "userstring.hh"
 
 namespace otk {
 
@@ -15,8 +14,8 @@ public:
   FocusLabel(Widget *parent);
   ~FocusLabel();
 
-  inline const userstring &getText(void) const { return _text; }
-  void setText(const userstring &text) { _text = text; _dirty = true; }
+  inline const std::string &getText(void) const { return _text; }
+  void setText(const std::string &text) { _text = text; _dirty = true; }
 
   void update(void);
 
@@ -26,7 +25,7 @@ private:
   //! Object used by Xft to render to the drawable
   XftDraw *_xftdraw;
   //! Text displayed in the label
-  userstring _text;
+  std::string _text;
 };
 
 }
index 6932971c1c3ca6c9cb83d8793d1b3616a7dcdf12..0f1ad8c1cb5559d20647e21df54db7c4dead0ef8 100644 (file)
@@ -10,7 +10,15 @@ extern "C" {
 #endif // HAVE_STDLIB_H
 }
 
+#include <iostream>
+#include <algorithm>
+
+using std::string;
+using std::cerr;
+using std::endl;
+
 #include "font.hh"
+#include "util.hh"
 #include "display.hh"
 #include "color.hh"
 #include "screeninfo.hh"
@@ -26,10 +34,10 @@ extern "C" {
 
 namespace otk {
 
-std::string Font::_fallback_font = "fixed";
+string      Font::_fallback_font = "fixed";
 bool        Font::_xft_init      = false;
 
-Font::Font(int screen_num, const std::string &fontstring,
+Font::Font(int screen_num, const string &fontstring,
              bool shadow, unsigned char offset, unsigned char tint)
   : _screen_num(screen_num),
     _fontstring(fontstring),
@@ -78,7 +86,7 @@ Font::~Font(void)
 
 
 void Font::drawString(XftDraw *d, int x, int y, const Color &color,
-                       const userstring &string) const
+                       const string &string, bool utf8) const
 {
   assert(d);
 
@@ -90,7 +98,7 @@ void Font::drawString(XftDraw *d, int x, int y, const Color &color,
     c.color.alpha = _tint | _tint << 8; // transparent shadow
     c.pixel = BlackPixel(Display::display, _screen_num);
 
-    if (string.utf8())
+    if (utf8)
       XftDrawStringUtf8(d, &c, _xftfont, x + _offset,
                         _xftfont->ascent + y + _offset,
                         (FcChar8*)string.c_str(), string.size());
@@ -107,7 +115,7 @@ void Font::drawString(XftDraw *d, int x, int y, const Color &color,
   c.pixel = color.pixel();
   c.color.alpha = 0xff | 0xff << 8; // no transparency in Color yet
 
-  if (string.utf8())
+  if (utf8)
     XftDrawStringUtf8(d, &c, _xftfont, x, _xftfont->ascent + y,
                       (FcChar8*)string.c_str(), string.size());
   else
@@ -118,11 +126,11 @@ void Font::drawString(XftDraw *d, int x, int y, const Color &color,
 }
 
 
-unsigned int Font::measureString(const userstring &string) const
+unsigned int Font::measureString(const string &string, bool utf8) const
 {
   XGlyphInfo info;
 
-  if (string.utf8())
+  if (utf8)
     XftTextExtentsUtf8(Display::display, _xftfont,
                        (FcChar8*)string.c_str(), string.size(), &info);
   else
index 2ffa39a51b2ecd40b483cb68f7d6b935aeb8ce60..9091b9bcf857638ba9f3bbfb65147000fcfd7eac 100644 (file)
@@ -58,7 +58,7 @@ public:
   unsigned int maxCharWidth() const;
 
   unsigned int measureString(const std::string &string,
-                             bool utf8 = true) const;
+                             bool utf8 = false) const;
 
   //! Draws a string into an XftDraw object
   /*!
@@ -66,7 +66,7 @@ public:
     different screens, you WILL have unpredictable results! :)
   */
   void drawString(XftDraw *d, int x, int y, const Color &color,
-                  const std::string &string, bool utf8 = true) const;
+                  const std::string &string, bool utf8 = false) const;
 };
 
 }
index cacbb08e18f8df6c2ae1293566c502796c6a94e4..6b6a8e358424406a34a2ca95678f501cbfeeb1ad 100644 (file)
@@ -35,7 +35,7 @@ void Label::update(void)
     const Font *ft = style()->getFont();
     unsigned int sidemargin = style()->getBevelWidth() * 2;
 
-    userstring t = _text; // the actual text to draw
+    std::string t = _text; // the actual text to draw
     int x = sidemargin;    // x coord for the text
 
     // find a string that will fit inside the area for text
index 94ebe0b3bcad15b49bf432079cb6062f0d0f9d10..0366c262c7195285abc1b6acc5090c331b061d65 100644 (file)
@@ -4,7 +4,6 @@
 
 #include "widget.hh"
 #include "font.hh"
-#include "userstring.hh"
 
 namespace otk {
 
@@ -15,8 +14,8 @@ public:
   Label(Widget *parent);
   ~Label();
 
-  inline const userstring &getText(void) const { return _text; }
-  void setText(const userstring &text) { _text = text; _dirty = true; }
+  inline const std::string &getText(void) const { return _text; }
+  void setText(const std::string &text) { _text = text; _dirty = true; }
 
   void update(void);
 
@@ -26,7 +25,7 @@ private:
   //! Object used by Xft to render to the drawable
   XftDraw *_xftdraw;
   //! Text displayed in the label
-  userstring _text;
+  std::string _text;
 };
 
 }
index 77bdfb0382fefff651a8d5e7ff644174982b54db..ad9eacc90736ce6a7ec1cb96c2f6676f5f79562e 100644 (file)
@@ -163,7 +163,7 @@ Property::~Property()
  */
 Atom Property::create(const char *name) const
 {
-  Atom a = XInternAtom(Display::display, name, false);
+  Atom a = XInternAtom(Display::display, name, False);
   assert(a);
   return a;
 }
@@ -196,7 +196,7 @@ void Property::set(Window win, Atoms atom, Atoms type,
   assert(atom >= 0 && atom < NUM_ATOMS);
   assert(type >= 0 && type < NUM_ATOMS);
   set(win, _atoms[atom], _atoms[type],
-           reinterpret_cast<unsigned char*>(&value), 32, 1, false);
+           reinterpret_cast<unsigned char*>(&value), 32, 1, False);
 }
 
 
@@ -209,7 +209,7 @@ void Property::set(Window win, Atoms atom, Atoms type,
   assert(atom >= 0 && atom < NUM_ATOMS);
   assert(type >= 0 && type < NUM_ATOMS);
   set(win, _atoms[atom], _atoms[type],
-      reinterpret_cast<unsigned char*>(value), 32, elements, false);
+      reinterpret_cast<unsigned char*>(value), 32, elements, False);
 }
 
 
@@ -217,7 +217,7 @@ void Property::set(Window win, Atoms atom, Atoms type,
  * Set an string property value on a window.
  */
 void Property::set(Window win, Atoms atom, StringType type,
-                          const userstring &value) const
+                          const std::string &value) const
 {
   assert(atom >= 0 && atom < NUM_ATOMS);
   assert(type >= 0 && type < NUM_STRING_TYPE);
@@ -226,11 +226,11 @@ void Property::set(Window win, Atoms atom, StringType type,
   switch (type) {
   case ascii: t = _atoms[Atom_String]; break;
   case utf8:  t = _atoms[Atom_Utf8]; break;
-  default: assert(false); return; // unhandled StringType
+  default: assert(False); return; // unhandled StringType
   }
   set(win, _atoms[atom], t,
       reinterpret_cast<unsigned char *>(const_cast<char *>(value.c_str())),
-      8, value.size() + 1, false); // add 1 to the size to include the null
+      8, value.size() + 1, False); // add 1 to the size to include the null
 }
 
 
@@ -238,7 +238,7 @@ void Property::set(Window win, Atoms atom, StringType type,
  * Set an array of string property values on a window.
  */
 void Property::set(Window win, Atoms atom, StringType type,
-                     const userstring::vector &strings) const
+                     const StringVect &strings) const
 {
   assert(atom >= 0 && atom < NUM_ATOMS);
   assert(type >= 0 && type < NUM_STRING_TYPE);
@@ -247,26 +247,26 @@ void Property::set(Window win, Atoms atom, StringType type,
   switch (type) {
   case ascii: t = _atoms[Atom_String]; break;
   case utf8:  t = _atoms[Atom_Utf8]; break;
-  default: assert(false); return; // unhandled StringType
+  default: assert(False); return; // unhandled StringType
   }
 
   std::string value;
 
-  userstring::vector::const_iterator it = strings.begin();
-  const userstring::vector::const_iterator end = strings.end();
+  StringVect::const_iterator it = strings.begin();
+  const StringVect::const_iterator end = strings.end();
   for (; it != end; ++it)
       value += *it + '\0';
 
   set(win, _atoms[atom], t,
       reinterpret_cast<unsigned char *>(const_cast<char *>(value.c_str())),
-      8, value.size(), false);
+      8, value.size(), False);
 }
 
 
 /*
  * Internal get function used by all of the typed get functions.
  * Gets an property's value from a window.
- * Returns true if the property was successfully retrieved; false if the
+ * Returns True if the property was successfully retrieved; False if the
  * property did not exist on the window, or has a different type/size format
  * than the user tried to retrieve.
  */
@@ -283,11 +283,11 @@ bool Property::get(Window win, Atom atom, Atom type,
   unsigned long ret_bytes;
   int result;
   unsigned long maxread = *nelements;
-  bool ret = false;
+  bool ret = False;
 
   // try get the first element
   result = XGetWindowProperty(Display::display, win, atom, 0l, 1l,
-                              false, AnyPropertyType, &ret_type, &ret_size,
+                              False, AnyPropertyType, &ret_type, &ret_size,
                               nelements, &ret_bytes, &c_val);
   ret = (result == Success && ret_type == type && ret_size == size &&
          *nelements > 0);
@@ -305,7 +305,7 @@ bool Property::get(Window win, Atom atom, Atom type,
       if (remain > size/8 * (signed)maxread) // dont get more than the max
         remain = size/8 * (signed)maxread;
       result = XGetWindowProperty(Display::display, win, atom, 0l,
-                                  remain, false, type, &ret_type, &ret_size,
+                                  remain, False, type, &ret_type, &ret_size,
                                   nelements, &ret_bytes, &c_val);
       ret = (result == Success && ret_type == type && ret_size == size &&
              ret_bytes == 0);
@@ -352,10 +352,10 @@ bool Property::get(Window win, Atoms atom, Atoms type,
   unsigned long num = 1;
   if (! get(win, _atoms[atom], _atoms[type], &num,
                  reinterpret_cast<unsigned char **>(&temp), 32))
-    return false;
+    return False;
   *value = temp[0];
   delete [] temp;
-  return true;
+  return True;
 }
 
 
@@ -363,25 +363,20 @@ bool Property::get(Window win, Atoms atom, Atoms type,
  * Gets an string property's value from a window.
  */
 bool Property::get(Window win, Atoms atom, StringType type,
-                     userstring *value) const
+                     std::string *value) const
 {
   unsigned long n = 1;
-  userstring::vector s;
+  StringVect s;
   if (get(win, atom, type, &n, &s)) {
     *value = s[0];
-    switch (type) {
-    case ascii: value->setUtf8(false); break;
-    case utf8:  value->setUtf8(true); break;
-    default: assert(false); return false; // unhandled StringType
-    }
-    return true;
+    return True;
   }
-  return false;
+  return False;
 }
 
 
 bool Property::get(Window win, Atoms atom, StringType type,
-                   unsigned long *nelements, userstring::vector *strings) const
+                     unsigned long *nelements, StringVect *strings) const
 {
   assert(atom >= 0 && atom < NUM_ATOMS);
   assert(type >= 0 && type < NUM_STRING_TYPE);
@@ -389,27 +384,26 @@ bool Property::get(Window win, Atoms atom, StringType type,
   assert(*nelements > 0);
 
   Atom t;
-  bool isutf8;
   switch (type) {
-  case ascii: t = _atoms[Atom_String]; isutf8 = false; break;
-  case utf8:  t = _atoms[Atom_Utf8];   isutf8 = true; break;
-  default: assert(false); return false; // unhandled StringType
+  case ascii: t = _atoms[Atom_String]; break;
+  case utf8:  t = _atoms[Atom_Utf8]; break;
+  default: assert(False); return False; // unhandled StringType
   }
   
   unsigned char *value;
   unsigned long elements = (unsigned) -1;
   if (!get(win, _atoms[atom], t, &elements, &value, 8) || elements < 1)
-    return false;
+    return False;
 
-  userstring s(reinterpret_cast<char *>(value), elements, isutf8);
+  std::string s(reinterpret_cast<char *>(value), elements);
   delete [] value;
 
-  userstring::const_iterator it = s.begin(), end = s.end();
+  std::string::const_iterator it = s.begin(), end = s.end();
   unsigned long num = 0;
   while(num < *nelements) {
-    userstring::const_iterator tmp = it;  // current string.begin()
+    std::string::const_iterator tmp = it; // current string.begin()
     it = std::find(tmp, end, '\0');       // look for null between tmp and end
-    strings->push_back(userstring(tmp, it, isutf8));   // s[tmp:it)
+    strings->push_back(std::string(tmp, it));   // s[tmp:it)
     ++num;
     if (it == end) break;
     ++it;
@@ -418,7 +412,7 @@ bool Property::get(Window win, Atoms atom, StringType type,
 
   *nelements = num;
 
-  return true;
+  return True;
 }
 
 
index b850c562800c84c8b6d2b41b1393625ebc2de97c..7f4ae266f9691b2834ccc01d331d1d00297e17bf 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef   __property_hh
-#define   __property_hh
+#ifndef   __atom_hh
+#define   __atom_hh
 
 /*! @file property.hh
   @brief Provides access to window properties
@@ -327,4 +327,4 @@ public:
 
 }
 
-#endif // __property_hh
+#endif // __atom_hh
diff --git a/otk/userstring.hh b/otk/userstring.hh
deleted file mode 100644 (file)
index c7c81d0..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-#ifndef   __userstring_hh
-#define   __userstring_hh
-
-#include <string>
-#include <vector>
-
-extern "C" {
-#include <assert.h>
-}
-
-namespace otk {
-
-//! userstring is a std::string with an extra flag specifying if the string is
-//! UTF-8 encoded.
-class userstring : public std::string
-{
-public:
-  //! A vector of userstrings
-  typedef std::vector<userstring> vector;
-  
-private:
-  bool _utf8;
-
-public:
-  userstring(bool utf8) : std::string(), _utf8(utf8) {}
-  userstring(const userstring& s, size_type pos = 0,
-            size_type n = npos) : std::string(s, pos, n), _utf8(s._utf8) {}
-  userstring(const char *s, bool utf8) : std::string(s), _utf8(utf8) {}
-  userstring(const char *s, size_type n, bool utf8) : std::string(s, n),
-                                                     _utf8(utf8) {}
-  userstring(size_type n, char c, bool utf8) : std::string(n, c),
-                                              _utf8(utf8) {}
-  userstring(const_iterator first, const_iterator last, bool utf8) :
-    std::string(first, last), _utf8(utf8) {}
-
-  //! Returns if the string is encoded in UTF-8 or not
-  inline bool utf8() const { return _utf8; }
-
-  inline void setUtf8(bool u) { _utf8 = u; }
-
-  inline userstring& insert(size_type pos, const userstring& s) {
-    assert(s._utf8 == _utf8);
-    std::string::insert(pos, s);
-    return *this;
-  }
-
-  inline userstring& insert(size_type pos,
-                           const userstring& s,
-                           size_type pos1, size_type n) {
-    assert(s._utf8 == _utf8);
-    std::string::insert(pos, s, pos1, n);
-    return *this;
-  }
-
-  inline userstring& append(const userstring& s) {
-    assert(s._utf8 == _utf8);
-    std::string::append(s);
-    return *this;
-  }
-
-  inline userstring& append(const userstring& s,
-                           size_type pos, size_type n) {
-    assert(s._utf8 == _utf8);
-    std::string::append(s, pos, n);
-    return *this;
-  }
-
-  inline userstring& assign(const userstring& s) {
-    assert(s._utf8 == _utf8);
-    std::string::assign(s);
-    return *this;
-  }
-  
-  inline userstring& assign(const userstring& s,
-                           size_type pos, size_type n) {
-    assert(s._utf8 == _utf8);
-    std::string::assign(s, pos, n);
-    return *this;
-  }
-
-  inline userstring& replace(size_type pos, size_type n,
-                            const userstring& s) {
-    assert(s._utf8 == _utf8);
-    std::string::replace(pos, n, s);
-    return *this;
-  }
-
-  inline userstring& replace(size_type pos, size_type n,
-                            const userstring& s,
-                            size_type pos1, size_type n1) {
-    assert(s._utf8 == _utf8);
-    std::string::replace(pos, n, s, pos1, n1);
-    return *this;
-  }
-
-  inline userstring& operator=(const userstring& s) {
-    return assign(s);
-  }
-  
-  inline userstring& operator+=(const userstring& s) {
-    return append(s);
-  }
-};
-
-}
-
-#endif // __userstring_hh
This page took 0.044152 seconds and 4 git commands to generate.