129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2005 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13
|
|
14 module dwtx.jface.text.IPainter;
|
|
15
|
|
16 import dwt.dwthelper.utils;
|
|
17
|
|
18
|
|
19 /**
|
|
20 * A painter is responsible for creating, managing, updating, and removing
|
|
21 * visual decorations on an <code>ITextViewer</code>'s text widget. Examples
|
|
22 * are the highlighting of the caret line, the print margin, or the highlighting
|
|
23 * of matching peer characters such as pairs of brackets.</p>
|
|
24 * <p>
|
|
25 * Clients may implement this interface.</p>
|
|
26 * <p>
|
|
27 * Painters should be registered with a
|
|
28 * {@link dwtx.jface.text.PaintManager}. The paint manager tracks
|
|
29 * several classes of events issued by an <code>ITextViewer</code> and reacts
|
|
30 * by appropriately invoking the registered painters.
|
|
31 * <p>
|
|
32 * Painters are either active or inactive. Usually, painters are initially
|
|
33 * inactive and are activated by the first call to their <code>paint</code>
|
|
34 * method. Painters can be deactivated by calling <code>deactivate</code>.
|
|
35 * Inactive painter can be reactivated by calling <code>paint</code>.
|
|
36 * <p>
|
|
37 * Painters usually have to manage state information. E.g., a painter painting a
|
|
38 * caret line highlight must redraw the previous and the actual caret line in
|
|
39 * the advent of a change of the caret position. This state information must be
|
|
40 * adapted to changes of the viewer's content. In order to support this common
|
|
41 * scenario, the <code>PaintManager</code> gives a painter access to a
|
|
42 * {@link dwtx.jface.text.IPaintPositionManager}. The painter can use
|
|
43 * this updater to manage its state information.
|
|
44 * <p>
|
|
45 *
|
|
46 * @see dwtx.jface.text.PaintManager
|
|
47 * @see dwtx.jface.text.IPaintPositionManager
|
|
48 * @since 2.1
|
|
49 */
|
|
50 public interface IPainter {
|
|
51
|
|
52 /**
|
|
53 * Constant describing the reason of a repaint request: selection changed.
|
|
54 */
|
|
55 int SELECTION= 0;
|
|
56 /**
|
|
57 * Constant describing the reason of a repaint request: text changed.
|
|
58 */
|
|
59 int TEXT_CHANGE= 1;
|
|
60 /**
|
|
61 * Constant describing the reason of a repaint request: key pressed.
|
|
62 */
|
|
63 int KEY_STROKE= 2;
|
|
64 /**
|
|
65 * Constant describing the reason of a repaint request: mouse button pressed.
|
|
66 */
|
|
67 int MOUSE_BUTTON= 4;
|
|
68 /**
|
|
69 * Constant describing the reason of a repaint request: paint manager internal change.
|
|
70 */
|
|
71 int INTERNAL= 8;
|
|
72 /**
|
|
73 * Constant describing the reason of a repaint request: paint manager or painter configuration changed.
|
|
74 */
|
|
75 int CONFIGURATION= 16;
|
|
76
|
|
77
|
|
78 /**
|
|
79 * Disposes this painter. Prior to disposing, a painter should be deactivated. A disposed
|
|
80 * painter can not be reactivated.
|
|
81 *
|
|
82 * @see #deactivate(bool)
|
|
83 */
|
|
84 void dispose();
|
|
85
|
|
86 /**
|
|
87 * Requests this painter to repaint because of the given reason. Based on
|
|
88 * the given reason the painter can decide whether it will repaint or not.
|
|
89 * If it repaints and is inactive, it will activate itself.
|
|
90 *
|
|
91 * @param reason the repaint reason, value is one of the constants defined
|
|
92 * in this interface
|
|
93 */
|
|
94 void paint(int reason);
|
|
95
|
|
96 /**
|
|
97 * Deactivates this painter. If the painter is inactive, this call does not
|
|
98 * have any effect. <code>redraw</code> indicates whether the painter
|
|
99 * should remove any decoration it previously applied. A deactivated painter
|
|
100 * can be reactivated by calling <code>paint</code>.
|
|
101 *
|
|
102 * @param redraw <code>true</code> if any previously applied decoration
|
|
103 * should be removed
|
|
104 * @see #paint(int)
|
|
105 */
|
|
106 void deactivate(bool redraw);
|
|
107
|
|
108 /**
|
|
109 * Sets the paint position manager that can be used by this painter or removes any previously
|
|
110 * set paint position manager.
|
|
111 *
|
|
112 * @param manager the paint position manager or <code>null</code>
|
|
113 */
|
|
114 void setPositionManager(IPaintPositionManager manager);
|
|
115 }
|