1/* This file is part of the KDE project
2 Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef __khtmlimage_h__
21#define __khtmlimage_h__
22
23#include "khtml_part.h"
24#include <kpluginfactory.h>
25#include <kparts/browserextension.h>
26#include <kparts/statusbarextension.h>
27
28#include "misc/loader_client.h"
29
30class KHTMLPart;
31class KComponentData;
32
33namespace khtml
34{
35 class CachedImage;
36}
37
38/**
39 * @internal
40 * (Only exported for khtmlimage_init.cpp, i.e. the part)
41 */
42class KHTML_EXPORT KHTMLImageFactory : public KPluginFactory
43{
44 Q_OBJECT
45public:
46 KHTMLImageFactory();
47 virtual ~KHTMLImageFactory();
48
49 virtual QObject *create(const char* iface,
50 QWidget *parentWidget,
51 QObject *parent,
52 const QVariantList& args,
53 const QString &keyword);
54
55 static const KComponentData &componentData() { return *s_componentData; }
56
57private:
58 static KComponentData *s_componentData;
59};
60
61/**
62 * @internal
63 */
64class KHTMLImage : public KParts::ReadOnlyPart, public khtml::CachedObjectClient
65{
66 Q_OBJECT
67public:
68 KHTMLImage( QWidget *parentWidget,
69 QObject *parent, KHTMLPart::GUIProfile prof );
70 virtual ~KHTMLImage();
71
72 virtual bool openFile() { return true; } // grmbl, should be non-pure in part.h, IMHO
73
74 virtual bool openUrl( const KUrl &url );
75
76 virtual bool closeUrl();
77
78 KHTMLPart *doc() const { return m_khtml; }
79
80 virtual void notifyFinished( khtml::CachedObject *o );
81
82protected:
83 virtual void guiActivateEvent( KParts::GUIActivateEvent *e );
84
85private Q_SLOTS:
86 void restoreScrollPosition();
87
88 void slotPopupMenu( const QPoint &global, const KUrl &url, mode_t mode,
89 const KParts::OpenUrlArguments &args,
90 const KParts::BrowserArguments &browserArgs,
91 KParts::BrowserExtension::PopupFlags flags,
92 const KParts::BrowserExtension::ActionGroupMap& actionGroups );
93
94// void slotImageJobFinished( KIO::Job *job );
95
96// void updateWindowCaption();
97
98private:
99 void disposeImage();
100
101 QPointer<KHTMLPart> m_khtml;
102 KParts::BrowserExtension *m_ext;
103 KParts::StatusBarExtension *m_sbExt;
104 QString m_mimeType;
105 khtml::CachedImage *m_image;
106 int m_xOffset, m_yOffset;
107};
108
109/**
110 * @internal
111 */
112class KHTMLImageBrowserExtension : public KParts::BrowserExtension
113{
114 Q_OBJECT
115public:
116 KHTMLImageBrowserExtension( KHTMLImage *parent );
117
118 virtual int xOffset();
119 virtual int yOffset();
120
121protected Q_SLOTS:
122 void print();
123 void reparseConfiguration();
124 void disableScrolling();
125
126private:
127 KHTMLImage *m_imgPart;
128};
129
130#endif
131