22#include <tqbuttongroup.h>
23#include <tqcheckbox.h>
24#include <tqgroupbox.h>
28#include <tqradiobutton.h>
30#include <tqstringlist.h>
36#include <kcolorbutton.h>
40#include <tdefontdialog.h>
41#include <tdelistview.h>
43#include <tdemessagebox.h>
45#include <kpushbutton.h>
47#include "contextstyle.h"
48#include "kformulaconfigpage.h"
49#include "kformuladocument.h"
50#include "symboltable.h"
53KFORMULA_NAMESPACE_BEGIN
56ConfigurePage::ConfigurePage(
Document* document, TQWidget* view, TDEConfig* config, TQVBox* box,
char* name )
57 : TQObject( box->parent(),
name ), m_document( document ), m_view( view ), m_config( config ), m_changed( false )
63 TQGroupBox *gbox =
new TQGroupBox( i18n(
"Fonts" ), box );
64 gbox->setColumnLayout( 0, TQt::Horizontal );
66 TQGridLayout* grid =
new TQGridLayout( gbox->layout(), 5, 3 );
69 grid->setColStretch(1, 1);
71 defaultFont = contextStyle.getDefaultFont();
72 nameFont = contextStyle.getNameFont();
73 numberFont = contextStyle.getNumberFont();
74 operatorFont = contextStyle.getOperatorFont();
76 connect( buildFontLine( gbox, grid, 0, defaultFont,
77 i18n(
"Default font:" ), defaultFontName ),
78 TQ_SIGNAL( clicked() ), TQ_SLOT( selectNewDefaultFont() ) );
80 connect( buildFontLine( gbox, grid, 1, nameFont,
81 i18n(
"Name font:" ), nameFontName ),
82 TQ_SIGNAL( clicked() ), TQ_SLOT( selectNewNameFont() ) );
84 connect( buildFontLine( gbox, grid, 2, numberFont,
85 i18n(
"Number font:" ), numberFontName ),
86 TQ_SIGNAL( clicked() ), TQ_SLOT( selectNewNumberFont() ) );
88 connect( buildFontLine( gbox, grid, 3, operatorFont,
89 i18n(
"Operator font:" ), operatorFontName ),
90 TQ_SIGNAL( clicked() ), TQ_SLOT( selectNewOperatorFont() ) );
92 TQLabel* sizeTitle =
new TQLabel( i18n(
"Default base size:" ), gbox );
93 grid->addWidget( sizeTitle, 4, 0 );
95 sizeSpin =
new KIntNumInput( contextStyle.baseSize(), gbox );
96 sizeSpin->setRange( 8, 72, 1,
true );
98 grid->addMultiCellWidget( sizeSpin, 4, 4, 1, 2 );
100 connect( sizeSpin, TQ_SIGNAL( valueChanged(
int ) ),
101 TQ_SLOT( baseSizeChanged(
int ) ) );
105 syntaxHighlighting =
new TQCheckBox( i18n(
"Use syntax highlighting" ),box );
106 syntaxHighlighting->setChecked( contextStyle.syntaxHighlighting() );
158 connect( syntaxHighlighting, TQ_SIGNAL( clicked() ),
159 TQ_SLOT( syntaxHighlightingClicked() ) );
161 syntaxHighlightingClicked();
163 connect( syntaxHighlighting, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotChanged() ) );
164 connect( sizeSpin, TQ_SIGNAL( valueChanged(
int ) ),
this, TQ_SLOT( slotChanged() ) );
166 Q_ASSERT( !m_changed );
170TQPushButton* ConfigurePage::buildFontLine( TQWidget* parent,
171 TQGridLayout* layout,
int number, TQFont font, TQString name,
174 TQLabel* fontTitle =
new TQLabel( name, parent );
176 TQString labelName = font.family() +
' ' + TQString::number( font.pointSize() );
177 fontName =
new TQLabel( labelName, parent );
178 fontName->setFont( font );
179 fontName->setFrameStyle(TQFrame::StyledPanel | TQFrame::Sunken);
181 TQPushButton* chooseButton =
new TQPushButton( i18n(
"Choose..." ), parent );
183 layout->addWidget( fontTitle, number, 0 );
184 layout->addWidget( fontName, number, 1 );
185 layout->addWidget( chooseButton, number, 2 );
191void ConfigurePage::apply()
196 ContextStyle& contextStyle = m_document->getContextStyle(
true );
198 contextStyle.setDefaultFont( defaultFont );
199 contextStyle.setNameFont( nameFont );
200 contextStyle.setNumberFont( numberFont );
201 contextStyle.setOperatorFont( operatorFont );
202 contextStyle.setBaseSize( sizeSpin->value() );
204 contextStyle.setSyntaxHighlighting( syntaxHighlighting->isChecked() );
211 m_config->setGroup(
"kformula Font" );
212 m_config->writeEntry(
"defaultFont", TQString(defaultFont.toString()) );
213 m_config->writeEntry(
"nameFont", TQString(nameFont.toString()) );
214 m_config->writeEntry(
"numberFont", TQString(numberFont.toString()) );
215 m_config->writeEntry(
"operatorFont", TQString(operatorFont.toString()) );
216 m_config->writeEntry(
"baseSize", TQString::number( sizeSpin->value() ) );
227 m_document->updateConfig();
231void ConfigurePage::slotDefault()
233 defaultFont = TQFont(
"Times", 12, TQFont::Normal,
true );
234 nameFont = TQFont(
"Times" );
235 numberFont = nameFont;
236 operatorFont = nameFont;
238 sizeSpin->setValue( 20 );
240 updateFontLabel( defaultFont, defaultFontName );
241 updateFontLabel( nameFont, nameFontName );
242 updateFontLabel( numberFont, numberFontName );
243 updateFontLabel( operatorFont, operatorFontName );
245 syntaxHighlighting->setChecked(
true );
246 syntaxHighlightingClicked();
256void ConfigurePage::syntaxHighlightingClicked()
262void ConfigurePage::selectNewDefaultFont()
264 if ( selectFont( defaultFont ) )
265 updateFontLabel( defaultFont, defaultFontName );
268void ConfigurePage::selectNewNameFont()
270 if ( selectFont( nameFont ) )
271 updateFontLabel( nameFont, nameFontName );
274void ConfigurePage::selectNewNumberFont()
276 if ( selectFont( numberFont ) )
277 updateFontLabel( numberFont, numberFontName );
280void ConfigurePage::selectNewOperatorFont()
282 if ( selectFont( operatorFont ) )
283 updateFontLabel( operatorFont, operatorFontName );
286bool ConfigurePage::selectFont( TQFont & font )
292 TDEFontDialog dlg( m_view, 0,
false,
true, list );
295 int result = dlg.exec();
296 if ( KDialog::Accepted == result ) {
305void ConfigurePage::baseSizeChanged(
int )
309void ConfigurePage::updateFontLabel( TQFont font, TQLabel* label )
311 label->setText( font.family() +
' ' + TQString::number( font.pointSize() ) );
312 label->setFont( font );
315void ConfigurePage::slotChanged()
540KFORMULA_NAMESPACE_END
542using namespace KFormula;
543#include "kformulaconfigpage.moc"
Contains all the style information for the formela.
A document that can contain a lot of formulas (container).
ContextStyle & getContextStyle(bool edit=false)
static void getFontList(TQStringList &list, uint fontListCriteria)
const char * name(StdAction id)