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
382
383
384
385
386
387
388
389
390
391
392
393
394
|
#ifndef _KVI_WINDOW_H_
#define _KVI_WINDOW_H_
//=============================================================================
//
// File : kvi_window.h
// Creation date : Tue Jul 6 1999 14:52:20 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_string.h"
#include "kvi_qstring.h"
#include "kvi_qcstring.h"
#include "kvi_settings.h"
#ifdef COMPILE_ON_WINDOWS
// The brain-damaged MSVC compiler can't instantiate TQPtrList templates without a destructor definition
#include "kvi_mdichild.h"
#else
class KviMdiChild;
#endif
#include <tqframe.h>
class KviFrame;
class KviTaskBarItem;
class KviConfig;
class KviIrcView;
class KviInput;
class KviConsole;
class KviIrcContext;
class KviIrcConnection;
class KviWindowToolPageButton;
class KviTalPopupMenu;
class TQPixmap;
class TQSplitter;
class KviTalHBox;
class TQToolButton;
class TQTextCodec;
class KviTalWidgetStack;
#include "kvi_tal_hbox.h"
#include "kvi_tal_widgetstack.h"
#include "kvi_accel.h"
#ifdef COMPILE_CRYPT_SUPPORT
class KviCryptController;
class KviCryptSessionInfo;
#endif
#include <tqwidget.h>
//
// Window types
//
// There are KVI_WINDOW_NUM_TYPES predefined
// window types: these are used by the KVIrc core and distributed modules
// If you add a new def, increase KVI_WINDOW_NUM_TYPES
//
#define KVI_WINDOW_TYPE_CONSOLE 0
#define KVI_WINDOW_TYPE_CHANNEL 1
#define KVI_WINDOW_TYPE_QUERY 2
#define KVI_WINDOW_TYPE_HELP 3
#define KVI_WINDOW_TYPE_TERM 4
#define KVI_WINDOW_TYPE_EDITOR 5
#define KVI_WINDOW_TYPE_DCCCHAT 6
#define KVI_WINDOW_TYPE_DCCSEND 7
#define KVI_WINDOW_TYPE_SOCKETSPY 8
#define KVI_WINDOW_TYPE_LINKS 9
#define KVI_WINDOW_TYPE_TOOL 10
#define KVI_WINDOW_TYPE_GNUTELLA 11
#define KVI_WINDOW_TYPE_DIRBROWSER 12
#define KVI_WINDOW_TYPE_DCCCANVAS 13
#define KVI_WINDOW_TYPE_DCCVOICE 14
#define KVI_WINDOW_TYPE_LIST 15
#define KVI_WINDOW_TYPE_OFFER 16
#define KVI_WINDOW_TYPE_LOGVIEW 17
#define KVI_WINDOW_TYPE_DEADCHANNEL 18
#define KVI_WINDOW_TYPE_DEADQUERY 19
#define KVI_WINDOW_TYPE_SCRIPTEDITOR 20
#define KVI_WINDOW_TYPE_SCRIPTOBJECT 21
#define KVI_WINDOW_TYPE_USERWINDOW 22
#define KVI_WINDOW_TYPE_DEBUG 23
#define KVI_WINDOW_NUM_TYPES 24
#define KVI_WINDOW_TYPE_USER 10000
#define KVI_ACTIVITY_NONE 0
#define KVI_ACTIVITY_VERYLOW 1
#define KVI_ACTIVITY_LOW 2
#define KVI_ACTIVITY_MEDIUM 3
#define KVI_ACTIVITY_HIGH 4
#define KVI_ACTIVITY_VERYHIGH 5
#define KVI_ACTIVITY_ICE 0
#define KVI_ACTIVITY_VERYCOLD 1
#define KVI_ACTIVITY_COLD 2
#define KVI_ACTIVITY_UNDEFINED 3
#define KVI_ACTIVITY_HOT 4
#define KVI_ACTIVITY_VERYHOT 5
#define KVI_ACTIVITY_FIRE 6
#ifdef COMPILE_USE_QT4
class TQPushButton;
#define BUTTON_CLASS TQPushButton
#else
#define BUTTON_CLASS TQToolButton
#endif
class KVIRC_API KviWindow : public TQWidget
{
friend class KviInput;
friend class KviFrame;
friend class KviTaskBarItem;
friend class KviTaskBarButton;
friend class KviTreeTaskBarItem;
friend class KviTreeTaskBar;
TQ_PROPERTY(int KviProperty_ChildFocusOwner READ type)
Q_OBJECT
public:
KviWindow(int type,KviFrame * lpFrm,const TQString &name,KviConsole * pConsole = 0);
virtual ~KviWindow();
protected: // almost private: don't touch :D
TQString m_szName; // the current window name (usually also the target)
KviFrame * m_pFrm;
KviConsole * m_pConsole;
KviIrcContext * m_pContext;
int m_iType;
KviTaskBarItem * m_pTaskBarItem;
TQWidget * m_pFocusHandler;
TQString m_szPlainTextCaption;
TQString m_szHtmlActiveCaption;
TQString m_szHtmlInactiveCaption;
KviIrcView * m_pIrcView;
KviInput * m_pInput;
TQSplitter * m_pSplitter;
KviTalHBox * m_pButtonBox;
unsigned long int m_uId;
TQString m_szTextEncoding;
#ifdef COMPILE_CRYPT_SUPPORT
KviWindowToolPageButton * m_pCryptControllerButton;
KviCryptController * m_pCryptController;
KviCryptSessionInfo * m_pCryptSessionInfo;
#endif
BUTTON_CLASS * m_pTextEncodingButton;
TQToolButton * m_pHideToolsButton;
TQWidget * m_pLastFocusedChild;
KviAccel * m_pAccel;
static const char * m_typeTable[KVI_WINDOW_NUM_TYPES + 1];
// text encoding and decoding
//unsigned int m_uTextEncoding;
TQTextCodec * m_pTextCodec;
// KviToolWindowsContainer * m_pEditorsContainer;
public:
// The global ID of this window: unique in the application
TQString id(){ return TQString("%1").arg(m_uId); };
unsigned long int numericId(){ return m_uId; };
public:
// THIS is the function that should be used
const TQString & windowName(){ return m_szName; };
void setWindowName(const TQString &szName);
// force QT to set our UNICODE name too... FIXME: this should be removed later...
virtual void setName(const char * szName);
// Window type management
int type() const { return m_iType; };
// This returns a descriptive name of the window type
// if the window is an user window, the typeString returned
// by THIS implementation is "unknown"
virtual const char * typeString();
TQTextCodec * textCodec(){ return m_pTextCodec ? m_pTextCodec : defaultTextCodec(); };
void forceTextCodec(TQTextCodec * c);
// The frame that this window belongs to
// It is always non-null and never changes
KviFrame * frame() const { return m_pFrm; };
// The KviIrcView of this window: may be NULL if the window has no KviIrcView (and thus supports no direct output)
KviIrcView * view() const { return m_pIrcView; };
// The mdiParent widget: may be nulll if the window is undocked
KviMdiChild * mdiParent(){ return (KviMdiChild *)parent(); };
// The console that this window belongs to: may be null for windows that aren't bound to irc contexts
KviConsole * console(){ return m_pConsole; };
// same as above
KviIrcContext * context(){ return m_pContext; };
// the current IRC connection (if any)
KviIrcConnection * connection();
// The splitter of this window: it *shouldn't* be null... but ... well.. who knows ? :D ...better check it
TQSplitter * splitter(){ return m_pSplitter; };
// The window has ALWAYS a taskbar item
KviTaskBarItem * taskBarItem(){ return m_pTaskBarItem; };
// The window *might* have a button container
virtual TQFrame * buttonContainer(){ return (TQFrame*)m_pButtonBox; };
virtual void toggleButtonContainer();
// The window *might* have an output proxy: if it has no view() for example
virtual KviWindow * outputProxy();
// The window input widget
KviInput * input(){ return m_pInput; };
// The target of this window: empty when it makes no sense :D
virtual const TQString & target(){ return KviTQString::empty; };
// The local nickname bound to this window: might be empty when a local nickname makes no sense
virtual const TQString & localNick(){ return KviTQString::empty; };
#ifdef COMPILE_CRYPT_SUPPORT
KviCryptSessionInfo * cryptSessionInfo(){ return m_pCryptSessionInfo; };
void setCryptSessionInfo(KviCryptSessionInfo * i);
#endif
virtual bool activityMeter(unsigned int * puActivityValue,unsigned int * puActivityTemperature);
void unhighlight();
virtual void getTaskBarTipText(TQString &buffer);
// This is meaningful only if view() is non NULL
const TQString & lastLineOfText();
const TQString & lastMessageText();
const TQString &textEncoding(){ return m_szTextEncoding; };
// returns true if the encoding could be succesfully set
bool setTextEncoding(const TQString &szTextEncoding);
// this must return a default text codec suitable for this window
virtual TQTextCodec * defaultTextCodec();
// encode the text from szSource by using m_uTextEncoding
KviTQCString encodeText(const TQString &szText);
TQString decodeText(const char * szText);
void contextPopup();
// Raises the window (after a light delay to prevent focus pingpongs)
void delayedAutoRaise();
// Window state: might work :D
bool isMinimized();
bool isMaximized();
// Retrieves the default log file name: this is pre-build
void getDefaultLogFileName(TQString &buffer);
// Well...the external geometry :)
TQRect externalGeometry();
void delayedClose(); // close that jumps out of the current event loop
// Interesting overridables:
virtual void fillContextPopup(KviTalPopupMenu * p);
virtual void getConfigGroupName(TQString &buf);
// virtual void getBaseLogFileName(KviStr &buffer);
virtual void getBaseLogFileName(TQString &buffer);
virtual void updateCaption();
virtual void applyOptions();
virtual void updateIcon();
virtual void ownMessage(const TQString &text){};
virtual void ownAction(const TQString &text){};
virtual const TQString & plainTextCaption(){ return m_szPlainTextCaption; };
virtual const TQString & htmlActiveCaption(){ return m_szHtmlActiveCaption; };
virtual const TQString & htmlInactiveCaption(){ return m_szHtmlInactiveCaption; };
virtual void setFocus();
void internalOutput(KviIrcView * pView,int msg_type,const kvi_wchar_t * text,int iFlags=0);
// You *might* want to override these too.. but better don't touch them :D
virtual void output(int msg_type,const char * format,...);
virtual void outputNoFmt(int msg_type,const char * text,int iFlags=0);
virtual void output(int msg_type,const kvi_wchar_t * format,...);
virtual void outputNoFmt(int msg_type,const kvi_wchar_t * text,int iFlags=0){ internalOutput(m_pIrcView,msg_type,text,iFlags); };
virtual void output(int msg_type,const TQString &szFmt,...);
virtual void outputNoFmt(int msg_type,const TQString &szText,int iFlags=0); // <-- these are KviIrcView::AppendTextFlags
// Just helpers.. FIXME: might be redesigned in some other way
void updateBackgrounds(TQObject * obj = 0);
void demandAttention();
bool hasAttention();
// This should die, probably
void listWindowTypes();
public slots:
void dock();
void undock();
void autoRaise();
void maximize();
void minimize();
void restore();
void reloadImages();
protected slots:
void savePropertiesAsDefault();
void toggleCryptController(); // This has to be here even if the crypt support is enabled...moc does not support conditionals
void cryptControllerFinished(); // same as above
void cryptSessionInfoDestroyed(); // same as above
void textEncodingButtonClicked();
void systemPopupRequest(const TQPoint &pnt);
void systemTextEncodingPopupSmartActivated(int id);
void systemTextEncodingPopupSmartUtf8Activated(int id);
void systemTextEncodingPopupStandardActivated(int id);
void systemTextEncodingPopupDefault();
void childDestroyed();
signals:
void windowNameChanged();
protected:
// Loading and saving of properties
// Protected: only KviFrame can call these
virtual void saveProperties(KviConfig *cfg);
virtual void loadProperties(KviConfig *cfg);
// Creation and destruction events: overridden in windows that have script events bound to creation and destruction
virtual void triggerCreationEvents(){};
virtual void triggerDestructionEvents(){};
// Internal: do not touch :D (KviFrame)
virtual void createTaskBarItem();
virtual void destroyTaskBarItem();
// called by KviFrame
// either lost the active window status or the frame is no longer active (but we're still the active kvirc's subwindow)
virtual void lostUserFocus();
// Sets the progress for the taskbar item: if "progress" makes sense in your window , well , use this
void setProgress(int progress);
// call this in the constructor if your caption is fixed:
// it will set m_szPlainTextCaption to szCaption and it will
// automatically use it without the need of overriding fillCaptionBuffers
void setFixedCaption(const TQString &szCaption);
// this by default calls fillSingleColorCaptionBuffer(plainTextCaption());
virtual void fillCaptionBuffers();
// protected helper
void fillSingleColorCaptionBuffers(const TQString &szName);
// Virtual events that signal dock state change
virtual void youAreDocked();
virtual void youAreUndocked();
// Reimplement to show a special icon in the taskbar items and captions
virtual TQPixmap * myIconPtr();
// Sets the type of this window: be careful with this
void setType(int iType);
bool eventFilter(TQObject *o,TQEvent *e);
// Virtuals overridden to manage the internal layouts...
virtual void moveEvent(TQMoveEvent *e);
virtual void closeEvent(TQCloseEvent *e);
virtual void wheelEvent(TQWheelEvent *e);
virtual void childEvent(TQChildEvent *e);
virtual void focusInEvent(TQFocusEvent *e);
void childInserted(TQWidget * o);
void childRemoved(TQWidget * o);
void activateSelf();
// Internal helpers
void createCryptControllerButton(TQWidget * par);
void createTextEncodingButton(TQWidget * par);
void createSystemTextEncodingPopup();
BUTTON_CLASS * createToolButton(TQWidget * par,const char * nam,int pixon,int pixoff,const TQString & tooltip,bool bOn);
// This is called by KviInput: actually it links the widgetAdded
virtual void childrenTreeChanged(TQWidget * widgetAdded);
virtual bool focusNextPrevChild(bool bNext);
virtual void preprocessMessage(TQString & szMessage);
};
#ifndef _KVI_WINDOW_CPP_
// The active window:
// This is almost always non null
// The exception is the startup (when there are no windows at all)
// and the last phase of the destructor.
// You usually shouldn't care of checking this pointer for NULL unless
// you're running very early at startup or very late at shutdown
extern KVIRC_API KviWindow * g_pActiveWindow;
#endif
#endif //_KVI_WINDOW_H_
|