lib

KoHighlightingTab.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001, 2002 Montel Laurent <lmontel@mandrakesoft.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include "KoHighlightingTab.h"
21#include "KoTextFormat.h"
22
23#include <tqstringlist.h>
24#include <tqbuttongroup.h>
25#include <tqradiobutton.h>
26#include <tqcheckbox.h>
27
28#include <kcombobox.h>
29#include <kcolorbutton.h>
30
31#include "KoHighlightingTab.moc"
32
33
34KoHighlightingTab::KoHighlightingTab( TQWidget* parent, const char* name, WFlags fl )
35 : KoHighlightingTabBase( parent, name, fl )
36{
37 underlineStyleKComboBox->insertStringList( KoTextFormat::underlineTypeList() );
38 underlineLineStyleKComboBox->insertStringList( KoTextFormat::underlineStyleList() );
39 strikethroughStyleKComboBox->insertStringList( KoTextFormat::strikeOutTypeList() );
40 strikethroughLineStyleKComboBox->insertStringList( KoTextFormat::strikeOutStyleList() );
41
42 capitalisationButtonGroup->setColumnLayout( 3, TQt::Horizontal );
43 TQStringList attributes = KoTextFormat::fontAttributeList();
44 for ( TQStringList::Iterator it = attributes.begin(); it != attributes.end(); ++it ) {
45 capitalisationButtonGroup->insert( new TQRadioButton( *it, capitalisationButtonGroup ) );
46 }
47 capitalisationButtonGroup->setButton( 0 );
48
49 connect( underlineStyleKComboBox, TQ_SIGNAL( activated( int ) ), this, TQ_SLOT( slotUnderlineChanged( int ) ) );
50 connect( underlineLineStyleKComboBox, TQ_SIGNAL( activated( int ) ), this, TQ_SIGNAL( underlineStyleChanged( int ) ) );
51 connect( underlineKColorButton, TQ_SIGNAL( changed( const TQColor & ) ), this, TQ_SIGNAL( underlineColorChanged( const TQColor & ) ) );
52 connect( strikethroughStyleKComboBox, TQ_SIGNAL( activated( int ) ), this, TQ_SLOT( slotStrikethroughChanged( int ) ) );
53 connect( strikethroughLineStyleKComboBox, TQ_SIGNAL( activated( int ) ), this, TQ_SIGNAL( strikethroughStyleChanged( int ) ) );
54 connect( underlineWordByWordCheckBox, TQ_SIGNAL( toggled( bool ) ), this, TQ_SIGNAL( wordByWordChanged( bool ) ) );
55 connect( capitalisationButtonGroup, TQ_SIGNAL( clicked( int ) ), this, TQ_SIGNAL( capitalisationChanged( int ) ) );
56}
57
58KoHighlightingTab::~KoHighlightingTab()
59{
60}
61
62KoTextFormat::UnderlineType KoHighlightingTab::getUnderline() const
63{
64 return static_cast<KoTextFormat::UnderlineType>( underlineStyleKComboBox->currentItem() );
65}
66
67KoTextFormat::UnderlineStyle KoHighlightingTab::getUnderlineStyle() const
68{
69 return static_cast<KoTextFormat::UnderlineStyle>( underlineLineStyleKComboBox->currentItem() );
70}
71
72TQColor KoHighlightingTab::getUnderlineColor() const
73{
74 return underlineKColorButton->color();
75}
76
77KoTextFormat::StrikeOutType KoHighlightingTab::getStrikethrough() const
78{
79 return static_cast<KoTextFormat::StrikeOutType>( strikethroughStyleKComboBox->currentItem() );
80}
81
82KoTextFormat::StrikeOutStyle KoHighlightingTab::getStrikethroughStyle() const
83{
84 return static_cast<KoTextFormat::StrikeOutStyle>( strikethroughLineStyleKComboBox->currentItem() );
85}
86
87bool KoHighlightingTab::getWordByWord() const
88{
89 return underlineWordByWordCheckBox->isOn();
90}
91
92KoTextFormat::AttributeStyle KoHighlightingTab::getCapitalisation() const
93{
94 return static_cast<KoTextFormat::AttributeStyle>( capitalisationButtonGroup->selectedId() );
95}
96
97void KoHighlightingTab::setUnderline( KoTextFormat::UnderlineType item )
98{
99 underlineStyleKComboBox->setCurrentItem( static_cast<int>( item ) );
100 slotUnderlineChanged( static_cast<int>( item ) );
101}
102
103void KoHighlightingTab::setUnderlineStyle( KoTextFormat::UnderlineStyle item )
104{
105 underlineLineStyleKComboBox->setCurrentItem( static_cast<int>( item ) );
106 emit underlineStyleChanged( static_cast<int>( item ) );
107}
108
109void KoHighlightingTab::setUnderlineColor( const TQColor &color )
110{
111 underlineKColorButton->setColor( color );
112}
113
114void KoHighlightingTab::setStrikethrough( int item )
115{
116 strikethroughStyleKComboBox->setCurrentItem( static_cast<int>( item ) );
117 slotStrikethroughChanged( static_cast<int>( item ) );
118}
119
120void KoHighlightingTab::setStrikethroughStyle( int item )
121{
122 strikethroughLineStyleKComboBox->setCurrentItem( static_cast<int>( item ) );
123 emit strikethroughStyleChanged( static_cast<int>( item ) );
124}
125
126void KoHighlightingTab::setWordByWord( bool state )
127{
128 underlineWordByWordCheckBox->setChecked( state );
129}
130
131void KoHighlightingTab::setCapitalisation( int item )
132{
133 capitalisationButtonGroup->setButton( static_cast<int>( item ) );
134 emit capitalisationChanged( static_cast<int>( item ) );
135}
136
137void KoHighlightingTab::slotUnderlineChanged( int item )
138{
139 underlineLineStyleKComboBox->setEnabled( item > 0 );
140 underlineKColorButton->setEnabled( item > 0 );
141 underlineWordByWordCheckBox->setEnabled( ( item > 0 ) || ( strikethroughStyleKComboBox->currentItem() > 0 ) );
142 emit underlineChanged( item );
143}
144
145void KoHighlightingTab::slotStrikethroughChanged( int item )
146{
147 strikethroughLineStyleKComboBox->setEnabled( item > 0 );
148 underlineWordByWordCheckBox->setEnabled( ( item > 0 ) || ( underlineStyleKComboBox->currentItem() > 0 ) );
149 emit strikethroughChanged( item );
150}
151
const char * name(StdAction id)