Back to index

scribus-ng  1.3.4.dfsg+svn20071115
stylecontextproxy.h
Go to the documentation of this file.
00001 /*
00002  For general Scribus (>=1.3.2) copyright and licensing information please refer
00003  to the COPYING file provided with the program. Following this notice may exist
00004  a copyright and/or license notice that predates the release of Scribus 1.3.2
00005  for which a new license (GPL+exception) is in place.
00006  */
00007 /***************************************************************************
00008 *                                                                         *
00009 *   This program is free software; you can redistribute it and/or modify  *
00010 *   it under the terms of the GNU General Public License as published by  *
00011 *   the Free Software Foundation; either version 2 of the License, or     *
00012 *   (at your option) any later version.                                   *
00013 *                                                                         *
00014 ***************************************************************************/
00015 
00016 
00017 #ifndef STYLECONTEXTPROXY_H
00018 #define STYLECONTEXTPROXY_H
00019 
00020 #include <cassert>
00021 #include <qsignal.h>
00022 #include <qstring.h>
00023 #include <qvaluelist.h>
00024 #include "scfonts.h"
00025 #include "scribusapi.h"
00026 #include "sccolor.h"
00027 #include "styles/stylecontext.h"
00028 
00029 
00034 class StyleContextProxy: public StyleContext 
00035 {
00036 public:
00037        const Style* resolve(const QString& name) const;
00038        
00039        StyleContextProxy(const Style* style) 
00040               : StyleContext(), m_default(style) {
00041               }
00042        
00043        StyleContextProxy(const StyleContextProxy& other)
00044               : StyleContext(other), m_default(other.m_default) {
00045               }
00046        
00047        StyleContextProxy& operator= (const StyleContextProxy& other)
00048        {
00049               static_cast<StyleContext&>(*this) = static_cast<const StyleContext&>(other); 
00050               m_default = other.m_default;
00051               return *this;
00052        }
00053        
00054        const Style* defaultStyle() const { return m_default; }
00055        
00056        void setDefaultStyle(const Style* def) { 
00057               assert(def);
00058               m_default = def; 
00059               invalidate();
00060        }
00061        
00062        bool checkConsistency() const 
00063        { 
00064               const StyleContext* context = m_default->context();
00065               return !context || context == this || !context->contextContained(this);
00066        }
00067        
00068        bool contextContained(const StyleContext* context) const 
00069        {
00070               const StyleContext* mycontext = m_default->context();
00071               return context == this || 
00072                      (mycontext && mycontext->contextContained(context));
00073        }
00074        
00075 private:
00076               const Style* m_default;
00077 };
00078 
00079 #endif