KOffice – TDE office suite
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

formulastring.cc 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* This file is part of the KDE project
  2. Copyright (C) 2002 Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public
  5. License as published by the Free Software Foundation; either
  6. version 2 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public License
  12. along with this library; see the file COPYING.LIB. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  14. * Boston, MA 02110-1301, USA.
  15. */
  16. #include <tqlabel.h>
  17. #include <tqlayout.h>
  18. #include <tqstringlist.h>
  19. #include <tqtextedit.h>
  20. #include <tqtooltip.h>
  21. #include <tqvariant.h>
  22. #include <tqwhatsthis.h>
  23. #include <tdeapplication.h>
  24. #include <tdemessagebox.h>
  25. #include <tdelocale.h>
  26. #include <kstdguiitem.h>
  27. #include <kpushbutton.h>
  28. #include "formulastring.h"
  29. #include "kformula_view.h"
  30. FormulaString::FormulaString( KFormulaPartView* parent, const char* name, bool modal, WFlags fl )
  31. : TQDialog( parent, name, modal, fl ), view( parent )
  32. {
  33. if ( !name )
  34. setName( "FormulaString" );
  35. resize( 511, 282 );
  36. setCaption( i18n( "Formula String" ) );
  37. setSizeGripEnabled( TRUE );
  38. TQVBoxLayout* FormulaStringLayout = new TQVBoxLayout( this, 11, 6, "FormulaStringLayout");
  39. textWidget = new TQTextEdit( this, "textWidget" );
  40. FormulaStringLayout->addWidget( textWidget );
  41. TQHBoxLayout* Layout2 = new TQHBoxLayout( 0, 0, 6, "Layout2");
  42. TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
  43. Layout2->addItem( spacer );
  44. position = new TQLabel( this, "position" );
  45. position->setText( trUtf8( "1:1" ) );
  46. Layout2->addWidget( position );
  47. FormulaStringLayout->addLayout( Layout2 );
  48. TQHBoxLayout* Layout1 = new TQHBoxLayout( 0, 0, 6, "Layout1");
  49. buttonHelp = new KPushButton( KStdGuiItem::help(), this, "buttonHelp" );
  50. buttonHelp->setAccel( 4144 );
  51. buttonHelp->setAutoDefault( TRUE );
  52. Layout1->addWidget( buttonHelp );
  53. spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
  54. Layout1->addItem( spacer );
  55. buttonOk = new KPushButton( KStdGuiItem::ok(), this, "buttonOk" );
  56. buttonOk->setAccel( 0 );
  57. buttonOk->setAutoDefault( TRUE );
  58. buttonOk->setDefault( TRUE );
  59. Layout1->addWidget( buttonOk );
  60. buttonCancel = new KPushButton( KStdGuiItem::cancel(), this, "buttonCancel" );
  61. buttonCancel->setAccel( 0 );
  62. buttonCancel->setAutoDefault( TRUE );
  63. Layout1->addWidget( buttonCancel );
  64. FormulaStringLayout->addLayout( Layout1 );
  65. // signals and slots connections
  66. connect( buttonOk, TQT_SIGNAL( clicked() ), this, TQT_SLOT( accept() ) );
  67. connect( buttonCancel, TQT_SIGNAL( clicked() ), this, TQT_SLOT( reject() ) );
  68. connect( buttonHelp, TQT_SIGNAL(clicked() ), this, TQT_SLOT( helpButtonClicked() ) );
  69. connect( textWidget, TQT_SIGNAL( cursorPositionChanged( int, int ) ),
  70. this, TQT_SLOT( cursorPositionChanged( int, int ) ) );
  71. }
  72. /*
  73. * Destroys the object and frees any allocated resources
  74. */
  75. FormulaString::~FormulaString()
  76. {
  77. // no need to delete child widgets, TQt does it all for us
  78. }
  79. void FormulaString::accept()
  80. {
  81. TQStringList errorList = view->readFormulaString( textWidget->text() );
  82. if ( errorList.count() == 0 ) {
  83. TQDialog::accept();
  84. }
  85. else {
  86. KMessageBox::sorry( this, errorList.join( "\n" ), i18n( "Parser Error" ) );
  87. }
  88. }
  89. void FormulaString::helpButtonClicked()
  90. {
  91. kapp->invokeHelp( "formula-strings", "kformula" );
  92. }
  93. void FormulaString::cursorPositionChanged( int para, int pos )
  94. {
  95. position->setText( TQString( "%1:%2" ).arg( para+1 ).arg( pos+1 ) );
  96. }
  97. #include "formulastring.moc"