summaryrefslogtreecommitdiffstats
path: root/bibletime/frontend/display/chtmlreaddisplay.h
blob: 8b9a5c88b8ec0b275bf187bf83fc097d9793a4d2 (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
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2006 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/



#ifndef CHTMLREADDISPLAY_H
#define CHTMLREADDISPLAY_H

//BibleTime includes
#include "creaddisplay.h"
//#include "frontend/ctooltip.h"

//TQt includes
#include <tqstring.h>
#include <tqwidget.h>

//KDE includes
#include <khtml_part.h>
#include <khtmlview.h>
#include <kparts/browserextension.h>

class CHTMLReadDisplayView;

/** The implementation for the HTML read display.
  * @author The BibleTime team
  */
class CHTMLReadDisplay : public KHTMLPart, public CReadDisplay {
	Q_OBJECT
  
public:
	//reimplemented functions from CDisplay
	/**
	* Returns the right text part in the specified format.
	*/
	virtual const TQString text( const CDisplay::TextType format = CDisplay::HTMLText, const CDisplay::TextPart part = CDisplay::Document );
	/**
	* Sets the new text for this display widget.
	*/
	virtual void setText( const TQString& newText );
	virtual const bool hasSelection();
	/**
	* Reimplementation.
	*/
	virtual TQScrollView* view();
	virtual void selectAll();
	virtual void moveToAnchor( const TQString& anchor );

	virtual void zoomIn();
	virtual void zoomOut();
	virtual void openFindTextDialog();
	
	virtual TQMap<CDisplay::NodeInfoType, TQString> getCurrentNodeInfo() {
		return m_nodeInfo;
	}

protected:
	friend class CDisplay;
	CHTMLReadDisplay( CReadWindow* readWindow, TQWidget* parent = 0 );
	virtual ~CHTMLReadDisplay();

	virtual void urlSelected( const TQString& url, int button, int state, const TQString& _target, KParts::URLArgs args);
	/**
	* Reimplementation.
	*/
	virtual void khtmlMouseReleaseEvent( khtml::MouseReleaseEvent* event );
	virtual void khtmlMousePressEvent( khtml::MousePressEvent* event );
	virtual void khtmlMouseMoveEvent( khtml::MouseMoveEvent* event );
	virtual void timerEvent(TQTimerEvent *event);


	struct DNDData {
		bool mousePressed;
		bool isDragging;
		DOM::Node node;
		DOM::DOMString anchor;
		TQString selection;
		TQPoint startPos;
		enum DragType {
			Link,
			Text
		} dragType;
	}
	m_dndData;

	TQMap<NodeInfoType, TQString> m_nodeInfo;
		
private:
	CHTMLReadDisplayView* m_view;
	struct URLWorkaroundData {
		bool doWorkaround;
		TQString url;
		int button;
		int state;
		TQString target;
		KParts::URLArgs args;

		TQString module;
		TQString key;
	}
	m_urlWorkaroundData;

	DOM::Node m_previousEventNode;
	TQString m_currentAnchorCache;

protected slots:
	void slotGoToAnchor();
};

class CHTMLReadDisplayView : public KHTMLView, public CPointers {
	Q_OBJECT
  
protected: // Protected methods
	friend class CHTMLReadDisplay;


	CHTMLReadDisplayView(CHTMLReadDisplay* display, TQWidget* parent);
	/**
	* Reimplementation from TQScrollView. Sets the right slots
	*/
	virtual void polish();
	/**
	* Reimplementatiob from TQScrollView.
	*/
	virtual void contentsDropEvent( TQDropEvent* );
	/**
	* Reimplementatiob from TQScrollView.
	*/
	virtual void contentsDragEnterEvent( TQDragEnterEvent* );

protected slots: // Protected slots
	/**
	* Opens the popupmenu at the given position.
	*/
	void popupMenu( const TQString&, const TQPoint& );

private:
	CHTMLReadDisplay* m_display;
};

#endif