summaryrefslogtreecommitdiffstats
path: root/kexi/widget/kexieditor.h
blob: f5bbc08b8ff215619a2c786b2d901b01f299d291 (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
/* This file is part of the KDE project
   Copyright (C) 2003 Lucijan Busch <[email protected]>
   Copyright (C) 2004-2005 Jaroslaw Staniek <[email protected]>
   Copyright (C) 2005 Cedric Pasteur <[email protected]>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This program 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef KEXIEDITOR_H
#define KEXIEDITOR_H

#include <tqwidget.h>
#include "kexiviewbase.h"

class KTextEdit;
class KexiEditorPrivate;

namespace KTextEditor
{
	class Document;
	class View;
}

//! An text editor view that uses both KTextEditor and KTextEdit
/*! It is used for SQL and script editor. */
class KEXIEXTWIDGETS_EXPORT KexiEditor : public KexiViewBase
{
	TQ_OBJECT
  

	public:

		/**
		* Constructor.
		* 
		* \param mainWin The \a KexiMainWindow instance this KexiEditor
		*        belongs too.
		* \param parent The parent \a TQWidget this KexiEditor is child
		*        of.  You don't need to free the KexiEditor cause TQt 
		*        will handle that for us.
		* \param name The name this KexiEditor has. Used only for debugging.
		*/
		KexiEditor(KexiMainWindow *mainWin, TQWidget *parent, const char *name = 0);

		/**
		* Destructor.
		*/
		virtual ~KexiEditor();

		/**
		* \return true if internally the KTextEditor::EditorChooser got
		* used else, if a simple KTextEdit is used, false is returned.
		*/
		static bool isAdvancedEditor();

		/**
		* \return the text displayed in the editor-widget.
		*/
		TQString text();

		/**
		* Set the highlight-mode to \p highlightmodename . If
		* \a isAdvancedEditor returns false (KTextEdit is used
		* rather then KTextEditor), then the method just does
		* nothing. The \p highlightmodename could be any kind
		* of string like e.g. "python", "kjs" or "sql" 
		* KTextEditor supports.
		*/
		void setHighlightMode(const TQString& highlightmodename);

		/**
		* Find row and column for this \p character and jump to the
		* position.
		*/
		void jump(int character);
		
		/**
		* Set the cursor position to \p line and \p col .
		*/
		void setCursorPosition(int line, int col);
		
		/**
		* Clear all remembered undo/redo-actions. Only
		* avaiable if \a isAdvancedEditor returns true.
		*/
		void clearUndoRedo();

	public slots:
		/*! Sets editor's text to \a text. 'Dirty' flag remains unchanged. 
		 Undo/redo buffer is cleared.*/
		void setText(const TQString &text);
		/*! Display the configuration-dialog. Only avaiable if isAdvancedEditor() returns true. */
		void slotConfigureEditor();

	protected:
		/*! Update the actions. This call is redirected to \a KexiViewBase::updateActions */
		virtual void updateActions(bool activated);

	signals:
		/*! Emitted if the text displayed in the editor changed. */
		void textChanged();

	private:
		/*! Private d-pointer class. */
		KexiEditorPrivate *d;
};

#endif