summaryrefslogtreecommitdiff
path: root/poppler-glib/src/action.hg
blob: b38f2a3197169388cbbf87448b00c44c1aadca13 (plain)
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
/* Copyright (c) 2010  Glenn Rice <glennricster@gmail.com>
 *
 * This file is part of poppler-glibmm.
 *
 * poppler-glibmm 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.
 *
 * poppler-glibmm 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 program.  If not, see <http://www.gnu.org/licenses/>.
 */

_DEFS(poppler-glibmm,poppler-glib)
#include <poppler-glibmm/media.h>
#include <poppler-glibmm/movie.h>
#include <poppler-glibmm/layer.h>
#include <poppler-action.h>

#ifndef DOXYGEN_SHOULD_SKIP_THIS
extern "C" { typedef union _PopplerAction PopplerAction; }
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

namespace Poppler
{

_WRAP_ENUM(ActionType, PopplerActionType)
_WRAP_ENUM(DestType, PopplerDestType)
_WRAP_ENUM(ActionMovieOperation, PopplerActionMovieOperation)
_WRAP_ENUM(ActionLayerAction, PopplerActionLayerAction)

/** Poppler::Dest is a structure for holding a destination
 */
class Dest
{
  _CLASS_BOXEDTYPE(Dest, PopplerDest, NONE, poppler_dest_copy, poppler_dest_free)

  public:
    _MEMBER_GET(dest_type, type, DestType, PopplerDestType)
    _MEMBER_SET(dest_type, type, DestType, PopplerDestType)
  
    _MEMBER_GET(page_num, page_num, int, int)
    _MEMBER_SET(page_num, page_num, int, int)
  
    _MEMBER_GET(left, left, double, double)
    _MEMBER_SET(left, left, double, double)
    _MEMBER_GET(bottom, bottom, double, double)
    _MEMBER_SET(bottom, bottom, double, double)
    _MEMBER_GET(right, right, double, double)
    _MEMBER_SET(right, right, double, double)
    _MEMBER_GET(top, top, double, double)
    _MEMBER_SET(top, top, double, double)
    _MEMBER_GET(zoom, zoom, double, double)
    _MEMBER_SET(zoom, zoom, double, double)

    _MEMBER_GET(named_dest, named_dest, Glib::ustring, gchar*)
    _MEMBER_SET(named_dest, named_dest, Glib::ustring, gchar*)

    _MEMBER_GET(change_left, change_left, guint, guint)
    _MEMBER_SET(change_left, change_left, guint, guint)
    _MEMBER_GET(change_top, change_top, guint, guint)
    _MEMBER_SET(change_top, change_top, guint, guint)
    _MEMBER_GET(change_zoom, change_zoom, guint, guint)
    _MEMBER_SET(change_zoom, change_zoom, guint, guint)

    /** This typedef is just to make it more obvious that
     * our operator const void* should be used like operator bool().
     */
    typedef const void* BoolExpr;

    /** Returns <tt>true</tt> if this Dest is valid, that is if the
     * underlying instance is non-null.
     * @return <tt>true</tt>, if the Dest is valid
     */
    inline operator BoolExpr() const { return gobj() ? GINT_TO_POINTER(1) : 0; }
};

/** Poppler::ActionLayer - Layer actions
  */
class ActionLayer
{
  _CLASS_GENERIC(ActionLayer, PopplerActionLayer)

  public:
    ActionLayer();

    explicit ActionLayer(const PopplerActionLayer* gobject); // always takes a copy

    ///Provides access to the underlying C instance.
    PopplerActionLayer* gobj() { return &gobject_; }

    ///Provides access to the underlying C instance.
    const PopplerActionLayer* gobj() const { return &gobject_; }

    _MEMBER_GET(action, action, ActionLayerAction, PopplerActionLayerAction)
#m4 _CONVERSION(`Glist*',`std::vector< Glib::RefPtr<Layer> >',
#m4             `Glib::ListHandler< Glib::RefPtr<Layer> >::list_to_vector($3, Glib::OWNERSHIP_NONE)')
    _MEMBER_GET(layers, layers, std::vector< Glib::RefPtr<Layer> >, GList*)

  protected:
    PopplerActionLayer gobject_;
};

#ifndef DOXYGEN_SHOULD_SKIP_THIS
struct ActionLayerTraits
{
  typedef ActionLayer CppType;
  typedef PopplerActionLayer* CType;
  typedef PopplerActionLayer* CTypeNonConst;

  static CppType to_cpp_type(CType item) { return ActionLayer(item); }
  static void release_c_type(CType) {};
};
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

/** Poppler::Action is a structure for holding an action
 */
class Action
{
  _CLASS_BOXEDTYPE(Action, PopplerAction, NONE, poppler_action_copy, poppler_action_free)
  _CUSTOM_STRUCT_PROTOTYPE

  public:
    _MEMBER_GET(action_type, type, ActionType, PopplerActionType)
    _MEMBER_GET(title, any.title, Glib::ustring, gchar*)

    // PopplerActionGotoDest members
    _MEMBER_GET(goto_dest_dest, goto_dest.dest, Dest, const PopplerDest*)

    // PopplerActionGotoRemote members
    _MEMBER_GET(goto_remote_dest, goto_remote.dest, Dest, const PopplerDest*)
    _MEMBER_GET(goto_remote_file_name, goto_remote.file_name, std::string, gchar*)

    // PopplerActionLaunch members
    _MEMBER_GET(launch_file_name, launch.file_name, std::string, gchar*)
    _MEMBER_GET(launch_params, launch.params, std::string, gchar*)

    // PopplerActionUri members
    _MEMBER_GET(uri, uri.uri, std::string, gchar*)

    // PopplerActionNamed members
    _MEMBER_GET(named_dest, named.named_dest, std::string, gchar*)

    // PopplerActionMovie members
    _MEMBER_GET(movie_operation, movie.operation, ActionMovieOperation, PopplerActionMovieOperation)
    _MEMBER_GET_GOBJECT(movie_movie, movie.movie, Movie, PopplerMovie*)

    // PopplerActionRendition members
    _MEMBER_GET(rendition_op, rendition.op, int, gint)
    _MEMBER_GET_GOBJECT(rendition_media, rendition.media, Media, PopplerMedia*)

    // PopplerActionOCGState members
#m4 _CONVERSION(`Glist*',`std::vector<ActionLayer>',
#m4             `Glib::ListHandler<ActionLayer,ActionLayerTraits>::list_to_vector($3, Glib::OWNERSHIP_NONE)')
    _MEMBER_GET(ocg_state_list, ocg_state.state_list, std::vector<ActionLayer>, GList*)

    // PopplerActionJavascript members
    _MEMBER_GET(javascript, javascript.script, std::string, gchar*)

    /** This typedef is just to make it more obvious that
     * our operator const void* should be used like operator bool().
     */
    typedef const void* BoolExpr;

    /** Tests whether the Action is valid.
     * For instance,
     * @code
     * if (action) do_something()
     * @endcode
     */
    inline operator BoolExpr() const { return gobj() ? GINT_TO_POINTER(1) : 0; }
};

} // namespace Poppler