summaryrefslogtreecommitdiffstats
path: root/src/modules/editor/scripteditor.h
blob: f37c7ab23ddfcb35e06991e69a26459255dd2e09 (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#ifndef _SCRIPTEDITOR_H_
#define _SCRIPTEDITOR_H_

//=============================================================================
//
//   File : scripteditor.h
//   Created on Sun Mar 28 1999 16:11:48 CEST by Szymon Stefanek
//
//   This file is part of the KVIrc IRC client distribution
//   Copyright (C) 1999-2004 Szymon Stefanek <pragma at kvirc dot net>
//
//   This program is FREE software. You can redistribute it and/or
//   modify it under the terms of the GNU General Public License
//   as published by the Free Software Foundation; either version 2
//   of the License, or (at your opinion) 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 General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program. If not, write to the Free Software Foundation,
//   Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=============================================================================

#include "kvi_scripteditor.h"

#include <tqlabel.h>
#include <kvi_tal_textedit.h>
#include <tqsyntaxhighlighter.h>
#include <tqdialog.h>
#include <tqcheckbox.h>
#include "kvi_tal_listbox.h"
#include <tqevent.h> 
#include "kvi_qcstring.h"

#include "kvi_tal_popupmenu.h"

#include "kvi_pointerlist.h"
#include "kvi_selectors.h"
typedef KviPointerList<int> ColumnList;

class KviCompletionBox: public KviTalListBox
{
	Q_OBJECT
  TQ_OBJECT
public:
	KviCompletionBox(TQWidget * tqparent);
	~KviCompletionBox(){};
	
	void updateContents(TQString word);
protected:
	virtual void keyPressEvent(TQKeyEvent * e);
};

class KviScriptEditorWidget : public KviTalTextEdit
{
	Q_OBJECT
  TQ_OBJECT
	TQ_PROPERTY(bool contextSensitiveHelp READ contextSensitiveHelp)
public:
	KviScriptEditorWidget(TQWidget * pParent);
	virtual ~KviScriptEditorWidget();
public:
	void updateOptions();
	void tqfind1();
	TQString m_szFind;
	KviCompletionBox *completelistbox;
	void completition(bool bCanComplete = 1);
	void getWordBeforeCursor(TQString &buffer,int index,bool *);
	void getWordOnCursor(TQString &buffer,int index) const;
	bool contextSensitiveHelp() const;
public slots:
	void slotFind();
	void slotHelp();
	void slotReplace();
	void slotComplete(const TQString &str);

signals:
	void keyPressed();
protected:
	virtual void keyPressEvent(TQKeyEvent * e);
	void contentsMousePressEvent(TQMouseEvent *);
#ifdef COMPILE_USE_QT4
	Q3PopupMenu *createPopupMenu( const TQPoint& pos );
#else
	TQPopupMenu *createPopupMenu( const TQPoint& pos );
#endif
	TQWidget *m_pParent;
	TQString m_szHelp;

};

#ifdef COMPILE_USE_QT4
	#include <tq3syntaxhighlighter.h>
	#define TQSyntaxHighlighter Q3SyntaxHighlighter
#else
	#include <tqobjectlist.h>
#endif
class KviScriptSyntaxHighlighter : public TQSyntaxHighlighter
{
public:
	KviScriptSyntaxHighlighter(KviScriptEditorWidget * pWidget);
	virtual ~KviScriptSyntaxHighlighter();
public:
	virtual int highlightParagraph(const TQString & text,int endStateOfLastPara);
};

class KviScriptEditorWidgetColorOptions : public TQDialog
{
	Q_OBJECT
  TQ_OBJECT
public:
	KviScriptEditorWidgetColorOptions(TQWidget * pParent);
	~KviScriptEditorWidgetColorOptions();
private:
	KviPointerList<KviSelectorInterface> * m_pSelectorInterfaceList;
protected:
	KviColorSelector * addColorSelector(TQWidget * pParent,const TQString & txt,TQColor * pOption,bool bEnabled);

protected slots:
	void okClicked();
};

class TQTimer;

class KviScriptEditorImplementation : public KviScriptEditor
{
	Q_OBJECT
  TQ_OBJECT
public:
	KviScriptEditorImplementation(TQWidget * par);
	virtual ~KviScriptEditorImplementation();
protected:
	KviScriptEditorWidget * m_pEditor;
	TQLabel                * m_pRowColLabel;
	TQPoint                  m_lastCursorPos;
public:
	virtual void setText(const TQString &txt);
	virtual void getText(TQString &txt);
	virtual void setText(const KviTQCString &txt);
	virtual void getText(KviTQCString &txt);
	virtual void setFindText(const TQString & text);
	virtual void setEnabled(bool bEnabled);
	virtual void setFocus();
	virtual bool isModified();
	void setFindLineeditReadOnly(bool b);
	void setCursorPosition(TQPoint);
	TQPoint getCursor();
	TQLineEdit *m_pFindlineedit;
	TQLineEdit * getFindlineedit();
protected:
	virtual void focusInEvent(TQFocusEvent *e);
	void loadOptions();
	void saveOptions();
protected slots:
	void saveToFile();
	void loadFromFile();
	void configureColors();
	void updateRowColLabel();
	void slotFind();
	void slotReplaceAll(const TQString &,const TQString &);
	void slotInitFind();
	void slotNextFind(const TQString &);
signals:
	void tqfind( const TQString &);
	void replaceAll( const TQString &, const TQString &);
	void initFind();
	void nextFind(const TQString &);
};

class KviScriptEditorReplaceDialog: public TQDialog
{
	Q_OBJECT
  TQ_OBJECT
public:
	KviScriptEditorReplaceDialog( TQWidget* tqparent = 0, const char* name = 0);
    ~KviScriptEditorReplaceDialog();
	TQLineEdit *m_pFindlineedit;
	TQLineEdit *m_pReplacelineedit;
protected:
	TQLabel *findlabel;
	TQLabel *replacelabel;
	TQPushButton *replacebutton;
	TQPushButton *tqreplace;
	TQPushButton *findNext;

//	TQPushButton *cancelbutton;
	KviStyledCheckBox *checkReplaceAll;
	TQWidget *m_pParent;
protected slots:
	void textChanged(const TQString &);
	void slotReplace();
	void slotNextFind();
signals:
	void replaceAll( const TQString &,const TQString &);
	void initFind();
	void nextFind(const TQString &);
	
};


#endif //!_SCRIPTEDITOR_H_