summaryrefslogtreecommitdiffstats
path: root/src/kvirc/ui/kvi_selectors.h
blob: 61497b661be0dcd430eded4a40dca2d2270815ae (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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
#ifndef _KVI_SELECTORS_H_
#define _KVI_SELECTORS_H_

//=============================================================================
//
//   File : kvi_selectors.h
//   Creation date : Mon Now 13 2000 15:21:10 CEST by Szymon Stefanek
//
//   This file is part of the KVirc irc client distribution
//   Copyright (C) 2000 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_settings.h"

#include <tqcheckbox.h>
#include "kvi_tal_hbox.h"
#include "kvi_tal_vbox.h"
#include <tqlineedit.h>
#include <tqlabel.h>
#include "kvi_tal_scrollview.h"
#include <tqpushbutton.h>
#include <tqcolor.h>
#include <tqfont.h>
#include "kvi_tal_listbox.h"
#include "kvi_tal_listview.h"
#include <tqspinbox.h>
#include <tqstringlist.h>
#include <tqvalidator.h>

#include "kvi_string.h"
#include "kvi_pixmap.h"
#include "kvi_styled_controls.h"

//#ifndef _KVI_SELECTORS_CPP_
//	extern void commitAllSelectors(TQWidget * par,const char * classname);
//#endif


//
// This is the common KviSelectorInterface
//
//     Note: I'm always learning
//           Today I have discovered that:
//              TQObject * o = new KviBoolSelector(...)
//              ((KviSelectorInterface *)o)->commit()
//           Does not work (SIGSEGV when jumping into commit(): bad vtable entry)
//           But the following works fine:
//              KviBoolSelector * b = new KviBoolSelector(...)
//              ((KviSelectorInterface *)b)->commit();
//           Mmmmmh.... the assembler generated by gcc
//           uses two different vtable offsets in the two cases
//           why ?
//

class KVIRC_API KviSelectorInterface
{
public:
	KviSelectorInterface(){};
	virtual ~KviSelectorInterface(){};
public:
	virtual void commit(){};
};

class KVIRC_API KviBoolSelector : public KviStyledCheckBox, public KviSelectorInterface
{
	Q_OBJECT
  
public:
	KviBoolSelector(TQWidget * par,const TQString & txt,bool *pOption,bool bEnabled);
	~KviBoolSelector(){};
private:
	bool * m_pOption;
public:
	virtual void commit();
public slots:
	void setNotEnabled(bool bNotEnabled);
};

class KVIRC_API KviStringSelector : public KviTalHBox, public KviSelectorInterface
{
	Q_OBJECT
  
public:
	KviStringSelector(TQWidget * par,const TQString & txt,TQString * pOption,bool bEnabled);
	~KviStringSelector();
protected:
	TQLabel    * m_pLabel;
	TQLineEdit * m_pLineEdit;
	TQString    * m_pOption;
public:
	void setValidator(TQValidator * v){ m_pLineEdit->setValidator(v); };
	void setMinimumLabelWidth(unsigned int uWidth){ m_pLabel->setMinimumWidth(uWidth); };
	virtual void commit();
	virtual void setEnabled(bool bEnabled);
	void setText(const TQString& text);
};


class KVIRC_API KviPasswordSelector : public KviStringSelector
{
	Q_OBJECT
  
public:
	KviPasswordSelector(TQWidget * par,const TQString & txt,TQString * pOption,bool bEnabled);
	~KviPasswordSelector(){};
};

class KVIRC_API KviPixmapPreview : public KviTalScrollView
{
	Q_OBJECT
  
public:
	KviPixmapPreview(TQWidget * par);
	~KviPixmapPreview();
protected:
	KviPixmap * m_pPixmap;
public:
	void setPixmap(KviPixmap * pix);
protected:
	virtual void drawContents(TQPainter * p, int clipx, int clipy, int clipw, int cliph);

};

class KVIRC_API KviPixmapSelector : public TQWidget, public KviSelectorInterface
{
	Q_OBJECT
  
public:
	KviPixmapSelector(TQWidget * par,const TQString & txt,KviPixmap * pOption,bool bEnabled);
	~KviPixmapSelector();
private:
	KviStyledCheckBox        * m_pCheckBox;
	TQLabel           * m_pFileNameLabel;
	KviPixmapPreview * m_pPreview;
	TQPushButton      * m_pChooseButton;
	KviPixmap        * m_pOption;
	KviPixmap          m_localPixmap;
public:
	void setImagePath(const char * path);
	virtual void commit();
	virtual void setEnabled(bool bEnabled);
protected slots:
	void checkBoxToggled(bool bEnabled);
	void choosePixmap();
};

class KVIRC_API KviUIntSelector : public KviTalHBox, public KviSelectorInterface
{
	Q_OBJECT
  
public:
	KviUIntSelector(TQWidget * par,const TQString & txt,unsigned int *pOption,
		unsigned int uLowBound,unsigned int uHighBound,unsigned int uDefault,bool bEnabled,bool bShortInt = false);
	~KviUIntSelector(){};
private:
	TQLabel    * m_pLabel;
	TQSpinBox  * m_pSpinBox;
	unsigned int * m_pOption;
	unsigned int m_uLowBound;
	unsigned int m_uHighBound;
	unsigned int m_uDefault;
	bool         m_bIsShortInt;
public:
	virtual void setPrefix(const TQString & txt);
	virtual void setSuffix(const TQString & txt);
	virtual void commit();
	virtual void setEnabled(bool bEnabled);
};


class KVIRC_API KviFileSelector : public KviTalHBox, public KviSelectorInterface
{
	Q_OBJECT
  
public:
	KviFileSelector(TQWidget * par,const TQString & txt,TQString * pOption,bool bEnabled,unsigned int uFlags = 0,const TQString &szFilter = TQString());
	~KviFileSelector(){};
public:
	enum Flags {
		ChooseSaveFileName = 1,
		DontConfirmOverwrite = 2
	};
protected:
	TQLabel      * m_pLabel;
	TQLineEdit   * m_pLineEdit;
	TQPushButton * m_pButton;
	TQString     * m_pOption;
	unsigned int  m_uFlags;
	TQString       m_szFilter;
public:
	virtual void commit();
	virtual void setEnabled(bool bEnabled);
	void setSelection(const TQString &szSelection);
signals:
	void selectionChanged(const TQString &szNewValue);
private slots:
	void browseClicked();
protected:
	virtual void select();
};

class KVIRC_API KviDirectorySelector : public KviFileSelector
{
	Q_OBJECT
  
public:
	KviDirectorySelector(TQWidget * par,const TQString & txt,TQString * pOption,bool bEnabled);
	~KviDirectorySelector(){};
protected:
	virtual void select();
};


class KVIRC_API KviColorSelector : public KviTalHBox, public KviSelectorInterface
{
	Q_OBJECT
  
public:
	KviColorSelector(TQWidget * par,const TQString & txt,TQColor * pOption,bool bEnabled);
	~KviColorSelector(){};
private:
	TQLabel      * m_pLabel;
	TQColor      * m_pOption;
	TQColor        m_memColor;
	TQPushButton * m_pButton;
public:
	virtual void commit();
	virtual void setEnabled(bool bEnabled);
	TQColor getColor(){ return m_memColor; };
	void forceColor(TQColor clr);
private:
	void setButtonPalette(TQColor * pOption);
private slots:
	void changeClicked();
};

class KVIRC_API KviFontSelector : public KviTalHBox, public KviSelectorInterface
{
	Q_OBJECT
  
public:
	KviFontSelector(TQWidget * par,const TQString & txt,TQFont * pOption,bool bEnabled);
	~KviFontSelector(){};
private:
	TQLabel      * m_pLabel;
	TQFont       * m_pOption;
	TQPushButton * m_pButton;
public:
	virtual void commit();
	virtual void setEnabled(bool bEnabled);
private:
	void setButtonFont(TQFont * pOption);
private slots:
	void changeClicked();
};

class KVIRC_API KviStringListSelector : public KviTalVBox, public KviSelectorInterface
{
	Q_OBJECT
  
public:
	KviStringListSelector(TQWidget * par,const TQString & txt,TQStringList * pOption,bool bEnabled);
	~KviStringListSelector();
private:
	TQLabel      * m_pLabel;
	KviTalListBox    * m_pListBox;
	TQLineEdit   * m_pLineEdit;
	TQPushButton * m_pAddButton;
	TQPushButton * m_pRemoveButton;
	TQStringList * m_pOption;
public:
	virtual void commit();
	virtual void setEnabled(bool bEnabled);
private slots:
	void textChanged(const TQString &str);
	void selectionChanged();
	void addClicked();
	void removeClicked();
};

class KviTalPopupMenu;

class KVIRC_API KviMircTextColorSelector : public KviTalHBox, public KviSelectorInterface
{
	Q_OBJECT
  
public:
	KviMircTextColorSelector(TQWidget * par,const TQString &txt,unsigned int * uFore,unsigned int * uBack,bool bEnabled);
	~KviMircTextColorSelector();
private:
	TQLabel *m_pLabel;
	TQPushButton * m_pButton;
	unsigned int * m_pUFore;
	unsigned int * m_pUBack;
	unsigned int m_uFore;
	unsigned int m_uBack;
	KviTalPopupMenu * m_pContextPopup;
	KviTalPopupMenu * m_pForePopup;
	KviTalPopupMenu * m_pBackPopup;
public:
	virtual void commit();
	virtual void setEnabled(bool bEnabled);
protected slots:
	void buttonClicked();
	void foreSelected(int);
	void backSelected(int);
protected:
	void setButtonPalette();
};


class KVIRC_API KviSoundSelector : public KviFileSelector
{
	Q_OBJECT
  
public:
	KviSoundSelector(TQWidget * par,const TQString & txt,TQString * pOption,bool bEnabled);
	~KviSoundSelector();
protected:
	TQPushButton	*m_pPlayButton;
private slots:
	void playSound();
public:
	virtual void setEnabled(bool bEnabled);
};

class KVIRC_API KviChanListViewItem : public KviTalListViewItem
{
private:
	TQString m_szPass;
public:
	KviChanListViewItem(KviTalListView* pList,TQString szChan,TQString szPass);
	~KviChanListViewItem() {};
	
	const TQString& pass() { return m_szPass; }
};

class KVIRC_API KviCahnnelListSelector : public KviTalVBox, public KviSelectorInterface
{
	Q_OBJECT
  
public:
	KviCahnnelListSelector(TQWidget * par,const TQString & txt,TQStringList * pOption,bool bEnabled);
	~KviCahnnelListSelector();
private:
	TQLabel       * m_pLabel;
	KviTalListView    * m_pListView;
	TQLineEdit    * m_pChanLineEdit;
	TQLineEdit    * m_pPassLineEdit;
	TQPushButton  * m_pAddButton;
	TQPushButton  * m_pRemoveButton;
	TQStringList  * m_pOption;
public:
	virtual void commit();
	virtual void setEnabled(bool bEnabled);
private slots:
	void textChanged(const TQString &str);
	void selectionChanged();
	void addClicked();
	void removeClicked();
};



#endif //!_KVI_SELECTORS_H_