summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofontselector.cpp65
-rw-r--r--libopie/ofontselector.h2
2 files changed, 43 insertions, 24 deletions
diff --git a/libopie/ofontselector.cpp b/libopie/ofontselector.cpp
index f6fd541..d32aeb4 100644
--- a/libopie/ofontselector.cpp
+++ b/libopie/ofontselector.cpp
@@ -1,277 +1,294 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qlistbox.h> 30#include <qlistbox.h>
31#include <qcombobox.h> 31#include <qcombobox.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qfont.h> 33#include <qfont.h>
34 34
35#include "ofontselector.h" 35#include "ofontselector.h"
36 36
37 37
38class FontListItem : public QListBoxText { 38class FontListItem : public QListBoxText {
39public: 39public:
40 FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText ( ) 40 FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText ( )
41 { 41 {
42 m_name = t; 42 m_name = t;
43 m_styles = styles; 43 m_styles = styles;
44 m_sizes = sizes; 44 m_sizes = sizes;
45 45
46 QString str = t; 46 QString str = t;
47 str [0] = str [0]. upper ( ); 47 str [0] = str [0]. upper ( );
48 setText ( str ); 48 setText ( str );
49 } 49 }
50 50
51 QString family ( ) const 51 QString family ( ) const
52 { 52 {
53 return m_name; 53 return m_name;
54 } 54 }
55 55
56 const QStringList &styles ( ) const 56 const QStringList &styles ( ) const
57 { 57 {
58 return m_styles; 58 return m_styles;
59 } 59 }
60 60
61 const QValueList<int> &sizes ( ) const 61 const QValueList<int> &sizes ( ) const
62 { 62 {
63 return m_sizes; 63 return m_sizes;
64 } 64 }
65 65
66private: 66private:
67 QStringList m_styles; 67 QStringList m_styles;
68 QValueList<int> m_sizes; 68 QValueList<int> m_sizes;
69 QString m_name; 69 QString m_name;
70}; 70};
71 71
72 72
73static int findItemCB ( QComboBox *box, const QString &str ) 73static int findItemCB ( QComboBox *box, const QString &str )
74{ 74{
75 for ( int i = 0; i < box-> count ( ); i++ ) { 75 for ( int i = 0; i < box-> count ( ); i++ ) {
76 if ( box-> text ( i ) == str ) 76 if ( box-> text ( i ) == str )
77 return i; 77 return i;
78 } 78 }
79 return -1; 79 return -1;
80} 80}
81 81
82 82
83 83
84OFontSelector::OFontSelector ( QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) 84OFontSelector::OFontSelector ( QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl )
85{ 85{
86 QGridLayout *gridLayout = new QGridLayout ( this, 0, 0, 4, 4 ); 86 QGridLayout *gridLayout = new QGridLayout ( this, 0, 0, 4, 4 );
87 gridLayout->setRowStretch ( 4, 10 ); 87 gridLayout->setRowStretch ( 4, 10 );
88 88
89 m_font_family_list = new QListBox( this, "FontListBox" ); 89 m_font_family_list = new QListBox( this, "FontListBox" );
90 gridLayout->addMultiCellWidget( m_font_family_list, 0, 4, 0, 0 ); 90 gridLayout->addMultiCellWidget( m_font_family_list, 0, 4, 0, 0 );
91 connect( m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) ); 91 connect( m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) );
92 92
93 QLabel *label = new QLabel( tr( "Style" ), this ); 93 QLabel *label = new QLabel( tr( "Style" ), this );
94 gridLayout->addWidget( label, 0, 1 ); 94 gridLayout->addWidget( label, 0, 1 );
95 95
96 m_font_style_list = new QComboBox( this, "StyleListBox" ); 96 m_font_style_list = new QComboBox( this, "StyleListBox" );
97 connect( m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) ); 97 connect( m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) );
98 gridLayout->addWidget( m_font_style_list, 1, 1 ); 98 gridLayout->addWidget( m_font_style_list, 1, 1 );
99 99
100 label = new QLabel( tr( "Size" ), this ); 100 label = new QLabel( tr( "Size" ), this );
101 gridLayout->addWidget( label, 2, 1 ); 101 gridLayout->addWidget( label, 2, 1 );
102 102
103 m_font_size_list = new QComboBox( this, "SizeListBox" ); 103 m_font_size_list = new QComboBox( this, "SizeListBox" );
104 connect( m_font_size_list, SIGNAL( activated( int ) ), 104 connect( m_font_size_list, SIGNAL( activated( int ) ),
105 this, SLOT( fontSizeClicked( int ) ) ); 105 this, SLOT( fontSizeClicked( int ) ) );
106 gridLayout->addWidget( m_font_size_list, 3, 1 ); 106 gridLayout->addWidget( m_font_size_list, 3, 1 );
107 107
108 loadFonts ( m_font_family_list ); 108 loadFonts ( m_font_family_list );
109} 109}
110 110
111OFontSelector::~OFontSelector ( ) 111OFontSelector::~OFontSelector ( )
112{ 112{
113} 113}
114 114
115bool OFontSelector::setSelectedFont ( const QString &family, const QString &styleStr, int size, const QString & /*charset*/ ) 115bool OFontSelector::setSelectedFont ( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & /*charset*/ )
116{ 116{
117 if ( size <= 0 ) 117 QString sizeStr = QString::number ( sizeVal );
118 size = 10; 118
119 QString familyStr = family. isEmpty ( ) ? QString ( "Helvetica" ) : family; 119 QListBoxItem *family = m_font_family_list-> findItem ( familyStr );
120 QString sizeStr = QString::number ( size ); 120 if ( !family )
121 121 family = m_font_family_list-> findItem ( "Helvetica" );
122 m_font_family_list-> setCurrentItem ( m_font_family_list-> findItem ( familyStr )); 122 if ( !family )
123 if ( m_font_family_list-> currentItem ( ) < 0 ) 123 family = m_font_family_list-> firstItem ( );
124 m_font_family_list-> setCurrentItem ( 0 ); 124 m_font_family_list-> setCurrentItem ( family );
125 125 fontFamilyClicked ( m_font_family_list-> index ( family ));
126 fontFamilyClicked ( m_font_family_list-> currentItem ( )); 126
127 127 int style = findItemCB ( m_font_style_list, styleStr );
128 m_font_style_list-> setCurrentItem ( findItemCB ( m_font_style_list, styleStr )); 128 if ( style < 0 )
129 fontStyleClicked ( m_font_style_list-> currentItem ( )); 129 style = findItemCB ( m_font_style_list, "Regular" );
130 130 if ( style < 0 && m_font_style_list-> count ( ) > 0 )
131 m_font_size_list-> setCurrentItem ( findItemCB ( m_font_size_list, sizeStr )); 131 style = 0;
132 fontSizeClicked ( m_font_size_list-> currentItem ( )); 132 m_font_style_list-> setCurrentItem ( style );
133 fontStyleClicked ( style );
134
135 int size = findItemCB ( m_font_size_list, sizeStr );
136 if ( size < 0 )
137 size = findItemCB ( m_font_size_list, "10" );
138 if ( size < 0 && m_font_size_list-> count ( ) > 0 )
139 size = 0;
140 m_font_size_list-> setCurrentItem ( size );
141 fontSizeClicked ( size );
133 142
134 return (( m_font_family_list-> currentItem ( ) >= 0 ) && 143 return (( family ) &&
135 ( m_font_style_list-> currentItem ( ) >= 0 ) && 144 ( style >= 0 ) &&
136 ( m_font_size_list-> currentItem ( ) >= 0 )); 145 ( size >= 0 ));
137} 146}
138 147
139bool OFontSelector::selectedFont ( QString &family, QString &style, int &size ) 148bool OFontSelector::selectedFont ( QString &family, QString &style, int &size )
140{ 149{
141 QString dummy; 150 QString dummy;
142 return selectedFont ( family, style, size, dummy ); 151 return selectedFont ( family, style, size, dummy );
143} 152}
144 153
145 154
146QString OFontSelector::fontFamily ( ) const 155QString OFontSelector::fontFamily ( ) const
147{ 156{
148 FontListItem *fli = (FontListItem *) m_font_family_list-> item ( m_font_family_list-> currentItem ( )); 157 FontListItem *fli = (FontListItem *) m_font_family_list-> item ( m_font_family_list-> currentItem ( ));
149 158
150 return fli ? fli-> family ( ) : QString::null; 159 return fli ? fli-> family ( ) : QString::null;
151} 160}
152 161
153QString OFontSelector::fontStyle ( ) const 162QString OFontSelector::fontStyle ( ) const
154{ 163{
155 FontListItem *fli = (FontListItem *) m_font_family_list-> item ( m_font_family_list-> currentItem ( )); 164 FontListItem *fli = (FontListItem *) m_font_family_list-> item ( m_font_family_list-> currentItem ( ));
156 int fst = m_font_style_list-> currentItem ( ); 165 int fst = m_font_style_list-> currentItem ( );
157 166
158 return ( fli && fst >= 0 ) ? fli-> styles ( ) [fst] : QString::null; 167 return ( fli && fst >= 0 ) ? fli-> styles ( ) [fst] : QString::null;
159} 168}
160 169
161int OFontSelector::fontSize ( ) const 170int OFontSelector::fontSize ( ) const
162{ 171{
163 FontListItem *fli = (FontListItem *) m_font_family_list-> item ( m_font_family_list-> currentItem ( )); 172 FontListItem *fli = (FontListItem *) m_font_family_list-> item ( m_font_family_list-> currentItem ( ));
164 int fsi = m_font_size_list-> currentItem ( ); 173 int fsi = m_font_size_list-> currentItem ( );
165 174
166 return ( fli && fsi >= 0 ) ? fli-> sizes ( ) [fsi] : 10; 175 return ( fli && fsi >= 0 ) ? fli-> sizes ( ) [fsi] : 10;
167} 176}
168 177
169QString OFontSelector::fontCharSet ( ) const 178QString OFontSelector::fontCharSet ( ) const
170{ 179{
171 FontListItem *fli = (FontListItem *) m_font_family_list-> item ( m_font_family_list-> currentItem ( )); 180 FontListItem *fli = (FontListItem *) m_font_family_list-> item ( m_font_family_list-> currentItem ( ));
172 181
173 return fli ? m_fdb. charSets ( fli-> family ( )) [0] : QString::null; 182 return fli ? m_fdb. charSets ( fli-> family ( )) [0] : QString::null;
174} 183}
175 184
176bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset ) 185bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset )
177{ 186{
178 int ffa = m_font_family_list-> currentItem ( ); 187 int ffa = m_font_family_list-> currentItem ( );
179 int fst = m_font_style_list-> currentItem ( ); 188 int fst = m_font_style_list-> currentItem ( );
180 int fsi = m_font_size_list-> currentItem ( ); 189 int fsi = m_font_size_list-> currentItem ( );
181 190
182 FontListItem *fli = (FontListItem *) m_font_family_list-> item ( ffa ); 191 FontListItem *fli = (FontListItem *) m_font_family_list-> item ( ffa );
183 192
184 if ( fli ) { 193 if ( fli ) {
185 family = fli-> family ( ); 194 family = fli-> family ( );
186 style = fst >= 0 ? fli-> styles ( ) [fst] : QString::null; 195 style = fst >= 0 ? fli-> styles ( ) [fst] : QString::null;
187 size = fsi >= 0 ? fli-> sizes ( ) [fsi] : 10; 196 size = fsi >= 0 ? fli-> sizes ( ) [fsi] : 10;
188 charset = m_fdb. charSets ( fli-> family ( )) [0]; 197 charset = m_fdb. charSets ( fli-> family ( )) [0];
189 198
190 return true; 199 return true;
191 } 200 }
192 else 201 else
193 return false; 202 return false;
194} 203}
195 204
196 205
197 206
198 207
199void OFontSelector::loadFonts ( QListBox *list ) 208void OFontSelector::loadFonts ( QListBox *list )
200{ 209{
201 QStringList f = m_fdb. families ( ); 210 QStringList f = m_fdb. families ( );
202 211
203 for ( QStringList::ConstIterator it = f. begin ( ); it != f. end ( ); ++it ) 212 for ( QStringList::ConstIterator it = f. begin ( ); it != f. end ( ); ++it )
204 list-> insertItem ( new FontListItem ( *it, m_fdb. styles ( *it ), m_fdb. pointSizes ( *it ))); 213 list-> insertItem ( new FontListItem ( *it, m_fdb. styles ( *it ), m_fdb. pointSizes ( *it )));
205} 214}
206 215
207void OFontSelector::fontFamilyClicked ( int index ) 216void OFontSelector::fontFamilyClicked ( int index )
208{ 217{
209 QString oldstyle = m_font_style_list-> currentText ( ); 218 QString oldstyle = m_font_style_list-> currentText ( );
210 QString oldsize = m_font_size_list-> currentText ( ); 219 QString oldsize = m_font_size_list-> currentText ( );
211 220
212 FontListItem *fli = (FontListItem *) m_font_family_list-> item ( index ); 221 FontListItem *fli = (FontListItem *) m_font_family_list-> item ( index );
213 222
214 m_font_style_list-> clear ( ); 223 m_font_style_list-> clear ( );
215 m_font_style_list-> insertStringList ( fli-> styles ( )); 224 m_font_style_list-> insertStringList ( fli-> styles ( ));
216 m_font_style_list-> setEnabled ( !fli-> styles ( ). isEmpty ( )); 225 m_font_style_list-> setEnabled ( !fli-> styles ( ). isEmpty ( ));
217 226
218 int i; 227 int i;
219 228
220 i = findItemCB ( m_font_style_list, oldstyle ); 229 i = findItemCB ( m_font_style_list, oldstyle );
221 if ( i < 0 ) 230 if ( i < 0 )
222 i = findItemCB ( m_font_style_list, "Regular" ); 231 i = findItemCB ( m_font_style_list, "Regular" );
223 if (( i < 0 ) && ( m_font_style_list-> count ( ) > 0 )) 232 if (( i < 0 ) && ( m_font_style_list-> count ( ) > 0 ))
224 i = 0; 233 i = 0;
225 234
226 if ( i >= 0 ) { 235 if ( i >= 0 ) {
227 m_font_style_list-> setCurrentItem ( i ); 236 m_font_style_list-> setCurrentItem ( i );
228 fontStyleClicked ( i ); 237 fontStyleClicked ( i );
229 } 238 }
230 239
231 m_font_size_list-> clear ( ); 240 m_font_size_list-> clear ( );
232 QValueList<int> sl = fli-> sizes ( ); 241 QValueList<int> sl = fli-> sizes ( );
233 242
234 for ( QValueList<int>::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) 243 for ( QValueList<int>::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
235 m_font_size_list-> insertItem ( QString::number ( *it )); 244 m_font_size_list-> insertItem ( QString::number ( *it ));
236 245
237 i = findItemCB ( m_font_size_list, oldsize ); 246 i = findItemCB ( m_font_size_list, oldsize );
238 if ( i < 0 ) 247 if ( i < 0 )
239 i = findItemCB ( m_font_size_list, "10" ); 248 i = findItemCB ( m_font_size_list, "10" );
240 if (( i < 0 ) && ( m_font_size_list-> count ( ) > 0 )) 249 if (( i < 0 ) && ( m_font_size_list-> count ( ) > 0 ))
241 i = 0; 250 i = 0;
242 251
243 if ( i >= 0 ) { 252 if ( i >= 0 ) {
244 m_font_size_list-> setCurrentItem ( i ); 253 m_font_size_list-> setCurrentItem ( i );
245 fontSizeClicked ( i ); 254 fontSizeClicked ( i );
246 } 255 }
247 changeFont ( ); 256 changeFont ( );
248} 257}
249 258
250void OFontSelector::fontStyleClicked ( int /*index*/ ) 259void OFontSelector::fontStyleClicked ( int /*index*/ )
251{ 260{
252 changeFont ( ); 261 changeFont ( );
253} 262}
254 263
255void OFontSelector::fontSizeClicked ( int /*index*/ ) 264void OFontSelector::fontSizeClicked ( int /*index*/ )
256{ 265{
257 changeFont ( ); 266 changeFont ( );
258} 267}
259 268
260void OFontSelector::changeFont ( ) 269void OFontSelector::changeFont ( )
261{ 270{
271 emit fontSelected ( selectedFont ( ));
272}
273
274
275QFont OFontSelector::selectedFont ( )
276{
262 int ffa = m_font_family_list-> currentItem ( ); 277 int ffa = m_font_family_list-> currentItem ( );
263 int fst = m_font_style_list-> currentItem ( ); 278 int fst = m_font_style_list-> currentItem ( );
264 int fsi = m_font_size_list-> currentItem ( ); 279 int fsi = m_font_size_list-> currentItem ( );
265 280
266 FontListItem *fli = (FontListItem *) m_font_family_list-> item ( ffa ); 281 FontListItem *fli = (FontListItem *) m_font_family_list-> item ( ffa );
267 282
268 if ( fli ) { 283 if ( fli ) {
269 emit fontSelected ( m_fdb. font ( fli-> family ( ), \ 284 return m_fdb. font ( fli-> family ( ), \
270 fst >= 0 ? fli-> styles ( ) [fst] : QString::null, \ 285 fst >= 0 ? fli-> styles ( ) [fst] : QString::null, \
271 fsi >= 0 ? fli-> sizes ( ) [fsi] : 10, \ 286 fsi >= 0 ? fli-> sizes ( ) [fsi] : 10, \
272 m_fdb. charSets ( fli-> family ( )) [0] )); 287 m_fdb. charSets ( fli-> family ( )) [0] );
273 } 288 }
289 else
290 return QFont ( );
274} 291}
275 292
276 293
277 \ No newline at end of file 294 \ No newline at end of file
diff --git a/libopie/ofontselector.h b/libopie/ofontselector.h
index 9227e48..2011e43 100644
--- a/libopie/ofontselector.h
+++ b/libopie/ofontselector.h
@@ -1,79 +1,81 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef __OPIE_FONTSELECTOR_H__ 29#ifndef __OPIE_FONTSELECTOR_H__
30#define __OPIE_FONTSELECTOR_H__ 30#define __OPIE_FONTSELECTOR_H__
31 31
32#include <qwidget.h> 32#include <qwidget.h>
33#include <qpe/fontdatabase.h> 33#include <qpe/fontdatabase.h>
34 34
35class QComboBox; 35class QComboBox;
36class QListBox; 36class QListBox;
37class QFont; 37class QFont;
38 38
39class OFontSelector : public QWidget 39class OFontSelector : public QWidget
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 42
43public: 43public:
44 OFontSelector ( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 44 OFontSelector ( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
45 virtual ~OFontSelector ( ); 45 virtual ~OFontSelector ( );
46 46
47 bool selectedFont ( QString &family, QString &style, int &size ); 47 bool selectedFont ( QString &family, QString &style, int &size );
48 bool selectedFont ( QString &family, QString &style, int &size, QString &charset ); 48 bool selectedFont ( QString &family, QString &style, int &size, QString &charset );
49 49
50 QFont selectedFont ( );
51
50 bool setSelectedFont ( const QString &family, const QString &style, int size, const QString &charset = 0 ); 52 bool setSelectedFont ( const QString &family, const QString &style, int size, const QString &charset = 0 );
51 53
52 QString fontFamily ( ) const; 54 QString fontFamily ( ) const;
53 QString fontStyle ( ) const; 55 QString fontStyle ( ) const;
54 int fontSize ( ) const; 56 int fontSize ( ) const;
55 QString fontCharSet ( ) const; 57 QString fontCharSet ( ) const;
56 58
57signals: 59signals:
58 void fontSelected ( const QFont & ); 60 void fontSelected ( const QFont & );
59 61
60protected slots: 62protected slots:
61 virtual void fontFamilyClicked ( int ); 63 virtual void fontFamilyClicked ( int );
62 virtual void fontStyleClicked ( int ); 64 virtual void fontStyleClicked ( int );
63 virtual void fontSizeClicked ( int ); 65 virtual void fontSizeClicked ( int );
64 66
65private: 67private:
66 void loadFonts ( QListBox * ); 68 void loadFonts ( QListBox * );
67 69
68 void changeFont ( ); 70 void changeFont ( );
69 71
70private: 72private:
71 QListBox * m_font_family_list; 73 QListBox * m_font_family_list;
72 QComboBox * m_font_style_list; 74 QComboBox * m_font_style_list;
73 QComboBox * m_font_size_list; 75 QComboBox * m_font_size_list;
74 76
75 FontDatabase m_fdb; 77 FontDatabase m_fdb;
76}; 78};
77 79
78#endif 80#endif
79 81