You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
4.0 KiB
119 lines
4.0 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 2002 Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
14 years ago
|
#include <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
14 years ago
|
#include <tqstringlist.h>
|
||
13 years ago
|
#include <tqtextedit.h>
|
||
14 years ago
|
#include <tqtooltip.h>
|
||
|
#include <tqvariant.h>
|
||
|
#include <tqwhatsthis.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
12 years ago
|
#include <tdemessagebox.h>
|
||
|
#include <tdelocale.h>
|
||
15 years ago
|
#include <kstdguiitem.h>
|
||
|
#include <kpushbutton.h>
|
||
|
|
||
|
#include "formulastring.h"
|
||
|
#include "kformula_view.h"
|
||
|
|
||
|
|
||
13 years ago
|
FormulaString::FormulaString( KFormulaPartView* parent, const char* name, bool modal, WFlags fl )
|
||
|
: TQDialog( parent, name, modal, fl ), view( parent )
|
||
15 years ago
|
{
|
||
|
if ( !name )
|
||
|
setName( "FormulaString" );
|
||
|
resize( 511, 282 );
|
||
|
setCaption( i18n( "Formula String" ) );
|
||
|
setSizeGripEnabled( TRUE );
|
||
14 years ago
|
TQVBoxLayout* FormulaStringLayout = new TQVBoxLayout( this, 11, 6, "FormulaStringLayout");
|
||
15 years ago
|
|
||
14 years ago
|
textWidget = new TQTextEdit( this, "textWidget" );
|
||
15 years ago
|
FormulaStringLayout->addWidget( textWidget );
|
||
|
|
||
14 years ago
|
TQHBoxLayout* Layout2 = new TQHBoxLayout( 0, 0, 6, "Layout2");
|
||
|
TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
|
||
15 years ago
|
Layout2->addItem( spacer );
|
||
|
|
||
14 years ago
|
position = new TQLabel( this, "position" );
|
||
15 years ago
|
position->setText( trUtf8( "1:1" ) );
|
||
|
Layout2->addWidget( position );
|
||
|
FormulaStringLayout->addLayout( Layout2 );
|
||
|
|
||
14 years ago
|
TQHBoxLayout* Layout1 = new TQHBoxLayout( 0, 0, 6, "Layout1");
|
||
15 years ago
|
|
||
|
buttonHelp = new KPushButton( KStdGuiItem::help(), this, "buttonHelp" );
|
||
|
buttonHelp->setAccel( 4144 );
|
||
|
buttonHelp->setAutoDefault( TRUE );
|
||
|
Layout1->addWidget( buttonHelp );
|
||
14 years ago
|
spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
|
||
15 years ago
|
Layout1->addItem( spacer );
|
||
|
|
||
|
buttonOk = new KPushButton( KStdGuiItem::ok(), this, "buttonOk" );
|
||
|
buttonOk->setAccel( 0 );
|
||
|
buttonOk->setAutoDefault( TRUE );
|
||
|
buttonOk->setDefault( TRUE );
|
||
|
Layout1->addWidget( buttonOk );
|
||
|
|
||
|
buttonCancel = new KPushButton( KStdGuiItem::cancel(), this, "buttonCancel" );
|
||
|
buttonCancel->setAccel( 0 );
|
||
|
buttonCancel->setAutoDefault( TRUE );
|
||
|
Layout1->addWidget( buttonCancel );
|
||
|
FormulaStringLayout->addLayout( Layout1 );
|
||
|
|
||
|
// signals and slots connections
|
||
14 years ago
|
connect( buttonOk, TQT_SIGNAL( clicked() ), this, TQT_SLOT( accept() ) );
|
||
|
connect( buttonCancel, TQT_SIGNAL( clicked() ), this, TQT_SLOT( reject() ) );
|
||
|
connect( buttonHelp, TQT_SIGNAL(clicked() ), this, TQT_SLOT( helpButtonClicked() ) );
|
||
|
connect( textWidget, TQT_SIGNAL( cursorPositionChanged( int, int ) ),
|
||
|
this, TQT_SLOT( cursorPositionChanged( int, int ) ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
/*
|
||
|
* Destroys the object and frees any allocated resources
|
||
|
*/
|
||
|
FormulaString::~FormulaString()
|
||
|
{
|
||
14 years ago
|
// no need to delete child widgets, TQt does it all for us
|
||
15 years ago
|
}
|
||
|
|
||
|
void FormulaString::accept()
|
||
|
{
|
||
14 years ago
|
TQStringList errorList = view->readFormulaString( textWidget->text() );
|
||
15 years ago
|
if ( errorList.count() == 0 ) {
|
||
14 years ago
|
TQDialog::accept();
|
||
15 years ago
|
}
|
||
|
else {
|
||
|
KMessageBox::sorry( this, errorList.join( "\n" ), i18n( "Parser Error" ) );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void FormulaString::helpButtonClicked()
|
||
|
{
|
||
|
kapp->invokeHelp( "formula-strings", "kformula" );
|
||
|
}
|
||
|
|
||
|
void FormulaString::cursorPositionChanged( int para, int pos )
|
||
|
{
|
||
13 years ago
|
position->setText( TQString( "%1:%2" ).arg( para+1 ).arg( pos+1 ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
#include "formulastring.moc"
|