1 /***************************************************************************
2 * *
3 * copyright : (C) 2008 The University of Toronto *
4 * netterfield@astro.utoronto.ca *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 ***************************************************************************/
12
13 #include "labelpropertiestab.h"
14
15 #include "application.h"
16 #include "objectstore.h"
17 #include "mainwindow.h"
18 #include "document.h"
19 #include "geticon.h"
20
21 namespace Kst {
22
LabelPropertiesTab(QWidget * parent)23 LabelPropertiesTab::LabelPropertiesTab(QWidget *parent)
24 : DialogTab(parent) {
25
26 setupUi(this);
27 setTabTitle(tr("Label Properties"));
28
29 _labelText->setObjectStore(kstApp->mainWindow()->document()->objectStore());
30
31 _labelText->setWhatsThis(tr("<qt>The syntax for labels is a derivative of a subset of LaTeX. "
32 "Supported syntax is: <b>\\[greeklettername]</b> and <b>\\[Greeklettername]</b>, "
33 "<b>\\approx</b>, <b>\\cdot</b>, <b>\\ge</b>, <b>\\geq</b>, <b>\\inf</b> ,"
34 "<b>\\int</b>, <b>\\le</b>, <b>\\leq</b>, <b>\\ne</b>, <b>\\n</b>, "
35 "<b>\\partial</b>, <b>\\prod</b>, <b>\\pm</b>, "
36 "<b>\\textcolor{color name}{colored text}</b>, <b>\\textbf{bold text}</b>, "
37 "<b>\\textit{italicized text}</b>, <b>\\t</b>, <b>\\sum</b>, <b>\\sqrt</b>, "
38 "<b>\\underline{underlined text}</b>, <b>x^y</b>, <b>x_y</b>. "
39 "Scalars, equations, and vector elements can be embedded. "
40 "Scalar: <i>[V1/Mean]</i>. Vector Element: <i>[V1[4]]</i>. "
41 "Equation: <i>[=[V1/Mean]^2]</i>. A [ character can be inserted as <i>\\[</i>."));
42
43 int h = fontMetrics().lineSpacing();
44 _bold->setFixedWidth(h);
45 _bold->setFixedHeight(h);
46 _bold->setIcon(KstGetIcon("kst_bold"));
47 _italic->setFixedWidth(h);
48 _italic->setFixedHeight(h);
49 _italic->setIcon(KstGetIcon("kst_italic"));
50 _labelColor->setFixedWidth(h);
51 _labelColor->setFixedHeight(h);
52
53 connect(_labelText, SIGNAL(labelChanged()), this, SIGNAL(modified()));
54 connect(_labelFontScale, SIGNAL(valueChanged(double)), this, SIGNAL(modified()));
55 connect(_labelColor, SIGNAL(changed(QColor)), this, SIGNAL(modified()));
56 connect(_bold, SIGNAL(toggled(bool)), this, SIGNAL(modified()));
57 connect(_italic, SIGNAL(toggled(bool)), this, SIGNAL(modified()));
58 connect(_family, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
59
60 }
61
62
~LabelPropertiesTab()63 LabelPropertiesTab::~LabelPropertiesTab() {
64 }
65
66
labelText() const67 QString LabelPropertiesTab::labelText() const {
68 return _labelText->labelText();
69 }
70
71
setLabelText(const QString & text)72 void LabelPropertiesTab::setLabelText(const QString &text) {
73 _labelText->setLabelText(text);
74 }
75
76
labelScale() const77 qreal LabelPropertiesTab::labelScale() const {
78 return _labelFontScale->value();
79 }
80
81
setLabelScale(const qreal scale)82 void LabelPropertiesTab::setLabelScale(const qreal scale) {
83 _labelFontScale->setValue(scale);
84 }
85
86
labelColor() const87 QColor LabelPropertiesTab::labelColor() const {
88 return _labelColor->color();
89 }
90
91
setLabelColor(const QColor & color)92 void LabelPropertiesTab::setLabelColor(const QColor &color) {
93 _labelColor->setColor(color);
94 }
95
96
labelFont() const97 QFont LabelPropertiesTab::labelFont() const {
98 QFont font(_family->currentFont());
99 font.setItalic(_italic->isChecked());
100 font.setBold(_bold->isChecked());
101 return font;
102 }
103
104
setLabelFont(const QFont & font)105 void LabelPropertiesTab::setLabelFont(const QFont &font) {
106 _family->setCurrentFont(font);
107 _bold->setChecked(font.bold());
108 _italic->setChecked(font.italic());
109 }
110
111
112
113 }
114 // vim: ts=2 sw=2 et
115