Mercurial > projects > dwt-linux
comparison dwt/widgets/Spinner.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 * |
45 * </dl> | 45 * </dl> |
46 * </p><p> | 46 * </p><p> |
47 * IMPORTANT: This class is <em>not</em> intended to be subclassed. | 47 * IMPORTANT: This class is <em>not</em> intended to be subclassed. |
48 * </p> | 48 * </p> |
49 * | 49 * |
50 * @see <a href="http://www.eclipse.org/swt/snippets/#spinner">Spinner snippets</a> | |
51 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a> | |
52 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
53 * | |
50 * @since 3.1 | 54 * @since 3.1 |
51 */ | 55 */ |
52 public class Spinner : Composite { | 56 public class Spinner : Composite { |
53 | 57 |
54 alias Composite.computeSize computeSize; | 58 alias Composite.computeSize computeSize; |
62 int lastEventTime = 0; | 66 int lastEventTime = 0; |
63 GdkEventKey* gdkEventKey; | 67 GdkEventKey* gdkEventKey; |
64 int fixStart = -1, fixEnd = -1; | 68 int fixStart = -1, fixEnd = -1; |
65 | 69 |
66 /** | 70 /** |
67 * The maximum number of characters that can be entered | 71 * the operating system limit for the number of characters |
68 * into a text widget. | 72 * that the text field in an instance of this class can hold |
69 * <p> | 73 * |
70 * Note that this value is platform dependent, based upon | 74 * @since 3.4 |
71 * the native widget implementation. | 75 */ |
72 * </p> | |
73 */ | |
74 public const static int LIMIT = 0x7FFFFFFF; | 76 public const static int LIMIT = 0x7FFFFFFF; |
75 | 77 |
76 /** | 78 /** |
77 * Constructs a new instance of this class given its parent | 79 * Constructs a new instance of this class given its parent |
78 * and a style value describing its behavior and appearance. | 80 * and a style value describing its behavior and appearance. |
477 auto value = adjustment.value; | 479 auto value = adjustment.value; |
478 for (int i = 0; i < digits; i++) value *= 10; | 480 for (int i = 0; i < digits; i++) value *= 10; |
479 return cast(int) (value > 0 ? value + 0.5 : value - 0.5); | 481 return cast(int) (value > 0 ? value + 0.5 : value - 0.5); |
480 } | 482 } |
481 | 483 |
484 /** | |
485 * Returns a string containing a copy of the contents of the | |
486 * receiver's text field, or an empty string if there are no | |
487 * contents. | |
488 * | |
489 * @return the receiver's text | |
490 * | |
491 * @exception DWTException <ul> | |
492 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
493 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
494 * </ul> | |
495 * | |
496 * @since 3.4 | |
497 */ | |
482 public String getText () { | 498 public String getText () { |
483 checkWidget (); | 499 checkWidget (); |
484 auto str = OS.gtk_entry_get_text (handle); | 500 auto str = OS.gtk_entry_get_text (handle); |
485 return fromStringz(str).dup; | 501 return fromStringz(str).dup; |
486 } | 502 } |
487 | 503 |
504 /** | |
505 * Returns the maximum number of characters that the receiver's | |
506 * text field is capable of holding. If this has not been changed | |
507 * by <code>setTextLimit()</code>, it will be the constant | |
508 * <code>Spinner.LIMIT</code>. | |
509 * | |
510 * @return the text limit | |
511 * | |
512 * @exception DWTException <ul> | |
513 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
514 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
515 * </ul> | |
516 * | |
517 * @see #LIMIT | |
518 * | |
519 * @since 3.4 | |
520 */ | |
488 public int getTextLimit () { | 521 public int getTextLimit () { |
489 checkWidget (); | 522 checkWidget (); |
490 int limit = OS.gtk_entry_get_max_length (handle); | 523 int limit = OS.gtk_entry_get_max_length (handle); |
491 return limit is 0 ? 0xFFFF : limit; | 524 return limit is 0 ? 0xFFFF : limit; |
492 } | 525 } |
875 OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); | 908 OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
876 } | 909 } |
877 | 910 |
878 /** | 911 /** |
879 * Sets the minimum value that the receiver will allow. This new | 912 * Sets the minimum value that the receiver will allow. This new |
880 * value will be ignored if it is negative or is not less than the receiver's | 913 * value will be ignored if it is not less than the receiver's |
881 * current maximum value. If the new minimum is applied then the receiver's | 914 * current maximum value. If the new minimum is applied then the receiver's |
882 * selection value will be adjusted if necessary to fall within its new range. | 915 * selection value will be adjusted if necessary to fall within its new range. |
883 * | 916 * |
884 * @param value the new minimum, which must be nonnegative and less than the current maximum | 917 * @param value the new minimum, which must be less than the current maximum |
885 * | 918 * |
886 * @exception DWTException <ul> | 919 * @exception DWTException <ul> |
887 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 920 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
888 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 921 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
889 * </ul> | 922 * </ul> |
945 OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); | 978 OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
946 OS.gtk_spin_button_set_value (cast(GtkSpinButton*)handle, newValue); | 979 OS.gtk_spin_button_set_value (cast(GtkSpinButton*)handle, newValue); |
947 OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); | 980 OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udVALUE_CHANGED); |
948 } | 981 } |
949 | 982 |
983 /** | |
984 * Sets the maximum number of characters that the receiver's | |
985 * text field is capable of holding to be the argument. | |
986 * <p> | |
987 * To reset this value to the default, use <code>setTextLimit(Spinner.LIMIT)</code>. | |
988 * Specifying a limit value larger than <code>Spinner.LIMIT</code> sets the | |
989 * receiver's limit to <code>Spinner.LIMIT</code>. | |
990 * </p> | |
991 * @param limit new text limit | |
992 * | |
993 * @exception IllegalArgumentException <ul> | |
994 * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li> | |
995 * </ul> | |
996 * @exception DWTException <ul> | |
997 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
998 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
999 * </ul> | |
1000 * | |
1001 * @see #LIMIT | |
1002 * | |
1003 * @since 3.4 | |
1004 */ | |
950 public void setTextLimit (int limit) { | 1005 public void setTextLimit (int limit) { |
951 checkWidget (); | 1006 checkWidget (); |
952 if (limit is 0) error (DWT.ERROR_CANNOT_BE_ZERO); | 1007 if (limit is 0) error (DWT.ERROR_CANNOT_BE_ZERO); |
953 OS.gtk_entry_set_max_length (handle, limit); | 1008 OS.gtk_entry_set_max_length (handle, limit); |
954 } | 1009 } |