22#include "KPrTextProperty.h"
24#include <tqcheckbox.h>
30#include "KPrMarginWidget.h"
33KPrTextProperty::KPrTextProperty( TQWidget *parent,
const char *name,
const MarginsStruct &marginsStruct,
34 const KoUnit::Unit unit, PropValue protectContent )
35: TQWidget( parent, name )
37, m_protectContent( protectContent )
39 TQGridLayout *layout =
new TQGridLayout(
this, 1, 1, 11, 6 );
41 layout->addWidget( m_protectContentCheck =
new TQCheckBox( i18n(
"Protect content" ),
this ), 0, 0 );
42 layout->addWidget( m_margins =
new KPrMarginWidget(
this, name, m_unit ), 1, 0 );
44 connect( m_protectContentCheck, TQ_SIGNAL( toggled (
bool ) ),
45 this, TQ_SLOT( slotProtectContentChanged(
bool ) ) );
47 resize( TQSize( 301, 217 ).expandedTo( minimumSizeHint() ) );
49 m_margins->setValues( marginsStruct.leftMargin, marginsStruct.rightMargin,
50 marginsStruct.topMargin, marginsStruct.bottomMargin );
56KPrTextProperty::~KPrTextProperty()
61int KPrTextProperty::getTextPropertyChange()
const
65 if ( m_protectContentCheck->state() != TQButton::NoChange )
67 if ( ( m_protectContentCheck->isOn() ? STATE_ON : STATE_OFF ) != m_protectContent )
69 flags |= ProtectContent;
72 if ( ! m_protectContentCheck->isOn() && m_margins->changed() )
82MarginsStruct KPrTextProperty::getMarginsStruct()
const
84 MarginsStruct marginsStruct;
85 marginsStruct.leftMargin = m_margins->leftValue();
86 marginsStruct.rightMargin = m_margins->rightValue();
87 marginsStruct.topMargin = m_margins->topValue();
88 marginsStruct.bottomMargin = m_margins->bottomValue();
93bool KPrTextProperty::getProtectContent()
const
95 return m_protectContentCheck->isOn();
99void KPrTextProperty::apply()
101 int flags = getTextPropertyChange();
103 if ( flags & ProtectContent )
104 m_protectContent = m_protectContentCheck->isOn() ? STATE_ON : STATE_OFF;
106 if ( flags & Margins )
107 m_margins->resetChanged();
111void KPrTextProperty::slotProtectContentChanged(
bool b )
113 m_margins->setEnabled( !b );
117void KPrTextProperty::slotReset()
119 switch ( m_protectContent )
122 m_protectContentCheck->setChecked(
true );
125 m_protectContentCheck->setChecked(
false );
128 m_protectContentCheck->setTristate(
true );
129 m_protectContentCheck->setNoChange();
132 m_protectContentCheck->setChecked(
false );
138#include "KPrTextProperty.moc"