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.
kbarcode/kbarcode/textlineedit.cpp

203 lines
5.3 KiB

//
// C++ Implementation: textlineedit
//
// Description:
//
//
// Author: Dominik Seichter <domseichter@web.de>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "textlineedit.h"
#include "tokendialog.h"
// KDE includes
#include <knuminput.h>
#include <kaction.h>
#include <tdeversion.h>
#include <kcolordialog.h>
#include <tdefiledialog.h>
#include <klocale.h>
#include <tdespell.h>
#include <klineedit.h>
#include <ktoolbar.h>
#include <kcombobox.h>
// TQt includes
#include <tqdockarea.h>
#include <tqregexp.h>
#include <tqlabel.h>
#include <tqlayout.h>
TextLineEditor::TextLineEditor( TokenProvider* token, TQWidget *parent, const char *name )
: TQWidget( parent, name ), m_token( token )
{
TQVBoxLayout* layout = new TQVBoxLayout( this, 6, 6 );
editor = new KLineEdit( this );
editor->setFocus();
TQDockArea* area = new TQDockArea( Qt::Horizontal, TQDockArea::Normal, this );
toolBar = new KToolBar( area );
tool2Bar = new KToolBar( area );
tool3Bar = new KToolBar( area );
setupActions();
layout->addWidget( area );
layout->addWidget( editor );
}
TextLineEditor::~TextLineEditor()
{
}
void TextLineEditor::setupActions()
{
ac = new KActionCollection( this );
KAction *action_undo = KStdAction::undo( TQT_TQOBJECT(editor), TQT_SLOT( undo() ), ac );
action_undo->setEnabled( false );
connect( editor, TQT_SIGNAL( undoAvailable(bool) ), action_undo, TQT_SLOT( setEnabled(bool) ) );
KAction *action_redo = KStdAction::redo( TQT_TQOBJECT(editor), TQT_SLOT( redo() ), ac );
action_redo->setEnabled( false );
connect( editor, TQT_SIGNAL( redoAvailable(bool) ), action_redo, TQT_SLOT( setEnabled(bool) ) );
KAction *action_cut = KStdAction::cut( TQT_TQOBJECT(editor), TQT_SLOT( cut() ), ac );
action_cut->setEnabled( false );
connect( editor, TQT_SIGNAL( copyAvailable(bool) ), action_cut, TQT_SLOT( setEnabled(bool) ) );
KAction *action_copy = KStdAction::copy( TQT_TQOBJECT(editor), TQT_SLOT( copy() ), ac );
action_copy->setEnabled( false );
connect( editor, TQT_SIGNAL( copyAvailable(bool) ), action_copy, TQT_SLOT( setEnabled(bool) ) );
KAction* action_paste = KStdAction::paste( TQT_TQOBJECT(editor), TQT_SLOT( paste() ), ac );
KAction* textDataAct = new KAction( i18n("Insert &Data Field"), "contents", 0, TQT_TQOBJECT(this), TQT_SLOT( insertNewField() ), ac, "text_data_act");
action_undo->plug( toolBar );
action_redo->plug( toolBar );
toolBar->insertSeparator();
action_cut->plug( toolBar );
action_copy->plug( toolBar );
action_paste->plug( toolBar );
TQStringList fuentes;
fuentes += "Tiems Roman (Medium) 8 point";
fuentes += "Tiems Roman (Medium) 10 point";
fuentes += "Tiems Roman (Bold) 10 point";
fuentes += "Tiems Roman (Bold) 12 point";
fuentes += "Tiems Roman (Bold) 14 point";
fuentes += "Tiems Roman (Italic) 12 point";
fuentes += "Helvetica (Medium) 6 point";
fuentes += "Helvetica (Medium) 10 point";
fuentes += "Helvetica (Medium) 12 point";
fuentes += "Helvetica (Bold) 12 point";
fuentes += "Helvetica (Bold) 14 point";
fuentes += "Helvetica (Italic) 12 point";
fuentes += "Presentation (Bold) 18 point";
fuentes += "Letter Gothic (Medium) 9.5 point";
fuentes += "Prestige Elite (Medium) 7 point";
fuentes += "Prestige Elite (Bold) 10 point";
fuentes += "Courier (Medium) 10 point";
fuentes += "Courier (Bold) 12 point";
fuentes += "OCR-A 12 point";
fuentes += "OCR-B 12 point";
textDataAct->plug( tool2Bar );
action_font_type = new KComboBox(tool2Bar,"font_type") ;
connect( action_font_type, TQT_SIGNAL( activated(int) ), TQT_TQOBJECT(this), TQT_SLOT( setFontType(int) ) );
action_font_type->insertStringList(fuentes) ;
TQLabel* labelv = new TQLabel( i18n("&Mag. Vert.:"), tool3Bar );
mag_vert = new KIntNumInput( tool3Bar,"magvert" );
TQLabel* labelh = new TQLabel( i18n("&Mag. Hor.:"), tool3Bar );
mag_hor = new KIntNumInput( tool3Bar,"maghor" );
connect( mag_vert, TQT_SIGNAL( activated(int) ), TQT_TQOBJECT(this), TQT_SLOT( setVerMag(int) ) );
connect( mag_hor, TQT_SIGNAL( activated(int) ), TQT_TQOBJECT(this), TQT_SLOT( setHorMag(int) ) );
mag_vert->setRange( 1, 9, 1, false );
mag_hor->setRange( 1, 9, 1, false );
labelv->setBuddy( mag_vert );
labelh->setBuddy( mag_hor );
updateActions();
}
TQString TextLineEditor::text()
{
return editor->text();
}
void TextLineEditor::setText( const TQString & t )
{
editor->setText( t );
}
void TextLineEditor::updateActions()
{
}
void TextLineEditor::insertNewField()
{
TokenDialog dlg( m_token, this, "dlg" );
if( dlg.exec() == TQDialog::Accepted )
editor->insert( dlg.token() ) ;
}
void TextLineEditor::setFontType( int index )
{
action_font_type->setCurrentItem(index);
}
int TextLineEditor::getFontType()
{
return action_font_type->currentItem();
}
void TextLineEditor::setVertMag( int index )
{
mag_vert->setValue(index);
}
int TextLineEditor::getVertMag()
{
return mag_vert->value();
}
void TextLineEditor::setHorMag( int index )
{
mag_hor->setValue(index);
}
int TextLineEditor::getHorMag()
{
return mag_hor->value();
}
#include "textlineedit.moc"