summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/imageicon.h
blob: 803b2f53fbce2d15e15c77a722ded4ee61437d14 (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
#ifndef __UI_DIALOG_IMAGE_H__
#define __UI_DIALOG_IMAGE_H__
/*
 * A simple image display widget, using Inkscape's own rendering engine
 *
 * Authors:
 *   Bob Jamison
 *   Other dudes from The Inkscape Organization
 *
 * Copyright (C) 2004 The Inkscape Organization
 *
 * Released under GNU GPL, read the file 'COPYING' for more information
 */

#include <glibmm/ustring.h>
#include <gtkmm/box.h>


class SPDocument;

namespace Inkscape
{
namespace UI
{
namespace Widget
{


/*#########################################################################
### ImageIcon widget
#########################################################################*/

/**
 * This class is evolved from the SVGPreview widget of the FileChooser
 * This uses Inkscape's renderer to show images in a variety of formats,
 * including SVG
 */
class ImageIcon : public Gtk::VBox
{
public:

    /**
     * Constructor
     */
    ImageIcon();

    /**
     * Construct from a file name
     */
    ImageIcon(const Glib::ustring &fileName);

    /**
     * Copy Constructor
     */
    ImageIcon(const ImageIcon &other);

    /**
     * Destructor
     */
    ~ImageIcon();

    /**
     *
     */
    bool showSvgDocument(const SPDocument *doc);

    /**
     *
     */
    bool showSvgFile(const Glib::ustring &fileName);

    /**
     *
     */
    bool showSvgFromMemory(const char *xmlBuffer);

    /**
     * Show image embedded in SVG
     */
    bool showBitmap(const Glib::ustring &fileName);

    /**
     * Show the "Too large" image
     */
    void showBrokenImage(const Glib::ustring &reason);

    /**
     *
     */
    bool show(const Glib::ustring &fileName);

private:

    /**
     * basic initialization, called by the various constructors
     */
    void init();

    /**
     * The svg document we are currently showing
     */
    SPDocument *document;

    /**
     * The sp_svg_view widget
     */
    Gtk::Widget *viewerGtkmm;

    /**
     * are we currently showing the "broken image" image?
     */
    bool showingBrokenImage;


    /**
     * will be set by showImageIcon as a side-effect of an error
     */
    Glib::ustring bitmapError;


    /**
     * will be set by showImageIcon as a side-effect of an error
     */
    Glib::ustring svgError;

};



} // namespace Widget
} // namespace UI
} // namespace Inkscape


#endif /* __UI_DIALOG_IMAGE_H__ */
/*#########################################################################
### E N D    O F    F I L E
#########################################################################*/