Main Page - Header
Author: The Inti Development Team

Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# attributes.h

Go to the documentation of this file.

    00001 /*  Inti: Integrated Foundation Classes
    00002  *  Copyright (C) 2002-2003 The Inti Development Team.
    00003  *
    00004  *  This program is free software; you can redistribute it and/or modify
    00005  *  it under the terms of the GNU General Public License as published by
    00006  *  the Free Software Foundation; either version 2 of the License, or
    00007  *  (at your option) any later version.
    00008  *
    00009  *  This program is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  *  GNU Library General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Library General Public License
    00015  *  along with this program; if not, write to the Free Software
    00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    00017  */
    00018
    00024
    00025 #ifndef INTI_PANGO_ATTRIBUTES_H
    00026 #define INTI_PANGO_ATTRIBUTES_H
    00027
    00028 #ifndef INTI_OBJECT_H
    00029 #include <inti/object.h>
    00030 #endif
    00031
    00032 #ifndef INTI_PANGO_FONT_H
    00033 #include <inti/pango/font.h>
    00034 #endif
    00035
    00036 #ifndef __PANGO_ATTRIBUTES_H__
    00037 #include <pango/pango-attributes.h>
    00038 #endif
    00039
    00040 #ifndef __GDK_PANGO_H__
    00041 #include <gdk/gdkpango.h>
    00042 #endif
    00043
    00044 #ifndef _CPP_VECTOR
    00045 #include <vector>
    00046 #endif
    00047
    00048 namespace Inti {
    00049
    00050 namespace Gdk {
    00051 class Bitmap;
    00052 }
    00053
    00054 namespace Pango {
    00055
    00058
    00059 enum Underline
    00060 {
    00061         UNDERLINE_NONE = PANGO_UNDERLINE_NONE,
    00063
    00064         UNDERLINE_SINGLE = PANGO_UNDERLINE_SINGLE,
    00066
    00067         UNDERLINE_DOUBLE = PANGO_UNDERLINE_DOUBLE,
    00069
    00070         UNDERLINE_LOW = PANGO_UNDERLINE_LOW
    00075 };
    00076
    00083
    00084 enum AttrType
    00085 {
    00086         ATTR_INVALID = PANGO_ATTR_INVALID,
    00087         ATTR_LANGUAGE = PANGO_ATTR_LANGUAGE,
    00088         ATTR_FAMILY = PANGO_ATTR_FAMILY,
    00089         ATTR_STYLE = PANGO_ATTR_STYLE,
    00090         ATTR_WEIGHT = PANGO_ATTR_WEIGHT,
    00091         ATTR_VARIANT = PANGO_ATTR_VARIANT,
    00092         ATTR_STRETCH = PANGO_ATTR_STRETCH,
    00093         ATTR_SIZE = PANGO_ATTR_SIZE,
    00094         ATTR_FONT_DESC = PANGO_ATTR_FONT_DESC,
    00095         ATTR_FOREGROUND = PANGO_ATTR_FOREGROUND,
    00096         ATTR_BACKGROUND = PANGO_ATTR_BACKGROUND,
    00097         ATTR_UNDERLINE = PANGO_ATTR_UNDERLINE,
    00098         ATTR_STRIKETHROUGH = PANGO_ATTR_STRIKETHROUGH,
    00099         ATTR_RISE = PANGO_ATTR_RISE,
    00100         ATTR_SHAPE = PANGO_ATTR_SHAPE,
    00101         ATTR_SCALE = PANGO_ATTR_SCALE
    00102 };
    00103
    00111
    00112 class Attribute : public ReferencedObject
    00113 {
    00114         PangoAttribute *attr_;
    00115
    00116 public:
    00119
    00120         explicit Attribute(PangoAttribute *attr, bool copy);
    00128
    00129         Attribute(const Attribute& src);
    00132
    00133         virtual ~Attribute();
    00135
    00136         Attribute& operator=(const Attribute& src);
    00139
    00143
    00144         PangoAttribute* pango_attribute() const { return attr_; }
    00146
    00147         const PangoAttrClass* pango_attr_class() const;
    00149
    00150         operator PangoAttribute* () const;
    00152
    00153         AttrType type() const;
    00156
    00157         bool is_language() const;
    00159
    00160         bool is_family() const;
    00162
    00163         bool is_foreground() const;
    00165
    00166         bool is_background() const;
    00168
    00169         bool is_size() const;
    00171
    00172         bool is_style() const;
    00174
    00175         bool is_weight() const;
    00177
    00178         bool is_variant() const;
    00180
    00181         bool is_stretch() const;
    00183
    00184         bool is_underline() const;
    00186
    00187         bool is_strikethrough() const;
    00189
    00190         bool is_rise() const;
    00192
    00193         bool is_font_description() const;
    00195
    00196         bool is_shape() const;
    00198
    00199         bool is_scale() const;
    00201
    00202         unsigned int start_index() const;
    00204
    00205         unsigned int end_index() const;
    00208
    00209         bool equal(const Attribute& other) const;
    00216
    00217         bool operator==(const Attribute& other) const;
    00224
    00225         bool operator!=(const Attribute& other) const;
    00232
    00236
    00237         void set_start_index(unsigned int start);
    00240
    00241         void set_end_index(unsigned int end);
    00244
    00245         void set_index(unsigned int start, unsigned int end);
    00249
    00251 };
    00252
    00257
    00258 class AttrString : public Attribute
    00259 {
    00260 protected:
    00263         explicit AttrString(PangoAttribute *attr, bool copy);
    00271
    00273
    00274 public:
    00277
    00278         PangoAttrString* pango_attr_string() const { return (PangoAttrString*)pango_attribute(); }
    00280
    00281         String get_string() const;
    00283
    00287
    00288         void set_string(const String& str);
    00291
    00293 };
    00294
    00299
    00300 class AttrLanguage : public Attribute
    00301 {
    00302 public:
    00305         explicit AttrLanguage(PangoLanguage *language);
    00308
    00312
    00313         PangoAttrLanguage* pango_attr_language() const { return (PangoAttrLanguage*)pango_attribute(); }
    00315
    00316         PangoLanguage* get_language() const;
    00318
    00322
    00323         void set_language(PangoLanguage *language);
    00326
    00328 };
    00329
    00334
    00335 class AttrFamily : public AttrString
    00336 {
    00337 public:
    00340
    00341         explicit AttrFamily(const String& font_family);
    00344
    00346 };
    00347
    00352
    00353 class AttrColor : public Attribute
    00354 {
    00355 protected:
    00358
    00359         explicit AttrColor(PangoAttribute *attr, bool copy);
    00367
    00369
    00370 public:
    00373
    00374         PangoAttrColor* pango_attr_color() const { return (PangoAttrColor*)pango_attribute(); }
    00376
    00377         unsigned short red() const;
    00379
    00380         unsigned short green() const;
    00382
    00383         unsigned short blue() const;
    00385
    00389
    00390         void set_color(unsigned short red, unsigned short green, unsigned short blue);
    00395
    00396         void set_grey(unsigned short value);
    00399
    00400         void set_red(unsigned short value);
    00403
    00404         void set_green(unsigned short value);
    00407
    00408         void set_blue(unsigned short value);
    00411
    00413 };
    00414
    00419
    00420 class AttrForeground : public AttrColor
    00421 {
    00422 public:
    00425
    00426         AttrForeground(unsigned short red, unsigned short green, unsigned short blue);
    00431
    00433 };
    00434
    00439
    00440 class AttrBackground : public AttrColor
    00441 {
    00442 public:
    00445
    00446         AttrBackground(unsigned short red, unsigned short green, unsigned short blue);
    00451
    00453 };
    00454
    00460
    00461 class AttrInt : public Attribute
    00462 {
    00463 protected:
    00466
    00467         explicit AttrInt(PangoAttribute *attr, bool copy);
    00475
    00477
    00478 public:
    00481
    00482         PangoAttrInt* pango_attr_int() const { return (PangoAttrInt*)pango_attribute(); }
    00484
    00485         int value() const;
    00487
    00491
    00492         void set_value(int value);
    00495
    00497 };
    00498
    00503
    00504 class AttrSize : public AttrInt
    00505 {
    00506 public:
    00509
    00510         explicit AttrSize(int size);
    00513
    00515 };
    00516
    00521
    00522 class AttrStyle : public AttrInt
    00523 {
    00524 public:
    00527
    00528         explicit AttrStyle(Style style = STYLE_NORMAL);
    00531
    00535
    00536         Style style() const;
    00538
    00542
    00543         void set_style(Style style);
    00546
    00548 };
    00549
    00554
    00555 class AttrWeight: public AttrInt
    00556 {
    00557 public:
    00560
    00561         explicit AttrWeight(Weight weight = WEIGHT_NORMAL);
    00564
    00568
    00569         Weight weight() const;
    00571
    00575
    00576         void set_weight(Weight weight);
    00579
    00581 };
    00582
    00587
    00588 class AttrVariant: public AttrInt
    00589 {
    00590 public:
    00593
    00594         explicit AttrVariant(Variant variant = VARIANT_NORMAL);
    00597
    00601
    00602         Variant variant() const;
    00604
    00608
    00609         void set_variant(Variant variant);
    00612
    00614 };
    00615
    00620
    00621 class AttrStretch: public AttrInt
    00622 {
    00623 public:
    00626
    00627         explicit AttrStretch(Stretch stretch = STRETCH_NORMAL);
    00630
    00634
    00635         Stretch stretch() const;
    00637
    00641
    00642         void set_stretch(Stretch stretch);
    00645
    00647 };
    00648
    00653
    00654 class AttrUnderline: public AttrInt
    00655 {
    00656 public:
    00659
    00660         explicit AttrUnderline(Underline underline = UNDERLINE_SINGLE);
    00663
    00667
    00668         Underline underline() const;
    00670
    00674
    00675         void set_underline(Underline underline);
    00678
    00680 };
    00681
    00686
    00687 class AttrStrikethrough: public AttrInt
    00688 {
    00689 public:
    00692
    00693         explicit AttrStrikethrough(bool strikethrough = true);
    00696
    00700
    00701         bool strikethrough() const;
    00703
    00707
    00708         void set_strikethrough(bool strikethrough);
    00711
    00713 };
    00714
    00719
    00720 class AttrRise: public AttrInt
    00721 {
    00722 public:
    00725
    00726         explicit AttrRise(int rise);
    00731
    00733 };
    00734
    00739
    00740 class AttrFontDesc : public Attribute
    00741 {
    00742 public:
    00745
    00746         AttrFontDesc(const FontDescription& desc);
    00752
    00756
    00757         PangoAttrFontDesc* pango_attr_font_desc() const { return (PangoAttrFontDesc*)pango_attribute(); }
    00759
    00760         Pointer<FontDescription> font_description() const;
    00762
    00766
    00767         void set_font_description(const FontDescription& desc);
    00769
    00771 };
    00772
    00777
    00778 class AttrShape : public Attribute
    00779 {
    00780 public:
    00783
    00784         AttrShape(const Rectangle& ink_rect, const Rectangle& logical_rect);
    00792
    00796
    00797         PangoAttrShape* pango_attr_shape() const { return (PangoAttrShape*)pango_attribute(); }
    00799
    00800         const Rectangle& ink_rect() const;
    00802
    00803         const Rectangle& logical_rect() const;
    00805
    00809
    00810         void set_rects(const Rectangle& ink_rect, const Rectangle& logical_rect);
    00814
    00815         void set_ink_rect(const Rectangle& rect);
    00818
    00819         void set_ink_rect(int x, int y, int width, int height);
    00825
    00826         void set_logical_rect(const Rectangle& rect);
    00829
    00830         void set_logical_rect(int x, int y, int width, int height);
    00836
    00838 };
    00839
    00844
    00845 class AttrFloat : public Attribute
    00846 {
    00847 protected:
    00850
    00851         explicit AttrFloat(PangoAttribute *attr, bool copy);
    00859
    00861
    00862 public:
    00863 // Accessors
    00864         PangoAttrFloat* pango_attr_float() const { return (PangoAttrFloat*)pango_attribute(); }
    00866
    00867         double value() const;
    00869
    00870 // Methods
    00871         void set_value(double value);
    00873 };
    00874
    00879
    00880 class AttrScale : public AttrFloat
    00881 {
    00882 public:
    00885
    00886         explicit AttrScale(double scale_factor);
    00891
    00893 };
    00894
    00900
    00901 class AttrStipple : public Attribute
    00902 {
    00903 public:
    00906         explicit AttrStipple(Gdk::Bitmap& stipple);
    00909
    00913
    00914         GdkPangoAttrStipple* gdk_pango_attr_stipple() const { return (GdkPangoAttrStipple*)pango_attribute(); }
    00916
    00917         Gdk::Bitmap* stipple() const;
    00920
    00922 };
    00923
    00930
    00931 class AttrEmbossed : public Attribute
    00932 {
    00933 public:
    00936
    00937         explicit AttrEmbossed(bool embossed);
    00940
    00944         GdkPangoAttrEmbossed* gdk_pango_attr_embossed() const { return (GdkPangoAttrEmbossed*)pango_attribute(); }
    00946
    00947         bool embossed() const;
    00949
    00951 };
    00952
    00962
    00963 class AttrIterator : public ReferencedObject
    00964 {
    00965         PangoAttrIterator *iterator_;
    00966
    00967 public:
    00970
    00971         explicit AttrIterator(PangoAttrIterator *iterator);
    00977
    00978         AttrIterator(const AttrIterator& src);
    00981
    00982         ~AttrIterator();
    00984
    00985         AttrIterator& operator=(const AttrIterator& src);
    00988
    00992
    00993         PangoAttrIterator* pango_attr_iterator() const { return (PangoAttrIterator*)iterator_; }
    00995
    00996         operator PangoAttrIterator* () const { return this ? pango_attr_iterator() : 0; }
    00998
    00999         int start_index() const;
    01001
    01002         int end_index() const;
    01004
    01005         void range(int *start, int *end) const;
    01009
    01010         Pointer<Attribute> get(AttrType type);
    01018
    01019         void get_font(FontDescription& desc, PangoLanguage **language, std::vector<Pointer<Attribute> > *extra_attrs) const;
    01029
    01030         bool get_attrs(std::vector<Pointer<Attribute> >& attrs) const;
    01034
    01038         bool next();
    01041
    01043 };
    01044
    01056
    01057 class AttrList : public G::Boxed
    01058 {
    01059 public:
    01060         typedef Slot1<bool, const Attribute&> AttrFilterSlot;
    01070
    01073
    01074         AttrList();
    01076
    01077         explicit AttrList(PangoAttrList *list);
    01085
    01086         AttrList(PangoAttrList *list, bool copy);
    01096
    01097         AttrList(const AttrList& src);
    01100
    01101         ~AttrList();
    01103
    01104         AttrList& operator=(const AttrList& src);
    01107
    01111
    01112         PangoAttrList* pango_attr_list() const { return (PangoAttrList*)boxed_; }
    01114
    01115         operator PangoAttrList* () const;
    01117
    01118         Pointer<AttrIterator> get_iterator() const;
    01124
    01128
    01129         void insert(Attribute& attr, bool before = false);
    01138
    01139         void change(Attribute& attr);
    01149
    01150         void splice(AttrList& other, int pos, int length);
    01166
    01167         Pointer<AttrList> filter(const AttrFilterSlot *slot);
    01174
    01176 };
    01177
    01178 } // namespace Pango
    01179
    01180 } // namespace Inti
    01181
    01182 #endif // INTI_PANGO_ATTRIBUTES_H
    01183

Main Page - Footer