File indexing completed on 2024-12-22 04:17:33
0001 /*************************************************************************** 0002 * * 0003 * copyright : (C) 2008 The University of Toronto * 0004 * netterfield@astro.utoronto.ca * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 ***************************************************************************/ 0012 0013 #include "labelpropertiestab.h" 0014 0015 #include "application.h" 0016 #include "objectstore.h" 0017 #include "mainwindow.h" 0018 #include "document.h" 0019 #include "geticon.h" 0020 0021 namespace Kst { 0022 0023 LabelPropertiesTab::LabelPropertiesTab(QWidget *parent) 0024 : DialogTab(parent) { 0025 0026 setupUi(this); 0027 setTabTitle(tr("Label Properties")); 0028 0029 _labelText->setObjectStore(kstApp->mainWindow()->document()->objectStore()); 0030 0031 _labelText->setWhatsThis(tr("<qt>The syntax for labels is a derivative of a subset of LaTeX. " 0032 "Supported syntax is: <b>\\[greeklettername]</b> and <b>\\[Greeklettername]</b>, " 0033 "<b>\\approx</b>, <b>\\cdot</b>, <b>\\ge</b>, <b>\\geq</b>, <b>\\inf</b> ," 0034 "<b>\\int</b>, <b>\\le</b>, <b>\\leq</b>, <b>\\ne</b>, <b>\\n</b>, " 0035 "<b>\\partial</b>, <b>\\prod</b>, <b>\\pm</b>, " 0036 "<b>\\textcolor{color name}{colored text}</b>, <b>\\textbf{bold text}</b>, " 0037 "<b>\\textit{italicized text}</b>, <b>\\t</b>, <b>\\sum</b>, <b>\\sqrt</b>, " 0038 "<b>\\underline{underlined text}</b>, <b>x^y</b>, <b>x_y</b>. " 0039 "Scalars, equations, and vector elements can be embedded. " 0040 "Scalar: <i>[V1/Mean]</i>. Vector Element: <i>[V1[4]]</i>. " 0041 "Equation: <i>[=[V1/Mean]^2]</i>. A [ character can be inserted as <i>\\[</i>.")); 0042 0043 int h = fontMetrics().lineSpacing(); 0044 _bold->setFixedWidth(h); 0045 _bold->setFixedHeight(h); 0046 _bold->setIcon(KstGetIcon("kst_bold")); 0047 _italic->setFixedWidth(h); 0048 _italic->setFixedHeight(h); 0049 _italic->setIcon(KstGetIcon("kst_italic")); 0050 _labelColor->setFixedWidth(h); 0051 _labelColor->setFixedHeight(h); 0052 0053 connect(_labelText, SIGNAL(labelChanged()), this, SIGNAL(modified())); 0054 connect(_labelFontScale, SIGNAL(valueChanged(double)), this, SIGNAL(modified())); 0055 connect(_labelColor, SIGNAL(changed(QColor)), this, SIGNAL(modified())); 0056 connect(_bold, SIGNAL(toggled(bool)), this, SIGNAL(modified())); 0057 connect(_italic, SIGNAL(toggled(bool)), this, SIGNAL(modified())); 0058 connect(_family, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified())); 0059 0060 } 0061 0062 0063 LabelPropertiesTab::~LabelPropertiesTab() { 0064 } 0065 0066 0067 QString LabelPropertiesTab::labelText() const { 0068 return _labelText->labelText(); 0069 } 0070 0071 0072 void LabelPropertiesTab::setLabelText(const QString &text) { 0073 _labelText->setLabelText(text); 0074 } 0075 0076 0077 qreal LabelPropertiesTab::labelScale() const { 0078 return _labelFontScale->value(); 0079 } 0080 0081 0082 void LabelPropertiesTab::setLabelScale(const qreal scale) { 0083 _labelFontScale->setValue(scale); 0084 } 0085 0086 0087 QColor LabelPropertiesTab::labelColor() const { 0088 return _labelColor->color(); 0089 } 0090 0091 0092 void LabelPropertiesTab::setLabelColor(const QColor &color) { 0093 _labelColor->setColor(color); 0094 } 0095 0096 0097 QFont LabelPropertiesTab::labelFont() const { 0098 QFont font(_family->currentFont()); 0099 font.setItalic(_italic->isChecked()); 0100 font.setBold(_bold->isChecked()); 0101 return font; 0102 } 0103 0104 0105 void LabelPropertiesTab::setLabelFont(const QFont &font) { 0106 _family->setCurrentFont(font); 0107 _bold->setChecked(font.bold()); 0108 _italic->setChecked(font.italic()); 0109 } 0110 0111 0112 0113 } 0114 // vim: ts=2 sw=2 et