MIDI branch becomes trunk
[ardour.git] / libs / gtkmm2 / pango / pangomm / fontdescription.h
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _PANGOMM_FONTDESCRIPTION_H
4 #define _PANGOMM_FONTDESCRIPTION_H
5
6 #include <glibmm.h>
7
8 /* $Id$ */
9
10 /* fontdescription.h
11  *
12  * Copyright (C) 1998-2002 The gtkmm Development Team
13  *
14  * This library is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU Library General Public
16  * License as published by the Free Software Foundation; either
17  * version 2 of the License, or (at your option) any later version.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22  * Library General Public License for more details.
23  *
24  * You should have received a copy of the GNU Library General Public
25  * License along with this library; if not, write to the Free
26  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27  */
28
29 #include <pango/pango-font.h>
30
31
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 extern "C" { typedef struct _PangoFontDescription PangoFontDescription; }
34 #endif
35
36 namespace Pango
37 {
38
39
40 /** @addtogroup pangommEnums Enums and Flags */
41
42 /**
43  * @ingroup pangommEnums
44  */
45 enum Style
46 {
47   STYLE_NORMAL,
48   STYLE_OBLIQUE,
49   STYLE_ITALIC
50 };
51
52 } // namespace Pango
53
54
55 #ifndef DOXYGEN_SHOULD_SKIP_THIS
56 namespace Glib
57 {
58
59 template <>
60 class Value<Pango::Style> : public Glib::Value_Enum<Pango::Style>
61 {
62 public:
63   static GType value_type() G_GNUC_CONST;
64 };
65
66 } // namespace Glib
67 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
68
69
70 namespace Pango
71 {
72
73 /**
74  * @ingroup pangommEnums
75  */
76 enum Variant
77 {
78   VARIANT_NORMAL,
79   VARIANT_SMALL_CAPS
80 };
81
82 } // namespace Pango
83
84
85 #ifndef DOXYGEN_SHOULD_SKIP_THIS
86 namespace Glib
87 {
88
89 template <>
90 class Value<Pango::Variant> : public Glib::Value_Enum<Pango::Variant>
91 {
92 public:
93   static GType value_type() G_GNUC_CONST;
94 };
95
96 } // namespace Glib
97 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
98
99
100 namespace Pango
101 {
102
103 /**
104  * @ingroup pangommEnums
105  */
106 enum Stretch
107 {
108   STRETCH_ULTRA_CONDENSED,
109   STRETCH_EXTRA_CONDENSED,
110   STRETCH_CONDENSED,
111   STRETCH_SEMI_CONDENSED,
112   STRETCH_NORMAL,
113   STRETCH_SEMI_EXPANDED,
114   STRETCH_EXPANDED,
115   STRETCH_EXTRA_EXPANDED,
116   STRETCH_ULTRA_EXPANDED
117 };
118
119 } // namespace Pango
120
121
122 #ifndef DOXYGEN_SHOULD_SKIP_THIS
123 namespace Glib
124 {
125
126 template <>
127 class Value<Pango::Stretch> : public Glib::Value_Enum<Pango::Stretch>
128 {
129 public:
130   static GType value_type() G_GNUC_CONST;
131 };
132
133 } // namespace Glib
134 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
135
136
137 namespace Pango
138 {
139
140 /**
141  * @ingroup pangommEnums
142  */
143 enum Weight
144 {
145   WEIGHT_ULTRALIGHT = 200,
146   WEIGHT_LIGHT = 300,
147   WEIGHT_NORMAL = 400,
148   WEIGHT_BOLD = 700,
149   WEIGHT_ULTRABOLD = 800,
150   WEIGHT_HEAVY = 900
151 };
152
153 } // namespace Pango
154
155
156 #ifndef DOXYGEN_SHOULD_SKIP_THIS
157 namespace Glib
158 {
159
160 template <>
161 class Value<Pango::Weight> : public Glib::Value_Enum<Pango::Weight>
162 {
163 public:
164   static GType value_type() G_GNUC_CONST;
165 };
166
167 } // namespace Glib
168 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
169
170
171 namespace Pango
172 {
173
174 /**
175  * @ingroup pangommEnums
176  * @par Bitwise operators:
177  * <tt>%FontMask operator|(FontMask, FontMask)</tt><br>
178  * <tt>%FontMask operator&(FontMask, FontMask)</tt><br>
179  * <tt>%FontMask operator^(FontMask, FontMask)</tt><br>
180  * <tt>%FontMask operator~(FontMask)</tt><br>
181  * <tt>%FontMask& operator|=(FontMask&, FontMask)</tt><br>
182  * <tt>%FontMask& operator&=(FontMask&, FontMask)</tt><br>
183  * <tt>%FontMask& operator^=(FontMask&, FontMask)</tt><br>
184  */
185 enum FontMask
186 {
187   FONT_MASK_FAMILY = 1 << 0,
188   FONT_MASK_STYLE = 1 << 1,
189   FONT_MASK_VARIANT = 1 << 2,
190   FONT_MASK_WEIGHT = 1 << 3,
191   FONT_MASK_STRETCH = 1 << 4,
192   FONT_MASK_SIZE = 1 << 5
193 };
194
195 /** @ingroup pangommEnums */
196 inline FontMask operator|(FontMask lhs, FontMask rhs)
197   { return static_cast<FontMask>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
198
199 /** @ingroup pangommEnums */
200 inline FontMask operator&(FontMask lhs, FontMask rhs)
201   { return static_cast<FontMask>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
202
203 /** @ingroup pangommEnums */
204 inline FontMask operator^(FontMask lhs, FontMask rhs)
205   { return static_cast<FontMask>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
206
207 /** @ingroup pangommEnums */
208 inline FontMask operator~(FontMask flags)
209   { return static_cast<FontMask>(~static_cast<unsigned>(flags)); }
210
211 /** @ingroup pangommEnums */
212 inline FontMask& operator|=(FontMask& lhs, FontMask rhs)
213   { return (lhs = static_cast<FontMask>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
214
215 /** @ingroup pangommEnums */
216 inline FontMask& operator&=(FontMask& lhs, FontMask rhs)
217   { return (lhs = static_cast<FontMask>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
218
219 /** @ingroup pangommEnums */
220 inline FontMask& operator^=(FontMask& lhs, FontMask rhs)
221   { return (lhs = static_cast<FontMask>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
222
223 } // namespace Pango
224
225
226 #ifndef DOXYGEN_SHOULD_SKIP_THIS
227 namespace Glib
228 {
229
230 template <>
231 class Value<Pango::FontMask> : public Glib::Value_Flags<Pango::FontMask>
232 {
233 public:
234   static GType value_type() G_GNUC_CONST;
235 };
236
237 } // namespace Glib
238 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
239
240
241 namespace Pango
242 {
243
244
245 /** A Pango::FontDescription represents the description of an ideal font.
246  * It is used both to list what fonts are available on the system and also for specifying the characteristics of a font to load.
247  */
248 class FontDescription
249 {
250   public:
251 #ifndef DOXYGEN_SHOULD_SKIP_THIS
252   typedef FontDescription CppObjectType;
253   typedef PangoFontDescription BaseObjectType;
254
255   static GType get_type() G_GNUC_CONST;
256 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
257
258   FontDescription();
259
260   explicit FontDescription(PangoFontDescription* gobject, bool make_a_copy = true);
261
262   FontDescription(const FontDescription& other);
263   FontDescription& operator=(const FontDescription& other);
264
265   ~FontDescription();
266
267   void swap(FontDescription& other);
268
269   ///Provides access to the underlying C instance.
270   PangoFontDescription*       gobj()       { return gobject_; }
271
272   ///Provides access to the underlying C instance.
273   const PangoFontDescription* gobj() const { return gobject_; }
274
275   ///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
276   PangoFontDescription* gobj_copy() const;
277
278 protected:
279   PangoFontDescription* gobject_;
280
281 private:
282
283   
284   /* These functions are dangerous! The first casts the "const" from the parameter away
285    * copying the pointer and keep it hanging around.
286    * So desc.set_family_static("some_family") would lead to a segfault.
287    * The latter makes a shallow copy of the parameter's "family" data member.
288    * So if the FontDescription you passed in dies, a pointer to its (deleted)
289    * family data member still hangs around!
290    * This is why we can't wrap these functions!
291    */
292   
293
294 public:
295   /** Constructs a font description from a string representation.
296    * @a font_name must have the form
297    * "[FAMILY-LIST] [STYLE-OPTIONS] [SIZE]", where FAMILY-LIST is a comma separated
298    * list of families optionally terminated by a comma, STYLE_OPTIONS is a whitespace
299    * separated list of words where each WORD describes one of style, variant, weight,
300    * or stretch, and SIZE is an decimal number (size in points). Any one of the
301    * options may be absent. If FAMILY-LIST is absent, then the family_name field
302    * of the resulting font description will be initialized to 0. If STYLE-OPTIONS
303    * is missing, then all style options will be set to the default values. If SIZE
304    * is missing, the size in the resulting font description will be set to 0.
305    * @param font_name String representation of a font description.
306    */
307   explicit FontDescription(const Glib::ustring& font_name);
308
309   
310   /** Computes a hash of a Pango::FontDescription structure suitable
311    * to be used, for example, as an argument to Glib::hash_table_new().
312    * @return The hash value.
313    */
314   guint hash() const;
315   
316   /** Sets the family name field of a font description. The family
317    * name represents a family of related font styles, and will
318    * resolve to a particular Pango::FontFamily. In some uses of
319    * Pango::FontDescription, it is also possible to use a comma
320    * separated list of family names for this field.
321    * @param family A string representing the family name.
322    */
323   void set_family(const Glib::ustring& family);
324   
325   /** Gets the family name field of a font description. See
326    * pango_font_description_set_family().
327    * @return The family name field. (Will be <tt>0</tt> if not previously set.).
328    */
329   Glib::ustring get_family() const;
330   
331   /** Sets the style field of a Pango::FontDescription. The
332    * Pango::Style enumeration describes whether the font is slanted and
333    * the manner in which it is slanted; it can be either
334    * Pango::STYLE_NORMAL, Pango::STYLE_ITALIC, or Pango::STYLE_OBLIQUE.
335    * Most fonts will either have a italic style or an oblique
336    * style, but not both, and font matching in Pango will 
337    * match italic specifications with oblique fonts and vice-versa
338    * if an exact match is not found.
339    * @param style The style for the font description.
340    */
341   void set_style(Style style);
342   
343   /** Gets the style field of a Pango::FontDescription. See
344    * pango_font_description_set_style().
345    * @return The style field for the font description. 
346    * Use pango_font_description_get_set_fields() to find out if
347    * the field was explicitely set or not.
348    */
349   Style get_style() const;
350   
351   /** Sets the variant field of a font description. The Pango::Variant
352    * can either be Pango::VARIANT_NORMAL or Pango::VARIANT_SMALL_CAPS.
353    * @param variant The variant type for the font description.
354    */
355   void set_variant(Variant variant);
356   
357   /** Gets the variant field of a Pango::FontDescription. See
358    * pango_font_description_set_variant().
359    * @return The variant field for the font description. Use
360    * pango_font_description_get_set_fields() to find out if
361    * the field was explicitely set or not.
362    */
363   Variant get_variant() const;
364   
365   /** Sets the weight field of a font description. The weight field
366    * specifies how bold or light the font should be. In addition
367    * to the values of the Pango::Weight enumeration, other intermediate
368    * numeric values are possible.
369    * @param weight The weight for the font description.
370    */
371   void set_weight(Weight weight);
372   
373   /** Gets the weight field of a font description. See
374    * pango_font_description_set_weight().
375    * @return The weight field for the font description. Use
376    * pango_font_description_get_set_fields() to find out if
377    * the field was explicitely set or not.
378    */
379   Weight get_weight() const;
380   
381   /** Sets the stretch field of a font description. The stretch field
382    * specifies how narrow or wide the font should be.
383    * @param stretch The stretch for the font description.
384    */
385   void set_stretch(Stretch stretch);
386   
387   /** Gets the stretch field of a font description.
388    * See pango_font_description_set_stretch().
389    * @return The stretch field for the font description. Use
390    * pango_font_description_get_set_fields() to find out if
391    * the field was explicitely set or not.
392    */
393   Stretch get_stretch() const;
394   
395   /** Sets the size field of a font description in fractional points. This is mutually
396    * exclusive with pango_font_description_set_absolute_size().
397    * @param size The size of the font in points, scaled by PANGO_SCALE. (That is,
398    * a @a size  value of 10 * PANGO_SCALE is a 10 point font. The conversion
399    * factor between points and device units depends on system configuration
400    * and the output device. For screen display, a logical DPI of 96 is
401    * common, in which case a 10 point font corresponds to a 10 * (96 / 72) = 13.3
402    * pixel font. Use pango_font_description_set_absolute_size() if you need
403    * a particular size in device units.
404    */
405   void set_size(int size);
406   
407   /** Gets the size field of a font description.
408    * See pango_font_description_get_size().
409    * @return The size field for the font description in points or device units.
410    * You must call pango_font_description_get_size_is_absolute()
411    * to find out which is the case. Returns 0 if the size field has not
412    * previously been set.  pango_font_description_get_set_fields() to
413    * find out if the field was explicitely set or not.
414    */
415   int get_size() const;
416   
417   /** Determines which fields in a font description have been set.
418    * @return A bitmask with bits set corresponding to the
419    * fields in @a desc  that have been set.
420    */
421   FontMask get_set_fields() const;
422   
423   /** Unsets some of the fields in a Pango::FontDescription. Note that
424    * this merely marks the fields cleared, it does not clear the
425    * settings for those fields, to clear a family name set with
426    * pango_font_description_set_family_static() so that it won't
427    * be returned by subsequent calls to pango_font_description_get_family(),
428    * you must actually call pango_font_description_set_family (desc, <tt>0</tt>);
429    * @param to_unset Bitmask of fields in the @a desc  to unset.
430    */
431   void unset_fields(FontMask to_unset);
432   
433   /** Merges the fields that are set in @a desc_to_merge  into the fields in
434    *  @a desc .  If @a replace_existing  is <tt>false</tt>, only fields in @a desc  that
435    * are not already set are affected. If <tt>true</tt>, then fields that are
436    * already set will be replaced as well.
437    * @param desc_to_merge The Pango::FontDescription to merge from.
438    * @param replace_existing If <tt>true</tt>, replace fields in @a desc  with the
439    * corresponding values from @a desc_to_merge , even if they
440    * are already exist.
441    */
442   void merge(const FontDescription& desc_to_merge, bool replace_existing);
443   
444   /** Determines if the style attributes of @a new_match  are a closer match
445    * for @a desc  than @a old_match , or if @a old_match  is <tt>0</tt>, determines if
446    *  @a new_match  is a match at all. Approximate matching is done for
447    * weight and style; other attributes must match exactly.
448    * @param old_match A Pango::FontDescription, or <tt>0</tt>.
449    * @param new_match A Pango::FontDescription.
450    * @return <tt>true</tt> if @a new_match  is a better match.
451    */
452   bool better_match(const FontDescription& old_match, const FontDescription& new_match) const;
453   
454   /** Creates a string representation of a font description. See
455    * description_from_string() for a description of the
456    * format of the string representation. The family list in the
457    * string description will only have a terminating comma if the
458    * last word of the list is a valid style option.
459    * @return The string.
460    */
461   Glib::ustring to_string() const;
462   
463   /** Creates a filename representation of a font description. The
464    * filename is identical to the result from calling
465    * pango_font_description_to_string(), but with underscores instead of
466    * characters that are untypical in filenames, and in lower case only.
467    * @return The filename.
468    */
469   Glib::ustring to_filename() const;
470
471
472 };
473
474 } //namespace Pango
475
476
477 namespace Pango
478 {
479
480 /** @relates Pango::FontDescription
481  * @param lhs The left-hand side
482  * @param rhs The right-hand side
483  * @result The result
484  */
485 bool operator==(const FontDescription& lhs, const FontDescription& rhs);
486
487 /** @relates Pango::FontDescription
488  * @param lhs The left-hand side
489  * @param rhs The right-hand side
490  * @result The result
491  */
492 bool operator!=(const FontDescription& lhs, const FontDescription& rhs);
493
494
495 } // namespace Pango
496
497
498 namespace Pango
499 {
500
501 /** @relates Pango::FontDescription
502  * @param lhs The left-hand side
503  * @param rhs The right-hand side
504  */
505 inline void swap(FontDescription& lhs, FontDescription& rhs)
506   { lhs.swap(rhs); }
507
508 } // namespace Pango
509
510 namespace Glib
511 {
512
513 /** @relates Pango::FontDescription
514  * @param object The C instance
515  * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
516  * @result A C++ instance that wraps this C instance.
517  */
518 Pango::FontDescription wrap(PangoFontDescription* object, bool take_copy = false);
519
520 #ifndef DOXYGEN_SHOULD_SKIP_THIS
521 template <>
522 class Value<Pango::FontDescription> : public Glib::Value_Boxed<Pango::FontDescription>
523 {};
524 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
525
526 } // namespace Glib
527
528 #endif /* _PANGOMM_FONTDESCRIPTION_H */
529