1
/* This file is part of the KDE project
2
Copyright (C) 2001 Christoph Cullmann (cullmann@kde.org)
3
Copyright (C) 2005 Dominik Haumann (dhdev@gmx.de) (documentation)
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
Boston, MA 02110-1301, USA.
21
#ifndef KDELIBS_KTEXTEDITOR_MARKINTERFACE_H
22
#define KDELIBS_KTEXTEDITOR_MARKINTERFACE_H
24
#include <ktexteditor/ktexteditor_export.h>
26
#include <QtCore/QHash>
27
#include <QtCore/QObject>
39
* \brief Mark class containing line and mark types.
41
* \section mark_intro Introduction
43
* The class Mark represents a mark in a Document. It contains the \e line
44
* and \e type. A line can have multiple marks, like a \e bookmark and a
45
* \e breakpoint, i.e. the \e type contains all marks combined with a logical
46
* \e OR (<tt>|</tt>). There are several predefined mark types, look into the
47
* MarkInterface for further details.
49
* \see KTextEditor::MarkInterface, KTextEditor::Document
54
/** The line that contains the mark. */
57
/** The mark types in the line, combined with logical OR. */
62
* \brief Mark extension interface for the Document.
64
* \ingroup kte_group_doc_extensions
66
* \section markext_intro Introduction
68
* The MarkInterface provides methods to enable and disable marks in a
69
* Document, a marked line can be visualized for example with a shaded
70
* background color and/or a pixmap in the iconborder of the Document's View.
71
* There are a number of predefined mark types, specified in
72
* reservedMarkersCount(). Additionally it is possible to add custom marks
73
* and set custom pixmaps.
75
* \section markext_access Accessing the Interface
77
* The MarkInterface is supposed to be an extension interface for a Document,
78
* i.e. the Document inherits the interface \e provided that the
79
* KTextEditor library in use implements the interface. Use qobject_cast to access
82
* // doc is of type KTextEditor::Document*
83
* KTextEditor::MarkInterface *iface =
84
* qobject_cast<KTextEditor::MarkInterface*>( doc );
87
* // the implementation supports the interface
92
* \section markext_handling Handling Marks
94
* Get all marks in the document by calling marks(). Use clearMarks() to
95
* remove all marks in the entire document. A single mark can be retrieved
96
* with mark(). To remove all marks from a line call clearMark(). To add
97
* and remove marks from a given line use addMark() and removeMark(). It is
98
* also possible to replace all marks with setMark(), i.e. setMark() is the
99
* same as a call of clearMark() followed by addMark(). The signals
100
* marksChanged() and markChanged() are emitted whenever a line's marks
103
* \attention A mark type is represented as an \e uint. An \e uint can have
104
* several mark types combined (see above: logical OR). That means for
105
* all functions/signals with an \e uint parameter, e.g. setMark(),
106
* removeMark(), etc, the \e uint may contain \e multiple marks, i.e.
107
* you can add and remove multiple marks \e simultaneously.
109
* \section markext_userdefined User Defined Marks
111
* All marks that should be editable by the user can be specified with a mark
112
* mask via setEditableMarks(). To set a description and pixmap of a mark type
113
* call setMarkDescription() and setMarkPixmap().
115
* \see KTextEditor::Document, KTextEditor::Mark
116
* \author Christoph Cullmann \<cullmann@kde.org\>
118
class KTEXTEDITOR_EXPORT MarkInterface
124
* Virtual destructor.
126
virtual ~MarkInterface ();
133
* Get all marks set on the \p line.
134
* \param line requested line
135
* \return a \e uint representing of the marks set in \p line concatenated
137
* \see addMark(), removeMark()
139
virtual uint mark (int line) = 0;
142
* Set the \p line's mark types to \p markType.
143
* If \p line already contains a mark of the given type it has no effect.
144
* All other marks are deleted before the mark is set. You can achieve
145
* the same by calling
148
* addMark(line, markType);
150
* \param line line to set the mark
151
* \param markType mark type
152
* \see clearMark(), addMark(), mark()
154
virtual void setMark (int line, uint markType) = 0;
157
* Clear all marks set in the \p line.
158
* \param line line to clear marks
159
* \see clearMarks(), removeMark(), addMark()
161
virtual void clearMark (int line) = 0;
164
* Add marks of type \p markType to \p line. Existing marks on this line
165
* are preserved. If the mark \p markType already is set, nothing
167
* \param line line to set the mark
168
* \param markType mark type
169
* \see removeMark(), setMark()
171
virtual void addMark (int line, uint markType) = 0;
174
* Remove the mark mask of type \p markType from \p line.
175
* \param line line to remove the mark
176
* \param markType mark type to be removed
179
virtual void removeMark (int line, uint markType) = 0;
182
* Get a hash holding all marks in the document.
183
* The hash key for a mark is its line.
184
* \return a hash holding all marks in the document
186
virtual const QHash<int, KTextEditor::Mark*> &marks () = 0;
189
* Clear all marks in the entire document.
190
* \see clearMark(), removeMark()
192
/// TODO: dominik: add argument unit mask = 0
193
virtual void clearMarks () = 0;
196
* Get the number of predefined mark types we have so far.
197
* \note FIXME: If you change this you have to make sure katepart
198
* supports the new size!
199
* \return number of reserved marker types
201
static int reservedMarkersCount() { return 7; }
204
* Predefined mark types.
206
* To add a new standard mark type, edit this interface and document
213
/** Breakpoint active */
215
/** Breakpoint reached */
217
/** Breakpoint disabled */
219
/** Execution mark */
239
markType21= 0x100000,
240
markType22= 0x200000,
241
markType23= 0x400000,
242
markType24= 0x800000,
243
markType25= 0x1000000,
244
markType26= 0x2000000,
245
markType27= 0x4000000,
246
markType28= 0x8000000,
247
markType29= 0x10000000,
248
markType30= 0x20000000,
249
markType31= 0x40000000,
250
markType32= 0x80000000,
252
Bookmark = markType01,
253
BreakpointActive = markType02,
254
BreakpointReached = markType03,
255
BreakpointDisabled = markType04,
256
Execution = markType05,
257
Warning = markType06,
266
* The \p document emits this signal whenever a mark mask changed.
267
* \param document document which emitted this signal
270
virtual void marksChanged (KTextEditor::Document* document) = 0;
273
* Methods to modify mark properties.
277
* Set the \p mark's pixmap to \p pixmap.
278
* \param mark mark to which the pixmap will be attached
279
* \param pixmap new pixmap
280
* \see setMarkDescription()
282
virtual void setMarkPixmap( MarkTypes mark, const QPixmap &pixmap ) = 0;
285
* Get the \p mark's pixmap.
286
* \param mark mark type. If the pixmap does not exist the resulting is null
287
* (check with QPixmap::isNull()).
288
* \see setMarkDescription()
290
virtual QPixmap markPixmap( MarkTypes mark ) const = 0;
293
* Set the \p mark's description to \p text.
294
* \param mark mark to set the description
295
* \param text new descriptive text
296
* \see markDescription(), setMarkPixmap()
298
virtual void setMarkDescription( MarkTypes mark, const QString &text ) = 0;
301
* Get the \p mark's description to text.
302
* \param mark mark to set the description
303
* \return text of the given \p mark or QString(), if the entry does not
305
* \see setMarkDescription(), setMarkPixmap()
307
virtual QString markDescription( MarkTypes mark ) const = 0;
310
* Set the mark mask the user is allowed to toggle to \p markMask.
311
* I.e. concatenate all editable marks with a logical OR. If the user should
312
* be able to add a bookmark and set a breakpoint with the context menu in
313
* the icon pane, you have to call
315
* // iface is of Type KTextEditor::MarkInterface*
316
* // only make bookmark and breakpoint editable
317
* iface->setEditableMarks( MarkInterface::Bookmark |
318
* MarkInterface::BreakpointActive );
320
* // or preserve last settings, and add bookmark and breakpoint
321
* iface->setEditableMarks( iface->editableMarks() |
322
* MarkInterface::Bookmark |
323
* MarkInterface::BreakpointActive );
325
* \param markMask bitmap pattern
326
* \see editableMarks(), setMarkPixmap(), setMarkDescription()
328
virtual void setEditableMarks( uint markMask ) = 0;
331
* Get, which marks can be toggled by the user.
332
* The returned value is a mark mask containing all editable marks combined
334
* \return mark mask containing all editable marks
335
* \see setEditableMarks()
337
virtual uint editableMarks() const = 0;
340
* Possible actions on a mark.
343
enum MarkChangeAction {
344
MarkAdded=0, /**< action: a mark was added. */
345
MarkRemoved=1 /**< action: a mark was removed. */
353
* The \p document emits this signal whenever the \p mark changes.
354
* \param document the document which emitted the signal
355
* \param mark changed mark
356
* \param action action, either removed or added
357
* \see marksChanged()
359
virtual void markChanged ( KTextEditor::Document* document, KTextEditor::Mark mark,
360
KTextEditor::MarkInterface::MarkChangeAction action) = 0;
365
* The \p document emits this signal whenever the \p mark is hovered using the mouse,
366
* and the receiver may show a tooltip.
367
* \param document the document which emitted the signal
368
* \param mark mark that was hovered
369
* \param position mouse position during the hovering
370
* \param handled set this to 'true' if this event was handled externally
372
void markToolTipRequested ( KTextEditor::Document* document, KTextEditor::Mark mark,
373
QPoint position, bool& handled );
376
* The \p document emits this signal whenever the \p mark is right-clicked to show a context menu.
377
* The receiver may show an own context menu instead of the kate internal one.
378
* \param document the document which emitted the signal
379
* \param mark mark that was right-clicked
380
* \param pos position where the menu should be started
381
* \param handled set this to 'true' if this event was handled externally, and kate should not create an own context menu.
383
void markContextMenuRequested( KTextEditor::Document* document, KTextEditor::Mark mark,
384
QPoint pos, bool& handled );
388
* The \p document emits this signal whenever the \p mark is left-clicked.
389
* \param document the document which emitted the signal
390
* \param mark mark that was right-clicked
391
* \param pos position where the menu should be started
392
* \param handled set this to 'true' if this event was handled externally, and kate should not do own handling of the left click.
394
void markClicked( KTextEditor::Document* document, KTextEditor::Mark mark, bool& handled );
397
class MarkInterfacePrivate* const d;
402
Q_DECLARE_INTERFACE(KTextEditor::MarkInterface, "org.kde.KTextEditor.MarkInterface")
406
// kate: space-indent on; indent-width 2; replace-tabs on;