22#include <tqcheckbox.h>
23#include <tqcombobox.h>
27#include <tqlineedit.h>
30#include <tqpushbutton.h>
31#include <tqtabwidget.h>
34#include <tdefontcombo.h>
35#include <tdefontdialog.h>
36#include <kiconloader.h>
38#include <tdeglobalsettings.h>
40#include <karbon_view.h>
41#include <karbon_part.h>
42#include <core/vdocument.h>
43#include <core/vglobal.h>
44#include <core/vselection.h>
45#include <core/vfill.h>
46#include <core/vgroup.h>
47#include <core/vstroke.h>
48#include <core/vcursor.h>
49#include <render/vpainterfactory.h>
50#include <render/vkopainter.h>
55traceShape( VKoPainter* p,
int x,
int y,
int w,
int h )
58 p->moveTo( KoPoint( x + w , y + h ) );
59 p->lineTo( KoPoint( x + w / 3, y + h ) );
60 p->lineTo( KoPoint( x + w / 3, y + h / 3 ) );
61 p->lineTo( KoPoint( x + w , y + h / 3 ) );
62 p->lineTo( KoPoint( x + w , y + h ) );
64 p->moveTo( KoPoint( x , y ) );
65 p->lineTo( KoPoint( x + ( w / 3 ) * 2, y ) );
66 p->lineTo( KoPoint( x + ( w / 3 ) * 2, y + ( h / 3 ) * 2 ) );
67 p->lineTo( KoPoint( x , y + ( h / 3 ) * 2 ) );
68 p->lineTo( KoPoint( x , y ) );
71ShadowPreview::ShadowPreview( ShadowWidget* parent )
72 : TQWidget( parent ), m_parent( parent )
74 setBackgroundMode( TQt::NoBackground );
75 setMinimumSize( 60, 60 );
77 connect(
this, TQ_SIGNAL( changed(
int,
int,
bool ) ), m_parent, TQ_SLOT( setShadowValues(
int,
int,
bool ) ) );
80ShadowPreview::~ShadowPreview()
85ShadowPreview::mouseReleaseEvent( TQMouseEvent* e )
87 int dx = e->x() - width() / 2;
88 int dy = e->y() - height() / 2;
90 float fd = sqrt(
double( dx * dx + dy * dy ) );
95 else if( dy == 0 && dx < 0 )
99 float r = acos( dx / fd );
100 a = int( ( dy <= 0 ? r : VGlobal::twopi - r ) / VGlobal::twopi * 360. );
103 emit changed( a, (
int ) fd, m_parent->isTranslucent() );
107ShadowPreview::paintEvent( TQPaintEvent* )
110 int h = height() - 4;
111 int d = m_parent->shadowDistance();
112 int a = 360 - m_parent->shadowAngle();
115 VKoPainter p( &pm, w, h );
120 fill.pattern() = VPattern( il.iconPath(
"karbon.png", TDEIcon::Small ) );
124 p.moveTo( KoPoint( 0, 0 ) );
125 p.lineTo( KoPoint( 0, h ) );
126 p.lineTo( KoPoint( w, h ) );
127 p.lineTo( KoPoint( w, 0 ) );
128 p.lineTo( KoPoint( 0, 0 ) );
132 color.set( 1., 1., 1. );
133 color.setOpacity( .5 );
134 p.setBrush( VFill( color ) );
137 if( m_parent->isTranslucent() )
139 color.set( 0., 0., 0. );
140 color.setOpacity( .3 );
144 color.set( .3, .3, .3 );
145 color.setOpacity( 1. );
148 p.setPen( VStroke( color ) );
149 p.setBrush( VFill( color ) );
153 int( w / 4 + d * cos( a / 360. * VGlobal::twopi ) ),
154 int( h / 4 + d * sin( a / 360. * VGlobal::twopi ) ),
int( w / 2 ),
int( h / 2 ) );
159 color.set( 0., 0., 1. );
160 color.setOpacity( 1. );
161 p.setBrush( VFill( color ) );
162 color.set( 0., 0., .5 );
163 p.setPen( VStroke( color ) );
164 traceShape( &p, w / 4, h / 4, w / 2, h / 2 );
168 if( !m_parent->useShadow() )
171 p.moveTo( KoPoint( 0, 0 ) );
172 p.lineTo( KoPoint( 0, h ) );
173 p.lineTo( KoPoint( w, h ) );
174 p.lineTo( KoPoint( w, 0 ) );
175 p.lineTo( KoPoint( 0, 0 ) );
176 VColor c( colorGroup().background() );
178 p.setBrush( VFill( c ) );
184 TQPainter painter(
this );
185 painter.drawPixmap( 2, 2, pm );
186 painter.setPen( colorGroup().light() );
187 painter.moveTo( 1, height() - 1 );
188 painter.lineTo( 1, 1 );
189 painter.lineTo( width() - 1, 1 );
190 painter.lineTo( width() - 1, height() - 1 );
191 painter.lineTo( 1, height() - 1 );
192 painter.setPen( colorGroup().dark() );
193 painter.moveTo( 0, height() - 1 );
194 painter.lineTo( 0, 0 );
195 painter.lineTo( width() - 1, 0 );
196 painter.moveTo( width() - 2, 2 );
197 painter.lineTo( width() - 2, height() - 2 );
198 painter.lineTo( 2, height() - 2 );
199 painter.setPen( TQt::black );
200 painter.drawLine( width() / 2 - 2, height() / 2, width() / 2 + 2, height() / 2 );
201 painter.drawLine( width() / 2, height() / 2 - 2, width() / 2, height() / 2 + 2 );
204ShadowWidget::ShadowWidget( TQWidget* parent,
const char* name,
int angle,
int distance,
bool translucent )
205 : TQGroupBox( parent, name )
207 setTitle( i18n(
"Shadow" ) );
208 setSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Minimum ) );
210 TQGridLayout* layout =
new TQGridLayout(
this );
211 layout->addRowSpacing( 0, 12 );
212 layout->setMargin( 3 );
213 layout->setSpacing( 2 );
214 layout->setColStretch( 0, 1 );
215 layout->setColStretch( 1, 0 );
216 layout->setColStretch( 2, 2 );
217 layout->addMultiCellWidget( m_preview =
new ShadowPreview(
this ), 1, 3, 0, 0 );
218 layout->addWidget(
new TQLabel( i18n(
"Angle:" ),
this ), 1, 1 );
219 layout->addWidget( m_angle =
new KIntNumInput(
this ), 1, 2 );
220 layout->addWidget(
new TQLabel( i18n(
"Distance:" ),
this ), 2, 1 );
221 layout->addWidget( m_distance =
new KIntNumInput(
this ), 2, 2 );
222 layout->addWidget( m_useShadow =
new TQCheckBox( i18n(
"Shadow" ),
this ), 3, 1 );
223 layout->addWidget( m_translucent =
new TQCheckBox( i18n(
"Draw translucent shadow" ),
this ), 3, 2 );
224 m_distance->setRange( 1, 37, 1,
true );
225 m_angle->setRange( 0, 360, 10,
true );
226 m_angle->setValue( angle );
227 m_distance->setValue( distance );
228 m_translucent->setChecked( translucent );
230 connect( m_angle, TQ_SIGNAL( valueChanged(
int ) ),
this, TQ_SLOT( updatePreview(
int ) ) );
231 connect( m_distance, TQ_SIGNAL( valueChanged(
int ) ),
this, TQ_SLOT( updatePreview(
int ) ) );
232 connect( m_useShadow, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( updatePreview() ) );
233 connect( m_translucent, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( updatePreview() ) );
238ShadowWidget::~ShadowWidget()
243ShadowWidget::setUseShadow(
bool use )
245 m_useShadow->setChecked( use );
249bool ShadowWidget::useShadow()
251 return m_useShadow->isChecked();
255ShadowWidget::setShadowAngle(
int angle )
257 m_angle->setValue( angle );
258 m_preview->repaint();
262ShadowWidget::shadowAngle()
264 return m_angle->value();
268ShadowWidget::setShadowDistance(
int distance )
270 m_distance->setValue( distance );
271 m_preview->repaint();
275ShadowWidget::shadowDistance()
277 return m_distance->value();
281ShadowWidget::setTranslucent(
bool translucent )
283 m_translucent->setChecked( translucent );
284 m_preview->repaint();
287bool ShadowWidget::isTranslucent()
289 return m_translucent->isChecked();
293ShadowWidget::setShadowValues(
int angle,
int distance,
bool translucent )
295 m_angle->setValue( angle );
296 m_distance->setValue( distance );
297 m_translucent->setChecked( translucent );
302ShadowWidget::updatePreview(
int )
304 m_preview->repaint();
308ShadowWidget::updatePreview()
310 m_preview->repaint();
311 bool ok = m_useShadow->isChecked();
312 m_angle->setEnabled( ok );
313 m_distance->setEnabled( ok );
314 m_translucent->setEnabled( ok );
317VTextOptionsWidget::VTextOptionsWidget( VTextTool* tool, TQWidget *parent )
318 : KDialogBase( parent,
"", true, i18n(
"Text" ), Ok | Cancel ), m_tool( tool )
322 TQWidget *base =
new TQWidget(
this );
323 TQVBoxLayout* mainLayout =
new TQVBoxLayout( base );
324 mainLayout->setMargin( 3 );
326 mainLayout->add( m_tabWidget =
new TQTabWidget( base ) );
328 m_tabWidget->setFont( TQFont( TDEGlobalSettings::generalFont().family() , 8 ) );
330 TQWidget* textWidget =
new TQWidget( m_tabWidget );
332 TQGridLayout* textLayout =
new TQGridLayout( textWidget );
335 TDEFontChooser::getFontList( list, TDEFontChooser::SmoothScalableFonts );
337 textLayout->setMargin( 3 );
338 textLayout->setSpacing( 2 );
339 textLayout->addMultiCellWidget( m_fontCombo =
new TDEFontCombo( list, textWidget ), 0, 0, 0, 2 );
340 textLayout->addWidget( m_fontSize =
new KIntNumInput( textWidget ), 1, 0 );
341 textLayout->addWidget( m_boldCheck =
new TQCheckBox( i18n(
"Bold" ), textWidget ), 1, 1 );
342 textLayout->addWidget( m_italicCheck =
new TQCheckBox( i18n(
"Italic" ), textWidget ), 1, 2 );
343 textLayout->addMultiCellWidget( m_textEditor =
new TQLineEdit( textWidget ), 2, 2, 0, 2 );
345 m_tabWidget->addTab( textWidget, i18n(
"Text" ) );
347 TQWidget* posWidget =
new TQWidget( m_tabWidget );
349 TQGridLayout* posLayout =
new TQGridLayout( posWidget );
350 textLayout->setMargin( 3 );
351 posLayout->setSpacing( 2 );
352 posLayout->addWidget(
new TQLabel( i18n(
"Alignment:" ), posWidget ), 0, 0 );
353 posLayout->addWidget( m_textAlignment =
new TQComboBox( posWidget ), 0, 1 );
354 posLayout->addWidget(
new TQLabel( i18n(
"Position:" ), posWidget ), 1, 0 );
355 posLayout->addWidget( m_textPosition =
new TQComboBox( posWidget ), 1, 1 );
356 posLayout->addWidget(
new TQLabel( i18n(
"Offset:" ), posWidget ), 2, 0 );
357 posLayout->addWidget( m_textOffset =
new KDoubleNumInput( posWidget ), 2, 1 );
358 posLayout->setColStretch( 0, 0 );
359 posLayout->setColStretch( 1, 1 );
361 m_tabWidget->addTab( posWidget, i18n(
"Position" ) );
363 TQWidget* fxWidget =
new TQWidget( m_tabWidget );
365 TQVBoxLayout* fxLayout =
new TQVBoxLayout( fxWidget );
367 fxLayout->setMargin( 3 );
368 fxLayout->setSpacing( 2 );
369 fxLayout->add( m_shadow =
new ShadowWidget( fxWidget, 0L, 315, 4,
true ) );
371 TQHBoxLayout* fxLayout2 =
new TQHBoxLayout( fxLayout );
373 fxLayout2->setSpacing( 2 );
374 fxLayout2->addWidget( m_editBasePath =
new TQPushButton( i18n(
"Edit Base Path" ), fxWidget ) );
375 fxLayout2->addWidget( m_convertToShapes =
new TQPushButton( i18n(
"Convert to Shapes" ), fxWidget ) );
377 m_tabWidget->addTab( fxWidget, i18n(
"Effects" ) );
379 m_fontCombo->setCurrentText( TDEGlobalSettings::generalFont().family() );
381 m_fontSize->setValue( 12 );
382 m_fontSize->setSuffix(
" pt" );
384 m_textEditor->setMinimumHeight( 100 );
385 m_textEditor->setText( i18n(
"New text") );
386 m_textEditor->selectAll();
388 m_convertToShapes->setEnabled(
true );
390 m_textAlignment->insertItem( i18n(
"Horizontal alignment",
"Left") );
391 m_textAlignment->insertItem( i18n(
"Horizontal alignment",
"Center") );
392 m_textAlignment->insertItem( i18n(
"Horizontal alignment",
"Right") );
394 m_textPosition->insertItem( i18n(
"Vertical alignment",
"Above") );
395 m_textPosition->insertItem( i18n(
"Vertical alignment",
"On") );
396 m_textPosition->insertItem( i18n(
"Vertical alignment",
"Under") );
398 m_textOffset->setRange( 0.0, 100.0, 1.0,
true );
400 connect( m_fontCombo, TQ_SIGNAL( activated(
int ) ),
this, TQ_SLOT( valueChanged(
int ) ) );
401 connect( m_boldCheck, TQ_SIGNAL( stateChanged(
int ) ),
this, TQ_SLOT( valueChanged(
int ) ) );
402 connect( m_italicCheck, TQ_SIGNAL( stateChanged(
int ) ),
this, TQ_SLOT( valueChanged(
int ) ) );
403 connect( m_fontSize, TQ_SIGNAL( valueChanged(
int ) ),
this, TQ_SLOT( valueChanged(
int ) ) );
404 connect( m_textPosition, TQ_SIGNAL( activated(
int ) ),
this, TQ_SLOT( valueChanged(
int ) ) );
405 connect( m_textAlignment, TQ_SIGNAL( activated(
int ) ),
this, TQ_SLOT( valueChanged(
int ) ) );
406 connect( m_textOffset, TQ_SIGNAL( valueChanged(
double ) ),
this, TQ_SLOT( valueChanged(
double ) ) );
407 connect( m_textEditor, TQ_SIGNAL( returnPressed() ),
this, TQ_SLOT( accept() ) );
408 connect( m_textEditor, TQ_SIGNAL( textChanged(
const TQString& ) ),
this, TQ_SLOT( textChanged(
const TQString& ) ) );
409 connect( m_editBasePath, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( editBasePath() ) );
410 connect( m_convertToShapes, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( convertToShapes() ) );
411 connect(
this, TQ_SIGNAL( cancelClicked() ),
this, TQ_SLOT( cancel() ) );
413 setMainWidget( base );
414 setFixedSize( baseSize() );
417VTextOptionsWidget::~VTextOptionsWidget()
422VTextOptionsWidget::valueChanged(
int )
424 m_fontCombo->setBold( m_boldCheck->isChecked() );
425 m_fontCombo->setItalic( m_italicCheck->isChecked() );
427 m_textEditor->setFont( TQFont( m_fontCombo->currentText(), m_fontSize->value(), ( m_boldCheck->isChecked() ? 75 : 50 ), m_italicCheck->isChecked() ) );
429 if( m_tool && isVisible() )
430 m_tool->textChanged();
434VTextOptionsWidget::valueChanged(
double )
436 if( m_tool && isVisible() )
437 m_tool->textChanged();
441VTextOptionsWidget::accept()
449VTextOptionsWidget::cancel()
456VTextOptionsWidget::textChanged(
const TQString& )
458 if( m_tool && isVisible() )
459 m_tool->textChanged();
463VTextOptionsWidget::editBasePath()
466 m_tool->editBasePath();
470VTextOptionsWidget::convertToShapes()
473 m_tool->convertToShapes();
477VTextOptionsWidget::setFont(
const TQFont& font )
479 m_fontCombo->setCurrentText( font.family() );
481 m_boldCheck->setChecked( font.bold() );
483 m_italicCheck->setChecked( font.italic() );
485 m_fontSize->setValue( font.pointSize() );
487 m_fontCombo->setBold( m_boldCheck->isChecked() );
488 m_fontCombo->setItalic( m_italicCheck->isChecked() );
490 m_textEditor->setFont( TQFont( m_fontCombo->currentText(), m_fontSize->value(), ( m_boldCheck->isChecked() ? 75 : 50 ), m_italicCheck->isChecked() ) );
493TQFont VTextOptionsWidget::font()
495 return TQFont( m_fontCombo->currentText(), m_fontSize->value(), ( m_boldCheck->isChecked() ? 75 : 50 ), m_italicCheck->isChecked() );
499VTextOptionsWidget::setText(
const TQString& text )
501 m_textEditor->setText( text );
504TQString VTextOptionsWidget::text()
506 return m_textEditor->text();
510VTextOptionsWidget::setPosition( VText::Position position )
512 m_textPosition->setCurrentItem( position );
515VText::Position VTextOptionsWidget::position()
517 return ( VText::Position ) m_textPosition->currentItem();
521VTextOptionsWidget::setAlignment( VText::Alignment alignment )
523 m_textAlignment->setCurrentItem( alignment );
526VText::Alignment VTextOptionsWidget::alignment()
528 return ( VText::Alignment ) m_textAlignment->currentItem();
532VTextOptionsWidget::setOffset(
double offset )
534 if( offset < 0.0 ) offset = 0.0;
535 if( offset > 100.0 ) offset = 100.0;
537 m_textOffset->setValue( offset );
540VTextOptionsWidget::offset()
542 return m_textOffset->value();
546VTextOptionsWidget::setUseShadow(
bool state )
548 m_shadow->setUseShadow( state );
551bool VTextOptionsWidget::useShadow()
553 return m_shadow->useShadow();
557VTextOptionsWidget::setShadow(
int angle,
int distance,
bool translucent )
559 m_shadow->setShadowValues( angle, distance, translucent );
562bool VTextOptionsWidget::translucentShadow()
564 return m_shadow->isTranslucent();
568VTextOptionsWidget::shadowAngle()
570 return m_shadow->shadowAngle();
574VTextOptionsWidget::shadowDistance()
576 return m_shadow->shadowDistance();
580VTextOptionsWidget::initialize(
VObject &text )
583 m_tool->visit( text );
586VTextTool::VTextTool( KarbonView *view )
587 :
VTool( view,
"tool_text" )
589 m_optionsWidget =
new VTextOptionsWidget(
this, 0L );
592 registerTool(
this );
596VTextTool::~VTextTool()
598 delete m_optionsWidget;
605 TQString s = i18n(
"<qt><b>Text Tool</b><br>" );
606 s += i18n(
"<i>Click</i> on document to place horizontal text.<br>" );
607 s += i18n(
"<i>Click and drag</i> in document to place directional text.<br>" );
608 s += i18n(
"<i>Click</i> on a selected path object to place text along its outline.<br>" );
609 s += i18n(
"<i>Click</i> on a selected text object to change it.<br></qt>" );
618 view()->statusMessage()->setText( i18n(
"Text Tool" ) );
619 view()->setCursor( *m_cursor );
633VTextTool::draw( VPainter* painter )
636 m_editedText->draw( painter, &m_editedText->boundingBox() );
640VTextTool::drawPathCreation()
642 VPainter * painter =
view()->painterFactory()->editpainter();
644 painter->setZoomFactor(
view()->zoom() );
646 painter->setRasterOp( TQt::NotROP );
648 painter->setPen( TQt::DotLine );
649 painter->setBrush( TQt::NoBrush );
651 painter->moveTo(
first() );
652 painter->lineTo( m_last );
653 painter->strokePath();
657VTextTool::drawEditedText()
660 view()->repaintAll( m_editedText->boundingBox() );
677 VSelection* selection =
view()->part()->document().
selection();
678 VObject* selObj = selection->
objects().getFirst();
682 m_optionsWidget->initialize( *selObj );
687 path.moveTo(
first() );
688 path.lineTo( KoPoint(
first().x()+10,
first().y() ) );
690 if( ! createText( path ) )
694 if(
dynamic_cast<VText*
>( selObj ) && selObj->
boundingBox().contains(
last() ) )
695 m_optionsWidget->setCaption( i18n(
"Change Text") );
697 m_optionsWidget->setCaption( i18n(
"Insert Text") );
699 m_optionsWidget->show();
709 KoPoint act =
last();
710 KoPoint dst = act -
first();
712 double angle = atan2( dst.y(), dst.x() );
714 angle += VGlobal::twopi;
717 double prevStep = angle - fmod( angle, VGlobal::pi_2 / 2.0f );
718 double nextStep = prevStep + VGlobal::pi_2 / 2.0f;
720 double length = sqrt( dst.x()*dst.x() + dst.y()*dst.y() );
723 if( angle - prevStep < nextStep - angle )
725 m_last.setX(
first().x() + length * cos( prevStep ) );
726 m_last.setY(
first().y() + length * sin( prevStep ) );
730 m_last.setX(
first().x() + length * cos( nextStep ) );
731 m_last.setY(
first().y() + length * sin( nextStep ) );
745 if( m_creating && m_editedText )
754 path.moveTo(
first() );
755 path.lineTo( m_last );
757 if( createText( path ) )
759 m_optionsWidget->setCaption( i18n(
"Insert Text") );
760 m_optionsWidget->show();
765VTextTool::createText(
VSubpath &path )
771 m_editedText =
new VText( m_optionsWidget->font(), path, m_optionsWidget->position(), m_optionsWidget->alignment(), m_optionsWidget->text() );
778#ifdef HAVE_KARBONTEXT
779 m_editedText->traceText();
789VTextTool::textChanged()
798 view()->repaintAll( m_text->boundingBox() );
801 view()->repaintAll( m_editedText->boundingBox() );
803 m_editedText->setText( m_optionsWidget->text() );
804 m_editedText->setFont( m_optionsWidget->font() );
805 m_editedText->setPosition( m_optionsWidget->position() );
806 m_editedText->setAlignment( m_optionsWidget->alignment() );
807 m_editedText->setOffset( 0.01 * m_optionsWidget->offset() );
808#ifdef HAVE_KARBONTEXT
809 m_editedText->traceText();
826 &
view()->part()->document(),
827 i18n(
"Change Text" ),
829 m_editedText->font(),
830 m_editedText->basePath(),
831 m_editedText->position(),
832 m_editedText->alignment(),
833 m_editedText->offset(),
834 m_editedText->text(),
835 m_optionsWidget->useShadow(),
836 m_optionsWidget->shadowAngle(),
837 m_optionsWidget->shadowDistance(),
838 m_optionsWidget->translucentShadow() );
842 VText *newText = m_editedText->clone();
843 newText->setUseShadow( m_optionsWidget->useShadow() );
844 newText->setShadow( m_optionsWidget->shadowAngle(), m_optionsWidget->shadowDistance(), m_optionsWidget->translucentShadow() );
847 &
view()->part()->document(),
848 i18n(
"Insert Text" ),
867 view()->repaintAll( m_text->boundingBox() );
877VTextTool::editBasePath()
888VTextTool::convertToShapes()
893 VTextToCompositeCmd* cmd =
new VTextToCompositeCmd(
894 &
view()->part()->document(),
895 i18n(
"Text Conversion" ),
909VTextTool::visitVPath(
VPath& composite )
911 if( composite.paths().count() == 0 )
914 if( createText( *composite.paths().getFirst() ) )
919VTextTool::visitVSubpath(
VSubpath& path )
921 if( createText( path ) )
926VTextTool::visitVText( VText& text )
930 m_editedText = text.clone();
932 m_optionsWidget->setFont( text.font() );
933 m_optionsWidget->setText( text.text() );
934 m_optionsWidget->setPosition( text.position() );
935 m_optionsWidget->setAlignment( text.alignment() );
936 m_optionsWidget->setOffset( text.offset() * 100.0 );
937 m_optionsWidget->setUseShadow( text.useShadow() );
938 m_optionsWidget->setShadow( text.shadowAngle(), text.shadowDistance(), text.translucentShadow() );
944VTextTool::VTextCmd::VTextCmd(
VDocument* doc,
const TQString& name, VText* text )
945 :
VCommand( doc, name,
"14_text" ), m_text( text )
947 m_textModifications = 0L;
952VTextTool::VTextCmd::VTextCmd(
VDocument* doc,
const TQString& name, VText* text,
953 const TQFont &newFont,
const VSubpath& newBasePath, VText::Position newPosition, VText::Alignment newAlignment,
double newOffset,
const TQString& newText,
954 bool newUseShadow,
int newShadowAngle,
int newShadowDistance,
bool newTranslucentShadow )
955 :
VCommand( doc, name,
"14_text" ), m_text( text )
957 m_textModifications =
new VTextModifPrivate();
958 m_textModifications->newFont = newFont;
959 m_textModifications->oldFont = text->font();
960 m_textModifications->newBasePath = newBasePath;
961 m_textModifications->oldBasePath = text->basePath();
962 m_textModifications->newPosition = newPosition;
963 m_textModifications->oldPosition = text->position();
964 m_textModifications->newAlignment = newAlignment;
965 m_textModifications->oldAlignment = text->alignment();
966 m_textModifications->newOffset = newOffset;
967 m_textModifications->oldOffset = text->offset();
968 m_textModifications->newText = newText;
969 m_textModifications->oldText = text->text();
970 m_textModifications->newUseShadow = newUseShadow;
971 m_textModifications->oldUseShadow = text->useShadow();
972 m_textModifications->newShadowAngle = newShadowAngle;
973 m_textModifications->oldShadowAngle = text->shadowAngle();
974 m_textModifications->newShadowDistance = newShadowDistance;
975 m_textModifications->oldShadowDistance = text->shadowDistance();
976 m_textModifications->newTranslucentShadow = newTranslucentShadow;
977 m_textModifications->oldTranslucentShadow = text->translucentShadow();
982VTextTool::VTextCmd::~VTextCmd()
984 delete m_textModifications;
993 if( !m_textModifications )
1000 document()->append( m_text );
1001 document()->selection()->clear();
1002 document()->selection()->append( m_text );
1007 m_text->setFont( m_textModifications->newFont );
1008 m_text->setBasePath( m_textModifications->newBasePath );
1009 m_text->setPosition( m_textModifications->newPosition );
1010 m_text->setAlignment( m_textModifications->newAlignment );
1011 m_text->setOffset( m_textModifications->newOffset );
1012 m_text->setText( m_textModifications->newText );
1013 m_text->setUseShadow( m_textModifications->newUseShadow );
1014 m_text->setShadow( m_textModifications->newShadowAngle, m_textModifications->newShadowDistance, m_textModifications->newTranslucentShadow );
1016#ifdef HAVE_KARBONTEXT
1017 m_text->traceText();
1034 if( !m_textModifications )
1036 document()->selection()->take( *m_text );
1041 m_text->setFont( m_textModifications->oldFont );
1042 m_text->setBasePath( m_textModifications->oldBasePath );
1043 m_text->setPosition( m_textModifications->oldPosition );
1044 m_text->setAlignment( m_textModifications->oldAlignment );
1045 m_text->setOffset( m_textModifications->oldOffset );
1046 m_text->setText( m_textModifications->oldText );
1047 m_text->setUseShadow( m_textModifications->oldUseShadow );
1048 m_text->setShadow( m_textModifications->oldShadowAngle, m_textModifications->oldShadowDistance, m_textModifications->oldTranslucentShadow );
1050#ifdef HAVE_KARBONTEXT
1051 m_text->traceText();
1062VTextTool::VTextToCompositeCmd::VTextToCompositeCmd( VDocument* doc,
const TQString& name, VText* text )
1063 : VCommand( doc, name,
"14_text" ), m_text( text ), m_group( 0L ), m_executed( false )
1067VTextTool::VTextToCompositeCmd::~VTextToCompositeCmd()
1079 m_group = m_text->toVGroup();
1080 document()->append( m_group );
1085 document()->selection()->clear();
1086 document()->selection()->append( m_group );
1101 document()->selection()->take( *m_group );
1113 VSelection* selection =
view()->part()->document().
selection();
1116 if( selection->
objects().count() == 1 )
1117 m_optionsWidget->initialize( *selection->
objects().getFirst());
1121 if(
dynamic_cast<VText*
>( selection->
objects().getFirst() ) )
1122 m_optionsWidget->setCaption(i18n(
"Change Text") );
1124 m_optionsWidget->setCaption(i18n(
"Insert Text") );
1126 m_optionsWidget->show();
1145VTextTool::setup( TDEActionCollection *collection )
1147 m_action =
static_cast<TDERadioAction *
>(collection ->
action( name() ) );
1151 m_action =
new TDERadioAction( i18n(
"Text Tool" ),
"14_text", TQt::SHIFT+TQt::Key_T,
this, TQ_SLOT(
activate() ), collection, name() );
1152 m_action->setToolTip( i18n(
"Text Tool" ) );
1153 m_action->setExclusiveGroup(
"misc" );
1158#include "vtexttool.moc"
void repaintAllViews(bool repaint=true)
repaint all views attached to this koDocument
void addCommand(VCommand *cmd, bool repaint=false)
insert a command into the undo/redo-history:
@ rgb
the RGB colorspace (red, green and blue components)
The base class for all karbon commands.
virtual void unexecute()
Unexecutes the command.
virtual void execute()=0
Executes the command.
@ CrossHair
unthemed crosshair cursor
static TQCursor createCursor(CursorType type)
Creates a predefined cursor of the specified type.
All non-visual, static doc info is in here.
VSelection * selection() const
Returns a pointer to the selection.
The base class for all karbon objects.
@ selected
visible, active and can be manipulated by tools
@ deleted
deleted, nearly dead
@ normal
visible, not active
@ edit
visible, active and is currently manipulated by a tool
virtual const KoRect & boundingBox() const
Calculates the tightest bounding box around the object.
A composite path consists of one or many subpaths.
const VObjectList & objects() const
Read only access to the selected objects.
void append()
Adds all objects to the selection.
void clear()
Removes the references to all objects, not the objects themselves.
VSubpath provides a sophisticated list of VSegment.
void setSuccess(bool success=true)
Set the success property.