home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / styles / stylecontextproxy.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-09-25  |  2.3 KB  |  79 lines

  1. /*
  2.  For general Scribus (>=1.3.2) copyright and licensing information please refer
  3.  to the COPYING file provided with the program. Following this notice may exist
  4.  a copyright and/or license notice that predates the release of Scribus 1.3.2
  5.  for which a new license (GPL+exception) is in place.
  6.  */
  7. /***************************************************************************
  8. *                                                                         *
  9. *   This program is free software; you can redistribute it and/or modify  *
  10. *   it under the terms of the GNU General Public License as published by  *
  11. *   the Free Software Foundation; either version 2 of the License, or     *
  12. *   (at your option) any later version.                                   *
  13. *                                                                         *
  14. ***************************************************************************/
  15.  
  16.  
  17. #ifndef STYLECONTEXTPROXY_H
  18. #define STYLECONTEXTPROXY_H
  19.  
  20. #include <cassert>
  21. #include <QString>
  22. #include "scfonts.h"
  23. #include "scribusapi.h"
  24. #include "sccolor.h"
  25. #include "styles/stylecontext.h"
  26. #include <QList>
  27.  
  28.  
  29. /** This class turns a style into a new stylecontext:
  30. *  it maps the empty name "" to the given default style and uses
  31. *  the style's context to resolve all other names.
  32. */
  33. class StyleContextProxy: public StyleContext 
  34. {
  35. public:
  36.     const Style* resolve(const QString& name) const;
  37.     
  38.     StyleContextProxy(const Style* style) 
  39.         : StyleContext(), m_default(style) {
  40.         }
  41.     
  42.     StyleContextProxy(const StyleContextProxy& other)
  43.         : StyleContext(other), m_default(other.m_default) {
  44.         }
  45.     
  46.     StyleContextProxy& operator= (const StyleContextProxy& other)
  47.     {
  48.         static_cast<StyleContext&>(*this) = static_cast<const StyleContext&>(other); 
  49.         m_default = other.m_default;
  50.         return *this;
  51.     }
  52.     
  53.     const Style* defaultStyle() const { return m_default; }
  54.     
  55.     void setDefaultStyle(const Style* def) { 
  56.         assert(def);
  57.         m_default = def; 
  58.         invalidate();
  59.     }
  60.     
  61.     bool checkConsistency() const 
  62.     { 
  63.         const StyleContext* context = m_default->context();
  64.         return !context || context == this || !context->contextContained(this);
  65.     }
  66.     
  67.     bool contextContained(const StyleContext* context) const 
  68.     {
  69.         const StyleContext* mycontext = m_default->context();
  70.         return context == this || 
  71.             (mycontext && mycontext->contextContained(context));
  72.     }
  73.     
  74. private:
  75.         const Style* m_default;
  76. };
  77.  
  78. #endif
  79.