summaryrefslogtreecommitdiffstats
path: root/src/modules/popupeditor/popupeditor.h
blob: 8b96713b1d9887c761881199fd95c24b138c5704 (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
206
207
208
209
#ifndef _POPUPEDITOR_H_
#define _POPUPEDITOR_H_
//
//   File : popupeditor.h
//   Creation date : Mon Dec 23 2002 20:24:55 CEST by Szymon Stefanek
//
//   This file is part of the KVirc irc client distribution
//   Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)
//
//   This program is FREE software. You can redistribute it and/or
//   modify it under the linkss 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_window.h"
#include "kvi_string.h"


#include <tqwidget.h>
#include "kvi_tal_listview.h"
#include <tqlineedit.h>
#include "kvi_tal_popupmenu.h"
#include <tqpushbutton.h>

class KviKvsPopupMenu;
class KviKvsPopupMenuItem;

// KviPopupListViewItem
class KviPopupListViewItem : public KviTalListViewItem
{
public:
	enum Type { Item , Menu , Separator , Label , Epilogue , Prologue , ExtMenu };
public:
	KviPopupListViewItem(KviTalListView * pListView,KviPopupListViewItem * after,Type t);
	KviPopupListViewItem(KviPopupListViewItem * parent,KviPopupListViewItem * after,Type t);
public:
	Type                   m_type;
	TQString                m_szText;
	TQString                m_szCondition;
	TQString                m_szIcon;
	TQString                m_szCode;
	TQString                m_szId;
private:
	void init();
public:
	void setItemText(const TQString & szText);
	void setCondition(const TQString & szCondition);
	void setIcon(const TQString & szIcon);
	void setCode(const TQString & szCode);
	void setId(const TQString & szId);
};



class KviScriptEditor;

class KviMenuListViewItem;

class KviSinglePopupEditor : public TQWidget
{
	Q_OBJECT
  
public:
	KviSinglePopupEditor(TQWidget * par);
	~KviSinglePopupEditor();
protected:
	TQPushButton          * m_pMenuButton;
	KviKvsPopupMenu      * m_pClipboard;
	KviKvsPopupMenu      * m_pTestPopup;
	KviPopupListViewItem * m_pLastSelectedItem;
	KviTalListView            * m_pListView;
	TQLineEdit            * m_pNameEditor;
	KviScriptEditor      * m_pEditor;
	TQLineEdit            * m_pTextEditor;
	TQLineEdit            * m_pIdEditor;
	TQLineEdit            * m_pIconEditor;
	TQLineEdit            * m_pConditionEditor;
	TQLineEdit            * m_pExtNameEditor;
	KviTalPopupMenu           * m_pContextPopup;
public:
	void edit(KviMenuListViewItem * it);
	KviKvsPopupMenu * getMenu();
protected:
	// theItem is the item above the first item that has to be inserted
	void populateMenu(KviKvsPopupMenu * pop,KviPopupListViewItem * par,KviPopupListViewItem * theItem = 0);
	void saveLastSelectedItem();
	void addItemToMenu(KviKvsPopupMenu * pop,KviPopupListViewItem * par);
	KviPopupListViewItem * newItem(KviPopupListViewItem * par,KviPopupListViewItem * after,KviPopupListViewItem::Type t);
	KviPopupListViewItem * newItemBelow(KviPopupListViewItem * it,KviPopupListViewItem::Type t);
	KviPopupListViewItem * newItemAbove(KviPopupListViewItem * it,KviPopupListViewItem::Type t);
	KviPopupListViewItem * newItemInside(KviPopupListViewItem * it,KviPopupListViewItem::Type t);
	void createNewItemAboveLastSelected(KviPopupListViewItem::Type t);
	void createNewItemBelowLastSelected(KviPopupListViewItem::Type t);
	void createNewItemInsideLastSelected(KviPopupListViewItem::Type t);
	KviPopupListViewItem * findMatchingItem(KviKvsPopupMenuItem * it,KviPopupListViewItem * item);
protected slots:
	void contextCut();
	void contextCopy();
	void contextPasteBelow();
	void contextPasteAbove();
	void contextPasteInside();
	void contextNewSeparatorBelow();
	void contextNewSeparatorAbove();
	void contextNewSeparatorInside();
	void contextNewItemBelow();
	void contextNewItemAbove();
	void contextNewItemInside();
	void contextNewMenuBelow();
	void contextNewMenuAbove();
	void contextNewMenuInside();
	void contextNewExtMenuBelow();
	void contextNewExtMenuAbove();
	void contextNewExtMenuInside();
	void contextNewLabelBelow();
	void contextNewLabelAbove();
	void contextNewLabelInside();
	void contextNewPrologue();
	void contextNewEpilogue();
	void selectionChanged(KviTalListViewItem * it);
	void itemPressed(KviTalListViewItem *it,const TQPoint &pnt,int col);
	void testPopup();
	void testModeMenuItemClicked(KviKvsPopupMenuItem * it);
};



class KviMenuListViewItem : public KviTalListViewItem
{
public:
	KviMenuListViewItem(KviTalListView * par,KviKvsPopupMenu * popup);
	~KviMenuListViewItem();
public:
	KviKvsPopupMenu * m_pPopup;
public:
	KviKvsPopupMenu * popup(){ return m_pPopup; };
public:
	void replacePopup(KviKvsPopupMenu * popup);
};


class KviPopupEditor : public TQWidget
{
	Q_OBJECT
  
public:
	KviPopupEditor(TQWidget * par);
	~KviPopupEditor();
public:
	KviSinglePopupEditor * m_pEditor;
	KviTalListView            * m_pListView;
	KviMenuListViewItem  * m_pLastEditedItem;
	bool                   m_bOneTimeSetupDone;
	KviTalPopupMenu           * m_pContextPopup;
public:
	void commit();
	void exportPopups(bool);
protected slots:
	void currentItemChanged(KviTalListViewItem *it);
	void newPopup();
	void exportAll();
	void exportSelected();
	void exportCurrentPopup();
	void removeCurrentPopup();
	void itemPressed(KviTalListViewItem *it,const TQPoint &pnt,int col);
protected:
	void showEvent(TQShowEvent *e);
	void getExportPopupBuffer(TQString &buffer,KviMenuListViewItem * it);
private:
	void oneTimeSetup();
	void saveLastEditedItem();
	void getUniquePopupName(KviMenuListViewItem * it,TQString &buffer);
};



class KviPopupEditorWindow : public KviWindow
{
	Q_OBJECT
  
public:
	KviPopupEditorWindow(KviFrame * lpFrm);
	~KviPopupEditorWindow();
protected:
	KviPopupEditor * m_pEditor;
	TQWidget        * m_pBase;
protected:
	virtual TQPixmap * myIconPtr();
	virtual void fillCaptionBuffers();
	virtual void resizeEvent(TQResizeEvent *e);
	virtual void getConfigGroupName(KviStr &szName);
	virtual void saveProperties(KviConfig *);
	virtual void loadProperties(KviConfig *);
protected slots:
	void cancelClicked();
	void okClicked();
	void applyClicked();
};

#endif //_POPUPEDITOR_H_