summaryrefslogtreecommitdiffstats
path: root/src/modules/notifier/notifierwindow.h
blob: dfc9d6de189e0f64e79286fa34f4d4dc375cb24c (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
#ifndef _NOTIFIERWINDOW_H_
#define _NOTIFIERWINDOW_H_
//==================================================================================
//
//   File : notifierwindow.h
//   Creation date : Tue Jul 6 2004 20:25:12 CEST by Szymon Stefanek
//
//   This file is part of the KVirc irc client distribution
//   Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it >
//
//   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_settings.h"

#include <tqbitmap.h>
#include <tqcolor.h>
#include <tqcursor.h>
#include <tqdatetime.h> 
#include <tqfont.h>
#include <tqimage.h>
#include <tqlineedit.h>
#include <tqpixmap.h>
#include <tqrect.h>
#include <tqtimer.h>
#include <tqwidget.h>

#include "kvi_qstring.h"
#include "kvi_pointerlist.h"
#include "kvi_time.h"

#include "notifiersettings.h"

class KviWindow;
class KviNotifierMessage;

class KviNotifierWindowBody;
class KviNotifierWindowBorder;
class KviNotifierWindowProgressBar;
class KviNotifierWindowTabs;

class TQPainter;
class TQPopupMenu;

extern kvi_time_t g_tNotifierDisabledUntil;

class KviNotifierWindow : public TQWidget
{
	Q_OBJECT
  TQ_OBJECT
public:
	KviNotifierWindow();
	~KviNotifierWindow();
protected:
	TQTimer * m_pShowHideTimer;
	TQTimer * m_pProgressTimer;
	TQTimer * m_pBlinkTimer;
	TQTimer * m_pAutoHideTimer;
	State   m_eState;
	bool    m_bBlinkOn;
	double  m_dOpacity;
	TQImage  m_imgDesktop;            // the desktop screenshot
	TQPixmap m_pixBackground;         // our background image
	TQPixmap m_pixBackgroundHighlighted;
	TQPixmap m_pixForeground;         // we paint the stuff HERE
	
	// Notifier graphic tqlayout
	TQPixmap m_pixBckgrnd;

	TQImage  m_imgBuffer;             // here we merge the two images

	bool    m_bCloseDown;
	bool    m_bPrevDown;
	bool    m_bNextDown;
	bool    m_bWriteDown;
	bool m_bCrashShowWorkAround;

	bool	m_bKeyShiftPressed;

	TQFont * m_pDefaultFont;
	TQFont * m_pTitleFont;
	
	TQRect	m_wndRect;

	TQColor  m_clrCurText;
	TQColor  m_clrOldText[NUM_OLD_COLORS];
	TQColor  m_clrHistoricText;
	TQColor  m_clrTitle;

	KviNotifierMessage * m_pCurrentMessage;
	TQLineEdit * m_pLineEdit;

	bool	m_bDragging;
	bool	m_bLeftButtonIsPressed;
	bool	m_bDiagonalResizing;
	bool	m_bResizing;
	
	int		m_whereResizing;
	
	TQPoint       m_pntDrag;
	TQPoint       m_pntPos;
	TQPoint		 m_pntClick;
	int          m_iInputHeight;
	int          m_iBlinkTimeout;
	int          m_iBlinkCount;
	TQPopupMenu * m_pContextPopup;
	TQPopupMenu * m_pDisablePopup;
	KviWindow * m_pWindowToRaise;
	kvi_time_t  m_tAutoHideAt;
	kvi_time_t  m_tStartedAt;
	TQTime	    m_qtStartedAt;
	bool		m_bDisableHideOnMainWindowGotAttention;
	//bool		m_bForceShowing;
	
	TQCursor m_cursor;
	
	KviNotifierWindowTabs 		* m_pWndTabs;
	KviNotifierWindowProgressBar	* m_pProgressBar;
	KviNotifierWindowBody 		* m_pWndBody;
	KviNotifierWindowBorder 	* m_pWndBorder;
public:
	void doShow(bool bDoAnimate);
	void doHide(bool bDoAnimate);
	const TQFont & defaultFont(){ return *m_pDefaultFont; };
	int textWidth();
	void addMessage(KviWindow * pWnd,const TQString &szImageId,const TQString &szText,unsigned int uMessageTime);
	State state() { return m_eState; };
	void setDisableHideOnMainWindowGotAttention(bool b){ m_bDisableHideOnMainWindowGotAttention = b; };
	int countTabs();
	void showLineEdit(bool bShow);
protected:
	virtual void showEvent(TQShowEvent *e);
	virtual void hideEvent(TQHideEvent * e);
	virtual void paintEvent(TQPaintEvent * e);
	virtual void mousePressEvent(TQMouseEvent * e);
	virtual void mouseReleaseEvent(TQMouseEvent * e);
	virtual void mouseMoveEvent(TQMouseEvent * e);
	virtual void leaveEvent(TQEvent * e);
	virtual void enterEvent(TQEvent * e);
	virtual void mouseDoubleClickEvent(TQMouseEvent * e);
	virtual void wheelEvent(TQWheelEvent * e);
	virtual bool eventFilter(TQObject * pEdit,TQEvent * e);
	virtual void keyPressEvent ( TQKeyEvent * e );
	virtual void keyReleaseEvent ( TQKeyEvent * e );
protected slots:
	void blink();
	void heartbeat();
	void returnPressed();
	void reloadImages();
	void fillContextPopup();
	void hideNow();
	void disableFor1Minute();
	void disableFor5Minutes();
	void disableFor15Minutes();
	void disableFor30Minutes();
	void disableFor60Minutes();
	void disableUntilKVIrcRestarted();
	void disablePermanently();
	void delayedRaiseSlot();
	void autoHide();
	void progressUpdate();
private:
	void contextPopup(const TQPoint &pos);
	void startBlinking();
	void markAllMessagesAsHistoric();
	void computeRect();
	void stopShowHideTimer();
	void stopBlinkTimer();
	void stopAutoHideTimer();
	void startAutoHideTimer();
	void delayedRaise(KviWindow * pWnd);
	void prevButtonClicked();
	void nextButtonClicked();
	bool shouldHideIfMainWindowGotAttention();
	void setCursor(int);
	void resize(TQPoint p, bool = true);
	void redrawWindow();
	void redrawText();
	bool checkResizing(TQPoint);
};

#endif //_NOTIFIERWINDOW_H_