File indexing completed on 2024-12-22 04:17:58
0001 /*************************************************************************** 0002 labelparser.h 0003 ---------------- 0004 begin : Dec 14 2004 0005 Copyright (C) 2004, The University of Toronto 0006 email : netterfield@astro.utoronto.ca 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 ***************************************************************************/ 0017 0018 #ifndef LABELPARSER_H 0019 #define LABELPARSER_H 0020 0021 #include "string_kst.h" 0022 #include "kstmath_export.h" 0023 0024 #include <qcolor.h> 0025 0026 typedef quint16 KstLJustifyType; 0027 typedef quint8 KstLHJustifyType; 0028 typedef quint8 KstLVJustifyType; 0029 #define KST_JUSTIFY_H(x) (x & 0x000000ffL) 0030 #define KST_JUSTIFY_H_NONE 0 0031 #define KST_JUSTIFY_H_LEFT 1 0032 #define KST_JUSTIFY_H_RIGHT 2 0033 #define KST_JUSTIFY_H_CENTER 3 0034 0035 #define KST_JUSTIFY_V(x) ((x >> 8) & 0x000000ffL) 0036 #define KST_JUSTIFY_V_NONE 0 0037 #define KST_JUSTIFY_V_TOP 1 0038 #define KST_JUSTIFY_V_BOTTOM 2 0039 #define KST_JUSTIFY_V_CENTER 3 0040 0041 #define SET_KST_JUSTIFY(h,v) ( ( h & 0x000000ffL ) | ( ( v & 0x000000ffL ) << 8 ) ) 0042 0043 0044 namespace Label { 0045 struct KSTMATH_EXPORT ChunkAttributes { 0046 ChunkAttributes() : bold(false), italic(false), underline(false), overline(false) {} 0047 inline bool empty() const { return !bold && !italic && !underline && !overline && !color.isValid(); } 0048 bool bold; 0049 bool italic; 0050 bool underline; 0051 bool overline; 0052 QColor color; 0053 }; 0054 0055 struct KSTMATH_EXPORT Chunk { 0056 enum VOffset { None = 0, Up = 1, Down = 2 }; 0057 Chunk(Chunk *parent, VOffset = None, bool isGroup = false, bool inherit = false); 0058 ~Chunk(); 0059 0060 bool locked() const; 0061 Chunk *next, *prev, *up, *down, *group; 0062 bool scalar : 1; 0063 bool linebreak : 1; 0064 bool tab : 1; 0065 bool vector : 1; 0066 bool formated : 1; 0067 VOffset vOffset 0068 #ifndef Q_OS_WIN32 0069 : 2 0070 #endif 0071 ; 0072 ChunkAttributes attributes; 0073 QString text; 0074 QString expression; 0075 QString format; 0076 }; 0077 0078 0079 struct KSTMATH_EXPORT Parsed { 0080 Parsed(); 0081 ~Parsed(); 0082 0083 Chunk *chunk; 0084 }; 0085 0086 0087 extern KSTMATH_EXPORT Parsed *parse(const QString&, const QColor &color, bool interpret = true, bool interpretNewLine = true); 0088 } 0089 0090 #endif 0091 // vim: ts=2 sw=2 et