add new sigc++2 directory
[ardour.git] / libs / gtkmm2 / pango / pangomm / tabarray.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3
4 #include <pangomm/tabarray.h>
5 #include <pangomm/private/tabarray_p.h>
6
7 #include <pango/pango-enum-types.h>
8 // -*- c++ -*-
9 /* $Id$ */
10
11 /*
12  *
13  * Copyright 2002 The gtkmm Development Team
14  *
15  * This library is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU Library General Public
17  * License as published by the Free Software Foundation; either
18  * version 2 of the License, or (at your option) any later version.
19  *
20  * This library is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23  * Library General Public License for more details.
24  *
25  * You should have received a copy of the GNU Library General Public
26  * License along with this library; if not, write to the Free
27  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28  */
29
30 namespace Pango
31 {
32
33 TabArray::TabArray(int initial_size, bool positions_in_pixels)
34 {
35   gobject_ = pango_tab_array_new(initial_size, (gboolean)positions_in_pixels);
36 }
37
38 std::pair<TabAlign,int> TabArray::get_tab(int tab_index) const
39 {
40   PangoTabAlign p_alignment;
41   TabAlign alignment;
42   int location;
43   pango_tab_array_get_tab(const_cast<PangoTabArray*>(gobj()), tab_index, &p_alignment, &location);
44   alignment = static_cast<TabAlign>(p_alignment);
45   return std::pair<TabAlign,int>(alignment, location);
46 }
47
48 Glib::ArrayHandle< std::pair<TabAlign,int> > TabArray::get_tabs() const
49 {
50   typedef std::pair<TabAlign,int> PairType;
51
52   PairType* pair_buffer = 0;
53   const int size = pango_tab_array_get_size(const_cast<PangoTabArray*>(gobj()));
54
55   if(size > 0)
56   {
57     // Get arrays
58     PangoTabAlign* pAlignments = 0;
59     int*           pLocations  = 0;
60     pango_tab_array_get_tabs(const_cast<PangoTabArray*>(gobj()), &pAlignments, &pLocations);
61
62     if(pAlignments && pLocations)
63     {
64       // Create temporary C array.  Fortunately, the C++ type is POD,
65       // so we can safely store it in the array.
66       pair_buffer = g_new(PairType, size);
67
68       for(int i = 0; i < size; ++i)
69       {
70         pair_buffer[i].first  = (TabAlign)(pAlignments[i]);
71         pair_buffer[i].second = pLocations[i];
72       }
73     }
74
75     g_free(pAlignments);
76     g_free(pLocations);
77   }
78
79   return Glib::ArrayHandle<PairType>(pair_buffer, size, Glib::OWNERSHIP_SHALLOW);
80 }
81
82 } /* namespace Pango */
83
84
85 namespace
86 {
87 } // anonymous namespace
88
89 // static
90 GType Glib::Value<Pango::TabAlign>::value_type()
91 {
92   return pango_tab_align_get_type();
93 }
94
95
96 namespace Glib
97 {
98
99 Pango::TabArray wrap(PangoTabArray* object, bool take_copy)
100 {
101   return Pango::TabArray(object, take_copy);
102 }
103
104 } // namespace Glib
105
106
107 namespace Pango
108 {
109
110
111 // static
112 GType TabArray::get_type()
113 {
114   return pango_tab_array_get_type();
115 }
116
117 TabArray::TabArray()
118 :
119   gobject_ (0) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
120 {}
121
122 TabArray::TabArray(const TabArray& other)
123 :
124   gobject_ ((other.gobject_) ? pango_tab_array_copy(other.gobject_) : 0)
125 {}
126
127 TabArray::TabArray(PangoTabArray* gobject, bool make_a_copy)
128 :
129   // For BoxedType wrappers, make_a_copy is true by default.  The static
130   // BoxedType wrappers must always take a copy, thus make_a_copy = true
131   // ensures identical behaviour if the default argument is used.
132   gobject_ ((make_a_copy && gobject) ? pango_tab_array_copy(gobject) : gobject)
133 {}
134
135 TabArray& TabArray::operator=(const TabArray& other)
136 {
137   TabArray temp (other);
138   swap(temp);
139   return *this;
140 }
141
142 TabArray::~TabArray()
143 {
144   if(gobject_)
145     pango_tab_array_free(gobject_);
146 }
147
148 void TabArray::swap(TabArray& other)
149 {
150   PangoTabArray *const temp = gobject_;
151   gobject_ = other.gobject_;
152   other.gobject_ = temp;
153 }
154
155 PangoTabArray* TabArray::gobj_copy() const
156 {
157   return pango_tab_array_copy(gobject_);
158 }
159
160
161 int TabArray::get_size() const
162 {
163   return pango_tab_array_get_size(const_cast<PangoTabArray*>(gobj()));
164 }
165
166 void TabArray::resize(int new_size)
167 {
168 pango_tab_array_resize(gobj(), new_size); 
169 }
170
171 void TabArray::set_tab(int tab_index, TabAlign alignment, int location)
172 {
173 pango_tab_array_set_tab(gobj(), tab_index, ((PangoTabAlign)(alignment)), location); 
174 }
175
176 bool TabArray::get_positions_in_pixels() const
177 {
178   return pango_tab_array_get_positions_in_pixels(const_cast<PangoTabArray*>(gobj()));
179 }
180
181
182 } // namespace Pango
183
184