00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SWINDER_FORMAT_H
00022 #define SWINDER_FORMAT_H
00023
00024 #include "ustring.h"
00025 #include <cstdio>
00026
00027 namespace Swinder
00028 {
00029
00037 class Color
00038 {
00039 public:
00040
00041 unsigned red, green, blue;
00042
00046 Color(){ red = green = blue = 0; };
00047
00051 Color( const Color& c )
00052 { red = c.red; green = c.green; blue = c.blue; }
00053
00057 Color( unsigned r, unsigned g, unsigned b )
00058 { red = r; green = g; blue = b; }
00059
00063 Color( const char* c )
00064 { std::sscanf(c, "#%2x%2x%2x", &red, &green, &blue); }
00065
00066 friend inline bool operator==(const Color&, const Color&);
00067 friend inline bool operator!=(const Color&, const Color&);
00068 };
00069
00073 inline bool operator==(const Color& c1, const Color& c2)
00074 { return c1.red == c2.red && c1.green == c2.green && c1.blue == c2.blue; }
00075
00079 inline bool operator!=(const Color& c1, const Color& c2)
00080 { return c1.red != c2.red || c1.green != c2.green || c1.blue != c2.blue; }
00081
00082 class Pen
00083 {
00084 public:
00085
00086 unsigned style;
00087
00088 unsigned width;
00089
00090 Color color;
00091
00092 enum {
00093 NoLine,
00094 SolidLine,
00095 DashLine,
00096 DotLine,
00097 DashDotLine,
00098 DashDotDotLine
00099 };
00100
00101 Pen(): style( SolidLine ), width( 0 ){}
00102
00103 friend inline bool operator==(const Pen&, const Pen&);
00104 friend inline bool operator!=(const Pen&, const Pen&);
00105 };
00106
00110 inline bool operator==(const Pen& p1, const Pen& p2)
00111 { return p1.style == p2.style && p1.width == p1.width && p1.color == p2.color; }
00112
00116 inline bool operator!=(const Pen& p1, const Pen& p2)
00117 { return p1.style != p2.style || p1.width != p1.width || p1.color != p2.color; }
00118
00119
00128 class FormatFont
00129 {
00130 public:
00131
00135 FormatFont();
00136
00140 ~FormatFont();
00141
00145 FormatFont( const FormatFont& );
00146
00150 FormatFont& operator=( const FormatFont& );
00151
00155 FormatFont& assign( const FormatFont& );
00156
00160 bool isNull() const;
00161
00165 const UString& fontFamily() const;
00166
00170 void setFontFamily( const UString& fontFamily );
00171
00175 double fontSize() const;
00176
00180 void setFontSize( double fs );
00181
00185 Color color() const;
00186
00190 void setColor( const Color& color );
00191
00195 bool bold() const;
00196
00200 void setBold( bool b );
00201
00205 bool italic() const;
00206
00210 void setItalic( bool i );
00211
00215 bool underline() const;
00216
00220 void setUnderline( bool u );
00221
00225 bool strikeout() const;
00226
00230 void setStrikeout( bool s );
00231
00235 bool subscript() const;
00236
00240 void setSubscript( bool s );
00241
00245 bool superscript() const;
00246
00250 void setSuperscript( bool s );
00251
00255 bool operator==(const FormatFont& f) const;
00256
00260 bool operator!=(const FormatFont& f) const;
00261
00262 private:
00263 class Private;
00264 Private *d;
00265 };
00266
00267
00276 class FormatAlignment
00277 {
00278 public:
00279
00283 FormatAlignment();
00284
00288 ~FormatAlignment();
00289
00293 FormatAlignment( const FormatAlignment& );
00294
00298 FormatAlignment& operator=( const FormatAlignment& );
00299
00303 FormatAlignment& assign( const FormatAlignment& );
00304
00308 bool isNull() const;
00309
00316 unsigned alignX() const;
00317
00323 void setAlignX( unsigned xa );
00324
00331 unsigned alignY() const;
00332
00338 void setAlignY( unsigned xa );
00339
00345 bool wrap() const;
00346
00352 void setWrap( bool w );
00353
00359 unsigned indentLevel() const;
00360
00366 void setIndentLevel( unsigned i );
00367
00373 unsigned rotationAngle() const;
00374
00380 void setRotationAngle( unsigned r );
00381
00385 bool operator==(const FormatAlignment& f) const;
00386
00390 bool operator!=(const FormatAlignment& f) const;
00391
00392 private:
00393 class Private;
00394 Private *d;
00395 };
00396
00401 class FormatBackground
00402 {
00403 public:
00407 FormatBackground();
00408
00412 ~FormatBackground();
00413
00417 FormatBackground( const FormatBackground& );
00418
00422 FormatBackground& operator=( const FormatBackground& );
00423
00427 FormatBackground& assign( const FormatBackground& );
00428
00432 bool isNull() const;
00433
00434 enum {
00435 SolidPattern,
00436 Dense1Pattern,
00437 Dense2Pattern,
00438 Dense3Pattern,
00439 Dense4Pattern,
00440 Dense5Pattern,
00441 Dense6Pattern,
00442 Dense7Pattern,
00443 HorPattern,
00444 VerPattern,
00445 CrossPattern,
00446 BDiagPattern,
00447 FDiagPattern,
00448 DiagCrossPattern,
00449 EmptyPattern
00450 };
00451
00457 unsigned pattern() const;
00458
00464 void setPattern( unsigned );
00465
00471 Color backgroundColor() const;
00472
00478 void setBackgroundColor( const Color& );
00479
00485 Color foregroundColor() const;
00486
00492 void setForegroundColor( const Color& );
00493
00497 bool operator==(const FormatBackground& f) const;
00498
00502 bool operator!=(const FormatBackground& f) const;
00503
00504 private:
00505 class Private;
00506 Private *d;
00507 };
00508
00514 class FormatBorders
00515 {
00516 public:
00517
00521 FormatBorders();
00522
00526 ~FormatBorders();
00527
00531 FormatBorders( const FormatBorders& );
00532
00536 FormatBorders& operator=( const FormatBorders& );
00537
00541 FormatBorders& assign( const FormatBorders& );
00542
00546 bool isNull() const;
00547
00553 const Pen& leftBorder() const;
00554
00560 void setLeftBorder( const Pen& pen );
00561
00567 const Pen& rightBorder() const;
00568
00574 void setRightBorder( const Pen& pen );
00575
00581 const Pen& topBorder() const;
00582
00588 void setTopBorder( const Pen& pen );
00589
00595 const Pen& bottomBorder() const;
00596
00602 void setBottomBorder( const Pen& pen );
00603
00607 bool operator==(const FormatBorders& f) const;
00608
00612 bool operator!=(const FormatBorders& f) const;
00613
00614 private:
00615 class Private;
00616 Private *d;
00617 };
00618
00641 class Format
00642 {
00643 public:
00644
00648 Format();
00649
00653 ~Format();
00654
00658 Format( const Format& f );
00659
00663 Format& operator= ( const Format& f );
00664
00668 Format& assign( const Format& f );
00669
00673 bool isNull() const;
00674
00678 FormatFont& font() const;
00679
00683 void setFont( const FormatFont& font );
00684
00688 FormatAlignment& alignment() const;
00689
00693 void setAlignment( const FormatAlignment& alignment );
00694
00698 FormatBorders& borders() const;
00699
00703 void setBorders( const FormatBorders& border );
00704
00708 FormatBackground& background() const;
00709
00713 void setBackground( const FormatBackground& );
00714
00718 const UString& valueFormat() const;
00719
00723 void setValueFormat( const UString& valueFormat );
00724
00725 enum { Left, Center, Right };
00726
00727 enum { Top, Middle, Bottom };
00728
00741 Format& apply( const Format& f );
00742
00746 bool operator==(const Format& f) const;
00747
00751 bool operator!=(const Format& f) const;
00752
00753 private:
00754 class Private;
00755 Private* d;
00756 };
00757
00758 }
00759
00760 #endif // SWINDER_FORMAT_H
00761