[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
klfstyle.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * file klfstyle.cpp
3  * This file is part of the KLatexFormula Project.
4  * Copyright (C) 2011 by Philippe Faist
5  * philippe.faist at bluewin.ch
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 /* $Id: klfstyle.cpp 603 2011-02-26 23:14:55Z phfaist $ */
23 
24 #include <QColor>
25 
26 #include "klfstyle.h"
27 
28 
30 {
31  return stream << b.top << b.right << b.bottom << b.left;
32 }
33 
35 {
36  return stream >> b.top >> b.right >> b.bottom >> b.left;
37 }
38 
39 
40 KLF_EXPORT QDataStream& operator<<(QDataStream& stream, const KLFStyle& style)
41 {
42  // yes, QIODevice inherits QObject and we can use dynamic properties...
43  QString compat_klfversion = stream.device()->property("klfDataStreamAppVersion").toString();
44  if (klfVersionCompare(compat_klfversion, "3.1") <= 0)
45  return stream << style.name << (quint32)style.fg_color << (quint32)style.bg_color
46  << style.mathmode << style.preamble << (quint16)style.dpi;
47  else
48  return stream << style.name << (quint32)style.fg_color << (quint32)style.bg_color
49  << style.mathmode << style.preamble << (quint16)style.dpi
50  << style.overrideBBoxExpand;
51 }
53 {
54  QString compat_klfversion = stream.device()->property("klfDataStreamAppVersion").toString();
55  if (klfVersionCompare(compat_klfversion, "3.1") <= 0) {
56  quint32 fg, bg;
57  quint16 dpi;
58  stream >> style.name;
59  stream >> fg >> bg >> style.mathmode >> style.preamble >> dpi;
60  style.fg_color = fg;
61  style.bg_color = bg;
62  style.dpi = dpi;
63  return stream;
64  } else {
65  quint32 fg, bg;
66  quint16 dpi;
67  stream >> style.name;
68  stream >> fg >> bg >> style.mathmode >> style.preamble >> dpi;
69  style.fg_color = fg;
70  style.bg_color = bg;
71  style.dpi = dpi;
72  stream >> style.overrideBBoxExpand;
73  return stream;
74  }
75 }
76 
77 KLF_EXPORT bool operator==(const KLFStyle& a, const KLFStyle& b)
78 {
79  return a.name == b.name &&
80  a.fg_color == b.fg_color &&
81  a.bg_color == b.bg_color &&
82  a.mathmode == b.mathmode &&
83  a.preamble == b.preamble &&
84  a.dpi == b.dpi &&
86 }
87 
88 
89 // No longer needed with new KLFLibEntryEditor widget
90 //
91 // KLF_EXPORT QString prettyPrintStyle(const KLFStyle& sty)
92 // {
93 // QString s = "";
94 // if (sty.name != QString::null)
95 // s = QObject::tr("<b>Style Name</b>: %1<br>").arg(sty.name);
96 // return s + QObject::tr("<b>Math Mode</b>: %1<br>"
97 // "<b>DPI Resolution</b>: %2<br>"
98 // "<b>Foreground Color</b>: %3 <font color=\"%4\"><b>[SAMPLE]</b></font><br>"
99 // "<b>Background is Transparent</b>: %5<br>"
100 // "<b>Background Color</b>: %6 <font color=\"%7\"><b>[SAMPLE]</b></font><br>"
101 // "<b>LaTeX Preamble:</b><br><pre>%8</pre>")
102 // .arg(sty.mathmode)
103 // .arg(sty.dpi)
104 // .arg(QColor(sty.fg_color).name()).arg(QColor(sty.fg_color).name())
105 // .arg( (qAlpha(sty.bg_color) != 255) ? QObject::tr("YES") : QObject::tr("NO") )
106 // .arg(QColor(sty.bg_color).name()).arg(QColor(sty.bg_color).name())
107 // .arg(sty.preamble)
108 // ;
109 // }
110 
111 
112 
113 
114 
115 
116 
int dpi
Definition: klfstyle.h:93
const char * style
Definition: klfutil.cpp:211
QString name
this may not always be set, it&#39;s only important in saved style list.
Definition: klfstyle.h:88
QString mathmode
Definition: klfstyle.h:91
KLF_EXPORT QDataStream & operator<<(QDataStream &stream, const KLFStyle::BBoxExpand &b)
Definition: klfstyle.cpp:29
KLF_EXPORT bool operator==(const KLFStyle &a, const KLFStyle &b)
Definition: klfstyle.cpp:77
a structure memorizing parameters for bbox expansion
Definition: klfstyle.h:49
QString preamble
Definition: klfstyle.h:92
A Formula Style (collection of properties)
Definition: klfstyle.h:37
BBoxExpand overrideBBoxExpand
Definition: klfstyle.h:94
KLF_EXPORT int klfVersionCompare(const QString &v1, const QString &v2)
KLF_EXPORT QDataStream & operator>>(QDataStream &stream, KLFStyle::BBoxExpand &b)
Definition: klfstyle.cpp:34
unsigned long bg_color
Definition: klfstyle.h:90
unsigned long fg_color
Definition: klfstyle.h:89

Generated by doxygen 1.8.11