[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project

src/klftools/klfstyle.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   file klfstyle.h
00003  *   This file is part of the KLatexFormula Project.
00004  *   Copyright (C) 2010 by Philippe Faist
00005  *   philippe.faist at bluewin.ch
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  ***************************************************************************/
00022 /* $Id: klfstyle.h 464 2010-08-28 22:48:32Z philippe $ */
00023 
00024 #ifndef KLFSTYLE_H
00025 #define KLFSTYLE_H
00026 
00027 #include <QList>
00028 #include <QDataStream>
00029 
00030 #include <klfbackend.h>
00031 
00032 
00037 struct KLF_EXPORT KLFStyle {
00049   struct KLF_EXPORT BBoxExpand {
00050     BBoxExpand(double t = -1, double r = -1, double b = -1, double l = -1)
00051       : top(t), right(r), bottom(b), left(l)  { }
00052     BBoxExpand(const BBoxExpand& c) : top(c.top), right(c.right), bottom(c.bottom), left(c.left) { }
00053 
00054     inline bool valid() const { return top >= 0 && right >= 0 && bottom >= 0 && left >= 0; }
00055 
00056     double top;
00057     double right;
00058     double bottom;
00059     double left;
00060     inline const BBoxExpand& operator=(const BBoxExpand& other)
00061     { top = other.top; right = other.right; bottom = other.bottom; left = other.left;  return *this; }
00062     inline bool operator==(const BBoxExpand& x) const
00063     { return top == x.top && right == x.right && bottom == x.bottom && left == x.left; }
00064   };
00065 
00066   KLFStyle(QString nm = QString(), unsigned long fgcol = qRgba(0,0,0,255),
00067            unsigned long bgcol = qRgba(255,255,255,0),
00068            const QString& mmode = QString(),
00069            const QString& pre = QString(),
00070            int dotsperinch = -1)
00071     : name(nm), fg_color(fgcol), bg_color(bgcol), mathmode(mmode), preamble(pre),
00072       dpi(dotsperinch)
00073   {
00074   }
00075 
00076   KLFStyle(const KLFBackend::klfInput& input)
00077     : name(), fg_color(input.fg_color), bg_color(input.bg_color), mathmode(input.mathmode),
00078       preamble(input.preamble), dpi(input.dpi), overrideBBoxExpand()
00079   {
00080   }
00081 
00082   KLFStyle(const KLFStyle& o)
00083     : name(o.name), fg_color(o.fg_color), bg_color(o.bg_color), mathmode(o.mathmode),
00084       preamble(o.preamble), dpi(o.dpi), overrideBBoxExpand(o.overrideBBoxExpand)
00085   {
00086   }
00087 
00088   QString name; 
00089   unsigned long fg_color;
00090   unsigned long bg_color;
00091   QString mathmode;
00092   QString preamble;
00093   int dpi;
00094   BBoxExpand overrideBBoxExpand;
00095 
00096   inline const KLFStyle& operator=(const KLFStyle& o) {
00097     name = o.name; fg_color = o.fg_color; bg_color = o.bg_color; mathmode = o.mathmode;
00098     preamble = o.preamble; dpi = o.dpi; overrideBBoxExpand = o.overrideBBoxExpand;
00099     return *this;
00100   }
00101 };
00102 
00103 Q_DECLARE_METATYPE(KLFStyle)
00104   ;
00105 
00106 typedef QList<KLFStyle> KLFStyleList;
00107 
00108 KLF_EXPORT QDataStream& operator<<(QDataStream& stream, const KLFStyle& style);
00109 KLF_EXPORT QDataStream& operator>>(QDataStream& stream, KLFStyle& style);
00110 // exact matches
00111 KLF_EXPORT bool operator==(const KLFStyle& a, const KLFStyle& b);
00112 
00113 
00114 
00115 
00116 #endif

Generated by doxygen 1.7.3