View | Details | Raw Unified | Return to bug 185966
Collapse All | Expand All

(-)src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java (-10 / +50 lines)
Lines 161-187 Link Here
161
	 * @since 3.3
161
	 * @since 3.3
162
	 */
162
	 */
163
	private static final class DashedBoxDrawingStrategy extends BoxDrawingStrategy {
163
	private static final class DashedBoxDrawingStrategy extends BoxDrawingStrategy {
164
		private int evenSteps(int len, int s) {
165
			int twoS= 2 * s;
166
			return (len) / twoS * twoS;
167
		}
168
		
164
		/*
169
		/*
165
		 * @see org.eclipse.ui.texteditor.SourceViewerDecorationSupport.BoxDrawingStrategy#drawBox(org.eclipse.swt.graphics.GC, org.eclipse.swt.graphics.Color, org.eclipse.swt.graphics.Rectangle)
170
		 * @see org.eclipse.ui.texteditor.SourceViewerDecorationSupport.BoxDrawingStrategy#drawBox(org.eclipse.swt.graphics.GC, org.eclipse.swt.graphics.Color, org.eclipse.swt.graphics.Rectangle)
166
		 */
171
		 */
167
		protected void drawBox(GC gc, StyledText textWidget, Color color, Rectangle bounds) {
172
		protected void drawBox(GC gc, StyledText textWidget, Color color, Rectangle bounds) {
168
			//clean bg:
173
			gc.setForeground(color);
169
			gc.setForeground(textWidget.getBackground());
170
			gc.setLineStyle(SWT.LINE_SOLID);
171
			int x= bounds.x;
174
			int x= bounds.x;
172
			int y= bounds.y;
175
			int y= bounds.y;
173
			int w= bounds.width - 1;
176
			int w= bounds.width - 1;
174
			int h= bounds.height - 1;
177
			int h= bounds.height - 1;
175
			gc.drawRectangle(x, y, w, h);
178
			gc.drawRectangle(x, y, w, h);
176
			
179
			
177
			gc.setForeground(color);
180
			gc.setForeground(textWidget.getBackground());
178
			gc.setLineDash(new int[] { 3 });
181
			
182
//dash from left & adjust right:
183
			int d= 3; //dash length
184
			int c= 4; //no-dash-zone at corners
185
			gc.setLineDash(new int[] { d });
186
			if (w > 2 * c) {
187
				int w2= evenSteps(w - 2 * c, d) + d - 1;
188
				gc.drawLine(x + c, y, x + c + w2, y);
189
				gc.drawLine(x + c, y + h, x + c + w2, y + h);
190
			}
191
			if (h > 2 * c) {
192
				int h2= evenSteps(h - 2 * c, d) + d - 1;
193
				gc.drawLine(x, y + c, x, y + c + h2);
194
				gc.drawLine(x + w, y + c, x + w, y + c + h2);
195
			}
196
			
197
////dash from left & right (partial dashes at center):
198
//			int d= 3;
199
//			int o= 6;
200
//			gc.setLineDash(new int[] { d });
201
//			if (w > 2 * o) {
202
//				gc.drawLine(x + o, y, x + w/2, y);
203
//				gc.drawLine(x + w - o, y, x + w/2, y);
204
//				
205
//				gc.drawLine(x + o, y + h, x + w/2, y + h);
206
//				gc.drawLine(x + w - o, y + h, x + w/2, y + h);
207
//			}
208
//			if (h > 2 * o) {
209
//				gc.drawLine(x, y + o, x, y + h - o);
210
//				gc.drawLine(x + w, y + o, x + w, y + h - o);
211
//			}
179
			
212
			
180
			// gc.drawRectangle(x, y, w, h) is platform-dependent and can look "animated"
213
////dash from left (partial dashes at right):
181
			gc.drawLine(x, y, x + w, y);
214
//			int d= 6;
182
			gc.drawLine(x, y + h, x + w, y + h);
215
//			int o= 6;
183
			gc.drawLine(x, y, x, y + h);
216
//			gc.setLineDash(new int[] { d });
184
			gc.drawLine(x + w, y, x + w, y + h);
217
//			if (w > 2 * o) {
218
//				gc.drawLine(x + o, y, x + w - o, y);
219
//				gc.drawLine(x + o, y + h, x + w - o, y + h);
220
//			}
221
//			if (h > 2 * o) {
222
//				gc.drawLine(x, y + o, x, y + h - o);
223
//				gc.drawLine(x + w, y + o, x + w, y + h - o);
224
//			}
185
225
186
			//RESET (same GC is passed around!):
226
			//RESET (same GC is passed around!):
187
			gc.setLineStyle(SWT.LINE_SOLID);
227
			gc.setLineStyle(SWT.LINE_SOLID);

Return to bug 185966