OSDN Git Service

6bf027c1b3f9153f80e2ea0e32246c78605b916a
[kita/kita.git] / kita / src / write / previewpart.h
1 /***************************************************************************
2 *   Copyright (C) 2004 by Kita Developers                                 *
3 *   ikemo@users.sourceforge.jp                                            *
4 *                                                                         *
5 *   This program is free software; you can redistribute it and/or modify  *
6 *   it under the terms of the GNU General Public License as published by  *
7 *   the Free Software Foundation; either version 2 of the License, or     *
8 *   (at your option) any later version.                                   *
9 ***************************************************************************/
10
11 #ifndef PREVIEWPART_H
12 #define PREVIEWPART_H
13
14 #include <khtml_part.h>
15 #include <qframe.h>
16 #include <qevent.h>
17
18 /* mode */
19 enum {
20     /* This part is not initialized. This part works as just KHTMLPart */
21     PREVIEWPART_MODE_KHTML,
22
23     /* on main window */
24     PREVIEWPART_MODE_MAINPART,
25
26     /* on popup       */
27     PREVIEWPART_MODE_POPUP
28 };
29
30 /* ID of user defined event */
31 #define EVENT_GotoAnchor ( QEvent::User + 100 )
32
33 class KitaDomTree;
34 class KURL;
35
36 namespace Kita
37 {
38     class ResPopup;
39 }
40
41 namespace DOM
42 {
43     class Node;
44 }
45
46
47 /*-------------------------------------------------------------*/
48
49 class KitaPreviewPart : public KHTMLPart
50 {
51     Q_OBJECT
52
53     Kita::ResPopup* m_popup;
54
55     /* basic information */
56     KURL m_datURL;
57
58     /* mouse event */
59     bool m_isPushedRightButton;
60
61     /* res popup */
62     bool m_multiPopup;
63     bool m_kitaIsActive;
64
65
66 public:
67
68     KitaPreviewPart( QWidget* parent, const char* name = 0 );
69     ~KitaPreviewPart();
70     bool setup( const KURL& url );
71
72     /* rendering */
73     void setInnerHTML( const QString& innerHTML );
74
75 public slots:
76
77     /* rendering */
78     void slotSetFaceOfHTMLPart();
79     void slotSetStyleSheetOfHTMLPart();
80
81     /* res popup */
82     void slotDeletePopup();
83
84 private:
85
86     void clearPart();
87
88     /* setup */
89     void connectSignals();
90     void createHTMLDocument();
91
92     /* click */
93     void clickAnchor( const KURL& urlin );
94
95     /* res popup */
96     void showPopup( const KURL& url, const QString& innerHTML );
97     void showPopupCore( const KURL& url, const QString& innerHTML, QPoint point );
98     bool startMultiPopup();
99     bool isMultiPopupMode();
100     void hidePopup();
101
102 protected:
103
104     /* user event */
105     virtual void customEvent( QCustomEvent * e );
106
107     /* mouse event */
108     virtual void khtmlMousePressEvent( khtml::MousePressEvent* e );
109
110
111 private slots:
112
113     /* res popup */
114     void slotLeave();
115     void slotVSliderReleased();
116     void slotHSliderReleased();
117     void slotHideChildPopup();
118     void slotKitaIsActive();
119     void slotOnURL( const QString& url );
120
121
122 signals:
123
124     void openURLRequestExt( const KURL& url, const KParts::URLArgs& args = KParts::URLArgs(),
125                             QString mimetype = QString::null,
126                             int usr1 = 0,
127                             const KURL& usrUrl1 = KURL() );
128     void mousePressed(); /* to KitaThreadView */
129
130     /* res popup */
131     void hideChildPopup();
132     void isKitaActive();
133 };
134
135 #endif