1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is Mozilla.org.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corp.
19 * Portions created by the Initial Developer are Copyright (C) 2003
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Daniel Glazman (glazman@netscape.com) (Original author)
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39 #include "nsISupports.idl"
40 #include "domstubs.idl"
41
42 [scriptable, uuid(91375f52-20e6-4757-9835-eb04fabe5498)]
43
44 interface nsIHTMLAbsPosEditor : nsISupports
45 {
46 /**
47 * true if the selection container is absolutely positioned
48 */
49 readonly attribute boolean selectionContainerAbsolutelyPositioned;
50
51 /**
52 * this contains the absolutely positioned element currently edited
53 * or null
54 */
55 readonly attribute nsIDOMElement positionedElement;
56
57 /**
58 * true if Absolute Positioning handling is enabled in the editor
59 */
60 attribute boolean absolutePositioningEnabled;
61
62
63 /* Utility methods */
64
65 /**
66 * true if Snap To Grid is enabled in the editor.
67 */
68 attribute boolean snapToGridEnabled;
69
70 /**
71 * sets the grid size in pixels.
72 * @param aSizeInPixels [IN] the size of the grid in pixels
73 */
74 attribute unsigned long gridSize;
75
76 /* Selection-based methods */
77
78 /**
79 * returns the deepest absolutely positioned container of the selection
80 * if it exists or null.
81 */
82 readonly attribute nsIDOMElement absolutelyPositionedSelectionContainer;
83
84 /**
85 * extracts the selection from the normal flow of the document and
86 * positions it.
87 * @param aEnabled [IN] true to absolutely position the selection,
88 * false to put it back in the normal flow
89 */
90 void absolutePositionSelection(in boolean aEnabled);
91
92 /**
93 * adds aChange to the z-index of the currently positioned element.
94 * @param aChange [IN] relative change to apply to current z-index
95 */
96 void relativeChangeZIndex(in long aChange);
97
98 /* Element-based methods */
99
100 /**
101 * extracts an element from the normal flow of the document and
102 * positions it, and puts it back in the normal flow.
103 * @param aElement [IN] the element
104 * @param aEnabled [IN] true to absolutely position the element,
105 * false to put it back in the normal flow
106 */
107 void absolutelyPositionElement(in nsIDOMElement aElement,
108 in boolean aEnabled);
109
110 /**
111 * sets the position of an element; warning it does NOT check if the
112 * element is already positioned or not and that's on purpose.
113 * @param aElement [IN] the element
114 * @param aX [IN] the x position in pixels.
115 * @param aY [IN] the y position in pixels.
116 */
117 void setElementPosition(in nsIDOMElement aElement, in long aX, in long aY);
118
119 /**
120 * returns the absolute z-index of a positioned element. Never returns 'auto'.
121 * @return the z-index of the element
122 * @param aElement [IN] the element.
123 */
124 long getElementZIndex(in nsIDOMElement aElement);
125
126 /**
127 * sets the z-index of an element.
128 * @param aElement [IN] the element
129 * @param aZorder [IN] the z-index
130 */
131 void setElementZIndex(in nsIDOMElement aElement, in long aZorder);
132
133 /**
134 * adds aChange to the z-index of an arbitrary element.
135 * @return the new z-index of the element
136 * @param aElement [IN] the element
137 * @param aChange [IN] relative change to apply to current z-index of
138 * the element
139 */
140 long relativeChangeElementZIndex(in nsIDOMElement aElement, in long aChange);
141
142 /* Other */
143
144 /**
145 * shows a grabber attached to an arbitrary element. The grabber is an image
146 * positioned on the left hand side of the top border of the element. Dragging
147 * and dropping it allows to change the element's absolute position in the
148 * document. See chrome://editor/content/images/grabber.gif
149 * @param aElement [IN] the element
150 */
151 void showGrabberOnElement(in nsIDOMElement aElement);
152
153 /**
154 * hide the grabber if it shown.
155 */
156 void hideGrabber();
157
158 /**
159 * refreshes the grabber if it shown, possibly updating its position or
160 * even hiding it.
161 */
162 void refreshGrabber();
163
164 };