GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

attributes.hh

Go to the documentation of this file.
00001 /* GFC-UI: GTK+ Foundation Classes (User Interface Library) 00002 * Copyright (C) 2002-2004 The GFC 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 GFC_PANGO_ATTRIBUTES_HH 00026 #define GFC_PANGO_ATTRIBUTES_HH 00027 00028 #ifndef GFC_OBJECT_HH 00029 #include <gfc/object.hh> 00030 #endif 00031 00032 #ifndef GFC_PANGO_FONT_HH 00033 #include <gfc/pango/font.hh> 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 GFC { 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 UNDERLINE_ERROR = PANGO_UNDERLINE_ERROR 00080 }; 00081 00088 00089 enum AttrType 00090 { 00091 ATTR_INVALID = PANGO_ATTR_INVALID, 00092 ATTR_LANGUAGE = PANGO_ATTR_LANGUAGE, 00093 ATTR_FAMILY = PANGO_ATTR_FAMILY, 00094 ATTR_STYLE = PANGO_ATTR_STYLE, 00095 ATTR_WEIGHT = PANGO_ATTR_WEIGHT, 00096 ATTR_VARIANT = PANGO_ATTR_VARIANT, 00097 ATTR_STRETCH = PANGO_ATTR_STRETCH, 00098 ATTR_SIZE = PANGO_ATTR_SIZE, 00099 ATTR_FONT_DESC = PANGO_ATTR_FONT_DESC, 00100 ATTR_FOREGROUND = PANGO_ATTR_FOREGROUND, 00101 ATTR_BACKGROUND = PANGO_ATTR_BACKGROUND, 00102 ATTR_UNDERLINE = PANGO_ATTR_UNDERLINE, 00103 ATTR_STRIKETHROUGH = PANGO_ATTR_STRIKETHROUGH, 00104 ATTR_RISE = PANGO_ATTR_RISE, 00105 ATTR_SHAPE = PANGO_ATTR_SHAPE, 00106 ATTR_SCALE = PANGO_ATTR_SCALE, 00107 ATTR_FALLBACK = PANGO_ATTR_FALLBACK 00108 }; 00109 00117 00118 class Attribute : public GFC::Object 00119 { 00120 protected: 00121 PangoAttribute *attr_; 00122 00123 public: 00126 00127 explicit Attribute(PangoAttribute *attr, bool copy); 00135 00136 Attribute(const Attribute& src); 00139 00140 virtual ~Attribute(); 00142 00143 Attribute& operator=(const Attribute& src); 00146 00150 00151 PangoAttribute* pango_attribute() const; 00153 00154 const PangoAttrClass* pango_attr_class() const; 00156 00157 operator PangoAttribute* () const; 00159 00160 AttrType type() const; 00163 00164 bool is_language() const; 00166 00167 bool is_family() const; 00169 00170 bool is_foreground() const; 00172 00173 bool is_background() const; 00175 00176 bool is_size() const; 00178 00179 bool is_style() const; 00181 00182 bool is_weight() const; 00184 00185 bool is_variant() const; 00187 00188 bool is_stretch() const; 00190 00191 bool is_underline() const; 00193 00194 bool is_strikethrough() const; 00196 00197 bool is_rise() const; 00199 00200 bool is_font_description() const; 00202 00203 bool is_shape() const; 00205 00206 bool is_scale() const; 00208 00209 unsigned int start_index() const; 00211 00212 unsigned int end_index() const; 00215 00216 bool equal(const Attribute& other) const; 00223 00224 bool operator==(const Attribute& other) const; 00231 00232 bool operator!=(const Attribute& other) const; 00239 00243 00244 void set_start_index(unsigned int start); 00247 00248 void set_end_index(unsigned int end); 00251 00252 void set_index(unsigned int start, unsigned int end); 00256 00258 }; 00259 00264 00265 class AttrString : public Attribute 00266 { 00267 protected: 00270 explicit AttrString(PangoAttribute *attr, bool copy); 00278 00280 00281 public: 00284 00285 PangoAttrString* pango_attr_string() const; 00287 00288 String get_string() const; 00290 00294 00295 void set_string(const char *str); 00296 void set_string(const String& str); 00299 00301 }; 00302 00307 00308 class AttrLanguage : public Attribute 00309 { 00310 public: 00313 explicit AttrLanguage(PangoLanguage *language); 00316 00320 00321 PangoAttrLanguage* pango_attr_language() const; 00323 00324 PangoLanguage* get_language() const; 00326 00330 00331 void set_language(PangoLanguage *language); 00334 00336 }; 00337 00342 00343 class AttrFamily : public AttrString 00344 { 00345 public: 00348 00349 explicit AttrFamily(const String& font_family); 00352 00354 }; 00355 00360 00361 class AttrColor : public Attribute 00362 { 00363 protected: 00366 00367 explicit AttrColor(PangoAttribute *attr, bool copy); 00375 00377 00378 public: 00381 00382 PangoAttrColor* pango_attr_color() const; 00384 00385 unsigned short red() const; 00387 00388 unsigned short green() const; 00390 00391 unsigned short blue() const; 00393 00397 00398 void set_color(unsigned short red, unsigned short green, unsigned short blue); 00403 00404 void set_grey(unsigned short value); 00407 00408 void set_red(unsigned short value); 00411 00412 void set_green(unsigned short value); 00415 00416 void set_blue(unsigned short value); 00419 00421 }; 00422 00427 00428 class AttrForeground : public AttrColor 00429 { 00430 public: 00433 00434 AttrForeground(unsigned short red, unsigned short green, unsigned short blue); 00439 00441 }; 00442 00447 00448 class AttrBackground : public AttrColor 00449 { 00450 public: 00453 00454 AttrBackground(unsigned short red, unsigned short green, unsigned short blue); 00459 00461 }; 00462 00468 00469 class AttrInt : public Attribute 00470 { 00471 protected: 00474 00475 explicit AttrInt(PangoAttribute *attr, bool copy); 00483 00485 00486 public: 00489 00490 PangoAttrInt* pango_attr_int() const; 00492 00493 int value() const; 00495 00499 00500 void set_value(int value); 00503 00505 }; 00506 00511 00512 class AttrSize : public AttrInt 00513 { 00514 public: 00517 00518 explicit AttrSize(int size); 00521 00523 }; 00524 00529 00530 class AttrStyle : public AttrInt 00531 { 00532 public: 00535 00536 explicit AttrStyle(Style style = STYLE_NORMAL); 00539 00543 00544 Style style() const; 00546 00550 00551 void set_style(Style style); 00554 00556 }; 00557 00562 00563 class AttrWeight: public AttrInt 00564 { 00565 public: 00568 00569 explicit AttrWeight(Weight weight = WEIGHT_NORMAL); 00572 00576 00577 Weight weight() const; 00579 00583 00584 void set_weight(Weight weight); 00587 00589 }; 00590 00595 00596 class AttrVariant: public AttrInt 00597 { 00598 public: 00601 00602 explicit AttrVariant(Variant variant = VARIANT_NORMAL); 00605 00609 00610 Variant variant() const; 00612 00616 00617 void set_variant(Variant variant); 00620 00622 }; 00623 00628 00629 class AttrStretch: public AttrInt 00630 { 00631 public: 00634 00635 explicit AttrStretch(Stretch stretch = STRETCH_NORMAL); 00638 00642 00643 Stretch stretch() const; 00645 00649 00650 void set_stretch(Stretch stretch); 00653 00655 }; 00656 00661 00662 class AttrUnderline: public AttrInt 00663 { 00664 public: 00667 00668 explicit AttrUnderline(Underline underline = UNDERLINE_SINGLE); 00671 00675 00676 Underline underline() const; 00678 00682 00683 void set_underline(Underline underline); 00686 00688 }; 00689 00694 00695 class AttrStrikethrough: public AttrInt 00696 { 00697 public: 00700 00701 explicit AttrStrikethrough(bool strikethrough = true); 00704 00708 00709 bool strikethrough() const; 00711 00715 00716 void set_strikethrough(bool strikethrough); 00719 00721 }; 00722 00727 00728 class AttrRise: public AttrInt 00729 { 00730 public: 00733 00734 explicit AttrRise(int rise); 00739 00741 }; 00742 00747 00748 class AttrFontDesc : public Attribute 00749 { 00750 public: 00753 00754 AttrFontDesc(const FontDescription& desc); 00760 00764 00765 PangoAttrFontDesc* pango_attr_font_desc() const; 00767 00768 Pointer<FontDescription> font_description() const; 00770 00774 00775 void set_font_description(const FontDescription& desc); 00777 00779 }; 00780 00785 00786 class AttrShape : public Attribute 00787 { 00788 public: 00791 00792 AttrShape(const Rectangle& ink_rect, const Rectangle& logical_rect); 00800 00804 00805 PangoAttrShape* pango_attr_shape() const; 00807 00808 const Rectangle& ink_rect() const; 00810 00811 const Rectangle& logical_rect() const; 00813 00817 00818 void set_rects(const Rectangle& ink_rect, const Rectangle& logical_rect); 00822 00823 void set_ink_rect(const Rectangle& rect); 00826 00827 void set_ink_rect(int x, int y, int width, int height); 00833 00834 void set_logical_rect(const Rectangle& rect); 00837 00838 void set_logical_rect(int x, int y, int width, int height); 00844 00846 }; 00847 00852 00853 class AttrFloat : public Attribute 00854 { 00855 protected: 00858 00859 explicit AttrFloat(PangoAttribute *attr, bool copy); 00867 00869 00870 public: 00871 // Accessors 00872 PangoAttrFloat* pango_attr_float() const; 00874 00875 double value() const; 00877 00878 // Methods 00879 void set_value(double value); 00881 }; 00882 00887 00888 class AttrScale : public AttrFloat 00889 { 00890 public: 00893 00894 explicit AttrScale(double scale_factor); 00899 00901 }; 00902 00907 00908 class AttrFallback: public AttrInt 00909 { 00910 public: 00913 00914 explicit AttrFallback(bool enable_fallback); 00922 00924 }; 00925 00931 00932 class AttrStipple : public Attribute 00933 { 00934 public: 00937 explicit AttrStipple(Gdk::Bitmap& stipple); 00940 00944 00945 GdkPangoAttrStipple* gdk_pango_attr_stipple() const; 00947 00948 Gdk::Bitmap* stipple() const; 00951 00953 }; 00954 00961 00962 class AttrEmbossed : public Attribute 00963 { 00964 public: 00967 00968 explicit AttrEmbossed(bool embossed); 00971 00975 GdkPangoAttrEmbossed* gdk_pango_attr_embossed() const; 00977 00978 bool embossed() const; 00980 00982 }; 00983 00993 00994 class AttrIterator : public GFC::Object 00995 { 00996 PangoAttrIterator *iterator_; 00997 00998 public: 01001 01002 explicit AttrIterator(PangoAttrIterator *iterator); 01008 01009 AttrIterator(const AttrIterator& src); 01012 01013 ~AttrIterator(); 01015 01016 AttrIterator& operator=(const AttrIterator& src); 01019 01023 01024 PangoAttrIterator* pango_attr_iterator() const; 01026 01027 operator PangoAttrIterator* () const { return this ? pango_attr_iterator() : 0; } 01029 01030 int start_index() const; 01032 01033 int end_index() const; 01035 01036 void range(int *start, int *end) const; 01040 01041 Pointer<Attribute> get(AttrType type); 01049 01050 void get_font(FontDescription& desc, PangoLanguage **language, std::vector<Pointer<Attribute> > *extra_attrs) const; 01060 01061 bool get_attrs(std::vector<Pointer<Attribute> >& attrs) const; 01065 01069 bool next(); 01072 01074 }; 01075 01087 01088 class AttrList : public G::Boxed 01089 { 01090 public: 01091 typedef sigc::slot<bool, const Attribute&> AttrFilterSlot; 01101 01104 01105 AttrList(); 01107 01108 explicit AttrList(PangoAttrList *list); 01116 01117 AttrList(PangoAttrList *list, bool copy); 01127 01128 AttrList(const AttrList& src); 01131 01132 ~AttrList(); 01134 01135 AttrList& operator=(const AttrList& src); 01138 01142 01143 PangoAttrList* pango_attr_list() const; 01145 01146 operator PangoAttrList* () const; 01148 01149 Pointer<AttrIterator> get_iterator() const; 01155 01159 01160 void insert(Attribute& attr, bool before = false); 01169 01170 void change(Attribute& attr); 01180 01181 void splice(AttrList& other, int pos, int length); 01197 01198 Pointer<AttrList> filter(const AttrFilterSlot& slot); 01205 01207 }; 01208 01209 } // namespace Pango 01210 01211 } // namespace GFC 01212 01213 #include <gfc/pango/inline/attributes.inl> 01214 01215 #endif // GFC_PANGO_ATTRIBUTES_HH 01216

Generated on Tue Aug 24 00:34:30 2004 for GFC-UI by doxygen 1.3.8