comparison dwt/widgets/Link.d @ 259:c0d810de7093

Update SWT 3.4M7 to 3.4
author Frank Benoit <benoit@tionex.de>
date Sun, 29 Jun 2008 14:33:38 +0200
parents 5a30aa9820f3
children
comparison
equal deleted inserted replaced
257:cc1d3de0e80b 259:c0d810de7093
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2000, 2007 IBM Corporation and others. 2 * Copyright (c) 2000, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
59 * </dl> 59 * </dl>
60 * <p> 60 * <p>
61 * IMPORTANT: This class is <em>not</em> intended to be subclassed. 61 * IMPORTANT: This class is <em>not</em> intended to be subclassed.
62 * </p> 62 * </p>
63 * 63 *
64 * @see <a href="http://www.eclipse.org/swt/snippets/#link">Link snippets</a>
65 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a>
66 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
67 *
64 * @since 3.1 68 * @since 3.1
65 */ 69 */
66 public class Link : Control { 70 public class Link : Control {
67 71
68 alias Control.computeSize computeSize; 72 alias Control.computeSize computeSize;
300 rects = tmp; 304 rects = tmp;
301 } 305 }
302 return rects; 306 return rects;
303 } 307 }
304 308
309 int getClientWidth () {
310 return (state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (handle);
311 }
312
305 /** 313 /**
306 * Returns the receiver's text, which will be an empty 314 * Returns the receiver's text, which will be an empty
307 * string if it has never been set. 315 * string if it has never been set.
308 * 316 *
309 * @return the receiver's text 317 * @return the receiver's text
323 if (result !is 0) return result; 331 if (result !is 0) return result;
324 if (gdkEvent.button is 1 && gdkEvent.type is OS.GDK_BUTTON_PRESS) { 332 if (gdkEvent.button is 1 && gdkEvent.type is OS.GDK_BUTTON_PRESS) {
325 if (focusIndex !is -1) setFocus (); 333 if (focusIndex !is -1) setFocus ();
326 int x = cast(int) gdkEvent.x; 334 int x = cast(int) gdkEvent.x;
327 int y = cast(int) gdkEvent.y; 335 int y = cast(int) gdkEvent.y;
336 if ((style & DWT.MIRRORED) !is 0) x = getClientWidth () - x;
328 int offset = layout.getOffset (x, y, null); 337 int offset = layout.getOffset (x, y, null);
329 int oldSelectionX = selection.x; 338 int oldSelectionX = selection.x;
330 int oldSelectionY = selection.y; 339 int oldSelectionY = selection.y;
331 selection.x = offset; 340 selection.x = offset;
332 selection.y = -1; 341 selection.y = -1;
359 if (result !is 0) return result; 368 if (result !is 0) return result;
360 if (focusIndex is -1) return result; 369 if (focusIndex is -1) return result;
361 if (gdkEvent.button is 1) { 370 if (gdkEvent.button is 1) {
362 int x = cast(int) gdkEvent.x; 371 int x = cast(int) gdkEvent.x;
363 int y = cast(int) gdkEvent.y; 372 int y = cast(int) gdkEvent.y;
373 if ((style & DWT.MIRRORED) !is 0) x = getClientWidth () - x;
364 Rectangle [] rects = getRectangles (focusIndex); 374 Rectangle [] rects = getRectangles (focusIndex);
365 for (int i = 0; i < rects.length; i++) { 375 for (int i = 0; i < rects.length; i++) {
366 Rectangle rect = rects [i]; 376 Rectangle rect = rects [i];
367 if (rect.contains (x, y)) { 377 if (rect.contains (x, y)) {
368 Event ev = new Event (); 378 Event ev = new Event ();
457 override int /*long*/ gtk_motion_notify_event (GtkWidget* widget, GdkEventMotion* gdkEvent) { 467 override int /*long*/ gtk_motion_notify_event (GtkWidget* widget, GdkEventMotion* gdkEvent) {
458 int /*long*/ result = super.gtk_motion_notify_event (widget, gdkEvent); 468 int /*long*/ result = super.gtk_motion_notify_event (widget, gdkEvent);
459 if (result !is 0) return result; 469 if (result !is 0) return result;
460 int x = cast(int) gdkEvent.x; 470 int x = cast(int) gdkEvent.x;
461 int y = cast(int) gdkEvent.y; 471 int y = cast(int) gdkEvent.y;
472 if ((style & DWT.MIRRORED) !is 0) x = getClientWidth () - x;
462 if ((gdkEvent.state & OS.GDK_BUTTON1_MASK) !is 0) { 473 if ((gdkEvent.state & OS.GDK_BUTTON1_MASK) !is 0) {
463 int oldSelection = selection.y; 474 int oldSelection = selection.y;
464 selection.y = layout.getOffset (x, y, null); 475 selection.y = layout.getOffset (x, y, null);
465 if (selection.y !is oldSelection) { 476 if (selection.y !is oldSelection) {
466 int newSelection = selection.y; 477 int newSelection = selection.y;
488 return result; 499 return result;
489 } 500 }
490 501
491 override void releaseWidget () { 502 override void releaseWidget () {
492 super.releaseWidget (); 503 super.releaseWidget ();
493 if (layout !is null) layout.dispose (); 504 if (layout !is null) layout.dispose ();
494 layout = null; 505 layout = null;
495 if (linkColor !is null) linkColor.dispose (); 506 if (linkColor !is null) linkColor.dispose ();
496 linkColor = null; 507 linkColor = null;
497 if (disabledColor !is null) disabledColor.dispose (); 508 if (disabledColor !is null) disabledColor.dispose ();
498 disabledColor = null; 509 disabledColor = null;
499 offsets = null; 510 offsets = null;
500 ids = null; 511 ids = null;