File: papersize.cc

package info (click to toggle)
gtkmm3.0 3.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 159,024 kB
  • ctags: 22,555
  • sloc: xml: 107,819; sh: 11,425; cpp: 7,074; makefile: 241; perl: 235
file content (238 lines) | stat: -rw-r--r-- 6,465 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
// Generated by gmmproc 2.42.0 -- DO NOT MODIFY!


#include <glibmm.h>

#include <gtkmm/papersize.h>
#include <gtkmm/private/papersize_p.h>


/* Copyright (C) 2006 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <glibmm/vectorutils.h>

#include <gtk/gtk.h>

namespace Gtk
{

//PaperSize::PaperSize()
//:
//  gobject_(gtk_paper_size_new(gtk_paper_size_get_default()))
//{}

PaperSize::PaperSize(const Glib::ustring& name)
:
  gobject_(gtk_paper_size_new(name.c_str()))
{}

PaperSize::PaperSize(const Glib::ustring& ppd_name, const Glib::ustring& ppd_display_name, double width, double height)
:
  gobject_(gtk_paper_size_new_from_ppd(ppd_name.c_str(),
                                       ppd_display_name.c_str(),
                                       gdouble(width),
                                       gdouble(height)))
{}

PaperSize::PaperSize(const Glib::ustring& name, const Glib::ustring& display_name, double width, double height, Unit unit)
:
  gobject_(gtk_paper_size_new_custom(name.c_str(),
                                     display_name.c_str(),
                                     gdouble(width),
                                     gdouble(height),
                                     GtkUnit(unit)))
{}

//TODO: Add an operator const void*() so we can detect if this succeeded:
//TODO: No, throw the error/exception instead.
PaperSize::PaperSize(const Glib::KeyFile& key_file, const Glib::ustring& group_name)
:
  gobject_(gtk_paper_size_new_from_key_file(const_cast<GKeyFile*>(key_file.gobj()), (group_name.empty() ? NULL : group_name.c_str()) , NULL /* GError */))
{}

bool PaperSize::equal(const PaperSize& other) const
{
  return (static_cast<bool>(gtk_paper_size_is_equal(const_cast<GtkPaperSize*>(this->gobj()),
                                                    const_cast<GtkPaperSize*>(other.gobj()))));
}

PaperSize::operator const void*() const
{
  return gobj() ? GINT_TO_POINTER(1) : 0;
}

void PaperSize::save_to_key_file(Glib::KeyFile& key_file)
{
  gtk_paper_size_to_key_file( gobj(), (key_file).gobj(), 0);
}


} // namespace Gtk

namespace
{
} // anonymous namespace

// static
GType Glib::Value<Gtk::Unit>::value_type()
{
  return gtk_unit_get_type();
}


namespace Glib
{

Gtk::PaperSize wrap(GtkPaperSize* object, bool take_copy)
{
  return Gtk::PaperSize(object, take_copy);
}

} // namespace Glib


namespace Gtk
{


// static
GType PaperSize::get_type()
{
  return gtk_paper_size_get_type();
}

PaperSize::PaperSize()
:
  gobject_ (0) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
{}

PaperSize::PaperSize(const PaperSize& other)
:
  gobject_ ((other.gobject_) ? gtk_paper_size_copy(other.gobject_) : 0)
{}

PaperSize::PaperSize(GtkPaperSize* gobject, bool make_a_copy)
:
  // For BoxedType wrappers, make_a_copy is true by default.  The static
  // BoxedType wrappers must always take a copy, thus make_a_copy = true
  // ensures identical behaviour if the default argument is used.
  gobject_ ((make_a_copy && gobject) ? gtk_paper_size_copy(gobject) : gobject)
{}

PaperSize& PaperSize::operator=(const PaperSize& other)
{
  PaperSize temp (other);
  swap(temp);
  return *this;
}

PaperSize::~PaperSize()
{
  if(gobject_)
    gtk_paper_size_free(gobject_);
}

void PaperSize::swap(PaperSize& other)
{
  GtkPaperSize *const temp = gobject_;
  gobject_ = other.gobject_;
  other.gobject_ = temp;
}

GtkPaperSize* PaperSize::gobj_copy() const
{
  return gtk_paper_size_copy(gobject_);
}


std::vector<PaperSize> PaperSize::get_paper_sizes(bool include_custom)
{
  return Glib::ListHandler<PaperSize, PaperSizeTraits>::list_to_vector(gtk_paper_size_get_paper_sizes(static_cast<int>(include_custom)), Glib::OWNERSHIP_DEEP);
}


Glib::ustring PaperSize::get_name() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gtk_paper_size_get_name(const_cast<GtkPaperSize*>(gobj())));
}

Glib::ustring PaperSize::get_display_name() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gtk_paper_size_get_display_name(const_cast<GtkPaperSize*>(gobj())));
}

Glib::ustring PaperSize::get_ppd_name() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gtk_paper_size_get_ppd_name(const_cast<GtkPaperSize*>(gobj())));
}

double PaperSize::get_width(Unit unit) const
{
  return gtk_paper_size_get_width(const_cast<GtkPaperSize*>(gobj()), ((GtkUnit)(unit)));
}

double PaperSize::get_height(Unit unit) const
{
  return gtk_paper_size_get_height(const_cast<GtkPaperSize*>(gobj()), ((GtkUnit)(unit)));
}

bool PaperSize::is_custom() const
{
  return gtk_paper_size_is_custom(const_cast<GtkPaperSize*>(gobj()));
}

void PaperSize::set_size(double width, double height, Unit unit)
{
  gtk_paper_size_set_size(gobj(), width, height, ((GtkUnit)(unit)));
}

double PaperSize::get_default_top_margin(Unit unit) const
{
  return gtk_paper_size_get_default_top_margin(const_cast<GtkPaperSize*>(gobj()), ((GtkUnit)(unit)));
}

double PaperSize::get_default_bottom_margin(Unit unit) const
{
  return gtk_paper_size_get_default_bottom_margin(const_cast<GtkPaperSize*>(gobj()), ((GtkUnit)(unit)));
}

double PaperSize::get_default_left_margin(Unit unit) const
{
  return gtk_paper_size_get_default_left_margin(const_cast<GtkPaperSize*>(gobj()), ((GtkUnit)(unit)));
}

double PaperSize::get_default_right_margin(Unit unit) const
{
  return gtk_paper_size_get_default_right_margin(const_cast<GtkPaperSize*>(gobj()), ((GtkUnit)(unit)));
}

Glib::ustring PaperSize::get_default()
{
  return Glib::convert_const_gchar_ptr_to_ustring(gtk_paper_size_get_default());
}


void PaperSize::save_to_key_file(Glib::KeyFile& key_file, const Glib::ustring& group_name)
{
  gtk_paper_size_to_key_file(gobj(), (key_file).gobj(), group_name.c_str());
}


} // namespace Gtk