comparison dwtx/jface/text/AbstractInformationControlManager.d @ 161:f8d52b926852

...
author Frank Benoit <benoit@tionex.de>
date Wed, 27 Aug 2008 14:49:30 +0200
parents 3678e4f1a766
children 1a5b8f8129df
comparison
equal deleted inserted replaced
160:3678e4f1a766 161:f8d52b926852
61 import dwtx.jface.text.IRegion; // packageimport 61 import dwtx.jface.text.IRegion; // packageimport
62 import dwtx.jface.text.IInformationControlExtension2; // packageimport 62 import dwtx.jface.text.IInformationControlExtension2; // packageimport
63 import dwtx.jface.text.IDocumentExtension4; // packageimport 63 import dwtx.jface.text.IDocumentExtension4; // packageimport
64 import dwtx.jface.text.IDocumentExtension2; // packageimport 64 import dwtx.jface.text.IDocumentExtension2; // packageimport
65 import dwtx.jface.text.IDocumentPartitionerExtension2; // packageimport 65 import dwtx.jface.text.IDocumentPartitionerExtension2; // packageimport
66 import dwtx.jface.text.Assert; // packageimport 66 // import dwtx.jface.text.Assert; // packageimport
67 import dwtx.jface.text.DefaultInformationControl; // packageimport 67 import dwtx.jface.text.DefaultInformationControl; // packageimport
68 import dwtx.jface.text.IWidgetTokenOwnerExtension; // packageimport 68 import dwtx.jface.text.IWidgetTokenOwnerExtension; // packageimport
69 import dwtx.jface.text.DocumentClone; // packageimport 69 import dwtx.jface.text.DocumentClone; // packageimport
70 import dwtx.jface.text.DefaultUndoManager; // packageimport 70 import dwtx.jface.text.DefaultUndoManager; // packageimport
71 import dwtx.jface.text.IFindReplaceTarget; // packageimport 71 import dwtx.jface.text.IFindReplaceTarget; // packageimport
337 public static Anchor ANCHOR_RIGHT() { return ANCHORS()[3]; } 337 public static Anchor ANCHOR_RIGHT() { return ANCHORS()[3]; }
338 /** 338 /**
339 * Anchor representing the middle of the subject control 339 * Anchor representing the middle of the subject control
340 * @since 2.1 340 * @since 2.1
341 */ 341 */
342 public const static Anchor ANCHOR_GLOBAL= new Anchor(DWT.CENTER); 342 public static Anchor ANCHOR_GLOBAL_;
343 public static Anchor ANCHOR_GLOBAL(){
344 if( ANCHOR_GLOBAL_ is null ) ANCHOR_GLOBAL_ = new Anchor(DWT.CENTER);
345 return ANCHOR_GLOBAL_;
346 }
343 347
344 /** 348 /**
345 * Dialog store constant for the location's x-coordinate. 349 * Dialog store constant for the location's x-coordinate.
346 * @since 3.0 350 * @since 3.0
347 */ 351 */
536 * @param creator the information control creator 540 * @param creator the information control creator
537 */ 541 */
538 protected this(IInformationControlCreator creator) { 542 protected this(IInformationControlCreator creator) {
539 fAnchor= ANCHOR_BOTTOM(); 543 fAnchor= ANCHOR_BOTTOM();
540 fFallbackAnchors= ANCHORS(); 544 fFallbackAnchors= ANCHORS();
541 Assert.isNotNull(creator); 545 Assert.isNotNull(cast(Object)creator);
542 fInformationControlCreator= creator; 546 fInformationControlCreator= creator;
543 } 547 }
544 548
545 /** 549 /**
546 * Computes the information to be displayed and the area in which the computed 550 * Computes the information to be displayed and the area in which the computed
557 * 561 *
558 * @param information the information, or <code>null</code> if none is available 562 * @param information the information, or <code>null</code> if none is available
559 * @param subjectArea the subject area, or <code>null</code> if none is available 563 * @param subjectArea the subject area, or <code>null</code> if none is available
560 */ 564 */
561 protected final void setInformation(String information, Rectangle subjectArea) { 565 protected final void setInformation(String information, Rectangle subjectArea) {
562 setInformation(cast(Object)information, subjectArea); 566 setInformation(stringcast(information), subjectArea);
563 } 567 }
564 568
565 /** 569 /**
566 * Sets the parameters of the information to be displayed. These are the information itself and 570 * Sets the parameters of the information to be displayed. These are the information itself and
567 * the area for which the given information is valid. This so called subject area is a graphical 571 * the area for which the given information is valid. This so called subject area is a graphical
1180 int bestArea= Integer.MIN_VALUE; 1184 int bestArea= Integer.MIN_VALUE;
1181 Anchor bestAnchor= null; 1185 Anchor bestAnchor= null;
1182 do { 1186 do {
1183 1187
1184 upperLeft= computeLocation(subjectArea, controlSize, testAnchor); 1188 upperLeft= computeLocation(subjectArea, controlSize, testAnchor);
1185 Monitor monitor= getClosestMonitor(subjectAreaDisplayRelative, testAnchor); 1189 dwt.widgets.Monitor.Monitor monitor= getClosestMonitor(subjectAreaDisplayRelative, testAnchor);
1186 if (updateLocation(upperLeft, controlSize, monitor.getClientArea(), testAnchor)) 1190 if (updateLocation(upperLeft, controlSize, monitor.getClientArea(), testAnchor))
1187 return upperLeft; 1191 return upperLeft;
1188 1192
1189 // compute available area for this anchor and update if better than best 1193 // compute available area for this anchor and update if better than best
1190 Rectangle available= computeAvailableArea(subjectAreaDisplayRelative, monitor.getClientArea(), testAnchor); 1194 Rectangle available= computeAvailableArea(subjectAreaDisplayRelative, monitor.getClientArea(), testAnchor);
1214 * @param anchor the anchor 1218 * @param anchor the anchor
1215 * @return the monitor closest to the edge of <code>area</code> defined by 1219 * @return the monitor closest to the edge of <code>area</code> defined by
1216 * <code>anchor</code> 1220 * <code>anchor</code>
1217 * @since 3.3 1221 * @since 3.3
1218 */ 1222 */
1219 private Monitor getClosestMonitor(Rectangle area, Anchor anchor) { 1223 private dwt.widgets.Monitor.Monitor getClosestMonitor(Rectangle area, Anchor anchor) {
1220 Point center; 1224 Point center;
1221 if (ANCHOR_GLOBAL is anchor) 1225 if (ANCHOR_GLOBAL is anchor)
1222 center= Geometry.centerPoint(area); 1226 center= Geometry.centerPoint(area);
1223 else 1227 else
1224 center= Geometry.centerPoint(Geometry.getExtrudedEdge(area, 0, anchor.getSWTFlag())); 1228 center= Geometry.centerPoint(Geometry.getExtrudedEdge(area, 0, anchor.getSWTFlag()));
1233 * @param display the display to search for monitors 1237 * @param display the display to search for monitors
1234 * @param rectangle the rectangle to find the closest monitor for (display coordinates) 1238 * @param rectangle the rectangle to find the closest monitor for (display coordinates)
1235 * @return the monitor closest to the given point 1239 * @return the monitor closest to the given point
1236 * @since 3.3 1240 * @since 3.3
1237 */ 1241 */
1238 private Monitor getClosestMonitor(Display display, Rectangle rectangle) { 1242 private dwt.widgets.Monitor.Monitor getClosestMonitor(Display display, Rectangle rectangle) {
1239 int closest = Integer.MAX_VALUE; 1243 int closest = Integer.MAX_VALUE;
1240 1244
1241 Point toFind= Geometry.centerPoint(rectangle); 1245 Point toFind= Geometry.centerPoint(rectangle);
1242 Monitor[] monitors = display.getMonitors(); 1246 dwt.widgets.Monitor.Monitor[] monitors = display.getMonitors();
1243 Monitor result = monitors[0]; 1247 dwt.widgets.Monitor.Monitor result = monitors[0];
1244 1248
1245 for (int idx = 0; idx < monitors.length; idx++) { 1249 for (int idx = 0; idx < monitors.length; idx++) {
1246 Monitor current = monitors[idx]; 1250 dwt.widgets.Monitor.Monitor current = monitors[idx];
1247 1251
1248 Rectangle clientArea = current.getClientArea(); 1252 Rectangle clientArea = current.getClientArea();
1249 1253
1250 if (clientArea.contains(toFind)) { 1254 if (clientArea.contains(toFind)) {
1251 return current; 1255 return current;
1286 * control if no information should be presented. The information has previously 1290 * control if no information should be presented. The information has previously
1287 * been set using <code>setInformation</code>. 1291 * been set using <code>setInformation</code>.
1288 */ 1292 */
1289 protected void presentInformation() { 1293 protected void presentInformation() {
1290 bool hasContents= false; 1294 bool hasContents= false;
1291 if ( cast(String)fInformation ) 1295 if ( stringcast(fInformation) )
1292 hasContents= (cast(String)fInformation).trim().length() > 0; 1296 hasContents= (stringcast(fInformation)).trim().length() > 0;
1293 else 1297 else
1294 hasContents= (fInformation !is null); 1298 hasContents= (fInformation !is null);
1295 1299
1296 if (fSubjectArea !is null && hasContents) 1300 if (fSubjectArea !is null && hasContents)
1297 internalShowInformationControl(fSubjectArea, fInformation); 1301 internalShowInformationControl(fSubjectArea, fInformation);