summaryrefslogtreecommitdiffstats
path: root/knewsticker/knewsticker.h
blob: 1991b9ef3217aa72b626c98cb9afa2a520e32e41 (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
/*
 * knewsticker.h
 *
 * Copyright (c) 2000, 2001 Frerich Raabe <raabe@kde.org>
 *
 * 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. For licensing and distribution details, check the
 * accompanying file 'COPYING'.
 */
#ifndef KNEWSTICKER_H
#define KNEWSTICKER_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <dcopobject.h>

#include <tqtoolbutton.h>
#include <kpanelapplet.h>
#include <tdepopupmenu.h>

#include "configiface.h"
#include "configaccess.h"
#include "newsengine.h"

class TDEInstance;
class NewsSource;
class KArrowButton;
class NewsIconMgr;
class NewsScroller;
class KNewsTickerMenu;
class TDEAboutData;
class TQTimer;

class KNewsTicker : public KPanelApplet, virtual public ConfigIface,
		virtual public DCOPObject
{
	TQ_OBJECT
//	
	K_DCOP

	friend class KNewsTickerMenu;

	public:
		KNewsTicker(const TQString &, Type, int, TQWidget * = 0, const char * = 0);
		virtual ~KNewsTicker();

		virtual int widthForHeight(int) const;
		virtual int heightForWidth(int) const;

	k_dcop:
		virtual void reparseConfig();
		virtual void updateNews() { slotUpdateNews(); }
		virtual uint interval() const { return m_cfg->interval(); }
		virtual uint scrollingSpeed() const { return m_cfg->scrollingSpeed(); }
		virtual uint mouseWheelSpeed() const { return m_cfg->mouseWheelSpeed(); }
		virtual uint scrollingDirection() const { return m_cfg->scrollingDirection(); }
		virtual bool customNames() const { return m_cfg->customNames(); }
		virtual bool scrollMostRecentOnly() const { return m_cfg->scrollMostRecentOnly(); }
		virtual bool offlineMode() const { return m_cfg->offlineMode(); }
		virtual bool underlineHighlighted() const { return m_cfg->underlineHighlighted(); }
		virtual bool showIcons() const { return m_cfg->showIcons(); }
		virtual bool slowedScrolling() const { return m_cfg->slowedScrolling(); }
		virtual TQColor foregroundColor() const { return m_cfg->foregroundColor(); }
		virtual TQColor backgroundColor() const { return m_cfg->backgroundColor(); }
		virtual TQColor highlightedColor() const { return m_cfg->highlightedColor(); }
		virtual TQStringList newsSources() const { return m_cfg->newsSources(); }
		virtual void setInterval(const uint);
		virtual void setScrollingSpeed(const uint);
		virtual void setMouseWheelSpeed(const uint);
		virtual void setScrollingDirection(const uint);
		virtual void setCustomNames(bool);
		virtual void setScrollMostRecentOnly(bool);
		virtual void setOfflineMode(bool);
		virtual void setUnderlineHighlighted(bool);
		virtual void setShowIcons(bool);
		virtual void setSlowedScrolling(bool);
		virtual void setForegroundColor(const TQColor &);
		virtual void setBackgroundColor(const TQColor &);
		virtual void setHighlightedColor(const TQColor &);
		virtual void setNewsSources(const TQStringList &) {}

	public slots:
		void slotUpdateNews();
		void slotOpenContextMenu();

	protected:
		virtual void preferences();
		virtual void about();
		virtual void help();
		virtual void reportBug();
		virtual void mousePressEvent(TQMouseEvent *);
		virtual void positionChange(Position);

	protected slots:
		void slotArrowButtonPressed();
		void slotNewsSourceUpdated(const NewsSourceBase::Ptr &, bool = false);
		void slotNewsSourceFailed(const NewsSourceBase::Ptr &);
		void slotContextMenuAboutToHide();
		void slotNotifyOfFailures();

	private:
		void setupArrowButton();

		TDEInstance            *m_instance;
		DCOPClient           *m_dcopClient;
		ConfigAccess         *m_cfg;
		KArrowButton         *m_arrowButton;
		TQTimer               *m_newsTimer;
		TQTimer               *m_updateTimer;
		NewsIconMgr          *m_newsIconMgr;
		NewsScroller         *m_scroller;
		TDEAboutData           *m_aboutData;
		KNewsTickerMenu      *m_contextMenu;
		bool                 m_newNews;
		NewsSourceBase::List m_newsSources;
		TQStringList	         m_failedNewsUpdates;
		TQStringList          m_pendingNewsUpdates;
};

class KNewsTickerMenu : public TDEPopupMenu
{
	TQ_OBJECT
//	

	public:
		KNewsTickerMenu(KNewsTicker *, const char * = 0);
		void setFullMenu(bool full) { m_fullMenu = full; populateMenu(); }

	protected slots:
		void populateMenu();

	private slots:
		void slotShowHelp();
		void slotShowAbout();
		void slotConfigure();
		void slotToggleOfflineMode();
		void slotCheckNews(int idx);
		void slotOpenArticle(int idx);

	private:
		KNewsTicker *m_parent;
		bool m_fullMenu;
};

#endif // KNEWSTICKER_H