KoContextCelp.h
1/* This file is part of the KDE project
2 Copyright (C) 2002, Benoit Vautrin <benoit.vautrin@free.fr>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef __KOCONTEXTHELPACTION_H__
21#define __KOCONTEXTHELPACTION_H__
22
23#include <tqwidget.h>
24#include <tqbitmap.h>
25#include <tqdockwindow.h>
26
27#include <tdeaction.h>
28#include <koffice_export.h>
29class TQPixmap;
30class TQLabel;
31class TQSimpleRichText;
32
33class KoVerticalLabel : public TQWidget
34{
35 TQ_OBJECT
36
37
38 public:
39 KoVerticalLabel( TQWidget* parent = 0, const char* name = 0 );
40 ~KoVerticalLabel();
41
42 public slots:
43 void setText( const TQString& text );
44
45 protected:
46 void paintEvent( TQPaintEvent* );
47
48 private:
49 TQString m_text;
50}; // KoVerticalLabel
51
52class KoHelpNavButton : public TQWidget
53{
54 TQ_OBJECT
55
56
57 public:
58 enum NavDirection {
59 Up,
60 Down
61 };
62
63 KoHelpNavButton( NavDirection d, TQWidget* parent );
64
65 signals:
66 void pressed();
67 void released();
68
69 protected:
70 void paintEvent( TQPaintEvent* );
71 void enterEvent( TQEvent* );
72 void leaveEvent( TQEvent* );
73
74 private:
75 TQBitmap m_bitmap;
76 bool m_pressed;
77}; // KoHelpNavButton
78
79class KoTinyButton : public TQWidget
80{
81 TQ_OBJECT
82
83
84 public:
85 enum Action {
86 Close,
87 Sticky
88 };
89
90 KoTinyButton( Action a, TQWidget* parent );
91
92 signals:
93 void clicked();
94 void toggled( bool );
95
96 protected:
97 void paintEvent( TQPaintEvent* );
98 void mousePressEvent( TQMouseEvent* );
99 void mouseReleaseEvent( TQMouseEvent* );
100
101 private:
102 TQBitmap m_bitmap;
103 bool m_pressed;
104 Action m_action;
105 bool m_toggled;
106}; // KoTinyButton
107
108class KoHelpView : public TQWidget
109{
110 TQ_OBJECT
111
112
113 public:
114 KoHelpView( TQWidget* parent );
115 ~KoHelpView();
116
117 void setText( const TQString& text );
118 bool eventFilter( TQObject* watched, TQEvent* e );
119
120 signals:
121 void linkClicked( const TQString& link );
122
123 protected:
124 virtual void mousePressEvent( TQMouseEvent* e );
125 virtual void mouseReleaseEvent( TQMouseEvent* e );
126 virtual void mouseMoveEvent( TQMouseEvent* e );
127 virtual void paintEvent( TQPaintEvent* e );
128
129 private:
130 TQSimpleRichText* currentText;
131 TQString currentAnchor;
132}; // KoHelpView
133
134class KoHelpWidget : public TQWidget
135{
136 TQ_OBJECT
137
138
139 public:
140 KoHelpWidget( TQString help, TQWidget* parent );
141
142 void setText( TQString text );
143 void timerEvent( TQTimerEvent* );
144 void updateButtons();
145
146 signals:
147 void linkClicked( const TQString& link );
148
149 public slots:
150 void scrollUp();
151 void scrollDown();
152 void startScrollingUp();
153 void startScrollingDown();
154 void stopScrolling();
155
156 protected:
157 void resizeEvent( TQResizeEvent* );
158
159 private:
160 int m_ypos;
161 bool m_scrollDown;
162 TQWidget* m_helpViewport;
163 KoHelpView* m_helpView;
164 KoHelpNavButton* m_upButton;
165 KoHelpNavButton* m_downButton;
166}; // KoHelpWidget
167
171class KoContextHelpPopup : public TQWidget
172{
173 TQ_OBJECT
174
175
176 public:
177 KoContextHelpPopup( TQWidget* parent = 0 );
179
180 public slots:
181 void setContextHelp( const TQString& title, const TQString& text, const TQPixmap* icon = 0 );
182 void setSticky( bool sticky ) { m_isSticky = sticky; }
183
184 protected:
185 virtual void mousePressEvent( TQMouseEvent* );
186 virtual void mouseMoveEvent( TQMouseEvent* );
187 virtual void resizeEvent( TQResizeEvent* );
188 virtual void paintEvent( TQPaintEvent* );
189 virtual void windowActivationChange( bool );
190 virtual void keyPressEvent ( TQKeyEvent* );
191 virtual void keyReleaseEvent ( TQKeyEvent* );
192
193 signals:
194 void wantsToBeClosed();
198 void linkClicked( const TQString& link );
199
200 private:
201 KoHelpWidget* m_helpViewer;
202 KoVerticalLabel* m_helpTitle;
203 TQLabel* m_helpIcon;
204 KoTinyButton* m_close;
205 KoTinyButton* m_sticky;
206
207 TQPoint m_mousePos;
208 bool m_isSticky;
209}; // KoContextHelpPopup
210
217class KOFFICEUI_EXPORT KoContextHelpAction : public TDEToggleAction
218{
219 TQ_OBJECT
220
221
222 public:
223 KoContextHelpAction( TDEActionCollection* parentCollection, TQWidget* parent = 0 );
224 virtual ~KoContextHelpAction();
225
226 public slots:
227 void updateHelp( const TQString& title, const TQString& text, const TQPixmap* icon = 0 );
228 void closePopup();
229
230 signals:
234 void linkClicked( const TQString& link );
235
236 private:
237 KoContextHelpPopup* m_popup;
238}; // KoContextHelpAction
239
240class KoContextHelpWidget : public TQWidget
241{
242 TQ_OBJECT
243
244
245 public:
246 KoContextHelpWidget( TQWidget* parent = 0, const char* name = 0 );
247 ~KoContextHelpWidget();
248
249 public slots:
250 void setContextHelp( const TQString& title, const TQString& text, const TQPixmap* icon = 0 );
251
252 signals:
256 void linkClicked( const TQString& link );
257
258 private:
259 KoHelpWidget* m_helpViewer;
260 KoVerticalLabel* m_helpTitle;
261 TQLabel* m_helpIcon;
262}; // KoContextHelpWidget
263
264class KoContextHelpDocker : public TQDockWindow
265{
266 TQ_OBJECT
267
268
269 public:
270 KoContextHelpDocker( TQWidget* parent = 0, const char* name = 0 );
271 ~KoContextHelpDocker();
272
273 public slots:
274 void setContextHelp( const TQString& title, const TQString& text, const TQPixmap* icon = 0 );
275
276 signals:
280 void linkClicked( const TQString& link );
281
282 private:
283 KoHelpWidget* m_helpViewer;
284 KoVerticalLabel* m_helpTitle;
285 TQLabel* m_helpIcon;
286}; // KoContextHelpDocker
287
288#endif /* __KOCONTEXTHELPACTION_H__ */
KoContextHelpAction provides a easy to use context help system.
void linkClicked(const TQString &link)
Connect to this signal to receive the href value of the links clicked.
KoContextHelpPopup is the popup displayed by ContextHelpAction.
void linkClicked(const TQString &link)
Connect to this signal to receive the href value of the links clicked.