~ubuntu-branches/ubuntu/vivid/ardour/vivid-proposed

« back to all changes in this revision

Viewing changes to libs/gtkmm2/pango/pangomm/tabarray.cc

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler, Jaromír Mikeš, Felipe Sateler
  • Date: 2014-05-22 14:39:25 UTC
  • mfrom: (29 sid)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: package-import@ubuntu.com-20140522143925-vwqfo9287pmkrroe
Tags: 1:2.8.16+git20131003-3
* Team upload

[ Jaromír Mikeš ]
* Add -dbg package

[ Felipe Sateler ]
* Upload to experimental

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Generated by gtkmmproc -- DO NOT MODIFY!
 
2
 
 
3
#include <pangomm/tabarray.h>
 
4
#include <pangomm/private/tabarray_p.h>
 
5
 
 
6
#include <pango/pango-enum-types.h>
 
7
// -*- c++ -*-
 
8
/* $Id$ */
 
9
 
 
10
/*
 
11
 *
 
12
 * Copyright 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
namespace Pango
 
30
{
 
31
 
 
32
TabArray::TabArray(int initial_size, bool positions_in_pixels)
 
33
{
 
34
  gobject_ = pango_tab_array_new(initial_size, (gboolean)positions_in_pixels);
 
35
}
 
36
 
 
37
std::pair<TabAlign,int> TabArray::get_tab(int tab_index) const
 
38
{
 
39
  TabAlign alignment;
 
40
  int location;
 
41
  pango_tab_array_get_tab(const_cast<PangoTabArray*>(gobj()), tab_index, (PangoTabAlign*)&alignment, &location);
 
42
  return std::pair<TabAlign,int>(alignment, location);
 
43
}
 
44
 
 
45
Glib::ArrayHandle< std::pair<TabAlign,int> > TabArray::get_tabs() const
 
46
{
 
47
  typedef std::pair<TabAlign,int> PairType;
 
48
 
 
49
  PairType* pair_buffer = 0;
 
50
  const int size = pango_tab_array_get_size(const_cast<PangoTabArray*>(gobj()));
 
51
 
 
52
  if(size > 0)
 
53
  {
 
54
    // Get arrays
 
55
    PangoTabAlign* pAlignments = 0;
 
56
    int*           pLocations  = 0;
 
57
    pango_tab_array_get_tabs(const_cast<PangoTabArray*>(gobj()), &pAlignments, &pLocations);
 
58
 
 
59
    if(pAlignments && pLocations)
 
60
    {
 
61
      // Create temporary C array.  Fortunately, the C++ type is POD,
 
62
      // so we can safely store it in the array.
 
63
      pair_buffer = g_new(PairType, size);
 
64
 
 
65
      for(int i = 0; i < size; ++i)
 
66
      {
 
67
        pair_buffer[i].first  = (TabAlign)(pAlignments[i]);
 
68
        pair_buffer[i].second = pLocations[i];
 
69
      }
 
70
    }
 
71
 
 
72
    g_free(pAlignments);
 
73
    g_free(pLocations);
 
74
  }
 
75
 
 
76
  return Glib::ArrayHandle<PairType>(pair_buffer, size, Glib::OWNERSHIP_SHALLOW);
 
77
}
 
78
 
 
79
} /* namespace Pango */
 
80
 
 
81
 
 
82
namespace
 
83
{
 
84
} // anonymous namespace
 
85
 
 
86
// static
 
87
GType Glib::Value<Pango::TabAlign>::value_type()
 
88
{
 
89
  return pango_tab_align_get_type();
 
90
}
 
91
 
 
92
 
 
93
namespace Glib
 
94
{
 
95
 
 
96
Pango::TabArray wrap(PangoTabArray* object, bool take_copy)
 
97
{
 
98
  return Pango::TabArray(object, take_copy);
 
99
}
 
100
 
 
101
} // namespace Glib
 
102
 
 
103
 
 
104
namespace Pango
 
105
{
 
106
 
 
107
 
 
108
// static
 
109
GType TabArray::get_type()
 
110
{
 
111
  return pango_tab_array_get_type();
 
112
}
 
113
 
 
114
TabArray::TabArray()
 
115
:
 
116
  gobject_ (0) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
 
117
{}
 
118
 
 
119
TabArray::TabArray(const TabArray& other)
 
120
:
 
121
  gobject_ ((other.gobject_) ? pango_tab_array_copy(other.gobject_) : 0)
 
122
{}
 
123
 
 
124
TabArray::TabArray(PangoTabArray* gobject, bool make_a_copy)
 
125
:
 
126
  // For BoxedType wrappers, make_a_copy is true by default.  The static
 
127
  // BoxedType wrappers must always take a copy, thus make_a_copy = true
 
128
  // ensures identical behaviour if the default argument is used.
 
129
  gobject_ ((make_a_copy && gobject) ? pango_tab_array_copy(gobject) : gobject)
 
130
{}
 
131
 
 
132
TabArray& TabArray::operator=(const TabArray& other)
 
133
{
 
134
  TabArray temp (other);
 
135
  swap(temp);
 
136
  return *this;
 
137
}
 
138
 
 
139
TabArray::~TabArray()
 
140
{
 
141
  if(gobject_)
 
142
    pango_tab_array_free(gobject_);
 
143
}
 
144
 
 
145
void TabArray::swap(TabArray& other)
 
146
{
 
147
  PangoTabArray *const temp = gobject_;
 
148
  gobject_ = other.gobject_;
 
149
  other.gobject_ = temp;
 
150
}
 
151
 
 
152
PangoTabArray* TabArray::gobj_copy() const
 
153
{
 
154
  return pango_tab_array_copy(gobject_);
 
155
}
 
156
 
 
157
 
 
158
int TabArray::get_size() const
 
159
{
 
160
  return pango_tab_array_get_size(const_cast<PangoTabArray*>(gobj()));
 
161
}
 
162
 
 
163
void TabArray::resize(int new_size)
 
164
{
 
165
  pango_tab_array_resize(gobj(), new_size);
 
166
}
 
167
 
 
168
void TabArray::set_tab(int tab_index, TabAlign alignment, int location)
 
169
{
 
170
  pango_tab_array_set_tab(gobj(), tab_index, ((PangoTabAlign)(alignment)), location);
 
171
}
 
172
 
 
173
bool TabArray::get_positions_in_pixels() const
 
174
{
 
175
  return pango_tab_array_get_positions_in_pixels(const_cast<PangoTabArray*>(gobj()));
 
176
}
 
177
 
 
178
 
 
179
} // namespace Pango
 
180
 
 
181