lib Library API Documentation

koGlobal.h

00001 /* This file is part of the KDE project 00002 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 00003 Copyright 2003 Nicolas GOUTTE <goutte@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 00021 #ifndef koGlobal_h 00022 #define koGlobal_h 00023 00024 #include <qstringlist.h> 00025 #include <koUnit.h> 00026 #include <qfont.h> 00027 class KConfig; 00028 00029 // paper formats ( mm ) - public for compat reasons, but DO NOT USE in new programs ! 00030 // See KoPageFormat's methods instead. 00031 #define PG_A3_WIDTH 297.0 00032 #define PG_A3_HEIGHT 420.0 00033 #define PG_A4_WIDTH 210.0 00034 #define PG_A4_HEIGHT 297.0 00035 #define PG_A5_WIDTH 148.0 00036 #define PG_A5_HEIGHT 210.0 00037 #define PG_B5_WIDTH 182.0 00038 #define PG_B5_HEIGHT 257.0 00039 #define PG_US_LETTER_WIDTH 216.0 00040 #define PG_US_LETTER_HEIGHT 279.0 00041 #define PG_US_LEGAL_WIDTH 216.0 00042 #define PG_US_LEGAL_HEIGHT 356.0 00043 #define PG_US_EXECUTIVE_WIDTH 191.0 00044 #define PG_US_EXECUTIVE_HEIGHT 254.0 00045 00051 enum KoFormat { 00052 PG_DIN_A3 = 0, 00053 PG_DIN_A4 = 1, 00054 PG_DIN_A5 = 2, 00055 PG_US_LETTER = 3, 00056 PG_US_LEGAL = 4, 00057 PG_SCREEN = 5, 00058 PG_CUSTOM = 6, 00059 PG_DIN_B5 = 7, 00060 PG_US_EXECUTIVE = 8, 00061 PG_DIN_A0 = 9, 00062 PG_DIN_A1 = 10, 00063 PG_DIN_A2 = 11, 00064 PG_DIN_A6 = 12, 00065 PG_DIN_A7 = 13, 00066 PG_DIN_A8 = 14, 00067 PG_DIN_A9 = 15, 00068 PG_DIN_B0 = 16, 00069 PG_DIN_B1 = 17, 00070 PG_DIN_B10 = 18, 00071 PG_DIN_B2 = 19, 00072 PG_DIN_B3 = 20, 00073 PG_DIN_B4 = 21, 00074 PG_DIN_B6 = 22, 00075 PG_ISO_C5 = 23, 00076 PG_US_COMM10 = 24, 00077 PG_ISO_DL = 25, 00078 PG_US_FOLIO = 26, 00079 PG_US_LEDGER = 27, 00080 PG_US_TABLOID = 28, 00081 // update the number below and the static arrays if you add more values to the enum 00082 PG_LAST_FORMAT = PG_US_TABLOID // used by koGlobal.cpp. 00083 }; 00084 00088 enum KoOrientation { 00089 PG_PORTRAIT = 0, 00090 PG_LANDSCAPE = 1 00091 }; 00092 00093 namespace KoPageFormat 00094 { 00102 int /*KPrinter::PageSize*/ printerPageSize( KoFormat format ); 00103 // We return int instead of the enum to avoid including kprinter.h 00104 00109 double width( KoFormat format, KoOrientation orientation ); 00110 00115 double height( KoFormat format, KoOrientation orientation ); 00116 00121 QString formatString( KoFormat format ); 00122 00127 KoFormat formatFromString( const QString & string ); 00128 00133 QString name( KoFormat format ); 00134 00138 QStringList allFormats(); 00139 00144 KoFormat guessFormat( double width, double height ); 00145 } 00146 00147 00158 enum KoHFType { 00159 HF_SAME = 0, 00160 HF_FIRST_EO_DIFF = 1, 00161 HF_FIRST_DIFF = 2, 00162 HF_EO_DIFF = 3 00163 }; 00164 00169 struct KoPageLayout 00170 { 00172 KoFormat format; 00174 KoOrientation orientation; 00175 00177 double ptWidth; 00179 double ptHeight; 00181 double ptLeft; 00183 double ptRight; 00185 double ptTop; 00187 double ptBottom; 00188 00189 bool operator==( const KoPageLayout& l ) const { 00190 return ( ptWidth == l.ptWidth && 00191 ptHeight == l.ptHeight && 00192 ptLeft == l.ptLeft && 00193 ptRight == l.ptHeight && 00194 ptTop == l.ptTop && 00195 ptBottom == l.ptBottom ); 00196 } 00197 bool operator!=( const KoPageLayout& l ) const { 00198 return !( *this == l ); 00199 } 00200 }; 00201 00203 struct KoHeadFoot 00204 { 00205 QString headLeft; 00206 QString headMid; 00207 QString headRight; 00208 QString footLeft; 00209 QString footMid; 00210 QString footRight; 00211 }; 00212 00214 struct KoColumns 00215 { 00216 int columns; 00217 double ptColumnSpacing; 00218 bool operator==( const KoColumns& rhs ) const { 00219 return columns == rhs.columns && 00220 QABS(ptColumnSpacing - rhs.ptColumnSpacing) <= 1E-10; 00221 } 00222 bool operator!=( const KoColumns& rhs ) const { 00223 return columns != rhs.columns || 00224 QABS(ptColumnSpacing - rhs.ptColumnSpacing) > 1E-10; 00225 } 00226 }; 00227 00229 struct KoKWHeaderFooter 00230 { 00231 KoHFType header; 00232 KoHFType footer; 00233 double ptHeaderBodySpacing; 00234 double ptFooterBodySpacing; 00235 double ptFootNoteBodySpacing; 00236 bool operator==( const KoKWHeaderFooter& rhs ) const { 00237 return header == rhs.header && footer == rhs.footer && 00238 QABS(ptHeaderBodySpacing - rhs.ptHeaderBodySpacing) <= 1E-10 && 00239 QABS(ptFooterBodySpacing - rhs.ptFooterBodySpacing) <= 1E-10 && 00240 QABS(ptFootNoteBodySpacing - rhs.ptFootNoteBodySpacing) <= 1E-10; 00241 } 00242 bool operator!=( const KoKWHeaderFooter& rhs ) const { 00243 return !( *this == rhs ); 00244 } 00245 }; 00246 00247 00248 class KoGlobal 00249 { 00250 public: 00252 static void initialize() { 00253 (void)self(); // I don't want to make KGlobal instances public, so self() is private 00254 } 00261 static QFont defaultFont() { 00262 return self()->_defaultFont(); 00263 } 00264 00271 static KConfig* kofficeConfig() { 00272 return self()->_kofficeConfig(); 00273 } 00274 00276 00277 static QStringList listOfLanguages() { 00278 return self()->_listOfLanguages(); 00279 } 00280 static QStringList listTagOfLanguages() { 00281 return self()->_listTagOfLanguages(); 00282 } 00283 static QString tagOfLanguage( const QString & _lang ); 00284 static int languageIndexFromTag( const QString &_lang ); 00285 static QString languageFromTag( const QString &_lang ); 00286 00287 ~KoGlobal(); 00288 00289 private: 00290 static KoGlobal* self(); 00291 KoGlobal(); 00292 QFont _defaultFont(); 00293 QStringList _listOfLanguages(); 00294 QStringList _listTagOfLanguages(); 00295 KConfig* _kofficeConfig(); 00296 void createListOfLanguages(); 00297 00298 int m_pointSize; 00299 QStringList m_languageList; 00300 QStringList m_languageTag; 00301 KConfig* m_kofficeConfig; 00302 // No BC problem here, constructor is private, feel free to add members 00303 00304 // Singleton pattern. Maybe this should even be refcounted, so 00305 // that it gets cleaned up when closing all koffice parts in e.g. konqueror? 00306 static KoGlobal* s_global; 00307 friend class this_is_a_singleton; // workaround gcc warning 00308 }; 00309 00310 #endif // koGlobal
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Nov 17 06:54:15 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003