# HG changeset patch # User John Reimer + *******************************************************************************/ +package dwt.DWT; + + +import dwt.internal.Compatibility; +import dwt.internal.Library; +import dwt.internal.Platform; +import dwt.DWTError; +import dwt.DWTException; + +import tango.core.Exception; + +/** + * This class provides access to a small number of DWT system-wide + * methods, and in addition defines the public constants provided + * by DWT. + *

+ * By defining constants like UP and DOWN in a single class, DWT + * can share common names and concepts at the same time minimizing + * the number of classes, names and constants for the application + * programmer. + *

+ * Note that some of the constants provided by this class represent + * optional, appearance related aspects of widgets which are available + * either only on some window systems, or for a differing set of + * widgets on each window system. These constants are marked + * as HINTs. The set of widgets which support a particular + * HINT may change from release to release, although we typically + * will not withdraw support for a HINT once it is made available. + *

+ */ + +/* NOTE: + * Good javadoc coding style is to put the values of static const + * constants in the comments. This reinforces the fact that + * consumers are allowed to rely on the value (and they must + * since the values are compiled inline in their code). We + * can not change the values of these constants between + * releases. + */ +public class DWT { + + /* Widget Event Constants */ + + /** + * The null event type (value is 0). + * + * @since 3.0 + */ + public static const int None = 0; + + /** + * The key down event type (value is 1). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addKeyListener + * @see dwt.widgets.Tracker#addKeyListener + * @see dwt.events.KeyListener#keyPressed + * @see dwt.events.KeyEvent + */ + public static const int KeyDown = 1; + + /** + * The key up event type (value is 2). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addKeyListener + * @see dwt.widgets.Tracker#addKeyListener + * @see dwt.events.KeyListener#keyReleased + * @see dwt.events.KeyEvent + */ + public static const int KeyUp = 2; + + /** + * The mouse down event type (value is 3). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addMouseListener + * @see dwt.events.MouseListener#mouseDown + * @see dwt.events.MouseEvent + */ + public static const int MouseDown = 3; + + /** + * The mouse up event type (value is 4). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addMouseListener + * @see dwt.events.MouseListener#mouseUp + * @see dwt.events.MouseEvent + */ + public static const int MouseUp = 4; + + /** + * The mouse move event type (value is 5). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addMouseMoveListener + * @see dwt.events.MouseMoveListener#mouseMove + * @see dwt.events.MouseEvent + */ + public static const int MouseMove = 5; + + /** + * The mouse enter event type (value is 6). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addMouseTrackListener + * @see dwt.events.MouseTrackListener#mouseEnter + * @see dwt.events.MouseEvent + */ + public static const int MouseEnter = 6; + + /** + * The mouse exit event type (value is 7). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addMouseTrackListener + * @see dwt.events.MouseTrackListener#mouseExit + * @see dwt.events.MouseEvent + */ + public static const int MouseExit = 7; + + /** + * The mouse double click event type (value is 8). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addMouseListener + * @see dwt.events.MouseListener#mouseDoubleClick + * @see dwt.events.MouseEvent + */ + public static const int MouseDoubleClick = 8; + + /** + * The paint event type (value is 9). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addPaintListener + * @see dwt.events.PaintListener#paintControl + * @see dwt.events.PaintEvent + */ + public static const int Paint = 9; + + /** + * The move event type (value is 10). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addControlListener + * @see dwt.widgets.TableColumn#addControlListener + * @see dwt.widgets.Tracker#addControlListener + * @see dwt.widgets.TreeColumn#addControlListener + * @see dwt.events.ControlListener#controlMoved + * @see dwt.events.ControlEvent + */ + public static const int Move = 10; + + /** + * The resize event type (value is 11). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addControlListener + * @see dwt.widgets.TableColumn#addControlListener + * @see dwt.widgets.Tracker#addControlListener + * @see dwt.widgets.TreeColumn#addControlListener + * @see dwt.events.ControlListener#controlResized + * @see dwt.events.ControlEvent + */ + public static const int Resize = 11; + + /** + * The dispose event type (value is 12). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Widget#addDisposeListener + * @see dwt.events.DisposeListener#widgetDisposed + * @see dwt.events.DisposeEvent + */ + public static const int Dispose = 12; + + /** + * The selection event type (value is 13). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Button#addSelectionListener + * @see dwt.widgets.Combo#addSelectionListener + * @see dwt.widgets.CoolItem#addSelectionListener + * @see dwt.widgets.Link#addSelectionListener + * @see dwt.widgets.List#addSelectionListener + * @see dwt.widgets.MenuItem#addSelectionListener + * @see dwt.widgets.Sash#addSelectionListener + * @see dwt.widgets.Scale#addSelectionListener + * @see dwt.widgets.ScrollBar#addSelectionListener + * @see dwt.widgets.Slider#addSelectionListener + * @see dwt.widgets.TabFolder#addSelectionListener + * @see dwt.widgets.Table#addSelectionListener + * @see dwt.widgets.TableColumn#addSelectionListener + * @see dwt.widgets.ToolItem#addSelectionListener + * @see dwt.widgets.TrayItem#addSelectionListener + * @see dwt.widgets.Tree#addSelectionListener + * @see dwt.widgets.TreeColumn#addSelectionListener + * @see dwt.events.SelectionListener#widgetSelected + * @see dwt.events.SelectionEvent + */ + public static const int Selection = 13; + + /** + * The default selection event type (value is 14). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Combo#addSelectionListener + * @see dwt.widgets.List#addSelectionListener + * @see dwt.widgets.Spinner#addSelectionListener + * @see dwt.widgets.Table#addSelectionListener + * @see dwt.widgets.Text#addSelectionListener + * @see dwt.widgets.TrayItem#addSelectionListener + * @see dwt.widgets.Tree#addSelectionListener + * @see dwt.events.SelectionListener#widgetDefaultSelected + * @see dwt.events.SelectionEvent + */ + public static const int DefaultSelection = 14; + + /** + * The focus in event type (value is 15). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addFocusListener + * @see dwt.events.FocusListener#focusGained + * @see dwt.events.FocusEvent + */ + public static const int FocusIn = 15; + + /** + * The focus out event type (value is 16). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addFocusListener + * @see dwt.events.FocusListener#focusLost + * @see dwt.events.FocusEvent + */ + public static const int FocusOut = 16; + + /** + * The expand event type (value is 17). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Tree#addTreeListener + * @see dwt.events.TreeListener#treeExpanded + * @see dwt.events.TreeEvent + */ + public static const int Expand = 17; + + /** + * The collapse event type (value is 18). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Tree#addTreeListener + * @see dwt.events.TreeListener#treeCollapsed + * @see dwt.events.TreeEvent + */ + public static const int Collapse = 18; + + /** + * The iconify event type (value is 19). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Shell#addShellListener + * @see dwt.events.ShellListener#shellIconified + * @see dwt.events.ShellEvent + */ + public static const int Iconify = 19; + + /** + * The de-iconify event type (value is 20). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Shell#addShellListener + * @see dwt.events.ShellListener#shellDeiconified + * @see dwt.events.ShellEvent + */ + public static const int Deiconify = 20; + + /** + * The close event type (value is 21). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Shell#addShellListener + * @see dwt.events.ShellListener#shellClosed + * @see dwt.events.ShellEvent + */ + public static const int Close = 21; + + /** + * The show event type (value is 22). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Menu#addMenuListener + * @see dwt.events.MenuListener#menuShown + * @see dwt.events.MenuEvent + */ + public static const int Show = 22; + + /** + * The hide event type (value is 23). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Menu#addMenuListener + * @see dwt.events.MenuListener#menuHidden + * @see dwt.events.MenuEvent + */ + public static const int Hide = 23; + + /** + * The modify event type (value is 24). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Combo#addModifyListener + * @see dwt.widgets.Spinner#addModifyListener + * @see dwt.widgets.Text#addModifyListener + * @see dwt.events.ModifyListener#modifyText + * @see dwt.events.ModifyEvent + */ + public static const int Modify = 24; + + /** + * The verify event type (value is 25). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Combo#addVerifyListener + * @see dwt.widgets.Text#addVerifyListener + * @see dwt.events.VerifyListener#verifyText + * @see dwt.events.VerifyEvent + */ + public static const int Verify = 25; + + /** + * The activate event type (value is 26). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Shell#addShellListener + * @see dwt.events.ShellListener#shellActivated + * @see dwt.events.ShellEvent + */ + public static const int Activate = 26; + + /** + * The deactivate event type (value is 27). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Shell#addShellListener + * @see dwt.events.ShellListener#shellDeactivated + * @see dwt.events.ShellEvent + */ + public static const int Deactivate = 27; + + /** + * The help event type (value is 28). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addHelpListener + * @see dwt.widgets.Menu#addHelpListener + * @see dwt.widgets.MenuItem#addHelpListener + * @see dwt.events.HelpListener#helpRequested + * @see dwt.events.HelpEvent + */ + public static const int Help = 28; + + /** + * The drag detect event type (value is 29). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.dnd.DragSource + */ + public static const int DragDetect = 29; + + /** + * The arm event type (value is 30). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.MenuItem#addArmListener + * @see dwt.events.ArmListener#widgetArmed + * @see dwt.events.ArmEvent + */ + public static const int Arm = 30; + + /** + * The traverse event type (value is 31). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addTraverseListener + * @see dwt.events.TraverseListener#keyTraversed + * @see dwt.events.TraverseEvent + */ + public static const int Traverse = 31; + + /** + * The mouse hover event type (value is 32). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Control#addMouseTrackListener + * @see dwt.events.MouseTrackListener#mouseHover + * @see dwt.events.MouseEvent + */ + public static const int MouseHover = 32; + + /** + * The hardware key down event type (value is 33). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + */ + public static const int HardKeyDown = 33; + + /** + * The hardware key up event type (value is 34). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + */ + public static const int HardKeyUp = 34; + + /** + * The menu detect event type (value is 35). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @since 3.0 + */ + public static const int MenuDetect = 35; + + /** + * The set data event type (value is 36). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @see dwt.widgets.Table + * @see dwt.widgets.Tree + * + * @since 3.0 + */ + public static const int SetData = 36; + + /** + * The mouse wheel event type (value is 37). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @since 3.1 + */ + public static const int MouseWheel = 37; + + /** + * The settings changed event type (value is 39). + *

+ * The settings changed event is sent when an operating system + * property, such as a system font or color, has been changed. + * The event occurs after the property has been changed, but + * before any widget is redrawn. Applications that cache operating + * system properties can use this event to update their caches. + * A specific property change can be detected by querying the + * new value of a property and comparing it with the equivalent + * cached value. The operating system automatically redraws and + * lays out all widgets after this event is sent. + *

+ * + * @see dwt.widgets.Display#addListener + * @see dwt.widgets.Event + * + * @since 3.2 + */ + public static const int Settings = 39; + + /** + * The erase item event type (value is 40). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @since 3.2 + */ + public static const int EraseItem = 40; + + /** + * The measure item event type (value is 41). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @since 3.2 + */ + public static const int MeasureItem = 41; + + /** + * The paint item event type (value is 42). + * + * @see dwt.widgets.Widget#addListener + * @see dwt.widgets.Display#addFilter + * @see dwt.widgets.Event + * + * @since 3.2 + */ + public static const int PaintItem = 42; + + /* Event Details */ + + /** + * Indicates that a user-interface component is being dragged, + * for example dragging the thumb of a scroll bar (value is 1). + */ + public static const int DRAG = 1; + + /** + * Event detail field that indicates a user-interface component + * state is selected (value is 1<<1). + * + * @since 3.2 + */ + public static const int SELECTED = 1 << 1; + + /** + * Event detail field that indicates a user-interface component + * state is focused (value is 1<<2). + * + * @since 3.2 + */ + public static const int FOCUSED = 1 << 2; + + /** + * Event detail field that indicates a user-interface component + * draws the background (value is 1<<3). + * + * @since 3.2 + */ + public static const int BACKGROUND = 1 << 3; + + /** + * Event detail field that indicates a user-interface component + * draws the foreground (value is 1<<4). + * + * @since 3.2 + */ + public static const int FOREGROUND = 1 << 4; + + /** + * Event detail field that indicates a user-interface component + * state is hot (value is 1<<5). + * + * @since 3.3 + */ + public static const int HOT = 1 << 5; + + /* This code is intentionally commented */ + //public static const int PRESSED = 1 << 3; + //public static const int ACTIVE = 1 << 4; + //public static const int DISABLED = 1 << 5; + //public static const int HOT = 1 << 6; + //public static const int DEFAULTED = 1 << 7; + + /** + * Traversal event detail field value indicating that no + * traversal action should be taken + * (value is 0). + */ + public static const int TRAVERSE_NONE = 0; + + /** + * Traversal event detail field value indicating that the + * key which designates that a dialog should be cancelled was + * pressed; typically, this is the ESC key + * (value is 1<<1). + */ + public static const int TRAVERSE_ESCAPE = 1 << 1; + + /** + * Traversal event detail field value indicating that the + * key which activates the default button in a dialog was + * pressed; typically, this is the ENTER key + * (value is 1<<2). + */ + public static const int TRAVERSE_RETURN = 1 << 2; + + /** + * Traversal event detail field value indicating that the + * key which designates that focus should be given to the + * previous tab group was pressed; typically, this is the + * SHIFT-TAB key sequence + * (value is 1<<3). + */ + public static const int TRAVERSE_TAB_PREVIOUS = 1 << 3; + + /** + * Traversal event detail field value indicating that the + * key which designates that focus should be given to the + * next tab group was pressed; typically, this is the + * TAB key + * (value is 1<<4). + */ + public static const int TRAVERSE_TAB_NEXT = 1 << 4; + + /** + * Traversal event detail field value indicating that the + * key which designates that focus should be given to the + * previous tab item was pressed; typically, this is either + * the LEFT-ARROW or UP-ARROW keys + * (value is 1<<5). + */ + public static const int TRAVERSE_ARROW_PREVIOUS = 1 << 5; + + /** + * Traversal event detail field value indicating that the + * key which designates that focus should be given to the + * previous tab item was pressed; typically, this is either + * the RIGHT-ARROW or DOWN-ARROW keys + * (value is 1<<6). + */ + public static const int TRAVERSE_ARROW_NEXT = 1 << 6; + + /** + * Traversal event detail field value indicating that a + * mnemonic key sequence was pressed + * (value is 1<<7). + */ + public static const int TRAVERSE_MNEMONIC = 1 << 7; + + /** + * Traversal event detail field value indicating that the + * key which designates that the previous page of a multi-page + * window should be shown was pressed; typically, this + * is the CTRL-PAGEUP key sequence + * (value is 1<<8). + */ + public static const int TRAVERSE_PAGE_PREVIOUS = 1 << 8; + + /** + * Traversal event detail field value indicating that the + * key which designates that the next page of a multi-page + * window should be shown was pressed; typically, this + * is the CTRL-PAGEDOWN key sequence + * (value is 1<<9). + */ + public static const int TRAVERSE_PAGE_NEXT = 1 << 9; + + /** + * A constant known to be zero (0), typically used in operations + * which take bit flags to indicate that "no bits are set". + */ + public static const int NONE = 0; + + /** + * A constant known to be zero (0), used in operations which + * take pointers to indicate a null argument. + */ + public static const int NULL = 0; + + /** + * Indicates that a default should be used (value is -1). + */ + public static const int DEFAULT = -1; + + /** + * Indicates that a property is off (value is 0). + * + * @since 3.1 + */ + public static const int OFF = 0; + + /** + * Indicates that a property is on (value is 1). + * + * @since 3.1 + */ + public static const int ON = 1; + + /** + * Indicates low quality (value is 1). + * + * @since 3.1 + */ + public static const int LOW = 1; + + /** + * Indicates high quality (value is 2). + * + * @since 3.1 + */ + public static const int HIGH = 2; + + /** + * Style constant for menu bar behavior (value is 1<<1). + *

Used By:

+ */ + public static const int BAR = 1 << 1; + + /** + * Style constant for drop down menu/list behavior (value is 1<<2). + *

Used By:

+ */ + public static const int DROP_DOWN = 1 << 2; + + /** + * Style constant for pop up menu behavior (value is 1<<3). + *

Used By:

+ */ + public static const int POP_UP = 1 << 3; + + /** + * Style constant for line separator behavior (value is 1<<1). + *

Used By:

+ */ + public static const int SEPARATOR = 1 << 1; + + /** + * Style constant for toggle button behavior (value is 1<<1). + *

Used By:

+ */ + public static const int TOGGLE = 1 << 1; + + /** + * Style constant for arrow button behavior (value is 1<<2). + *

Used By:

+ */ + public static const int ARROW = 1 << 2; + + /** + * Style constant for push button behavior (value is 1<<3). + *

Used By:

+ */ + public static const int PUSH = 1 << 3; + + /** + * Style constant for radio button behavior (value is 1<<4). + *

Used By:

+ */ + public static const int RADIO = 1 << 4; + + /** + * Style constant for check box behavior (value is 1<<5). + *

Used By:

+ */ + public static const int CHECK = 1 << 5; + + /** + * Style constant for cascade behavior (value is 1<<6). + *

Used By:

+ */ + public static const int CASCADE = 1 << 6; + + /** + * Style constant for multi-selection behavior in lists + * and multiple line support on text fields (value is 1<<1). + *

Used By:

+ */ + public static const int MULTI = 1 << 1; + + /** + * Style constant for single selection behavior in lists + * and single line support on text fields (value is 1<<2). + *

Used By:

+ */ + public static const int SINGLE = 1 << 2; + + /** + * Style constant for read-only behavior (value is 1<<3). + *

Used By:

+ */ + public static const int READ_ONLY = 1 << 3; + + /** + * Style constant for automatic line wrap behavior (value is 1<<6). + *

Used By:

+ */ + public static const int WRAP = 1 << 6; + + /** + * Style constant for search behavior (value is 1<<7). + *

Used By:

+ * + * @since 3.3 + */ + public static const int SEARCH = 1 << 7; + + /** + * Style constant for simple (not drop down) behavior (value is 1<<6). + *

Used By:

+ */ + public static const int SIMPLE = 1 << 6; + + /** + * Style constant for password behavior (value is 1<<22). + *

Used By:

+ * + * @since 3.0 + */ + public static const int PASSWORD = 1 << 22; + + /** + * Style constant for shadow in behavior (value is 1<<2). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int SHADOW_IN = 1 << 2; + + /** + * Style constant for shadow out behavior (value is 1<<3). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int SHADOW_OUT = 1 << 3; + + /** + * Style constant for shadow etched in behavior (value is 1<<4). + *
Note that this is a HINT. It is ignored on all platforms except Motif. + *

Used By:

+ */ + public static const int SHADOW_ETCHED_IN = 1 << 4; + + /** + * Style constant for shadow etched out behavior (value is 1<<6). + *
Note that this is a HINT. It is ignored on all platforms except Motif. + *

Used By:

+ */ + public static const int SHADOW_ETCHED_OUT = 1 << 6; + + /** + * Style constant for no shadow behavior (value is 1<<5). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int SHADOW_NONE = 1 << 5; + + /** + * Style constant for progress bar behavior (value is 1<<1). + *

Used By:

+ */ + public static const int INDETERMINATE = 1 << 1; + + /** + * Style constant for tool window behavior (value is 1<<2). + *

+ * A tool window is a window intended to be used as a floating toolbar. + * It typically has a title bar that is shorter than a normal title bar, + * and the window title is typically drawn using a smaller font. + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int TOOL = 1 << 2; + + /** + * Style constant to ensure no trimmings are used (value is 1<<3). + *
Note that this overrides all other trim styles. + *

Used By:

+ */ + public static const int NO_TRIM = 1 << 3; + + /** + * Style constant for resize box trim (value is 1<<4). + *

Used By:

+ */ + public static const int RESIZE = 1 << 4; + + /** + * Style constant for title area trim (value is 1<<5). + *

Used By:

+ */ + public static const int TITLE = 1 << 5; + + /** + * Style constant for close box trim (value is 1<<6, + * since we do not distinguish between CLOSE style and MENU style). + *

Used By:

+ */ + public static const int CLOSE = 1 << 6; + + /** + * Style constant for shell menu trim (value is 1<<6, + * since we do not distinguish between CLOSE style and MENU style). + *

Used By:

+ */ + public static const int MENU = CLOSE; + + /** + * Style constant for minimize box trim (value is 1<<7). + *

Used By:

+ */ + public static const int MIN = 1 << 7; + + /** + * Style constant for maximize box trim (value is 1<<10). + *

Used By:

+ */ + public static const int MAX = 1 << 10; + + /** + * Style constant for horizontal scrollbar behavior (value is 1<<8). + *

Used By:

+ */ + public static const int H_SCROLL = 1 << 8; + + /** + * Style constant for vertical scrollbar behavior (value is 1<<9). + *

Used By:

+ */ + public static const int V_SCROLL = 1 << 9; + + /** + * Style constant for bordered behavior (value is 1<<11). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int BORDER = 1 << 11; + + /** + * Style constant indicating that the window manager should clip + * a widget's children with respect to its viewable area. (value is 1<<12). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int CLIP_CHILDREN = 1 << 12; + + /** + * Style constant indicating that the window manager should clip + * a widget's siblings with respect to its viewable area. (value is 1<<13). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int CLIP_SIBLINGS = 1 << 13; + + /** + * Style constant for always on top behavior (value is 1<<14). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int ON_TOP = 1 << 14; + + /** + * Trim style convenience constant for the most common top level shell appearance + * (value is CLOSE|TITLE|MIN|MAX|RESIZE). + *

Used By:

+ */ + public static const int SHELL_TRIM = CLOSE | TITLE | MIN | MAX | RESIZE; + + /** + * Trim style convenience constant for the most common dialog shell appearance + * (value is CLOSE|TITLE|BORDER). + *

Used By:

+ */ + public static const int DIALOG_TRIM = TITLE | CLOSE | BORDER; + + /** + * Style constant for modeless behavior (value is 0). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int MODELESS = 0; + + /** + * Style constant for primary modal behavior (value is 1<<15). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int PRIMARY_MODAL = 1 << 15; + + /** + * Style constant for application modal behavior (value is 1<<16). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int APPLICATION_MODAL = 1 << 16; + + /** + * Style constant for system modal behavior (value is 1<<17). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int SYSTEM_MODAL = 1 << 17; + + /** + * Style constant for selection hiding behavior when the widget loses focus (value is 1<<15). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int HIDE_SELECTION = 1 << 15; + + /** + * Style constant for full row selection behavior and + * selection constant indicating that a full line should be + * drawn. (value is 1<<16). + *
Note that for some widgets this is a HINT. + *

Used By:

+ */ + public static const int FULL_SELECTION = 1 << 16; + + /** + * Style constant for flat appearance. (value is 1<<23). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int FLAT = 1 << 23; + + /** + * Style constant for smooth appearance. (value is 1<<16). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int SMOOTH = 1 << 16; + + /** + * Style constant for no background behavior (value is 1<<18). + *

+ * By default, before a widget paints, the client area is filled with the current background. + * When this style is specified, the background is not filled, and the application is responsible + * for filling every pixel of the client area. + * This style might be used as an alternative to "double-buffering" in order to reduce flicker. + * This style does not mean "transparent" - widgets that are obscured will not draw through. + *

Used By:

+ */ + public static const int NO_BACKGROUND = 1 << 18; + + /** + * Style constant for no focus from the mouse behavior (value is 1<<19). + *
Note that this is a HINT. + *

Used By:

+ */ + public static const int NO_FOCUS = 1 << 19; + + /** + * Style constant for no redraw on resize behavior (value is 1<<20). + *

+ * This style stops the entire client area from being invalidated when the size + * of the Canvas changes. Specifically, when the size of the Canvas gets smaller, + * the DWT.Paint event is not sent. When it gets bigger, an DWT.Paint event is + * sent with a GC clipped to only the new areas to be painted. Without this + * style, the entire client area will be repainted. + *

Used By:

+ */ + public static const int NO_REDRAW_RESIZE = 1 << 20; + + /** + * Style constant for no paint event merging behavior (value is 1<<21). + *

Used By:

+ */ + public static const int NO_MERGE_PAINTS = 1 << 21; + + /** + * Style constant for preventing child radio group behavior (value is 1<<22). + *

Used By:

+ */ + public static const int NO_RADIO_GROUP = 1 << 22; + + /** + * Style constant for left to right orientation (value is 1<<25). + *

+ * When orientation is not explicitly specified, orientation is + * inherited. This means that children will be assigned the + * orientation of their parent. To override this behavior and + * force an orientation for a child, explicitly set the orientation + * of the child when that child is created. + *
Note that this is a HINT. + *

+ *

Used By:

+ * + * @since 2.1.2 + */ + public static const int LEFT_TO_RIGHT = 1 << 25; + + /** + * Style constant for right to left orientation (value is 1<<26). + *

+ * When orientation is not explicitly specified, orientation is + * inherited. This means that children will be assigned the + * orientation of their parent. To override this behavior and + * force an orientation for a child, explicitly set the orientation + * of the child when that child is created. + *
Note that this is a HINT. + *

+ *

Used By:

+ * + * @since 2.1.2 + */ + public static const int RIGHT_TO_LEFT = 1 << 26; + + /** + * Style constant to indicate coordinate mirroring (value is 1<<27). + *

Used By:

+ * + * @since 2.1.2 + */ + public static const int MIRRORED = 1 << 27; + + /** + * Style constant to allow embedding (value is 1<<24). + *

Used By:

+ * + * @since 3.0 + */ + public static const int EMBEDDED = 1 << 24; + + /** + * Style constant to allow virtual data (value is 1<<28). + *

Used By:

+ * + * @since 3.0 + */ + public static const int VIRTUAL = 1 << 28; + + /** + * Style constant to indicate double buffering (value is 1<<29). + *

Used By:

+ * + * @since 3.1 + */ + public static const int DOUBLE_BUFFERED = 1 << 29; + + /** + * Style constant for align up behavior (value is 1<<7, + * since align UP and align TOP are considered the same). + *

Used By:

+ */ + public static const int UP = 1 << 7; + + /** + * Style constant for align top behavior (value is 1<<7, + * since align UP and align TOP are considered the same). + *

Used By:

+ */ + public static const int TOP = UP; + + /** + * Style constant for align down behavior (value is 1<<10, + * since align DOWN and align BOTTOM are considered the same). + *

Used By:

+ */ + public static const int DOWN = 1 << 10; + + /** + * Style constant for align bottom behavior (value is 1<<10, + * since align DOWN and align BOTTOM are considered the same). + *

Used By:

+ */ + public static const int BOTTOM = DOWN; + + /** + * Style constant for leading alignment (value is 1<<14). + *

Used By:

+ * + * @since 2.1.2 + */ + public static const int LEAD = 1 << 14; + + /** + * Style constant for align left behavior (value is 1<<14). + * This is a synonym for LEAD (value is 1<<14). Newer + * applications should use LEAD instead of LEFT to make code more + * understandable on right-to-left platforms. + */ + public static const int LEFT = LEAD; + + /** + * Style constant for trailing alignment (value is 1<<17). + *

Used By:

+ * + * @since 2.1.2 + */ + public static const int TRAIL = 1 << 17; + + /** + * Style constant for align right behavior (value is 1<<17). + * This is a synonym for TRAIL (value is 1<<17). Newer + * applications should use TRAIL instead of RIGHT to make code more + * understandable on right-to-left platforms. + */ + public static const int RIGHT = TRAIL; + + /** + * Style constant for align center behavior (value is 1<<24). + *

Used By:

+ */ + public static const int CENTER = 1 << 24; + + /** + * Style constant for horizontal alignment or orientation behavior (value is 1<<8). + *

Used By:

+ */ + public static const int HORIZONTAL = 1 << 8; + + /** + * Style constant for vertical alignment or orientation behavior (value is 1<<9). + *

Used By:

+ */ + public static const int VERTICAL = 1 << 9; + + /** + * Style constant for date display (value is 1<<5). + *

Used By:

+ * + * @since 3.3 + */ + public static const int DATE = 1 << 5; + + /** + * Style constant for time display (value is 1<<7). + *

Used By:

+ * + * @since 3.3 + */ + public static const int TIME = 1 << 7; + + /** + * Style constant for calendar display (value is 1<<10). + *

Used By:

+ * + * @since 3.3 + */ + public static const int CALENDAR = 1 << 10; + + /** + * Style constant for short date/time format (value is 1<<15). + *

+ * A short date displays the month and year. + * A short time displays hours and minutes. + *
Note that this is a HINT. + *

+ *

Used By:

+ * + * @since 3.3 + */ + public static const int SHORT = 1 << 15; + + /** + * Style constant for medium date/time format (value is 1<<16). + *

+ * A medium date displays the day, month and year. + * A medium time displays hours, minutes, and seconds. + *
Note that this is a HINT. + *

+ *

Used By:

+ * + * @since 3.3 + */ + public static const int MEDIUM = 1 << 16; + + /** + * Style constant for long date/time format (value is 1<<28). + *

+ * A long date displays the day, month and year. + * A long time displays hours, minutes, and seconds. + * The day and month names may be displayed. + *
Note that this is a HINT. + *

+ *

Used By:

+ * + * @since 3.3 + */ + public static const int LONG = 1 << 28; + + /** + * Style constant specifying that a Browser should use a Mozilla GRE + * for rendering its content (value is 1<<15). + *

+ *

Used By:

+ * + * @since 3.3 + */ + public static const int MOZILLA = 1 << 15; + + /** + * Style constant for balloon behavior (value is 1<<12). + *

Used By:

+ * + * @since 3.2 + */ + public static const int BALLOON = 1 << 12; + + /** + * Style constant for vertical alignment or orientation behavior (value is 1). + *

Used By:

+ */ + public static const int BEGINNING = 1; + + /** + * Style constant for vertical alignment or orientation behavior (value is 4). + *

Used By:

+ */ + public static const int FILL = 4; + + /** + * Input Method Editor style constant for double byte + * input behavior (value is 1<<1). + */ + public static const int DBCS = 1 << 1; + + /** + * Input Method Editor style constant for alpha + * input behavior (value is 1<<2). + */ + public static const int ALPHA = 1 << 2; + + /** + * Input Method Editor style constant for native + * input behavior (value is 1<<3). + */ + public static const int NATIVE = 1 << 3; + + /** + * Input Method Editor style constant for phonetic + * input behavior (value is 1<<4). + */ + public static const int PHONETIC = 1 << 4; + + /** + * Input Method Editor style constant for romanicized + * input behavior (value is 1<<5). + */ + public static const int ROMAN = 1 << 5; + + /** + * ASCII character convenience constant for the backspace character + * (value is the char '\b'). + */ + public static const char BS = '\b'; + + /** + * ASCII character convenience constant for the carriage return character + * (value is the char '\r'). + */ + public static const char CR = '\r'; + + /** + * ASCII character convenience constant for the delete character + * (value is the char with value 127). + */ + public static const char DEL = 0x7F; + + /** + * ASCII character convenience constant for the escape character + * (value is the char with value 27). + */ + public static const char ESC = 0x1B; + + /** + * ASCII character convenience constant for the line feed character + * (value is the char '\n'). + */ + public static const char LF = '\n'; + + /** + * ASCII character convenience constant for the tab character + * (value is the char '\t'). + * + * @since 2.1 + */ + public static const char TAB = '\t'; + + /** + * keyboard and/or mouse event mask indicating that the ALT key + * was pushed on the keyboard when the event was generated + * (value is 1<<16). + */ + public static const int ALT = 1 << 16; + + /** + * Keyboard and/or mouse event mask indicating that the SHIFT key + * was pushed on the keyboard when the event was generated + * (value is 1<<17). + */ + public static const int SHIFT = 1 << 17; + + /** + * Keyboard and/or mouse event mask indicating that the CTRL key + * was pushed on the keyboard when the event was generated + * (value is 1<<18). + */ + public static const int CTRL = 1 << 18; + + /** + * Keyboard and/or mouse event mask indicating that the CTRL key + * was pushed on the keyboard when the event was generated. This + * is a synonym for CTRL (value is 1<<18). + */ + public static const int CONTROL = CTRL; + + /** + * Keyboard and/or mouse event mask indicating that the COMMAND key + * was pushed on the keyboard when the event was generated + * (value is 1<<22). + * + * @since 2.1 + */ + public static const int COMMAND = 1 << 22; + + /** + * Keyboard and/or mouse event mask indicating all possible + * keyboard modifiers. + * + * To allow for the future, this mask is intended to be used in + * place of code that references each individual keyboard mask. + * For example, the following expression will determine whether + * any modifier is pressed and will continue to work as new modifier + * masks are added. + * + * (stateMask & DWT.MODIFIER_MASK) !is 0. + * + * @since 2.1 + */ + public static const int MODIFIER_MASK; + + /** + * Keyboard and/or mouse event mask indicating that mouse button one + * was pushed when the event was generated. (value is 1<<19). + */ + public static const int BUTTON1 = 1 << 19; + + /** + * Keyboard and/or mouse event mask indicating that mouse button two + * was pushed when the event was generated. (value is 1<<20). + */ + public static const int BUTTON2 = 1 << 20; + + /** + * Keyboard and/or mouse event mask indicating that mouse button three + * was pushed when the event was generated. (value is 1<<21). + */ + public static const int BUTTON3 = 1 << 21; + + /** + * Keyboard and/or mouse event mask indicating that mouse button four + * was pushed when the event was generated. (value is 1<<23). + * + * @since 3.1 + */ + public static const int BUTTON4 = 1 << 23; + + /** + * Keyboard and/or mouse event mask indicating that mouse button five + * was pushed when the event was generated. (value is 1<<25). + * + * @since 3.1 + */ + public static const int BUTTON5 = 1 << 25; + + /** + * Keyboard and/or mouse event mask indicating all possible + * mouse buttons. + * + * To allow for the future, this mask is intended to be used + * in place of code that references each individual button mask. + * For example, the following expression will determine whether + * any button is pressed and will continue to work as new button + * masks are added. + * + * (stateMask & DWT.BUTTON_MASK) !is 0. + * + * @since 2.1 + */ + public static const int BUTTON_MASK; + + /** + * Keyboard and/or mouse event mask indicating that the MOD1 key + * was pushed on the keyboard when the event was generated. + * + * This is the primary keyboard modifier for the platform. + * + * @since 2.1 + */ + public static const int MOD1; + + /** + * Keyboard and/or mouse event mask indicating that the MOD2 key + * was pushed on the keyboard when the event was generated. + * + * This is the secondary keyboard modifier for the platform. + * + * @since 2.1 + */ + public static const int MOD2; + + /** + * Keyboard and/or mouse event mask indicating that the MOD3 key + * was pushed on the keyboard when the event was generated. + * + * @since 2.1 + */ + public static const int MOD3; + + /** + * Keyboard and/or mouse event mask indicating that the MOD4 key + * was pushed on the keyboard when the event was generated. + * + * @since 2.1 + */ + public static const int MOD4; + + /** + * Constants to indicate line scrolling (value is 1). + *

Used By:

+ * + * @since 3.1 + */ + public static const int SCROLL_LINE = 1; + + /** + * Constants to indicate page scrolling (value is 2). + *

Used By:

+ * + * @since 3.1 + */ + public static const int SCROLL_PAGE = 2; + + /** + * Accelerator constant used to differentiate a key code from a + * unicode character. + * + * If this bit is set, then the key stroke + * portion of an accelerator represents a key code. If this bit + * is not set, then the key stroke portion of an accelerator is + * a unicode character. + * + * The following expression is false: + * + * ((DWT.MOD1 | DWT.MOD2 | 'T') & DWT.KEYCODE_BIT) !is 0. + * + * The following expression is true: + * + * ((DWT.MOD3 | DWT.F2) & DWT.KEYCODE_BIT) !is 0. + * + * (value is (1<<24)) + * + * @since 2.1 + */ + public static const int KEYCODE_BIT = (1 << 24); + + /** + * Accelerator constant used to extract the key stroke portion of + * an accelerator. + * + * The key stroke may be a key code or a unicode + * value. If the key stroke is a key code KEYCODE_BIT + * will be set. + * + * @since 2.1 + */ + public static const int KEY_MASK = KEYCODE_BIT + 0xFFFF; + + /** + * Keyboard event constant representing the UP ARROW key + * (value is (1<<24)+1). + */ + public static const int ARROW_UP = KEYCODE_BIT + 1; + + /** + * Keyboard event constant representing the DOWN ARROW key + * (value is (1<<24)+2). + */ + public static const int ARROW_DOWN = KEYCODE_BIT + 2; + + /** + * Keyboard event constant representing the LEFT ARROW key + * (value is (1<<24)+3). + */ + public static const int ARROW_LEFT = KEYCODE_BIT + 3; + + /** + * Keyboard event constant representing the RIGHT ARROW key + * (value is (1<<24)+4). + */ + public static const int ARROW_RIGHT = KEYCODE_BIT + 4; + + /** + * Keyboard event constant representing the PAGE UP key + * (value is (1<<24)+5). + */ + public static const int PAGE_UP = KEYCODE_BIT + 5; + + /** + * Keyboard event constant representing the PAGE DOWN key + * (value is (1<<24)+6). + */ + public static const int PAGE_DOWN = KEYCODE_BIT + 6; + + /** + * Keyboard event constant representing the HOME key + * (value is (1<<24)+7). + */ + public static const int HOME = KEYCODE_BIT + 7; + + /** + * Keyboard event constant representing the END key + * (value is (1<<24)+8). + */ + public static const int END = KEYCODE_BIT + 8; + + /** + * Keyboard event constant representing the INSERT key + * (value is (1<<24)+9). + */ + public static const int INSERT = KEYCODE_BIT + 9; + + /** + * Keyboard event constant representing the F1 key + * (value is (1<<24)+10). + */ + public static const int F1 = KEYCODE_BIT + 10; + + /** + * Keyboard event constant representing the F2 key + * (value is (1<<24)+11). + */ + public static const int F2 = KEYCODE_BIT + 11; + + /** + * Keyboard event constant representing the F3 key + * (value is (1<<24)+12). + */ + public static const int F3 = KEYCODE_BIT + 12; + + /** + * Keyboard event constant representing the F4 key + * (value is (1<<24)+13). + */ + public static const int F4 = KEYCODE_BIT + 13; + + /** + * Keyboard event constant representing the F5 key + * (value is (1<<24)+14). + */ + public static const int F5 = KEYCODE_BIT + 14; + + /** + * Keyboard event constant representing the F6 key + * (value is (1<<24)+15). + */ + public static const int F6 = KEYCODE_BIT + 15; + + /** + * Keyboard event constant representing the F7 key + * (value is (1<<24)+16). + */ + public static const int F7 = KEYCODE_BIT + 16; + + /** + * Keyboard event constant representing the F8 key + * (value is (1<<24)+17). + */ + public static const int F8 = KEYCODE_BIT + 17; + + /** + * Keyboard event constant representing the F9 key + * (value is (1<<24)+18). + */ + public static const int F9 = KEYCODE_BIT + 18; + + /** + * Keyboard event constant representing the F10 key + * (value is (1<<24)+19). + */ + public static const int F10 = KEYCODE_BIT + 19; + + /** + * Keyboard event constant representing the F11 key + * (value is (1<<24)+20). + */ + public static const int F11 = KEYCODE_BIT + 20; + + /** + * Keyboard event constant representing the F12 key + * (value is (1<<24)+21). + */ + public static const int F12 = KEYCODE_BIT + 21; + + /** + * Keyboard event constant representing the F13 key + * (value is (1<<24)+22). + * + * @since 3.0 + */ + public static const int F13 = KEYCODE_BIT + 22; + + /** + * Keyboard event constant representing the F14 key + * (value is (1<<24)+23). + * + * @since 3.0 + */ + public static const int F14 = KEYCODE_BIT + 23; + + /** + * Keyboard event constant representing the F15 key + * (value is (1<<24)+24). + * + * @since 3.0 + */ + public static const int F15 = KEYCODE_BIT + 24; + + /** + * Keyboard event constant representing the numeric key + * pad multiply key (value is (1<<24)+42). + * + * @since 3.0 + */ + public static const int KEYPAD_MULTIPLY = KEYCODE_BIT + 42; + + /** + * Keyboard event constant representing the numeric key + * pad add key (value is (1<<24)+43). + * + * @since 3.0 + */ + public static const int KEYPAD_ADD = KEYCODE_BIT + 43; + + /** + * Keyboard event constant representing the numeric key + * pad subtract key (value is (1<<24)+45). + * + * @since 3.0 + */ + public static const int KEYPAD_SUBTRACT = KEYCODE_BIT + 45; + + /** + * Keyboard event constant representing the numeric key + * pad decimal key (value is (1<<24)+46). + * + * @since 3.0 + */ + public static const int KEYPAD_DECIMAL = KEYCODE_BIT + 46; + + /** + * Keyboard event constant representing the numeric key + * pad divide key (value is (1<<24)+47). + * + * @since 3.0 + */ + public static const int KEYPAD_DIVIDE = KEYCODE_BIT + 47; + + /** + * Keyboard event constant representing the numeric key + * pad zero key (value is (1<<24)+48). + * + * @since 3.0 + */ + public static const int KEYPAD_0 = KEYCODE_BIT + 48; + + /** + * Keyboard event constant representing the numeric key + * pad one key (value is (1<<24)+49). + * + * @since 3.0 + */ + public static const int KEYPAD_1 = KEYCODE_BIT + 49; + + /** + * Keyboard event constant representing the numeric key + * pad two key (value is (1<<24)+50). + * + * @since 3.0 + */ + public static const int KEYPAD_2 = KEYCODE_BIT + 50; + + /** + * Keyboard event constant representing the numeric key + * pad three key (value is (1<<24)+51). + * + * @since 3.0 + */ + public static const int KEYPAD_3 = KEYCODE_BIT + 51; + + /** + * Keyboard event constant representing the numeric key + * pad four key (value is (1<<24)+52). + * + * @since 3.0 + */ + public static const int KEYPAD_4 = KEYCODE_BIT + 52; + + /** + * Keyboard event constant representing the numeric key + * pad five key (value is (1<<24)+53). + * + * @since 3.0 + */ + public static const int KEYPAD_5 = KEYCODE_BIT + 53; + + /** + * Keyboard event constant representing the numeric key + * pad six key (value is (1<<24)+54). + * + * @since 3.0 + */ + public static const int KEYPAD_6 = KEYCODE_BIT + 54; + + /** + * Keyboard event constant representing the numeric key + * pad seven key (value is (1<<24)+55). + * + * @since 3.0 + */ + public static const int KEYPAD_7 = KEYCODE_BIT + 55; + + /** + * Keyboard event constant representing the numeric key + * pad eight key (value is (1<<24)+56). + * + * @since 3.0 + */ + public static const int KEYPAD_8 = KEYCODE_BIT + 56; + + /** + * Keyboard event constant representing the numeric key + * pad nine key (value is (1<<24)+57). + * + * @since 3.0 + */ + public static const int KEYPAD_9 = KEYCODE_BIT + 57; + + /** + * Keyboard event constant representing the numeric key + * pad equal key (value is (1<<24)+61). + * + * @since 3.0 + */ + public static const int KEYPAD_EQUAL = KEYCODE_BIT + 61; + + /** + * Keyboard event constant representing the numeric key + * pad enter key (value is (1<<24)+80). + * + * @since 3.0 + */ + public static const int KEYPAD_CR = KEYCODE_BIT + 80; + + /** + * Keyboard event constant representing the help + * key (value is (1<<24)+81). + * + * NOTE: The HELP key maps to the key labeled "help", + * not "F1". If your keyboard does not have a HELP key, + * you will never see this key press. To listen for + * help on a control, use DWT.Help. + * + * @since 3.0 + * + * @see DWT#Help + */ + public static const int HELP = KEYCODE_BIT + 81; + + /** + * Keyboard event constant representing the caps + * lock key (value is (1<<24)+82). + * + * @since 3.0 + */ + public static const int CAPS_LOCK = KEYCODE_BIT + 82; + + /** + * Keyboard event constant representing the num + * lock key (value is (1<<24)+83). + * + * @since 3.0 + */ + public static const int NUM_LOCK = KEYCODE_BIT + 83; + + /** + * Keyboard event constant representing the scroll + * lock key (value is (1<<24)+84). + * + * @since 3.0 + */ + public static const int SCROLL_LOCK = KEYCODE_BIT + 84; + + /** + * Keyboard event constant representing the pause + * key (value is (1<<24)+85). + * + * @since 3.0 + */ + public static const int PAUSE = KEYCODE_BIT + 85; + + /** + * Keyboard event constant representing the break + * key (value is (1<<24)+86). + * + * @since 3.0 + */ + public static const int BREAK = KEYCODE_BIT + 86; + + /** + * Keyboard event constant representing the print screen + * key (value is (1<<24)+87). + * + * @since 3.0 + */ + public static const int PRINT_SCREEN = KEYCODE_BIT + 87; + + /** + * The MessageBox style constant for error icon + * behavior (value is 1). + */ + public static const int ICON_ERROR = 1; + + /** + * The MessageBox style constant for information icon + * behavior (value is 1<<1). + */ + public static const int ICON_INFORMATION = 1 << 1; + + /** + * The MessageBox style constant for question icon + * behavior (value is 1<<2). + */ + public static const int ICON_QUESTION = 1 << 2; + + /** + * The MessageBox style constant for warning icon + * behavior (value is 1<<3). + */ + public static const int ICON_WARNING = 1 << 3; + + /** + * The MessageBox style constant for "working" icon + * behavior (value is 1<<4). + */ + public static const int ICON_WORKING = 1 << 4; + + /** + * The MessageBox style constant for an OK button; + * valid combinations are OK, OK|CANCEL + * (value is 1<<5). + */ + public static const int OK = 1 << 5; + + /** + * The MessageBox style constant for YES button; + * valid combinations are YES|NO, YES|NO|CANCEL + * (value is 1<<6). + */ + public static const int YES = 1 << 6; + + /** + * The MessageBox style constant for NO button; + * valid combinations are YES|NO, YES|NO|CANCEL + * (value is 1<<7). + */ + public static const int NO = 1 << 7; + + /** + * The MessageBox style constant for a CANCEL button; + * valid combinations are OK|CANCEL, YES|NO|CANCEL, RETRY|CANCEL + * (value is 1<<8). This style constant is also used with + * Text in combination with SEARCH. + * + *

Used By:

+ */ + public static const int CANCEL = 1 << 8; + + /** + * The MessageBox style constant for an ABORT button; + * the only valid combination is ABORT|RETRY|IGNORE + * (value is 1<<9). + */ + public static const int ABORT = 1 << 9; + + /** + * The MessageBox style constant for a RETRY button; + * valid combinations are ABORT|RETRY|IGNORE, RETRY|CANCEL + * (value is 1<<10). + */ + public static const int RETRY = 1 << 10; + + /** + * The MessageBox style constant for an IGNORE button; + * the only valid combination is ABORT|RETRY|IGNORE + * (value is 1<<11). + */ + public static const int IGNORE = 1 << 11; + + /** + * The FileDialog style constant for open file dialog behavior + * (value is 1<<12). + */ + public static const int OPEN = 1 << 12; + + /** + * The FileDialog style constant for save file dialog behavior + * (value is 1<<13). + */ + public static const int SAVE = 1 << 13; + + /** + * The Composite constant to indicate that + * an attribute (such as background) is not inherited + * by the children (value is 0). + * + * @since 3.2 + */ + public static const int INHERIT_NONE = 0; + + /** + * The Composite constant to indicate that + * an attribute (such as background) is inherited by + * children who choose this value as their "default" + * (value is 1). For example, a label child will + * typically choose to inherit the background color + * of a composite while a list or table will not. + * + * @since 3.2 + */ + public static const int INHERIT_DEFAULT = 1; + + /** + * The Composite constant to indicate that + * an attribute (such as background) is inherited by + * all children. + * + * @since 3.2 + */ + public static const int INHERIT_FORCE = 2; + + /** + * Default color white (value is 1). + */ + public static const int COLOR_WHITE = 1; + + /** + * Default color black (value is 2). + */ + public static const int COLOR_BLACK = 2; + + /** + * Default color red (value is 3). + */ + public static const int COLOR_RED = 3; + + /** + * Default color dark red (value is 4). + */ + public static const int COLOR_DARK_RED = 4; + + /** + * Default color green (value is 5). + */ + public static const int COLOR_GREEN = 5; + + /** + * Default color dark green (value is 6). + */ + public static const int COLOR_DARK_GREEN = 6; + + /** + * Default color yellow (value is 7). + */ + public static const int COLOR_YELLOW = 7; + + /** + * Default color dark yellow (value is 8). + */ + public static const int COLOR_DARK_YELLOW = 8; + + /** + * Default color blue (value is 9). + */ + public static const int COLOR_BLUE = 9; + + /** + * Default color dark blue (value is 10). + */ + public static const int COLOR_DARK_BLUE = 10; + + /** + * Default color magenta (value is 11). + */ + public static const int COLOR_MAGENTA = 11; + + /** + * Default color dark magenta (value is 12). + */ + public static const int COLOR_DARK_MAGENTA = 12; + + /** + * Default color cyan (value is 13). + */ + public static const int COLOR_CYAN = 13; + + /** + * Default color dark cyan (value is 14). + */ + public static const int COLOR_DARK_CYAN = 14; + + /** + * Default color gray (value is 15). + */ + public static const int COLOR_GRAY = 15; + + /** + * Default color dark gray (value is 16). + */ + public static const int COLOR_DARK_GRAY = 16; + + /* + * System Colors + * + * Dealing with system colors is an area where there are + * many platform differences. On some platforms, system + * colors can change dynamically while the program is + * running. On other platforms, system colors can be + * changed for all instances of a particular widget. + * Therefore, the only truly portable method to obtain + * a widget color query is to query the color from an + * instance of the widget. + * + * It is expected that the list of supported colors + * will grow over time. + */ + + /** + * System color used to paint dark shadow areas (value is 17). + */ + public static const int COLOR_WIDGET_DARK_SHADOW = 17; + + /** + * System color used to paint normal shadow areas (value is 18). + */ + public static const int COLOR_WIDGET_NORMAL_SHADOW = 18; + + /** + * System color used to paint light shadow areas (value is 19). + */ + public static const int COLOR_WIDGET_LIGHT_SHADOW = 19; + + /** + * System color used to paint highlight shadow areas (value is 20). + */ + public static const int COLOR_WIDGET_HIGHLIGHT_SHADOW = 20; + + /** + * System color used to paint foreground areas (value is 21). + */ + public static const int COLOR_WIDGET_FOREGROUND = 21; + + /** + * System color used to paint background areas (value is 22). + */ + public static const int COLOR_WIDGET_BACKGROUND = 22; + + /** + * System color used to paint border areas (value is 23). + */ + public static const int COLOR_WIDGET_BORDER = 23; + + /** + * System color used to paint list foreground areas (value is 24). + */ + public static const int COLOR_LIST_FOREGROUND = 24; + + /** + * System color used to paint list background areas (value is 25). + */ + public static const int COLOR_LIST_BACKGROUND = 25; + + /** + * System color used to paint list selection background areas (value is 26). + */ + public static const int COLOR_LIST_SELECTION = 26; + + /** + * System color used to paint list selected text (value is 27). + */ + public static const int COLOR_LIST_SELECTION_TEXT = 27; + + /** + * System color used to paint tooltip text (value is 28). + */ + public static const int COLOR_INFO_FOREGROUND = 28; + + /** + * System color used to paint tooltip background areas (value is 29). + */ + public static const int COLOR_INFO_BACKGROUND = 29; + + /** + * System color used to paint title text (value is 30). + */ + public static const int COLOR_TITLE_FOREGROUND = 30; + + /** + * System color used to paint title background areas (value is 31). + */ + public static const int COLOR_TITLE_BACKGROUND = 31; + + /** + * System color used to paint title background gradient (value is 32). + */ + public static const int COLOR_TITLE_BACKGROUND_GRADIENT = 32; + + /** + * System color used to paint inactive title text (value is 33). + */ + public static const int COLOR_TITLE_INACTIVE_FOREGROUND = 33; + + /** + * System color used to paint inactive title background areas (value is 34). + */ + public static const int COLOR_TITLE_INACTIVE_BACKGROUND = 34; + + /** + * System color used to paint inactive title background gradient (value is 35). + */ + public static const int COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = 35; + + /** + * Draw constant indicating whether the drawing operation + * should fill the background (value is 1<<0). + */ + public static const int DRAW_TRANSPARENT = 1 << 0; + + /** + * Draw constant indicating whether the string drawing operation + * should handle line-delimiters (value is 1<<1). + */ + public static const int DRAW_DELIMITER = 1 << 1; + + /** + * Draw constant indicating whether the string drawing operation + * should expand TAB characters (value is 1<<2). + */ + public static const int DRAW_TAB = 1 << 2; + + /** + * Draw constant indicating whether the string drawing operation + * should handle mnemonics (value is 1<<3). + */ + public static const int DRAW_MNEMONIC = 1 << 3; + + + /** + * Selection constant indicating that a line delimiter should be + * drawn (value is 1<<17). + * + *

Used By:

+ * + * @see #FULL_SELECTION + * @see #LAST_LINE_SELECTION + * + * @since 3.3 + */ + public static const int DELIMITER_SELECTION = 1 << 17; + + /** + * Selection constant indicating that the last line is selected + * to the end and should be drawn using either a line delimiter + * or full line selection (value is 1<<20). + * + *

Used By:

+ * + * @see #DELIMITER_SELECTION + * @see #FULL_SELECTION + * + * @since 3.3 + */ + public static const int LAST_LINE_SELECTION = 1 << 20; + + /** + * DWT error constant indicating that no error number was specified + * (value is 1). + */ + public static const int ERROR_UNSPECIFIED = 1; + + /** + * DWT error constant indicating that no more handles for an + * operating system resource are available + * (value is 2). + */ + public static const int ERROR_NO_HANDLES = 2; + + /** + * DWT error constant indicating that no more callback resources are available + * (value is 3). + */ + public static const int ERROR_NO_MORE_CALLBACKS = 3; + + /** + * DWT error constant indicating that a null argument was passed in + * (value is 4). + */ + public static const int ERROR_NULL_ARGUMENT = 4; + + /** + * DWT error constant indicating that an invalid argument was passed in + * (value is 5). + */ + public static const int ERROR_INVALID_ARGUMENT = 5; + + /** + * DWT error constant indicating that a value was found to be + * outside the allowable range + * (value is 6). + */ + public static const int ERROR_INVALID_RANGE = 6; + + /** + * DWT error constant indicating that a value which can not be + * zero was found to be + * (value is 7). + */ + public static const int ERROR_CANNOT_BE_ZERO = 7; + + /** + * DWT error constant indicating that the underlying operating + * system was unable to provide the value of an item + * (value is 8). + */ + public static const int ERROR_CANNOT_GET_ITEM = 8; + + /** + * DWT error constant indicating that the underlying operating + * system was unable to provide the selection + * (value is 9). + */ + public static const int ERROR_CANNOT_GET_SELECTION = 9; + + /** + * DWT error constant indicating that the matrix is not invertible + * (value is 10). + * + * @since 3.1 + */ + public static const int ERROR_CANNOT_INVERT_MATRIX = 10; + + /** + * DWT error constant indicating that the underlying operating + * system was unable to provide the height of an item + * (value is 11). + */ + public static const int ERROR_CANNOT_GET_ITEM_HEIGHT = 11; + + /** + * DWT error constant indicating that the underlying operating + * system was unable to provide the text of a widget + * (value is 12). + */ + public static const int ERROR_CANNOT_GET_TEXT = 12; + + /** + * DWT error constant indicating that the underlying operating + * system was unable to set the text of a widget + * (value is 13). + */ + public static const int ERROR_CANNOT_SET_TEXT = 13; + + /** + * DWT error constant indicating that the underlying operating + * system was unable to add an item + * (value is 14). + */ + public static const int ERROR_ITEM_NOT_ADDED = 14; + + /** + * DWT error constant indicating that the underlying operating + * system was unable to remove an item + * (value is 15). + */ + public static const int ERROR_ITEM_NOT_REMOVED = 15; + + /** + * DWT error constant indicating that the graphics library + * is not available + * (value is 16). + */ + public static const int ERROR_NO_GRAPHICS_LIBRARY = 16; + + /** + * DWT error constant indicating that a particular feature has + * not been implemented on this platform + * (value is 20). + */ + public static const int ERROR_NOT_IMPLEMENTED = 20; + + /** + * DWT error constant indicating that a menu which needed + * to have the drop down style had some other style instead + * (value is 21). + */ + public static const int ERROR_MENU_NOT_DROP_DOWN = 21; + + /** + * DWT error constant indicating that an attempt was made to + * invoke an DWT operation which can only be executed by the + * user-interface thread from some other thread + * (value is 22). + */ + public static const int ERROR_THREAD_INVALID_ACCESS = 22; + + /** + * DWT error constant indicating that an attempt was made to + * invoke an DWT operation using a widget which had already + * been disposed + * (value is 24). + */ + public static const int ERROR_WIDGET_DISPOSED = 24; + + /** + * DWT error constant indicating that a menu item which needed + * to have the cascade style had some other style instead + * (value is 27). + */ + public static const int ERROR_MENUITEM_NOT_CASCADE = 27; + + /** + * DWT error constant indicating that the underlying operating + * system was unable to set the selection of a widget + * (value is 28). + */ + public static const int ERROR_CANNOT_SET_SELECTION = 28; + + /** + * DWT error constant indicating that the underlying operating + * system was unable to set the menu + * (value is 29). + */ + public static const int ERROR_CANNOT_SET_MENU = 29; + + /** + * DWT error constant indicating that the underlying operating + * system was unable to set the enabled state + * (value is 30). + */ + public static const int ERROR_CANNOT_SET_ENABLED = 30; + + /** + * DWT error constant indicating that the underlying operating + * system was unable to provide enabled/disabled state information + * (value is 31). + */ + public static const int ERROR_CANNOT_GET_ENABLED = 31; + + /** + * DWT error constant indicating that a provided widget can + * not be used as a parent in the current operation + * (value is 32). + */ + public static const int ERROR_INVALID_PARENT = 32; + + /** + * DWT error constant indicating that a menu which needed + * to have the menu bar style had some other style instead + * (value is 33). + */ + public static const int ERROR_MENU_NOT_BAR = 33; + + /** + * DWT error constant indicating that the underlying operating + * system was unable to provide count information + * (value is 36). + */ + public static const int ERROR_CANNOT_GET_COUNT = 36; + + /** + * DWT error constant indicating that a menu which needed + * to have the pop up menu style had some other style instead + * (value is 37). + */ + public static const int ERROR_MENU_NOT_POP_UP = 37; + + /** + * DWT error constant indicating that a graphics operation + * was attempted with an image of an unsupported depth + * (value is 38). + */ + public static const int ERROR_UNSUPPORTED_DEPTH = 38; + + /** + * DWT error constant indicating that an input/output operation + * failed during the execution of an DWT operation + * (value is 39). + */ + public static const int ERROR_IO = 39; + + /** + * DWT error constant indicating that a graphics operation + * was attempted with an image having an invalid format + * (value is 40). + */ + public static const int ERROR_INVALID_IMAGE = 40; + + /** + * DWT error constant indicating that a graphics operation + * was attempted with an image having a valid but unsupported + * format + * (value is 42). + */ + public static const int ERROR_UNSUPPORTED_FORMAT = 42; + + /** + * DWT error constant indicating that an attempt was made + * to subclass an DWT widget class without implementing the + * checkSubclass() method + * (value is 43). + * + * For additional information see the comment in + * Widget.checkSubclass(). + * + * @see dwt.widgets.Widget#checkSubclass + */ + public static const int ERROR_INVALID_SUBCLASS = 43; + + /** + * DWT error constant indicating that an attempt was made to + * invoke an DWT operation using a graphics object which had + * already been disposed + * (value is 44). + */ + public static const int ERROR_GRAPHIC_DISPOSED = 44; + + /** + * DWT error constant indicating that an attempt was made to + * invoke an DWT operation using a device which had already + * been disposed + * (value is 45). + */ + public static const int ERROR_DEVICE_DISPOSED = 45; + + /** + * DWT error constant indicating that an exception happened + * when executing a runnable + * (value is 46). + */ + public static const int ERROR_FAILED_EXEC = 46; + + /** + * DWT error constant indicating that an unsatisfied link + * error occurred while attempting to load a library + * (value is 47). + * + * @since 3.1 + */ + public static const int ERROR_FAILED_LOAD_LIBRARY = 47; + + /** + * DWT error constant indicating that a font is not valid + * (value is 48). + * + * @since 3.1 + */ + public static const int ERROR_INVALID_FONT = 48; + + /** + * Constant indicating that an image or operation is of type bitmap (value is 0). + */ + public static const int BITMAP = 0; + + /** + * Constant indicating that an image or operation is of type icon (value is 1). + */ + public static const int ICON = 1; + + /** + * The Image constructor argument indicating that + * the new image should be a copy of the image provided as + * an argument (value is 0). + */ + public static const int IMAGE_COPY = 0; + + /** + * The Image constructor argument indicating that + * the new image should have the appearance of a "disabled" + * (using the platform's rules for how this should look) + * copy of the image provided as an argument (value is 1). + */ + public static const int IMAGE_DISABLE = 1; + + /** + * The Image constructor argument indicating that + * the new image should have the appearance of a "gray scaled" + * copy of the image provided as an argument (value is 2). + */ + public static const int IMAGE_GRAY = 2; + + /** + * The font style constant indicating a normal weight, non-italic font + * (value is 0). + */ + public static const int NORMAL = 0; + + /** + * The font style constant indicating a bold weight font + * (value is 1<<0). + */ + public static const int BOLD = 1 << 0; + + /** + * The font style constant indicating an italic font + * (value is 1<<1). + */ + public static const int ITALIC = 1 << 1; + + /** + * System arrow cursor (value is 0). + */ + public static const int CURSOR_ARROW = 0; + + /** + * System wait cursor (value is 1). + */ + public static const int CURSOR_WAIT = 1; + + /** + * System cross hair cursor (value is 2). + */ + public static const int CURSOR_CROSS = 2; + + /** + * System app startup cursor (value is 3). + */ + public static const int CURSOR_APPSTARTING = 3; + + /** + * System help cursor (value is 4). + */ + public static const int CURSOR_HELP = 4; + + /** + * System resize all directions cursor (value is 5). + */ + public static const int CURSOR_SIZEALL = 5; + + /** + * System resize north-east-south-west cursor (value is 6). + */ + public static const int CURSOR_SIZENESW = 6; + + /** + * System resize north-south cursor (value is 7). + */ + public static const int CURSOR_SIZENS = 7; + + /** + * System resize north-west-south-east cursor (value is 8). + */ + public static const int CURSOR_SIZENWSE = 8; + + /** + * System resize west-east cursor (value is 9). + */ + public static const int CURSOR_SIZEWE = 9; + + /** + * System resize north cursor (value is 10). + */ + public static const int CURSOR_SIZEN = 10; + + /** + * System resize south cursor (value is 11). + */ + public static const int CURSOR_SIZES = 11; + + /** + * System resize east cursor (value is 12). + */ + public static const int CURSOR_SIZEE = 12; + + /** + * System resize west cursor (value is 13). + */ + public static const int CURSOR_SIZEW = 13; + + /** + * System resize north-east cursor (value is 14). + */ + public static const int CURSOR_SIZENE = 14; + + /** + * System resize south-east cursor (value is 15). + */ + public static const int CURSOR_SIZESE = 15; + + /** + * System resize south-west cursor (value is 16). + */ + public static const int CURSOR_SIZESW = 16; + + /** + * System resize north-west cursor (value is 17). + */ + public static const int CURSOR_SIZENW = 17; + + /** + * System up arrow cursor (value is 18). + */ + public static const int CURSOR_UPARROW = 18; + + /** + * System i-beam cursor (value is 19). + */ + public static const int CURSOR_IBEAM = 19; + + /** + * System "not allowed" cursor (value is 20). + */ + public static const int CURSOR_NO = 20; + + /** + * System hand cursor (value is 21). + */ + public static const int CURSOR_HAND = 21; + + /** + * Line drawing style for flat end caps (value is 1). + * + * @see dwt.graphics.GC#setLineCap(int) + * @see dwt.graphics.GC#getLineCap() + * + * @since 3.1 + */ + public static const int CAP_FLAT = 1; + + /** + * Line drawing style for rounded end caps (value is 2). + * + * @see dwt.graphics.GC#setLineCap(int) + * @see dwt.graphics.GC#getLineCap() + * + * @since 3.1 + */ + public static const int CAP_ROUND = 2; + + /** + * Line drawing style for square end caps (value is 3). + * + * @see dwt.graphics.GC#setLineCap(int) + * @see dwt.graphics.GC#getLineCap() + * + * @since 3.1 + */ + public static const int CAP_SQUARE = 3; + + /** + * Line drawing style for miter joins (value is 1). + * + * @see dwt.graphics.GC#setLineJoin(int) + * @see dwt.graphics.GC#getLineJoin() + * + * @since 3.1 + */ + public static const int JOIN_MITER = 1; + + /** + * Line drawing style for rounded joins (value is 2). + * + * @see dwt.graphics.GC#setLineJoin(int) + * @see dwt.graphics.GC#getLineJoin() + * + * @since 3.1 + */ + public static const int JOIN_ROUND = 2; + + /** + * Line drawing style for bevel joins (value is 3). + * + * @see dwt.graphics.GC#setLineJoin(int) + * @see dwt.graphics.GC#getLineJoin() + * + * @since 3.1 + */ + public static const int JOIN_BEVEL = 3; + + /** + * Line drawing style for solid lines (value is 1). + */ + public static const int LINE_SOLID = 1; + + /** + * Line drawing style for dashed lines (value is 2). + */ + public static const int LINE_DASH = 2; + + /** + * Line drawing style for dotted lines (value is 3). + */ + public static const int LINE_DOT = 3; + + /** + * Line drawing style for alternating dash-dot lines (value is 4). + */ + public static const int LINE_DASHDOT = 4; + + /** + * Line drawing style for dash-dot-dot lines (value is 5). + */ + public static const int LINE_DASHDOTDOT = 5; + + /** + * Line drawing style for custom dashed lines (value is 6). + * + * @see dwt.graphics.GC#setLineDash(int[]) + * @see dwt.graphics.GC#getLineDash() + * + * @since 3.1 + */ + public static const int LINE_CUSTOM = 6; + + /** + * Path constant that represents a "move to" operation (value is 1). + * + * @since 3.1 + */ + public static const int PATH_MOVE_TO = 1; + + /** + * Path constant that represents a "line to" operation (value is 2). + * + * @since 3.1 + */ + public static const int PATH_LINE_TO = 2; + + /** + * Path constant that represents a "quadratic curve to" operation (value is 3). + * + * @since 3.1 + */ + public static const int PATH_QUAD_TO = 3; + + /** + * Path constant that represents a "cubic curve to" operation (value is 4). + * + * @since 3.1 + */ + public static const int PATH_CUBIC_TO = 4; + + /** + * Path constant that represents a "close" operation (value is 5). + * + * @since 3.1 + */ + public static const int PATH_CLOSE = 5; + + /** + * Even odd rule for filling operations (value is 1). + * + * @since 3.1 + */ + public static const int FILL_EVEN_ODD = 1; + + /** + * Winding rule for filling operations (value is 2). + * + * @since 3.1 + */ + public static const int FILL_WINDING = 2; + + /** + * Image format constant indicating an unknown image type (value is -1). + */ + public static const int IMAGE_UNDEFINED = -1; + + /** + * Image format constant indicating a Windows BMP format image (value is 0). + */ + public static const int IMAGE_BMP = 0; + + /** + * Image format constant indicating a run-length encoded + * Windows BMP format image (value is 1). + */ + public static const int IMAGE_BMP_RLE = 1; + + /** + * Image format constant indicating a GIF format image (value is 2). + */ + public static const int IMAGE_GIF = 2; + + /** + * Image format constant indicating a ICO format image (value is 3). + */ + public static const int IMAGE_ICO = 3; + + /** + * Image format constant indicating a JPEG format image (value is 4). + */ + public static const int IMAGE_JPEG = 4; + + /** + * Image format constant indicating a PNG format image (value is 5). + */ + public static const int IMAGE_PNG = 5; + + /** + * Image format constant indicating a TIFF format image (value is 6). + */ + public static const int IMAGE_TIFF = 6; + + /** + * Image format constant indicating an OS/2 BMP format image (value is 7). + */ + public static const int IMAGE_OS2_BMP = 7; + + /** + * GIF image disposal method constants indicating that the + * disposal method is unspecified (value is 0). + */ + public static const int DM_UNSPECIFIED = 0x0; + + /** + * GIF image disposal method constants indicating that the + * disposal method is to do nothing; that is, to leave the + * previous image in place (value is 1). + */ + public static const int DM_FILL_NONE = 0x1; + + /** + * GIF image disposal method constants indicating that the + * the previous images should be covered with the background + * color before displaying the next image (value is 2). + */ + public static const int DM_FILL_BACKGROUND = 0x2; + + /** + * GIF image disposal method constants indicating that the + * disposal method is to restore the previous picture + * (value is 3). + */ + public static const int DM_FILL_PREVIOUS = 0x3; + + /** + * Image transparency constant indicating that the image + * contains no transparency information (value is 0). + */ + public static const int TRANSPARENCY_NONE = 0x0; + + /** + * Image transparency constant indicating that the image + * contains alpha transparency information (value is 1<<0). + */ + public static const int TRANSPARENCY_ALPHA = 1 << 0; + + /** + * Image transparency constant indicating that the image + * contains a transparency mask (value is 1<<1). + */ + public static const int TRANSPARENCY_MASK = 1 << 1; + + /** + * Image transparency constant indicating that the image + * contains a transparent pixel (value is 1<<2). + */ + public static const int TRANSPARENCY_PIXEL = 1 << 2; + + /** + * The character movement type (value is 1<<0). + * This constant is used to move a text offset over a character. + * + * @see dwt.graphics.TextLayout#getNextOffset(int, int) + * @see dwt.graphics.TextLayout#getPreviousOffset(int, int) + * + * @since 3.0 + */ + public static const int MOVEMENT_CHAR = 1 << 0; + + /** + * The cluster movement type (value is 1<<1). + * This constant is used to move a text offset over a cluster. + * A cluster groups one or more characters. A cluster is + * undivisible, this means that a caret offset can not be placed in the + * middle of a cluster. + * + * @see dwt.graphics.TextLayout#getNextOffset(int, int) + * @see dwt.graphics.TextLayout#getPreviousOffset(int, int) + * + * @since 3.0 + */ + public static const int MOVEMENT_CLUSTER = 1 << 1; + + /** + * The word movement type (value is 1<<2). + * This constant is used to move a text offset over a word. + * The behavior of this constant depends on the platform and on the + * direction of the movement. For example, on Windows the stop is + * always at the start of the word. On GTK and Mac the stop is at the end + * of the word if the direction is next and at the start of the word if the + * direction is previous. + * + * @see dwt.graphics.TextLayout#getNextOffset(int, int) + * @see dwt.graphics.TextLayout#getPreviousOffset(int, int) + * + * @since 3.0 + */ + public static const int MOVEMENT_WORD = 1 << 2; + + /** + * The word end movement type (value is 1<<3). + * This constant is used to move a text offset to the next or previous + * word end. The behavior of this constant does not depend on the platform. + * + * + * @see dwt.graphics.TextLayout#getNextOffset(int, int) + * @see dwt.graphics.TextLayout#getPreviousOffset(int, int) + * + * @since 3.3 + */ + public static const int MOVEMENT_WORD_END = 1 << 3; + + /** + * The word start movement type (value is 1<<4). + * This constant is used to move a text offset to the next or previous + * word start. The behavior of this constant does not depend on the platform. + * + * @see dwt.graphics.TextLayout#getNextOffset(int, int) + * @see dwt.graphics.TextLayout#getPreviousOffset(int, int) + * + * @since 3.3 + */ + public static const int MOVEMENT_WORD_START = 1 << 4; + + +/** + * Answers a concise, human readable description of the error code. + * + * @param code the DWT error code. + * @return a description of the error code. + * + * @see DWT + */ +static char[] findErrorText (int code) { + switch (code) { + case ERROR_UNSPECIFIED: return "Unspecified error"; //$NON-NLS-1$ + case ERROR_NO_HANDLES: return "No more handles"; //$NON-NLS-1$ + case ERROR_NO_MORE_CALLBACKS: return "No more callbacks"; //$NON-NLS-1$ + case ERROR_NULL_ARGUMENT: return "Argument cannot be null"; //$NON-NLS-1$ + case ERROR_INVALID_ARGUMENT: return "Argument not valid"; //$NON-NLS-1$ + case ERROR_INVALID_RANGE: return "Index out of bounds"; //$NON-NLS-1$ + case ERROR_CANNOT_BE_ZERO: return "Argument cannot be zero"; //$NON-NLS-1$ + case ERROR_CANNOT_GET_ITEM: return "Cannot get item"; //$NON-NLS-1$ + case ERROR_CANNOT_GET_SELECTION: return "Cannot get selection"; //$NON-NLS-1$ + case ERROR_CANNOT_GET_ITEM_HEIGHT: return "Cannot get item height"; //$NON-NLS-1$ + case ERROR_CANNOT_GET_TEXT: return "Cannot get text"; //$NON-NLS-1$ + case ERROR_CANNOT_SET_TEXT: return "Cannot set text"; //$NON-NLS-1$ + case ERROR_ITEM_NOT_ADDED: return "Item not added"; //$NON-NLS-1$ + case ERROR_ITEM_NOT_REMOVED: return "Item not removed"; //$NON-NLS-1$ + case ERROR_NOT_IMPLEMENTED: return "Not implemented"; //$NON-NLS-1$ + case ERROR_MENU_NOT_DROP_DOWN: return "Menu must be a drop down"; //$NON-NLS-1$ + case ERROR_THREAD_INVALID_ACCESS: return "Invalid thread access"; //$NON-NLS-1$ + case ERROR_WIDGET_DISPOSED: return "Widget is disposed"; //$NON-NLS-1$ + case ERROR_MENUITEM_NOT_CASCADE: return "Menu item is not a CASCADE"; //$NON-NLS-1$ + case ERROR_CANNOT_SET_SELECTION: return "Cannot set selection"; //$NON-NLS-1$ + case ERROR_CANNOT_SET_MENU: return "Cannot set menu"; //$NON-NLS-1$ + case ERROR_CANNOT_SET_ENABLED: return "Cannot set the enabled state"; //$NON-NLS-1$ + case ERROR_CANNOT_GET_ENABLED: return "Cannot get the enabled state"; //$NON-NLS-1$ + case ERROR_INVALID_PARENT: return "Widget has the wrong parent"; //$NON-NLS-1$ + case ERROR_MENU_NOT_BAR: return "Menu is not a BAR"; //$NON-NLS-1$ + case ERROR_CANNOT_GET_COUNT: return "Cannot get count"; //$NON-NLS-1$ + case ERROR_MENU_NOT_POP_UP: return "Menu is not a POP_UP"; //$NON-NLS-1$ + case ERROR_UNSUPPORTED_DEPTH: return "Unsupported color depth"; //$NON-NLS-1$ + case ERROR_IO: return "i/o error"; //$NON-NLS-1$ + case ERROR_INVALID_IMAGE: return "Invalid image"; //$NON-NLS-1$ + case ERROR_UNSUPPORTED_FORMAT: return "Unsupported or unrecognized format"; //$NON-NLS-1$ + case ERROR_INVALID_SUBCLASS: return "Subclassing not allowed"; //$NON-NLS-1$ + case ERROR_GRAPHIC_DISPOSED: return "Graphic is disposed"; //$NON-NLS-1$ + case ERROR_DEVICE_DISPOSED: return "Device is disposed"; //$NON-NLS-1$ + case ERROR_FAILED_EXEC: return "Failed to execute runnable"; //$NON-NLS-1$ + case ERROR_FAILED_LOAD_LIBRARY: return "Unable to load library"; //$NON-NLS-1$ + case ERROR_CANNOT_INVERT_MATRIX: return "Cannot invert matrix"; //$NON-NLS-1$ + case ERROR_NO_GRAPHICS_LIBRARY: return "Unable to load graphics library"; //$NON-NLS-1$ + case ERROR_INVALID_FONT: return "Font not valid"; //$NON-NLS-1$ + default: + } + return "Unknown error"; //$NON-NLS-1$ +} + +/** + * Returns the NLS'ed message for the given argument. + * + * @param key the key to look up + * @return the message for the given key + * + * @exception IllegalArgumentException + */ +public static char[] getMessage(char[] key) { + return Compatibility.getMessage(key); +} + +/** + * Returns the DWT platform name. + * Examples: "win32", "motif", "gtk", "photon", "carbon" + * + * @return the DWT platform name + */ +public static char[] getPlatform () { + return Platform.PLATFORM; +} + +/** + * Returns the DWT version number as an integer. + * Example: "SWT051" is 51 + * + * @return the DWT version number + */ +public static int getVersion () { + return Library.SWT_VERSION; +} + +/** + * Throws an appropriate exception based on the passed in error code. + * + * @param code the DWT error code + */ +public static void error (int code) { + error (code, null); +} + +/** + * Throws an appropriate exception based on the passed in error code. + * The throwable argument should be either null, or the + * throwable which caused DWT to throw an exception. + *

+ * In DWT, errors are reported by throwing one of three exceptions: + *

+ *
java.lang.IllegalArgumentException
+ *
thrown whenever one of the API methods is invoked with an illegal argument
+ *
org.eclipse.swt.DWTException (extends java.lang.RuntimeException)
+ *
thrown whenever a recoverable error happens internally in DWT
+ *
org.eclipse.swt.DWTError (extends java.lang.Error)
+ *
thrown whenever a non-recoverable error happens internally in DWT
+ *
+ * This method provides the logic which maps between error codes + * and one of the above exceptions. + *

+ * + * @param code the DWT error code. + * @param throwable the exception which caused the error to occur. + * + * @see DWTError + * @see DWTException + * @see IllegalArgumentException + */ +public static void error (int code, TracedException throwable) { + error (code, throwable, null); +} + +/** + * Throws an appropriate exception based on the passed in error code. + * The throwable argument should be either null, or the + * throwable which caused DWT to throw an exception. + *

+ * In DWT, errors are reported by throwing one of three exceptions: + *

+ *
java.lang.IllegalArgumentException
+ *
thrown whenever one of the API methods is invoked with an illegal argument
+ *
org.eclipse.swt.DWTException (extends java.lang.RuntimeException)
+ *
thrown whenever a recoverable error happens internally in DWT
+ *
org.eclipse.swt.DWTError (extends java.lang.Error)
+ *
thrown whenever a non-recoverable error happens internally in DWT
+ *
+ * This method provides the logic which maps between error codes + * and one of the above exceptions. + *

+ * + * @param code the DWT error code. + * @param throwable the exception which caused the error to occur. + * @param detail more information about error. + * + * @see DWTError + * @see DWTException + * @see IllegalArgumentException + * + * @since 3.0 + */ +public static void error (int code, TracedException throwable, char[] detail) { + + /* + * This code prevents the creation of "chains" of SWTErrors and + * SWTExceptions which in turn contain other SWTErrors and + * SWTExceptions as their throwable. This can occur when low level + * code throws an exception past a point where a higher layer is + * being "safe" and catching all exceptions. (Note that, this is + * _a_bad_thing_ which we always try to avoid.) + * + * On the theory that the low level code is closest to the + * original problem, we simply re-throw the original exception here. + * + * NOTE: Exceptions thrown in syncExec and asyncExec must be + * wrapped. + */ + if (code !is DWT.ERROR_FAILED_EXEC) { + if (auto t = cast(DWTError)throwable ) throw t; + if (auto t = cast(DWTException)throwable ) throw t; + } + + char[] message = findErrorText (code); + if (detail != null) message ~= detail; + switch (code) { + + /* Illegal Arguments (non-fatal) */ + case ERROR_NULL_ARGUMENT: + case ERROR_CANNOT_BE_ZERO: + case ERROR_INVALID_ARGUMENT: + case ERROR_MENU_NOT_BAR: + case ERROR_MENU_NOT_DROP_DOWN: + case ERROR_MENU_NOT_POP_UP: + case ERROR_MENUITEM_NOT_CASCADE: + case ERROR_INVALID_PARENT: + case ERROR_INVALID_RANGE: { + throw new IllegalArgumentException (message); + } + + /* DWT Exceptions (non-fatal) */ + case ERROR_INVALID_SUBCLASS: + case ERROR_THREAD_INVALID_ACCESS: + case ERROR_WIDGET_DISPOSED: + case ERROR_GRAPHIC_DISPOSED: + case ERROR_DEVICE_DISPOSED: + case ERROR_INVALID_IMAGE: + case ERROR_UNSUPPORTED_DEPTH: + case ERROR_UNSUPPORTED_FORMAT: + case ERROR_FAILED_EXEC: + case ERROR_CANNOT_INVERT_MATRIX: + case ERROR_NO_GRAPHICS_LIBRARY: + case ERROR_IO: { + auto exception = new DWTException (code, message); + exception.throwable = throwable; + throw exception; + } + + /* Operation System Errors (fatal, may occur only on some platforms) */ + case ERROR_CANNOT_GET_COUNT: + case ERROR_CANNOT_GET_ENABLED: + case ERROR_CANNOT_GET_ITEM: + case ERROR_CANNOT_GET_ITEM_HEIGHT: + case ERROR_CANNOT_GET_SELECTION: + case ERROR_CANNOT_GET_TEXT: + case ERROR_CANNOT_SET_ENABLED: + case ERROR_CANNOT_SET_MENU: + case ERROR_CANNOT_SET_SELECTION: + case ERROR_CANNOT_SET_TEXT: + case ERROR_ITEM_NOT_ADDED: + case ERROR_ITEM_NOT_REMOVED: + case ERROR_NO_HANDLES: + //FALL THROUGH + + /* DWT Errors (fatal, may occur only on some platforms) */ + case ERROR_FAILED_LOAD_LIBRARY: + case ERROR_NO_MORE_CALLBACKS: + case ERROR_NOT_IMPLEMENTED: + case ERROR_UNSPECIFIED: { + auto error = new DWTError (code, message); + error.throwable = throwable; + throw error; + } + default: + } + + /* Unknown/Undefined Error */ + DWTError error = new DWTError (code, message); + error.throwable = throwable; + throw error; +} + +/+ +static { + /* + * These values represent bit masks that may need to + * expand in the future. Therefore they are not initialized + * in the declaration to stop the compiler from inlining. + */ + BUTTON_MASK = BUTTON1 | BUTTON2 | BUTTON3 | BUTTON4 | BUTTON5; + MODIFIER_MASK = ALT | SHIFT | CTRL | COMMAND; + + /* + * These values can be different on different platforms. + * Therefore they are not initialized in the declaration + * to stop the compiler from inlining. + */ + char[] platform = getPlatform (); + if ("carbon".equals (platform)) { //$NON-NLS-1$ + MOD1 = COMMAND; + MOD2 = SHIFT; + MOD3 = ALT; + MOD4 = CONTROL; + } else { + MOD1 = CONTROL; + MOD2 = SHIFT; + MOD3 = ALT; + MOD4 = 0; + } +} ++/ + +} diff -r 000000000000 -r 5406a8f6526d dwt/DWTError.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/DWTError.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,155 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.DWTError; + +import dwt.DWT; + +import tango.core.Exception; +import tango.io.Stdout; + +/** + * This error is thrown whenever an unrecoverable error + * occurs internally in DWT. The message text and error code + * provide a further description of the problem. The exception + * has a throwable field which holds the underlying + * throwable that caused the problem (if this information is + * available (i.e. it may be null)). + *

+ * SWTErrors are thrown when something fails internally which + * either leaves DWT in an unknown state (eg. the o/s call to + * remove an item from a list returns an error code) or when DWT + * is left in a known-to-be-unrecoverable state (eg. it runs out + * of callback resources). SWTErrors should not occur in typical + * programs, although "high reliability" applications should + * still catch them. + *

+ * This class also provides support methods used by DWT to match + * error codes to the appropriate exception class (DWTError, + * DWTException, or IllegalArgumentException) and to provide + * human readable strings for DWT error codes. + *

+ * + * @see DWTException + * @see DWT#error(int) + */ + +public class DWTError : PlatformException { + /** + * The DWT error code, one of DWT.ERROR_*. + */ + public int code; + + /** + * The underlying throwable that caused the problem, + * or null if this information is not available. + */ + public TracedException throwable; + + //static final long serialVersionUID = 3833467327105808433L; + +/** + * Constructs a new instance of this class with its + * stack trace filled in. The error code is set to an + * unspecified value. + */ +public this () { + this (DWT.ERROR_UNSPECIFIED); +} + +/** + * Constructs a new instance of this class with its + * stack trace and message filled in. The error code is + * set to an unspecified value. Specifying null + * as the message is equivalent to specifying an empty string. + * + * @param message the detail message for the exception + */ +public this (String message) { + this (DWT.ERROR_UNSPECIFIED, message); +} + +/** + * Constructs a new instance of this class with its + * stack trace and error code filled in. + * + * @param code the DWT error code + */ +public this (int code) { + this (code, DWT.findErrorText (code)); +} + +/** + * Constructs a new instance of this class with its + * stack trace, error code and message filled in. + * Specifying null as the message is + * equivalent to specifying an empty string. + * + * @param code the DWT error code + * @param message the detail message for the exception + */ +public this (int code, char[] message) { + super (message); + this.code = code; +} + +/** + * Returns the underlying throwable that caused the problem, + * or null if this information is not available. + *

+ * NOTE: This method overrides Throwable.getCause() that was + * added to JDK1.4. It is necessary to override this method + * in order for inherited printStackTrace() methods to work. + *

+ * @return the underlying throwable + * + * @since 3.1 + */ +public Exception getCause() { + return throwable; +} + +/** + * Returns the string describing this DWTError object. + *

+ * It is combined with the message string of the Throwable + * which caused this DWTError (if this information is available). + *

+ * @return the error message string of this DWTError object + */ +public char[] getMessage () { + if (throwable is null) + return super.toString (); + return super.toString () ~ " (" ~ throwable.toString () ~ ")"; //$NON-NLS-1$ //$NON-NLS-2$ +} + +/** + * Outputs a printable representation of this error's + * stack trace on the standard error stream. + *

+ * Note: printStackTrace(PrintStream) and printStackTrace(PrintWriter) + * are not provided in order to maintain compatibility with CLDC. + *

+ */ +public void printStackTrace () { + Stderr.formatln( "stacktrace follows (if feature compiled in)" ); + foreach( msg; this ){ + Stderr.formatln( "{}", msg ); + } + if ( throwable !is null) { + Stderr.formatln ("*** Stack trace of contained error ***"); //$NON-NLS-1$ + foreach( msg; throwable ){ + Stderr.formatln( "{}", msg ); + } + } + +} diff -r 000000000000 -r 5406a8f6526d dwt/DWTException.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/DWTException.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,147 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.DWTException; + +import dwt.DWT; + +import tango.core.Exception; +import tango.io.Stdout; + +/** + * This runtime exception is thrown whenever a recoverable error + * occurs internally in DWT. The message text and error code + * provide a further description of the problem. The exception + * has a throwable field which holds the underlying + * exception that caused the problem (if this information is + * available (i.e. it may be null)). + *

+ * SWTExceptions are thrown when something fails internally, + * but DWT is left in a known stable state (eg. a widget call + * was made from a non-u/i thread, or there is failure while + * reading an Image because the source file was corrupt). + *

+ * + * @see DWTError + */ + +public class DWTException : TracedException { + /** + * The DWT error code, one of DWT.ERROR_*. + */ + public int code; + + /** + * The underlying throwable that caused the problem, + * or null if this information is not available. + */ + public TracedException throwable; + + //static final long serialVersionUID = 3257282552304842547L; + +/** + * Constructs a new instance of this class with its + * stack trace filled in. The error code is set to an + * unspecified value. + */ +public this () { + this (DWT.ERROR_UNSPECIFIED); +} + +/** + * Constructs a new instance of this class with its + * stack trace and message filled in. The error code is + * set to an unspecified value. Specifying null + * as the message is equivalent to specifying an empty string. + * + * @param message the detail message for the exception + */ +public this (char[] message) { + this (DWT.ERROR_UNSPECIFIED, message); +} + +/** + * Constructs a new instance of this class with its + * stack trace and error code filled in. + * + * @param code the DWT error code + */ +public this (int code) { + this (code, DWT.findErrorText (code)); +} + +/** + * Constructs a new instance of this class with its + * stack trace, error code and message filled in. + * Specifying null as the message is + * equivalent to specifying an empty string. + * + * @param code the DWT error code + * @param message the detail message for the exception + */ +public this (int code, char[] message) { + super (message); + this.code = code; +} + +/** + * Returns the underlying throwable that caused the problem, + * or null if this information is not available. + *

+ * NOTE: This method overrides Throwable.getCause() that was + * added to JDK1.4. It is necessary to override this method + * in order for inherited printStackTrace() methods to work. + *

+ * @return the underlying throwable + * + * @since 3.1 + */ +public TracedException getCause() { + return throwable; +} + +/** + * Returns the string describing this DWTException object. + *

+ * It is combined with the message string of the Throwable + * which caused this DWTException (if this information is available). + *

+ * @return the error message string of this DWTException object + */ +public char[] getMessage () { + if (throwable is null) + return super.toString (); + return super.toString () ~ " (" ~ throwable.toString () ~ ")"; //$NON-NLS-1$ //$NON-NLS-2$ +} + +/** + * Outputs a printable representation of this exception's + * stack trace on the standard error stream. + *

+ * Note: printStackTrace(PrintStream) and printStackTrace(PrintWriter) + * are not provided in order to maintain compatibility with CLDC. + *

+ */ +public void printStackTrace () { + Stderr.formatln( "stacktrace follows (if feature compiled in)" ); + foreach( msg; this ){ + Stderr.formatln( "{}", msg ); + } + if ( throwable !is null) { + Stderr.formatln ("*** Stack trace of contained exception ***"); //$NON-NLS-1$ + foreach( msg; throwable ){ + Stderr.formatln( "{}", msg ); + } + } +} + + diff -r 000000000000 -r 5406a8f6526d dwt/dwthelper/BufferedInputStream.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/dwthelper/BufferedInputStream.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,107 @@ +/** + * Authors: Frank Benoit + */ +module dwt.dwthelper.BufferedInputStream; + +import dwt.dwthelper.InputStream; +import dwt.dwthelper.utils; + +import tango.core.Exception; + +public class BufferedInputStream : dwt.dwthelper.InputStream.InputStream { + + alias dwt.dwthelper.InputStream.InputStream.read read; + + private const int defaultSize = 8192; + protected byte[] buf; + protected int count = 0; /// The index one greater than the index of the last valid byte in the buffer. + protected int pos = 0; /// The current position in the buffer. + protected int markpos = (-1); + protected int marklimit; + dwt.dwthelper.InputStream.InputStream istr; + + public this ( dwt.dwthelper.InputStream.InputStream istr ){ + this( istr, defaultSize ); + } + + public this ( dwt.dwthelper.InputStream.InputStream istr, int size ){ + this.istr = istr; + if( size <= 0 ){ + throw new IllegalArgumentException( "Buffer size <= 0" ); + } + buf.length = size; + } + + private InputStream getAndCheckIstr(){ + InputStream res = istr; + if( res is null ){ + throw new IOException( "Stream closed" ); + } + return res; + } + private byte[] getAndCheckBuf(){ + byte[] res = buf; + if( res is null ){ + throw new IOException( "Stream closed" ); + } + return res; + } + private void fill(){ + assert( pos == count ); + pos = 0; + count = 0; + int count = getAndCheckIstr().read( buf ); + if( count < 0 ){ + count = 0; + istr = null; + } + } + public synchronized int read(){ + if( pos >= count ){ + fill(); + if( pos >= count ){ + return -1; + } + } + return getAndCheckBuf()[pos++] & 0xFF; + } + + public synchronized int read( byte[] b, int off, int len ){ + return super.read( b, off, len ); + } + + public synchronized long skip( long n ){ + return this.istr.skip(n); + } + + public synchronized int available(){ + int istr_avail = 0; + if( istr !is null ){ + istr_avail = istr.available(); + } + return istr_avail + (count - pos); + } + + public synchronized void mark( int readlimit ){ + implMissing( __FILE__, __LINE__ ); + this.istr.mark( readlimit ); + } + + public synchronized void reset(){ + implMissing( __FILE__, __LINE__ ); + this.istr.reset(); + } + + public bool markSupported(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + public void close(){ + this.istr.close(); + } + + +} + + diff -r 000000000000 -r 5406a8f6526d dwt/dwthelper/ByteArrayOutputStream.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/dwthelper/ByteArrayOutputStream.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,69 @@ +/** + * Authors: Frank Benoit + */ +module dwt.dwthelper.ByteArrayOutputStream; + +public import dwt.dwthelper.OutputStream; +import dwt.dwthelper.utils; + +public class ByteArrayOutputStream : dwt.dwthelper.OutputStream.OutputStream { + + alias dwt.dwthelper.OutputStream.OutputStream.write write; + + protected byte[] buf; + protected int count; + public this (){ + } + + public this ( int par_size ){ + } + + public synchronized void write( int b ){ + implMissing( __FILE__, __LINE__ ); + } + + public synchronized void write( byte[] b, int off, int len ){ + implMissing( __FILE__, __LINE__ ); + } + + public synchronized void writeTo( dwt.dwthelper.OutputStream.OutputStream out_KEYWORDESCAPE ){ + implMissing( __FILE__, __LINE__ ); + } + + public synchronized void reset(){ + implMissing( __FILE__, __LINE__ ); + } + + public synchronized byte[] toByteArray(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public int size(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + + public override char[] toString(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public char[] toString( char[] enc ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public char[] toString( int hibyte ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public override void close(){ + implMissing( __FILE__, __LINE__ ); + } + + +} + + diff -r 000000000000 -r 5406a8f6526d dwt/dwthelper/File.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/dwthelper/File.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,202 @@ +/** + * Authors: Frank Benoit + */ +module dwt.dwthelper.File; + +import dwt.dwthelper.utils; + +static import tango.io.FileConst; +static import tango.io.FilePath; +static import tango.io.FileSystem; + +public class File { + + public static char separatorChar; + public static char[] separator; + public static char pathSeparatorChar; + public static char[] pathSeparator; + + private tango.io.FilePath.FilePath mFilePath; + + static this(){ + separator = tango.io.FileConst.FileConst.PathSeparatorString; + separatorChar = tango.io.FileConst.FileConst.PathSeparatorChar; + pathSeparator = tango.io.FileConst.FileConst.SystemPathString; + pathSeparatorChar = tango.io.FileConst.FileConst.SystemPathChar; + } + + public this ( char[] pathname ){ + mFilePath = new tango.io.FilePath.FilePath( pathname ); + } + + public this ( char[] parent, char[] child ){ + mFilePath = new tango.io.FilePath.FilePath( tango.io.FilePath.FilePath.join( parent, child ) ); + } + + public this ( dwt.dwthelper.File.File parent, char[] child ){ + mFilePath = new tango.io.FilePath.FilePath( tango.io.FilePath.FilePath.join( parent.mFilePath.toString, child ) ); + } + + public int getPrefixLength(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + + public char[] getName(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public char[] getParent(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public dwt.dwthelper.File.File getParentFile(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public char[] getPath(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public bool isAbsolute(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + public char[] getAbsolutePath(){ + return tango.io.FileSystem.FileSystem.toAbsolute( mFilePath ).toString; + } + + public dwt.dwthelper.File.File getAbsoluteFile(){ + return new File( getAbsolutePath() ); + } + + public char[] getCanonicalPath(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public dwt.dwthelper.File.File getCanonicalFile(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public bool canRead(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + public bool canWrite(){ + return mFilePath.isWritable; + } + + public bool exists(){ + return mFilePath.exists; + } + + public bool isDirectory(){ + return mFilePath.isFolder; + } + + public bool isFile(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + public bool isHidden(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + public long lastModified(){ + implMissing( __FILE__, __LINE__ ); + return 0L; + } + + public long length(){ + implMissing( __FILE__, __LINE__ ); + return 0L; + } + + public bool createNewFile(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + public bool delete_KEYWORDESCAPE(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + public void deleteOnExit(){ + implMissing( __FILE__, __LINE__ ); + } + + public char[][] list(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public dwt.dwthelper.File.File[] listFiles(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public bool mkdir(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + public bool mkdirs(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + public bool renameTo( dwt.dwthelper.File.File dest ){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + public bool setLastModified( long time ){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + public bool setReadOnly(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + public static dwt.dwthelper.File.File[] listRoots(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public static dwt.dwthelper.File.File createTempFile( char[] prefix, char[] suffix, dwt.dwthelper.File.File directory ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public static dwt.dwthelper.File.File createTempFile( char[] prefix, char[] suffix ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public int compareTo( dwt.dwthelper.File.File pathname ){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + + public char[] toString(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + +} + + diff -r 000000000000 -r 5406a8f6526d dwt/dwthelper/FileInputStream.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/dwthelper/FileInputStream.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,77 @@ +/** + * Authors: Frank Benoit + */ +module dwt.dwthelper.FileInputStream; + +import dwt.dwthelper.utils; +import dwt.dwthelper.File; +import dwt.dwthelper.InputStream; + +import tango.io.FileConduit; +import tango.io.protocol.Reader; +import tango.core.Exception; +import tango.text.convert.Format; + +public class FileInputStream : dwt.dwthelper.InputStream.InputStream { + + alias dwt.dwthelper.InputStream.InputStream.read read; + + private FileConduit conduit; + private ubyte[] buffer; + private int buf_pos; + private int buf_size; + private const int BUFFER_SIZE = 0x10000; + private bool eof; + + public this ( char[] name ){ + conduit = new FileConduit( name ); + buffer = new ubyte[]( BUFFER_SIZE ); + } + + public this ( dwt.dwthelper.File.File file ){ + implMissing( __FILE__, __LINE__ ); + conduit = new FileConduit( file.getAbsolutePath(), FileConduit.ReadExisting ); + buffer = new ubyte[]( BUFFER_SIZE ); + } + + public override int read(){ + if( eof ){ + return -1; + } + try{ + if( buf_pos == buf_size ){ + buf_pos = 0; + buf_size = conduit.input.read( buffer ); + } + if( buf_size <= 0 ){ + eof = true; + return -1; + } + assert( buf_pos < BUFFER_SIZE, Format( "{0} {1}", buf_pos, buf_size ) ); + assert( buf_size <= BUFFER_SIZE ); + int res = cast(int) buffer[ buf_pos ]; + buf_pos++; + return res; + } + catch( IOException e ){ + eof = true; + return -1; + } + } + + public long skip( long n ){ + implMissing( __FILE__, __LINE__ ); + return 0L; + } + + public int available(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + + public override void close(){ + conduit.close(); + } +} + + diff -r 000000000000 -r 5406a8f6526d dwt/dwthelper/FileOutputStream.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/dwthelper/FileOutputStream.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,55 @@ +/** + * Authors: Frank Benoit + */ +module dwt.dwthelper.FileOutputStream; + +public import dwt.dwthelper.File; +public import dwt.dwthelper.OutputStream; + +import dwt.dwthelper.utils; + +public class FileOutputStream : dwt.dwthelper.OutputStream.OutputStream { + + alias dwt.dwthelper.OutputStream.OutputStream.write write; + alias dwt.dwthelper.OutputStream.OutputStream.close close; + + public this ( char[] name ){ + implMissing( __FILE__, __LINE__ ); + } + + public this ( char[] name, bool append ){ + implMissing( __FILE__, __LINE__ ); + } + + public this ( dwt.dwthelper.File.File file ){ + implMissing( __FILE__, __LINE__ ); + } + + public this ( dwt.dwthelper.File.File file, bool append ){ + implMissing( __FILE__, __LINE__ ); + } + + public void write( int b ){ + implMissing( __FILE__, __LINE__ ); + } + + public void write( byte[] b ){ + implMissing( __FILE__, __LINE__ ); + } + + public void write( byte[] b, int off, int len ){ + implMissing( __FILE__, __LINE__ ); + } + + public void close(){ + implMissing( __FILE__, __LINE__ ); + } + + public void finalize(){ + implMissing( __FILE__, __LINE__ ); + } + + +} + + diff -r 000000000000 -r 5406a8f6526d dwt/dwthelper/InflaterInputStream.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/dwthelper/InflaterInputStream.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,68 @@ +/** + * Authors: Frank Benoit + */ +module dwt.dwthelper.InflaterInputStream; + +public import dwt.dwthelper.InputStream; +import dwt.dwthelper.utils; + +public class InflaterInputStream : dwt.dwthelper.InputStream.InputStream { + + alias dwt.dwthelper.InputStream.InputStream.read read; + alias dwt.dwthelper.InputStream.InputStream.skip skip; + alias dwt.dwthelper.InputStream.InputStream.available available; + alias dwt.dwthelper.InputStream.InputStream.close close; + alias dwt.dwthelper.InputStream.InputStream.mark mark; + alias dwt.dwthelper.InputStream.InputStream.reset reset; + alias dwt.dwthelper.InputStream.InputStream.markSupported markSupported; + + protected byte[] buf; + protected int len; + package bool usesDefaultInflater = false; + + public this ( dwt.dwthelper.InputStream.InputStream istr ){ + } + + public int read(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + + public int read( byte[] b, int off, int len ){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + + public int available(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + + public long skip( long n ){ + implMissing( __FILE__, __LINE__ ); + return 0L; + } + + public void close(){ + implMissing( __FILE__, __LINE__ ); + } + + public void fill(){ + implMissing( __FILE__, __LINE__ ); + } + + public bool markSupported(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + public synchronized void mark( int readlimit ){ + implMissing( __FILE__, __LINE__ ); + } + + public synchronized void reset(){ + implMissing( __FILE__, __LINE__ ); + } +} + + diff -r 000000000000 -r 5406a8f6526d dwt/dwthelper/InputStream.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/dwthelper/InputStream.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,61 @@ +/** + * Authors: Frank Benoit + */ + +module dwt.dwthelper.InputStream; + +import dwt.dwthelper.utils; + +public abstract class InputStream { + + + public this (){ + } + + public abstract int read(); + + public int read( byte[] b ){ + foreach( uint idx, inout byte val; b ){ + int c = read(); + if( c == -1 ){ + return idx; + } + b[ idx] = cast(byte)( c & 0xFF ); + } + return b.length; + } + + public int read( byte[] b, int off, int len ){ + return read( b[ off .. off+len ] ); + } + + public long skip( long n ){ + implMissing( __FILE__, __LINE__ ); + return 0L; + } + + public int available(){ + return 0; + } + + public void close(){ + implMissing( __FILE__, __LINE__ ); + } + + public synchronized void mark( int readlimit ){ + implMissing( __FILE__, __LINE__ ); + } + + public synchronized void reset(){ + implMissing( __FILE__, __LINE__ ); + } + + public bool markSupported(){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + +} + + diff -r 000000000000 -r 5406a8f6526d dwt/dwthelper/Integer.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/dwthelper/Integer.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,118 @@ +/** + * Authors: Frank Benoit + */ + +module dwt.dwthelper.Integer; + +import dwt.dwthelper.utils; + +static import tango.text.convert.Integer; + +public final class Integer { + + public static int MIN_VALUE = 0x80000000; + public static int MAX_VALUE = 0x7fffffff; + public static int SIZE = 32; + + public int value; + public this ( int value ){ + this.value = value; + } + + public this ( char[] s ){ + } + + public static char[] toString( int i, int radix ){ + switch( radix ){ + case 2: + return toBinaryString(i); + case 8: + return toOctalString(i); + case 10: + return toString(i); + case 16: + return toHexString(i); + default: + implMissing( __FILE__, __LINE__ ); + return null; + } + } + + public static char[] toHexString( int i ){ + return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Hex ); + } + + public static char[] toOctalString( int i ){ + return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Octal ); + } + + public static char[] toBinaryString( int i ){ + return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Binary ); + } + + public static char[] toString( int i ){ + return tango.text.convert.Integer.toString(i); + } + + public static int parseInt( char[] s, int radix ){ + return tango.text.convert.Integer.parse( s, cast(uint)radix ); + } + + public static int parseInt( char[] s ){ + return tango.text.convert.Integer.parse( s ); + } + + public static Integer valueOf( char[] s, int radix ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public static Integer valueOf( char[] s ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public static Integer valueOf( int i ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public byte byteValue(){ + return cast(byte)value; + } + + public short shortValue(){ + return cast(short)value; + } + + public int intValue(){ + return value; + } + + public long longValue(){ + return cast(long)value; + } + + public float floatValue(){ + return cast(float)value; + } + + public double doubleValue(){ + return cast(double)value; + } + + public override hash_t toHash(){ + return intValue(); + } + + public override int opEquals( Object obj ){ + implMissing( __FILE__, __LINE__ ); + return false; + } + + public override char[] toString(){ + return tango.text.convert.Integer.toString( value ); + } +} + + diff -r 000000000000 -r 5406a8f6526d dwt/dwthelper/OutputStream.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/dwthelper/OutputStream.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,50 @@ +/** + * Authors: Frank Benoit + */ +module dwt.dwthelper.OutputStream; + +import dwt.dwthelper.utils; +static import tango.io.model.IConduit; + +public abstract class OutputStream { + + private tango.io.model.IConduit.OutputStream ostr; + + public this(){ + } + + protected this( tango.io.model.IConduit.OutputStream aOutStream) { + this.ostr = aOutStream; + } + + protected this(OutputStream rhs) { + ostr = rhs.ostr; + } + + public abstract void write( int b ); + + public void write( byte[] b ){ + ostr.write(b); + } + + public void write(char[] c) { + ostr.write(c); + } + + public void write( byte[] b, int off, int len ){ + implMissing( __FILE__, __LINE__ ); + } + + public void flush(){ + ostr.flush(); + } + + public void close(){ + ostr.flush(); + implMissing( __FILE__, __LINE__ ); + } + + +} + + diff -r 000000000000 -r 5406a8f6526d dwt/dwthelper/ResourceBundle.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/dwthelper/ResourceBundle.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,21 @@ +/** + * Authors: Frank Benoit + */ +module dwt.dwthelper.ResourceBundle; + +class ResourceBundle { + + public this( char[] name ){ + } + + public char[] getString( char[] key ){ + return key; + } + + public static ResourceBundle getBundle( char[] name ){ + return new ResourceBundle( name ); + } + +} + + diff -r 000000000000 -r 5406a8f6526d dwt/dwthelper/Runnable.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/dwthelper/Runnable.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,12 @@ +/** + * Authors: Frank Benoit + */ +module dwt.dwthelper.Runnable; + +public interface Runnable { + + public abstract void run(); + +} + + diff -r 000000000000 -r 5406a8f6526d dwt/dwthelper/System.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/dwthelper/System.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,128 @@ +/** + * Authors: Frank Benoit + */ +module dwt.dwthelper.System; + +import tango.core.Exception; + +template SimpleType(T) { + debug{ + static void validCheck(uint SrcLen, uint DestLen, uint copyLen){ + if(SrcLen < copyLen || DestLen < copyLen|| SrcLen < 0 || DestLen < 0){ + Util.trace("Error : SimpleType.arraycopy(), out of bounds."); + assert(0); + } + } + } + + static void remove(inout T[] items, int index) { + if(items.length == 0) + return; + + if(index < 0 || index >= items.length){ + throw new ArrayBoundsException(__FILE__, __LINE__); + } + + T element = items[index]; + + int length = items.length; + if(length == 1){ + items.length = 0; + return;// element; + } + + if(index == 0) + items = items[1 .. $]; + else if(index == length - 1) + items = items[0 .. index]; + else + items = items[0 .. index] ~ items[index + 1 .. $]; + } + + static void insert(inout T[] items, T item, int index = -1) { + if(index == -1) + index = items.length; + + if(index < 0 || index > items.length ){ + throw new ArrayBoundsException(__FILE__, __LINE__); + } + + if(index == items.length){ + items ~= item; + }else if(index == 0){ + T[] newVect; + newVect ~= item; + items = newVect ~ items; + }else if(index < items.length ){ + T[] arr1 = items[0 .. index]; + T[] arr2 = items[index .. $]; + + // Important : if you write like the following commented, + // you get wrong data + // code: T[] arr1 = items[0..index]; + // T[] arr2 = items[index..$]; + // items = arr1 ~ item; // error, !!! + // items ~= arr2; // item replace the arrr2[0] here + items = arr1 ~ item ~ arr2; + } + } + + static void arraycopy(T[] src, uint srcPos, T[] dest, uint destPos, uint len) + { + if(len == 0) return; + + assert(src); + assert(dest); + debug{validCheck(src.length - srcPos, dest.length - destPos, len);} + + if(src is dest){ + for(int i=0; i + */ +module dwt.dwthelper.utils; + +public import dwt.dwthelper.System; + +import tango.io.Stdout; +import tango.text.Unicode; +import tango.stdc.stdlib : exit; + +void implMissing( char[] file, uint line ){ + Stderr.formatln( "implementation missing in file {} line {}", file, line ); + Stderr.formatln( "exiting ..." ); + exit(1); +} + +abstract class ArrayWrapper{ +} + +class ArrayWrapperT(T) : ArrayWrapper { + public T[] array; + public this( T[] data ){ + array = data; + } +} + +alias ArrayWrapperT!(byte) ArrayWrapperByte; +alias ArrayWrapperT!(int) ArrayWrapperInt; +alias ArrayWrapperT!(Object) ArrayWrapperObject; +alias ArrayWrapperT!(char) ArrayWrapperString; +alias ArrayWrapperT!(char[]) ArrayWrapperString2; + +dchar getFirstCodepoint( char[] str ){ + foreach( dchar d; str ){ + return d; + } +} +dchar CharacterToLower( dchar c ){ + dchar[] r = tango.text.Unicode.toLower( [c] ); + return r[0]; +} +dchar CharacterToUpper( dchar c ){ + dchar[] r = tango.text.Unicode.toUpper( [c] ); + return r[0]; +} + diff -r 000000000000 -r 5406a8f6526d dwt/events/ArmEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/ArmEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.ArmEvent; + +import dwt.widgets.Event; +import dwt.events.TypedEvent; + +/** + * Instances of this class are sent as a result of + * a widget such as a menu item being armed. + * + * @see ArmListener + */ + +public final class ArmEvent : TypedEvent { + + //static final long serialVersionUID = 3258126964249212217L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); +} + +} diff -r 000000000000 -r 5406a8f6526d dwt/events/ArmListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/ArmListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.ArmListener; + +public import dwt.internal.DWTEventListener; +public import dwt.events.ArmEvent; + +/** + * Classes which implement this interface provide a method + * that deals with the event that is generated when a widget, + * such as a menu item, is armed. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a widget using the + * addArmListener method and removed using + * the removeArmListener method. When the + * widget is armed, the widgetArmed method will be invoked. + *

+ * + * @see ArmEvent + */ +public interface ArmListener : DWTEventListener { + +/** + * Sent when a widget is armed, or 'about to be selected'. + * + * @param e an event containing information about the arm + */ +public void widgetArmed(ArmEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/ControlAdapter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/ControlAdapter.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.ControlAdapter; + +import dwt.events.ControlListener; +/** + * This adapter class provides default implementations for the + * methods described by the ControlListener interface. + *

+ * Classes that wish to deal with ControlEvents can + * extend this class and override only the methods which they are + * interested in. + *

+ * + * @see ControlListener + * @see ControlEvent + */ +public abstract class ControlAdapter : ControlListener { + +/** + * Sent when the location (x, y) of a control changes relative + * to its parent (or relative to the display, for Shells). + * The default behavior is to do nothing. + * + * @param e an event containing information about the move + */ +public void controlMoved(ControlEvent e) { +} + +/** + * Sent when the size (width, height) of a control changes. + * The default behavior is to do nothing. + * + * @param e an event containing information about the resize + */ +public void controlResized(ControlEvent e) { +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/ControlEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/ControlEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.ControlEvent; + + +import dwt.widgets.Event; +import dwt.events.TypedEvent; + +/** + * Instances of this class are sent as a result of + * controls being moved or resized. + * + * @see ControlListener + */ + +public final class ControlEvent : TypedEvent { + + //static final long serialVersionUID = 3258132436155119161L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); +} + +} + + diff -r 000000000000 -r 5406a8f6526d dwt/events/ControlListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/ControlListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.ControlListener; + +public import dwt.internal.DWTEventListener; +public import dwt.events.ControlEvent; + +/** + * Classes which implement this interface provide methods + * that deal with the events that are generated by moving + * and resizing controls. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a control using the + * addControlListener method and removed using + * the removeControlListener method. When a + * control is moved or resized, the appropriate method will + * be invoked. + *

+ * + * @see ControlAdapter + * @see ControlEvent + */ +public interface ControlListener : DWTEventListener { + +/** + * Sent when the location (x, y) of a control changes relative + * to its parent (or relative to the display, for Shells). + * + * @param e an event containing information about the move + */ +public void controlMoved(ControlEvent e); + +/** + * Sent when the size (width, height) of a control changes. + * + * @param e an event containing information about the resize + */ +public void controlResized(ControlEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/DisposeEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/DisposeEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.DisposeEvent; + + +import dwt.widgets.Event; +import dwt.events.TypedEvent; + +/** + * Instances of this class are sent as a result of + * widgets being disposed. + * + * @see DisposeListener + */ + +public final class DisposeEvent : TypedEvent { + + //static final long serialVersionUID = 3257566187633521206L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); +} + +} + diff -r 000000000000 -r 5406a8f6526d dwt/events/DisposeListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/DisposeListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.DisposeListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.DisposeEvent; + +/** + * Classes which implement this interface provide a method + * that deals with the event that is generated when a widget + * is disposed. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a widget using the + * addDisposeListener method and removed using + * the removeDisposeListener method. When a + * widget is disposed, the widgetDisposed method will + * be invoked. + *

+ * + * @see DisposeEvent + */ +public interface DisposeListener : DWTEventListener { + +/** + * Sent when the widget is disposed. + * + * @param e an event containing information about the dispose + */ +public void widgetDisposed(DisposeEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/DragDetectEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/DragDetectEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.DragDetectEvent; + +import dwt.widgets.Event; +import dwt.events.MouseEvent; + +/** + * Instances of this class are sent as a result of + * a drag gesture. + * + * @see DragDetectListener + * + * @since 3.3 + */ + +public final class DragDetectEvent : MouseEvent { + + //private static final long serialVersionUID = -7229172519733647232L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/DragDetectListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/DragDetectListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.DragDetectListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.DragDetectEvent; + +/** + * Classes which implement this interface provide methods + * that deal with the events that are generated when a drag + * gesture is detected. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a control using the + * addDragDetectListener method and removed using + * the removeDragDetectListener method. When the + * drag is detected, the drageDetected method will be invoked. + *

+ * + * @see DragDetectEvent + * + * @since 3.3 + */ +public interface DragDetectListener : DWTEventListener { + +/** + * Sent when a drag gesture is detected. + * + * @param e an event containing information about the drag + */ +public void dragDetected(DragDetectEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/ExpandAdapter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/ExpandAdapter.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.ExpandAdapter; + +import dwt.events.ExpandListener; + +/** + * This adapter class provides default implementations for the + * methods described by the ExpandListener interface. + *

+ * Classes that wish to deal with ExpandEvents can + * extend this class and override only the methods which they are + * interested in. + *

+ * + * @see ExpandListener + * @see ExpandEvent + * + * @since 3.2 + */ +public abstract class ExpandAdapter : ExpandListener { + +/** + * Sent when an item is collapsed. + * The default behavior is to do nothing. + * + * @param e an event containing information about the operation + */ +public void itemCollapsed(ExpandEvent e) { +} + +/** + * Sent when an item is expanded. + * The default behavior is to do nothing. + * + * @param e an event containing information about the operation + */ +public void itemExpanded(ExpandEvent e) { +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/ExpandEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/ExpandEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.ExpandEvent; + + +import dwt.widgets.Event; +import dwt.events.SelectionEvent; + +/** + * Instances of this class are sent as a result of + * ExpandItems being expanded or collapsed. + * + * @see ExpandListener + * + * @since 3.2 + */ + +public class ExpandEvent : SelectionEvent { + + //static final long serialVersionUID = 3976735856884987356L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); +} + +} diff -r 000000000000 -r 5406a8f6526d dwt/events/ExpandListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/ExpandListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.ExpandListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.ExpandEvent; + +/** + * Classes which implement this interface provide methods + * that deal with the expanding and collapsing of ExpandItems. + * + *

+ * After creating an instance of a class that extends + * this interface it can be added to a ExpandBar + * control using the addExpandListener method and + * removed using the removeExpandListener method. + * When a item of the ExpandBar is expanded or + * collapsed, the appropriate method will be invoked. + *

+ * + * @see ExpandAdapter + * @see ExpandEvent + * + * @since 3.2 + */ +public interface ExpandListener : DWTEventListener { + +/** + * Sent when an item is collapsed. + * + * @param e an event containing information about the operation + */ +public void itemCollapsed(ExpandEvent e); + +/** + * Sent when an item is expanded. + * + * @param e an event containing information about the operation + */ +public void itemExpanded(ExpandEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/FocusAdapter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/FocusAdapter.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.FocusAdapter; + +import dwt.events.FocusListener; + +/** + * This adapter class provides default implementations for the + * methods described by the FocusListener interface. + *

+ * Classes that wish to deal with FocusEvents can + * extend this class and override only the methods which they are + * interested in. + *

+ * + * @see FocusListener + * @see FocusEvent + */ +public abstract class FocusAdapter : FocusListener { + +/** + * Sent when a control gets focus. + * The default behavior is to do nothing. + * + * @param e an event containing information about the focus change + */ +public void focusGained(FocusEvent e) { +} + +/** + * Sent when a control loses focus. + * The default behavior is to do nothing. + * + * @param e an event containing information about the focus change + */ +public void focusLost(FocusEvent e) { +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/FocusEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/FocusEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.FocusEvent; + + +import dwt.widgets.Event; +import dwt.events.TypedEvent; + +/** + * Instances of this class are sent as a result of + * widgets gaining and losing focus. + * + * @see FocusListener + */ + +public final class FocusEvent : TypedEvent { + + //static final long serialVersionUID = 3258134643684227381L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); +} + +} + diff -r 000000000000 -r 5406a8f6526d dwt/events/FocusListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/FocusListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.FocusListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.FocusEvent; + +/** + * Classes which implement this interface provide methods + * that deal with the events that are generated as controls + * gain and lose focus. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a control using the + * addFocusListener method and removed using + * the removeFocusListener method. When a + * control gains or loses focus, the appropriate method + * will be invoked. + *

+ * + * @see FocusAdapter + * @see FocusEvent + */ +public interface FocusListener : DWTEventListener { + +/** + * Sent when a control gets focus. + * + * @param e an event containing information about the focus change + */ +public void focusGained(FocusEvent e); + +/** + * Sent when a control loses focus. + * + * @param e an event containing information about the focus change + */ +public void focusLost(FocusEvent e); +} + diff -r 000000000000 -r 5406a8f6526d dwt/events/HelpEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/HelpEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.HelpEvent; + + +import dwt.widgets.Event; +import dwt.events.TypedEvent; + +/** + * Instances of this class are sent as a result of + * help being requested for a widget. + * + * @see HelpListener + */ + +public final class HelpEvent : TypedEvent { + + //static final long serialVersionUID = 3257001038606251315L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); +} + +} + diff -r 000000000000 -r 5406a8f6526d dwt/events/HelpListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/HelpListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.HelpListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.HelpEvent; + +/** + * Classes which implement this interface provide a method + * that deals with the event that is generated when help is + * requested for a control, typically when the user presses F1. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a control using the + * addHelpListener method and removed using + * the removeHelpListener method. When help + * is requested for a control, the helpRequested method + * will be invoked. + *

+ * + * @see HelpEvent + */ +public interface HelpListener : DWTEventListener { + +/** + * Sent when help is requested for a control, typically + * when the user presses F1. + * + * @param e an event containing information about the help + */ +public void helpRequested(HelpEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/KeyAdapter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/KeyAdapter.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.KeyAdapter; + +import dwt.events.KeyListener; + +/** + * This adapter class provides default implementations for the + * methods described by the KeyListener interface. + *

+ * Classes that wish to deal with KeyEvents can + * extend this class and override only the methods which they are + * interested in. + *

+ * + * @see KeyListener + * @see KeyEvent + */ +public abstract class KeyAdapter : KeyListener { + +/** + * Sent when a key is pressed on the system keyboard. + * The default behavior is to do nothing. + * + * @param e an event containing information about the key press + */ +public void keyPressed(KeyEvent e) { +} + +/** + * Sent when a key is released on the system keyboard. + * The default behavior is to do nothing. + * + * @param e an event containing information about the key release + */ +public void keyReleased(KeyEvent e) { +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/KeyEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/KeyEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,106 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.KeyEvent; + + +import dwt.widgets.Event; +import dwt.events.TypedEvent; + +import tango.text.convert.Format; + +/** + * Instances of this class are sent as a result of + * keys being pressed and released on the keyboard. + *

+ * When a key listener is added to a control, the control + * will take part in widget traversal. By default, all + * traversal keys (such as the tab key and so on) are + * delivered to the control. In order for a control to take + * part in traversal, it should listen for traversal events. + * Otherwise, the user can traverse into a control but not + * out. Note that native controls such as table and tree + * implement key traversal in the operating system. It is + * not necessary to add traversal listeners for these controls, + * unless you want to override the default traversal. + *

+ * @see KeyListener + * @see TraverseListener + */ + +public class KeyEvent : TypedEvent { + + /** + * the character represented by the key that was typed. + * This is the final character that results after all modifiers have been + * applied. For example, when the user types Ctrl+A, the character value + * is 0x01. It is important that applications do not attempt to modify the + * character value based on a stateMask (such as DWT.CTRL) or the resulting + * character will not be correct. + */ + public wchar character = '\0'; + + /** + * the key code of the key that was typed, + * as defined by the key code constants in class DWT. + * When the character field of the event is ambiguous, this field + * contains the unicode value of the original character. For example, + * typing Ctrl+M or Return both result in the character '\r' but the + * keyCode field will also contain '\r' when Return was typed. + * + * @see dwt.DWT + */ + public int keyCode; + + /** + * the state of the keyboard modifier keys at the time + * the event was generated, as defined by the key code + * constants in class DWT. + * + * @see dwt.DWT + */ + public int stateMask; + + /** + * A flag indicating whether the operation should be allowed. + * Setting this field to false will cancel the operation. + */ + public bool doit; + + static final long serialVersionUID = 3256442491011412789L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); + this.character = e.character; + this.keyCode = e.keyCode; + this.stateMask = e.stateMask; + this.doit = e.doit; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public char[] toString() { + return Format( "{} character={} keyCode={} stateMask={} doit={}}", + super.toString[ 0 .. $-2 ], + character, keyCode, stateMask, doit ); +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/KeyListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/KeyListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.KeyListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.KeyEvent; + +/** + * Classes which implement this interface provide methods + * that deal with the events that are generated as keys + * are pressed on the system keyboard. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a control using the + * addKeyListener method and removed using + * the removeKeyListener method. When a + * key is pressed or released, the appropriate method will + * be invoked. + *

+ * + * @see KeyAdapter + * @see KeyEvent + */ +public interface KeyListener : DWTEventListener { + +/** + * Sent when a key is pressed on the system keyboard. + * + * @param e an event containing information about the key press + */ +public void keyPressed(KeyEvent e); + +/** + * Sent when a key is released on the system keyboard. + * + * @param e an event containing information about the key release + */ +public void keyReleased(KeyEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/MenuAdapter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/MenuAdapter.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.MenuAdapter; + +import dwt.events.MenuListener; + +/** + * This adapter class provides default implementations for the + * methods described by the MenuListener interface. + *

+ * Classes that wish to deal with MenuEvents can + * extend this class and override only the methods which they are + * interested in. + *

+ * + * @see MenuListener + * @see MenuEvent + */ +public abstract class MenuAdapter : MenuListener { + +/** + * Sent when a menu is hidden. + * The default behavior is to do nothing. + * + * @param e an event containing information about the menu operation + */ +public void menuHidden(MenuEvent e) { +} + +/** + * Sent when a menu is shown. + * The default behavior is to do nothing. + * + * @param e an event containing information about the menu operation + */ +public void menuShown(MenuEvent e) { +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/MenuDetectEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/MenuDetectEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.MenuDetectEvent; + + +import dwt.widgets.Event; +import dwt.events.TypedEvent; + +import tango.text.convert.Format; +/** + * Instances of this class are sent whenever the platform- + * specific trigger for showing a context menu is detected. + * + * @see MenuDetectListener + * + * @since 3.3 + */ + +public final class MenuDetectEvent : TypedEvent { + + /** + * the display-relative x coordinate of the pointer + * at the time the context menu trigger occurred + */ + public int x; + + /** + * the display-relative y coordinate of the pointer + * at the time the context menu trigger occurred + */ + public int y; + + /** + * A flag indicating whether the operation should be allowed. + * Setting this field to false will cancel the operation. + */ + public bool doit; + + //private static final long serialVersionUID = -3061660596590828941L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); + this.x = e.x; + this.y = e.y; + this.doit = e.doit; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public char[] toString() { + return Format( "{} x={} y={} doit={}}", super.toString[ 0 .. $-2 ], x, y, doit ); +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/MenuDetectListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/MenuDetectListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.MenuDetectListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.MenuDetectEvent; + +/** + * Classes which implement this interface provide methods + * that deal with the events that are generated when the + * platform-specific trigger for showing a context menu is + * detected. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a control or TrayItem + * using the addMenuDetectListener method and + * removed using the removeMenuDetectListener method. + * When the context menu trigger occurs, the + * menuDetected method will be invoked. + *

+ * + * @see MenuDetectEvent + * + * @since 3.3 + */ +public interface MenuDetectListener : DWTEventListener { + +/** + * Sent when the platform-dependent trigger for showing a menu item is detected. + * + * @param e an event containing information about the menu detect + */ +public void menuDetected (MenuDetectEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/MenuEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/MenuEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.MenuEvent; + + +import dwt.widgets.Event; +import dwt.events.TypedEvent; + +/** + * Instances of this class are sent as a result of + * menus being shown and hidden. + * + * @see MenuListener + */ + +public final class MenuEvent : TypedEvent { + + //static final long serialVersionUID = 3258132440332383025L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); +} + +} + diff -r 000000000000 -r 5406a8f6526d dwt/events/MenuListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/MenuListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.MenuListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.MenuEvent; + +/** + * Classes which implement this interface provide methods + * that deal with the hiding and showing of menus. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a menu using the + * addMenuListener method and removed using + * the removeMenuListener method. When the + * menu is hidden or shown, the appropriate method will + * be invoked. + *

+ * + * @see MenuAdapter + * @see MenuEvent + */ +public interface MenuListener : DWTEventListener { + +/** + * Sent when a menu is hidden. + * + * @param e an event containing information about the menu operation + */ +public void menuHidden(MenuEvent e); + +/** + * Sent when a menu is shown. + * + * @param e an event containing information about the menu operation + */ +public void menuShown(MenuEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/ModifyEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/ModifyEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.ModifyEvent; + + +import dwt.widgets.Event; +import dwt.events.TypedEvent; + +/** + * Instances of this class are sent as a result of + * text being modified. + * + * @see ModifyListener + */ + +public final class ModifyEvent : TypedEvent { + + //static final long serialVersionUID = 3258129146227011891L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); +} + +} + diff -r 000000000000 -r 5406a8f6526d dwt/events/ModifyListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/ModifyListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.ModifyListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.ModifyEvent; + +/** + * Classes which implement this interface provide a method + * that deals with the events that are generated when text + * is modified. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a text widget using the + * addModifyListener method and removed using + * the removeModifyListener method. When the + * text is modified, the modifyText method will be invoked. + *

+ * + * @see ModifyEvent + */ +public interface ModifyListener : DWTEventListener { + +/** + * Sent when the text is modified. + * + * @param e an event containing information about the modify + */ +public void modifyText(ModifyEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/MouseAdapter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/MouseAdapter.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.MouseAdapter; + +import dwt.events.MouseListener; + +/** + * This adapter class provides default implementations for the + * methods described by the MouseListener interface. + *

+ * Classes that wish to deal with MouseEvents + * which occur as mouse buttons are pressed and released can + * extend this class and override only the methods which they are + * interested in. + *

+ * + * @see MouseListener + * @see MouseEvent + */ +public abstract class MouseAdapter : MouseListener { + +/** + * Sent when a mouse button is pressed twice within the + * (operating system specified) double click period. + * The default behavior is to do nothing. + * + * @param e an event containing information about the mouse double click + * + * @see dwt.widgets.Display#getDoubleClickTime() + */ +public void mouseDoubleClick(MouseEvent e) { +} + +/** + * Sent when a mouse button is pressed. + * The default behavior is to do nothing. + * + * @param e an event containing information about the mouse button press + */ +public void mouseDown(MouseEvent e) { +} + +/** + * Sent when a mouse button is released. + * The default behavior is to do nothing. + * + * @param e an event containing information about the mouse button release + */ +public void mouseUp(MouseEvent e) { +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/MouseEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/MouseEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,101 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.MouseEvent; + + +import dwt.widgets.Event; +import dwt.events.TypedEvent; + +import tango.text.convert.Format; + +/** + * Instances of this class are sent whenever mouse + * related actions occur. This includes mouse buttons + * being pressed and released, the mouse pointer being + * moved and the mouse pointer crossing widget boundaries. + *

+ * Note: The button field is an integer that + * represents the mouse button number. This is not the same + * as the DWT mask constants BUTTONx. + *

+ * + * @see MouseListener + * @see MouseMoveListener + * @see MouseTrackListener + */ + +public class MouseEvent : TypedEvent { + + /** + * the button that was pressed or released; 1 for the + * first button, 2 for the second button, and 3 for the + * third button, etc. + */ + public int button; + + /** + * the state of the keyboard modifier keys at the time + * the event was generated + */ + public int stateMask; + + /** + * the widget-relative, x coordinate of the pointer + * at the time the mouse button was pressed or released + */ + public int x; + + /** + * the widget-relative, y coordinate of the pointer + * at the time the mouse button was pressed or released + */ + public int y; + + /** + * the number times the mouse has been clicked, as defined + * by the operating system; 1 for the first click, 2 for the + * second click and so on. + * + * @since 3.3 + */ + public int count; + + //static final long serialVersionUID = 3257288037011566898L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); + this.x = e.x; + this.y = e.y; + this.button = e.button; + this.stateMask = e.stateMask; + this.count = e.count; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public char[] toString() { + return Format( "{} button={} stateMask={} x={} y={} count={}}", + super.toString[ 0 .. $-2 ], + button, stateMask, x, y, count ); +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/MouseListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/MouseListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.MouseListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.MouseEvent; + +/** + * Classes which implement this interface provide methods + * that deal with the events that are generated as mouse buttons + * are pressed. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a control using the + * addMouseListener method and removed using + * the removeMouseListener method. When a + * mouse button is pressed or released, the appropriate method + * will be invoked. + *

+ * + * @see MouseAdapter + * @see MouseEvent + */ +public interface MouseListener : DWTEventListener { + +/** + * Sent when a mouse button is pressed twice within the + * (operating system specified) double click period. + * + * @param e an event containing information about the mouse double click + * + * @see dwt.widgets.Display#getDoubleClickTime() + */ +public void mouseDoubleClick(MouseEvent e); + +/** + * Sent when a mouse button is pressed. + * + * @param e an event containing information about the mouse button press + */ +public void mouseDown(MouseEvent e); + +/** + * Sent when a mouse button is released. + * + * @param e an event containing information about the mouse button release + */ +public void mouseUp(MouseEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/MouseMoveListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/MouseMoveListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.MouseMoveListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.MouseEvent; + +/** + * Classes which implement this interface provide a method + * that deals with the events that are generated as the mouse + * pointer moves. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a control using the + * addMouseMoveListener method and removed using + * the removeMouseMoveListener method. As the + * mouse moves, the mouseMove method will be invoked. + *

+ * + * @see MouseEvent + */ +public interface MouseMoveListener : DWTEventListener { + +/** + * Sent when the mouse moves. + * + * @param e an event containing information about the mouse move + */ +public void mouseMove(MouseEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/MouseTrackAdapter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/MouseTrackAdapter.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.MouseTrackAdapter; + +import dwt.events.MouseTrackListener; + +/** + * This adapter class provides default implementations for the + * methods described by the MouseTrackListener interface. + *

+ * Classes that wish to deal with MouseEvents which + * occur as the mouse pointer passes (or hovers) over controls can + * extend this class and override only the methods which they are + * interested in. + *

+ * + * @see MouseTrackListener + * @see MouseEvent + */ +public abstract class MouseTrackAdapter : MouseTrackListener { + +/** + * Sent when the mouse pointer passes into the area of + * the screen covered by a control. + * The default behavior is to do nothing. + * + * @param e an event containing information about the mouse enter + */ +public void mouseEnter(MouseEvent e) { +} + +/** + * Sent when the mouse pointer passes out of the area of + * the screen covered by a control. + * The default behavior is to do nothing. + * + * @param e an event containing information about the mouse exit + */ +public void mouseExit(MouseEvent e) { +} + +/** + * Sent when the mouse pointer hovers (that is, stops moving + * for an (operating system specified) period of time) over + * a control. + * The default behavior is to do nothing. + * + * @param e an event containing information about the hover + */ +public void mouseHover(MouseEvent e) { +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/MouseTrackListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/MouseTrackListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.MouseTrackListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.MouseEvent; + +/** + * Classes which implement this interface provide methods + * that deal with the events that are generated as the mouse + * pointer passes (or hovers) over controls. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a control using the + * addMouseTrackListener method and removed using + * the removeMouseTrackListener method. When the + * mouse pointer passes into or out of the area of the screen + * covered by a control or pauses while over a control, the + * appropriate method will be invoked. + *

+ * + * @see MouseTrackAdapter + * @see MouseEvent + */ +public interface MouseTrackListener : DWTEventListener { + +/** + * Sent when the mouse pointer passes into the area of + * the screen covered by a control. + * + * @param e an event containing information about the mouse enter + */ +public void mouseEnter(MouseEvent e); + +/** + * Sent when the mouse pointer passes out of the area of + * the screen covered by a control. + * + * @param e an event containing information about the mouse exit + */ +public void mouseExit(MouseEvent e); + +/** + * Sent when the mouse pointer hovers (that is, stops moving + * for an (operating system specified) period of time) over + * a control. + * + * @param e an event containing information about the hover + */ +public void mouseHover(MouseEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/MouseWheelListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/MouseWheelListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.MouseWheelListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.MouseEvent; + +/** + * Classes which implement this interface provide a method + * that deals with the event that is generated as the mouse + * wheel is scrolled. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a control using the + * addMouseWheelListener method and removed using + * the removeMouseWheelListener method. When the + * mouse wheel is scrolled the mouseScrolled method + * will be invoked. + *

+ * + * @see MouseEvent + * + * @since 3.3 + */ +public interface MouseWheelListener : DWTEventListener { + +/** + * Sent when the mouse wheel is scrolled. + * + * @param e an event containing information about the mouse wheel action + */ +public void mouseScrolled (MouseEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/PaintEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/PaintEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,101 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.PaintEvent; + + +import dwt.widgets.Event; +import dwt.graphics.GC; + +import dwt.events.TypedEvent; + +import tango.text.convert.Format; + +/** + * Instances of this class are sent as a result of + * visible areas of controls requiring re-painting. + * + * @see PaintListener + */ + +public final class PaintEvent : TypedEvent { + + /** + * the graphics context to use when painting + * that is configured to use the colors, font and + * damaged region of the control. It is valid + * only during the paint and must not be disposed + */ + public GC gc; + + /** + * the x offset of the bounding rectangle of the + * region that requires painting + */ + public int x; + + /** + * the y offset of the bounding rectangle of the + * region that requires painting + */ + public int y; + + /** + * the width of the bounding rectangle of the + * region that requires painting + */ + public int width; + + /** + * the height of the bounding rectangle of the + * region that requires painting + */ + public int height; + + /** + * the number of following paint events which + * are pending which may always be zero on + * some platforms + */ + public int count; + + //static final long serialVersionUID = 3256446919205992497L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); + this.gc = e.gc; + this.x = e.x; + this.y = e.y; + this.width = e.width; + this.height = e.height; + this.count = e.count; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public char[] toString() { + return Format( "{} gc={} x={} y={} width={} height={} count={}}", + super.toString[ 0 .. $-2 ], + gc, x, y, width, height, count ); +} +} + diff -r 000000000000 -r 5406a8f6526d dwt/events/PaintListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/PaintListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.PaintListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.PaintEvent; + +/** + * Classes which implement this interface provide methods + * that deal with the events that are generated when the + * control needs to be painted. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a control using the + * addPaintListener method and removed using + * the removePaintListener method. When a + * paint event occurs, the paintControl method will be + * invoked. + *

+ * + * @see PaintEvent + */ +public interface PaintListener : DWTEventListener { + +/** + * Sent when a paint event occurs for the control. + * + * @param e an event containing information about the paint + */ +public void paintControl(PaintEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/SelectionAdapter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/SelectionAdapter.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.SelectionAdapter; + +import dwt.events.SelectionListener; + +/** + * This adapter class provides default implementations for the + * methods described by the SelectionListener interface. + *

+ * Classes that wish to deal with SelectionEvents can + * extend this class and override only the methods which they are + * interested in. + *

+ * + * @see SelectionListener + * @see SelectionEvent + */ +public abstract class SelectionAdapter : SelectionListener { + +/** + * Sent when selection occurs in the control. + * The default behavior is to do nothing. + * + * @param e an event containing information about the selection + */ +public void widgetSelected(SelectionEvent e) { +} + +/** + * Sent when default selection occurs in the control. + * The default behavior is to do nothing. + * + * @param e an event containing information about the default selection + */ +public void widgetDefaultSelected(SelectionEvent e) { +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/SelectionEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/SelectionEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,145 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.SelectionEvent; + + +import dwt.widgets.Event; +import dwt.widgets.Widget; +import dwt.events.TypedEvent; + +import tango.text.convert.Format; +/** + * Instances of this class are sent as a result of + * widgets being selected. + *

+ * Note: The fields that are filled in depend on the widget. + *

+ * + * @see SelectionListener + */ + +public class SelectionEvent : TypedEvent { + + /** + * The item that was selected. + */ + public Widget item; + + /** + * Extra detail information about the selection, depending on the widget. + * + *

Sash

    + *
  • {@link dwt.DWT#DRAG}
  • + *

ScrollBar and Slider

    + *
  • {@link dwt.DWT#DRAG}
  • + *
  • {@link dwt.DWT#HOME}
  • + *
  • {@link dwt.DWT#END}
  • + *
  • {@link dwt.DWT#ARROW_DOWN}
  • + *
  • {@link dwt.DWT#ARROW_UP}
  • + *
  • {@link dwt.DWT#PAGE_DOWN}
  • + *
  • {@link dwt.DWT#PAGE_UP}
  • + *

Table and Tree

    + *
  • {@link dwt.DWT#CHECK}
  • + *

Text

    + *
  • {@link dwt.DWT#CANCEL}
  • + *

CoolItem and ToolItem

    + *
  • {@link dwt.DWT#ARROW}
  • + *

+ */ + public int detail; + + /** + * The x location of the selected area. + */ + public int x; + + /** + * The y location of selected area. + */ + public int y; + + /** + * The width of selected area. + */ + public int width; + + /** + * The height of selected area. + */ + public int height; + + /** + * The state of the keyboard modifier keys at the time + * the event was generated. + */ + public int stateMask; + + /** + * The text of the hyperlink that was selected. + * This will be either the text of the hyperlink or the value of its HREF, + * if one was specified. + * + * @see dwt.widgets.Link#setText(String) + * @since 3.1 + */ + public char[] text; + + /** + * A flag indicating whether the operation should be allowed. + * Setting this field to false will cancel the + * operation, depending on the widget. + */ + public bool doit; + + //static final long serialVersionUID = 3976735856884987953L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); + this.item = e.item; + this.x = e.x; + this.y = e.y; + this.width = e.width; + this.height = e.height; + this.detail = e.detail; + this.stateMask = e.stateMask; + this.text = e.text; + this.doit = e.doit; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public char[] toString() { + return Format( "{} item={} detail={} x={} y={} width={} height={} stateMask={} text={} doit={}}", + super.toString[ 0 .. $-2 ], + item, + detail, + x, + y, + width, + height, + stateMask, + text, + doit ); +} +} + diff -r 000000000000 -r 5406a8f6526d dwt/events/SelectionListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/SelectionListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.SelectionListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.SelectionEvent; + +/** + * Classes which implement this interface provide methods + * that deal with the events that are generated when selection + * occurs in a control. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a control using the + * addSelectionListener method and removed using + * the removeSelectionListener method. When + * selection occurs in a control the appropriate method + * will be invoked. + *

+ * + * @see SelectionAdapter + * @see SelectionEvent + */ +public interface SelectionListener : DWTEventListener { + +/** + * Sent when selection occurs in the control. + *

+ * For example, selection occurs in a List when the user selects + * an item or items with the keyboard or mouse. On some platforms, + * the event occurs when a mouse button or key is pressed. On others, + * it happens when the mouse or key is released. The exact key or + * mouse gesture that causes this event is platform specific. + *

+ * + * @param e an event containing information about the selection + */ +public void widgetSelected(SelectionEvent e); + +/** + * Sent when default selection occurs in the control. + *

+ * For example, on some platforms default selection occurs in a List + * when the user double-clicks an item or types return in a Text. + * On some platforms, the event occurs when a mouse button or key is + * pressed. On others, it happens when the mouse or key is released. + * The exact key or mouse gesture that causes this event is platform + * specific. + *

+ * + * @param e an event containing information about the default selection + */ +public void widgetDefaultSelected(SelectionEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/ShellAdapter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/ShellAdapter.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,123 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.ShellAdapter; + +import dwt.events.ShellListener; + +/** + * This adapter class provides default implementations for the + * methods described by the ShellListener interface. + *

+ * Classes that wish to deal with ShellEvents can + * extend this class and override only the methods which they are + * interested in. + *

+ * + * @see ShellListener + * @see ShellEvent + */ +public abstract class ShellAdapter : ShellListener { + +/** + * Sent when a shell becomes the active window. + * The default behavior is to do nothing. + * + * @param e an event containing information about the activation + */ +public void shellActivated(ShellEvent e) { +} + +/** + * Sent when a shell is closed. + * The default behavior is to do nothing. + * + * @param e an event containing information about the close + */ +public void shellClosed(ShellEvent e) { +} + +/** + * Sent when a shell stops being the active window. + * The default behavior is to do nothing. + * + * @param e an event containing information about the deactivation + */ +public void shellDeactivated(ShellEvent e) { +} + +/** + * Sent when a shell is un-minimized. + * The default behavior is to do nothing. + * + * @param e an event containing information about the un-minimization + */ +public void shellDeiconified(ShellEvent e) { +} + +/** + * Sent when a shell is minimized. + * The default behavior is to do nothing. + * + * @param e an event containing information about the minimization + */ +public void shellIconified(ShellEvent e) { +} +} + +class ShellDelegator : ShellAdapter { + alias void delegate(ShellEvent) DFunc; + DFunc delShellActivated; + DFunc delShellClosed; + DFunc delShellDeactivated; + DFunc delShellDeiconified; + DFunc delShellIconified; + +private this( + DFunc delShellActivated, + DFunc delShellClosed, + DFunc delShellDeactivated, + DFunc delShellDeiconified, + DFunc delShellIconified ) +{ + this.delShellActivated = delShellActivated; + this.delShellClosed = delShellClosed; + this.delShellDeactivated = delShellDeactivated; + this.delShellDeiconified = delShellDeiconified; + this.delShellIconified = delShellIconified; +} + +static ShellDelegator createShellActivated( DFunc del ){ + return new ShellDelegator( del, null, null, null, null ); +} +static ShellDelegator createShellClosed( DFunc del ){ + return new ShellDelegator( null, del, null, null, null ); +} + +public void shellActivated(ShellEvent e) { + if( delShellActivated !is null ) delShellActivated(e); +} +public void shellClosed(ShellEvent e) { + if( delShellClosed !is null ) delShellClosed(e); +} +public void shellDeactivated(ShellEvent e) { + if( delShellDeactivated !is null ) delShellDeactivated(e); +} +public void shellDeiconified(ShellEvent e) { + if( delShellDeiconified !is null ) delShellDeiconified(e); +} +public void shellIconified(ShellEvent e) { + if( delShellIconified !is null ) delShellIconified(e); +} +} + + diff -r 000000000000 -r 5406a8f6526d dwt/events/ShellEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/ShellEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.ShellEvent; + + +import dwt.widgets.Event; +import dwt.events.TypedEvent; + +import tango.text.convert.Format; + +/** + * Instances of this class are sent as a result of + * operations being performed on shells. + * + * @see ShellListener + */ + +public final class ShellEvent : TypedEvent { + + /** + * A flag indicating whether the operation should be allowed. + * Setting this field to false will cancel the operation. + */ + public bool doit; + + //static final long serialVersionUID = 3257569490479888441L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); + this.doit = e.doit; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public char[] toString() { + return Format( "{} doit={}}", super.toString[ 0 .. $-2 ], doit ); +} +} + diff -r 000000000000 -r 5406a8f6526d dwt/events/ShellListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/ShellListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.ShellListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.ShellEvent; + +/** + * Classes which implement this interface provide methods + * that deal with changes in state of Shells. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a shell using the + * addShellListener method and removed using + * the removeShellListener method. When the + * state of the shell changes, the appropriate method will + * be invoked. + *

+ * + * @see ShellAdapter + * @see ShellEvent + */ +public interface ShellListener : DWTEventListener { + +/** + * Sent when a shell becomes the active window. + * + * @param e an event containing information about the activation + */ +public void shellActivated(ShellEvent e); + +/** + * Sent when a shell is closed. + * + * @param e an event containing information about the close + */ +public void shellClosed(ShellEvent e); + +/** + * Sent when a shell stops being the active window. + * + * @param e an event containing information about the deactivation + */ +public void shellDeactivated(ShellEvent e); + +/** + * Sent when a shell is un-minimized. + * + * @param e an event containing information about the un-minimization + */ +public void shellDeiconified(ShellEvent e); + +/** + * Sent when a shell is minimized. + * + * @param e an event containing information about the minimization + */ +public void shellIconified(ShellEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/TraverseEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/TraverseEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,137 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.TraverseEvent; + + +import dwt.widgets.Event; +import dwt.events.KeyEvent; + +import tango.text.convert.Format; +/** + * Instances of this class are sent as a result of + * widget traversal actions. + *

+ * The traversal event allows fine control over keyboard traversal + * in a control both to implement traversal and override the default + * traversal behavior defined by the system. This is achieved using + * two fields, detail and doit. + *

+ * When a control is traversed, a traverse event is sent. The detail + * describes the type of traversal and the doit field indicates the default + * behavior of the system. For example, when a right arrow key is pressed + * in a text control, the detail field is TRAVERSE_ARROW_NEXT + * and the doit field is false, indicating that the system + * will not traverse to the next tab item and the arrow key will be + * delivered to the text control. If the same key is pressed in a radio + * button, the doit field will be true, indicating that + * traversal is to proceed to the next tab item, possibly another radio + * button in the group and that the arrow key is not to be delivered + * to the radio button. + *

+ * How can the traversal event be used to implement traversal? + * When a tab key is pressed in a canvas, the detail field will be + * TRAVERSE_TAB_NEXT and the doit field will be + * false. The default behavior of the system is to + * provide no traversal for canvas controls. This means that by + * default in a canvas, a key listener will see every key that the + * user types, including traversal keys. To understand why this + * is so, it is important to understand that only the widget implementor + * can decide which traversal is appropriate for the widget. Returning + * to the TRAVERSE_TAB_NEXT example, a text widget implemented + * by a canvas would typically want to use the tab key to insert a + * tab character into the widget. A list widget implementation, on the + * other hand, would like the system default traversal behavior. Using + * only the doit flag, both implementations are possible. The text widget + * implementor sets doit to false, ensuring that the system + * will not traverse and that the tab key will be delivered to key listeners. + * The list widget implementor sets doit to true, indicating + * that the system should perform tab traversal and that the key should not + * be delivered to the list widget. + *

+ * How can the traversal event be used to override system traversal? + * When the return key is pressed in a single line text control, the + * detail field is TRAVERSE_RETURN and the doit field + * is true. This means that the return key will be processed + * by the default button, not the text widget. If the text widget has + * a default selection listener, it will not run because the return key + * will be processed by the default button. Imagine that the text control + * is being used as an in-place editor and return is used to dispose the + * widget. Setting doit to false will stop the system from + * activating the default button but the key will be delivered to the text + * control, running the key and selection listeners for the text. How + * can TRAVERSE_RETURN be implemented so that the default button + * will not be activated and the text widget will not see the return key? + * This is achieved by setting doit to true, and the detail + * to TRAVERSE_NONE. + *

+ * Note: A widget implementor will typically implement traversal using + * only the doit flag to either enable or disable system traversal. + *

+ * + * @see TraverseListener + */ + +public final class TraverseEvent : KeyEvent { + + /** + * The traversal type. + *

    + *
  • {@link dwt.DWT#TRAVERSE_NONE}
  • + *
  • {@link dwt.DWT#TRAVERSE_ESCAPE}
  • + *
  • {@link dwt.DWT#TRAVERSE_RETURN}
  • + *
  • {@link dwt.DWT#TRAVERSE_TAB_NEXT}
  • + *
  • {@link dwt.DWT#TRAVERSE_TAB_PREVIOUS}
  • + *
  • {@link dwt.DWT#TRAVERSE_ARROW_NEXT}
  • + *
  • {@link dwt.DWT#TRAVERSE_ARROW_PREVIOUS}
  • + *
  • {@link dwt.DWT#TRAVERSE_MNEMONIC}
  • + *
  • {@link dwt.DWT#TRAVERSE_PAGE_NEXT}
  • + *
  • {@link dwt.DWT#TRAVERSE_PAGE_PREVIOUS}
  • + *

+ * + * Setting this field will change the type of traversal. + * For example, setting the detail to TRAVERSE_NONE + * causes no traversal action to be taken. + * + * When used in conjunction with the doit field, the + * traversal detail field can be useful when overriding the default + * traversal mechanism for a control. For example, setting the doit + * field to false will cancel the operation and allow + * the traversal key stroke to be delivered to the control. Setting + * the doit field to true indicates that the traversal + * described by the detail field is to be performed. + */ + public int detail; + + //static final long serialVersionUID = 3257565105301239349L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); + this.detail = e.detail; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public char[] toString() { + return Format( "{} detail={}}", super.toString[ 0 .. $-2 ], detail ); +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/TraverseListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/TraverseListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.TraverseListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.TraverseEvent; + +/** + * Classes which implement this interface provide a method + * that deals with the events that are generated when a + * traverse event occurs in a control. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a control using the + * addTraverseListener method and removed using + * the removeTraverseListener method. When a + * traverse event occurs in a control, the keyTraversed method + * will be invoked. + *

+ * + * @see TraverseEvent + */ +public interface TraverseListener : DWTEventListener { + +/** + * Sent when a traverse event occurs in a control. + *

+ * A traverse event occurs when the user presses a traversal + * key. Traversal keys are typically tab and arrow keys, along + * with certain other keys on some platforms. Traversal key + * constants beginning with TRAVERSE_ are defined + * in the DWT class. + *

+ * + * @param e an event containing information about the traverse + */ +public void keyTraversed(TraverseEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/TreeAdapter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/TreeAdapter.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.TreeAdapter; + +import dwt.events.TreeListener; + +/** + * This adapter class provides default implementations for the + * methods described by the TreeListener interface. + *

+ * Classes that wish to deal with TreeEvents can + * extend this class and override only the methods which they are + * interested in. + *

+ * + * @see TreeListener + * @see TreeEvent + */ +public abstract class TreeAdapter : TreeListener { + +/** + * Sent when a tree branch is collapsed. + * The default behavior is to do nothing. + * + * @param e an event containing information about the tree operation + */ +public void treeCollapsed(TreeEvent e) { +} + +/** + * Sent when a tree branch is expanded. + * The default behavior is to do nothing. + * + * @param e an event containing information about the tree operation + */ +public void treeExpanded(TreeEvent e) { +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/TreeEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/TreeEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.TreeEvent; + + +import dwt.widgets.Event; +import dwt.events.SelectionEvent; + +/** + * Instances of this class are sent as a result of + * trees being expanded and collapsed. + * + * @see TreeListener + */ + +public final class TreeEvent : SelectionEvent { + + //static final long serialVersionUID = 3257282548009677109L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); +} + +} + diff -r 000000000000 -r 5406a8f6526d dwt/events/TreeListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/TreeListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.TreeListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.TreeEvent; + +/** + * Classes which implement this interface provide methods + * that deal with the expanding and collapsing of tree + * branches. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a tree control using the + * addTreeListener method and removed using + * the removeTreeListener method. When a branch + * of the tree is expanded or collapsed, the appropriate method + * will be invoked. + *

+ * + * @see TreeAdapter + * @see TreeEvent + */ +public interface TreeListener : DWTEventListener { + +/** + * Sent when a tree branch is collapsed. + * + * @param e an event containing information about the tree operation + */ +public void treeCollapsed(TreeEvent e); + +/** + * Sent when a tree branch is expanded. + * + * @param e an event containing information about the tree operation + */ +public void treeExpanded(TreeEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/events/TypedEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/TypedEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.TypedEvent; + + +import dwt.widgets.Event; +import dwt.widgets.Display; +import dwt.widgets.Widget; +import dwt.internal.DWTEventObject; + +import tango.text.convert.Format; +import tango.text.Util : split; + +/** + * This is the super class for all typed event classes provided + * by DWT. Typed events contain particular information which is + * applicable to the event occurrence. + * + * @see dwt.widgets.Event + */ +public class TypedEvent : DWTEventObject { + + /** + * the display where the event occurred + * + * @since 2.0 + */ + public Display display; + + /** + * the widget that issued the event + */ + public Widget widget; + + /** + * the time that the event occurred. + * + * NOTE: This field is an unsigned integer and should + * be AND'ed with 0xFFFFFFFFL so that it can be treated + * as a signed long. + */ + public int time; + + /** + * a field for application use + */ + public Object data; + + //static final long serialVersionUID = 3257285846578377524L; + +/** + * Constructs a new instance of this class. + * + * @param object the object that fired the event + */ +public this(Object object) { + super(object); +} + +/** + * Constructs a new instance of this class based on the + * information in the argument. + * + * @param e the low level event to initialize the receiver with + */ +public this(Event e) { + super(e.widget); + this.display = e.display; + this.widget = e.widget; + this.time = e.time; + this.data = e.data; +} + +/** + * Returns the name of the event. This is the name of + * the class without the module name. + * + * @return the name of the event + */ +char[] getName () { + char[] str = this.classinfo.name; + return split( str, "." )[$-1]; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public char[] toString() { + return Format( "{}{{{} time={} data={}}", widget.toString(), time, data.toString() ); +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/VerifyEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/VerifyEvent.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.VerifyEvent; + + +import dwt.widgets.Event; +import dwt.events.KeyEvent; + +import tango.text.convert.Format; +/** + * Instances of this class are sent as a result of + * widgets handling keyboard events + * + * @see VerifyListener + */ + +public final class VerifyEvent : KeyEvent { + + /** + * the range of text being modified. + * Setting these fields has no effect. + */ + public int start, end; + + /** + * the new text that will be inserted. + * Setting this field will change the text that is about to + * be inserted or deleted. + */ + public char[] text; + + //static final long serialVersionUID = 3257003246269577014L; + +/** + * Constructs a new instance of this class based on the + * information in the given untyped event. + * + * @param e the untyped event containing the information + */ +public this(Event e) { + super(e); + this.start = e.start; + this.end = e.end; + this.text = e.text; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public char[] toString() { + return Format( "{} start={} end={} text={}}", super.toString[ 0 .. $-2 ], start, end, text ); +} +} diff -r 000000000000 -r 5406a8f6526d dwt/events/VerifyListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/events/VerifyListener.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.events.VerifyListener; + + +public import dwt.internal.DWTEventListener; +public import dwt.events.VerifyEvent; + +/** + * Classes which implement this interface provide a method + * that deals with the events that are generated when text + * is about to be modified. + *

+ * After creating an instance of a class that extends + * this interface it can be added to a text control using the + * addVerifyListener method and removed using + * the removeVerifyListener method. When the + * text is about to be modified, the verifyText method + * will be invoked. + *

+ * + * @see VerifyEvent + */ +public interface VerifyListener : DWTEventListener { + +/** + * Sent when the text is about to be modified. + *

+ * A verify event occurs after the user has done something + * to modify the text (typically typed a key), but before + * the text is modified. The doit field in the verify event + * indicates whether or not to modify the text. + *

+ * + * @param e an event containing information about the verify + */ +public void verifyText(VerifyEvent e); +} diff -r 000000000000 -r 5406a8f6526d dwt/layout/FillData.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/layout/FillData.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.layout.FillData; + +import dwt.DWT; +import dwt.graphics.Point; +import dwt.widgets.Control; + +class FillData { + + int defaultWidth = -1, defaultHeight = -1; + int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1; + +Point computeSize (Control control, int wHint, int hHint, bool flushCache_) { + if (flushCache_) flushCache(); + if (wHint is DWT.DEFAULT && hHint is DWT.DEFAULT) { + if (defaultWidth is -1 || defaultHeight is -1) { + Point size = control.computeSize (wHint, hHint, flushCache_); + defaultWidth = size.x; + defaultHeight = size.y; + } + return new Point(defaultWidth, defaultHeight); + } + if (currentWidth is -1 || currentHeight is -1 || wHint !is currentWhint || hHint !is currentHhint) { + Point size = control.computeSize (wHint, hHint, flushCache_); + currentWhint = wHint; + currentHhint = hHint; + currentWidth = size.x; + currentHeight = size.y; + } + return new Point(currentWidth, currentHeight); +} +void flushCache () { + defaultWidth = defaultHeight = -1; + currentWidth = currentHeight = -1; +} +} diff -r 000000000000 -r 5406a8f6526d dwt/layout/FillLayout.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/layout/FillLayout.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,245 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.layout.FillLayout; + +import dwt.DWT; +import dwt.graphics.Point; +import dwt.graphics.Rectangle; +import dwt.widgets.Control; +import dwt.widgets.Layout; +import dwt.widgets.Composite; +import dwt.widgets.Scrollable; +import dwt.layout.FillData; + +import tango.text.Util; +import tango.util.Convert; + +/** + * FillLayout is the simplest layout class. It lays out + * controls in a single row or column, forcing them to be the same size. + *

+ * Initially, the controls will all be as tall as the tallest control, + * and as wide as the widest. FillLayout does not wrap, + * but you can specify margins and spacing. You might use it to + * lay out buttons in a task bar or tool bar, or to stack checkboxes + * in a Group. FillLayout can also be used + * when a Composite only has one child. For example, + * if a Shell has a single Group child, + * FillLayout will cause the Group to + * completely fill the Shell (if margins are 0). + *

+ *

+ * Example code: first a FillLayout is created and + * its type field is set, and then the layout is set into the + * Composite. Note that in a FillLayout, + * children are always the same size, and they fill all available space. + *

+ *      FillLayout fillLayout = new FillLayout();
+ *      fillLayout.type = DWT.VERTICAL;
+ *      shell.setLayout(fillLayout);
+ * 
+ *

+ */ +public final class FillLayout : Layout { + /** + * type specifies how controls will be positioned + * within the layout. + * + * The default value is HORIZONTAL. + * + * Possible values are:
    + *
  • HORIZONTAL: Position the controls horizontally from left to right
  • + *
  • VERTICAL: Position the controls vertically from top to bottom
  • + *
+ */ + public int type = DWT.HORIZONTAL; + + /** + * marginWidth specifies the number of pixels of horizontal margin + * that will be placed along the left and right edges of the layout. + * + * The default value is 0. + * + * @since 3.0 + */ + public int marginWidth = 0; + + /** + * marginHeight specifies the number of pixels of vertical margin + * that will be placed along the top and bottom edges of the layout. + * + * The default value is 0. + * + * @since 3.0 + */ + public int marginHeight = 0; + + /** + * spacing specifies the number of pixels between the edge of one cell + * and the edge of its neighbouring cell. + * + * The default value is 0. + * + * @since 3.0 + */ + public int spacing = 0; + +/** + * Constructs a new instance of this class. + */ +public this () { +} + +/** + * Constructs a new instance of this class given the type. + * + * @param type the type of fill layout + * + * @since 2.0 + */ +public this (int type) { + this.type = type; +} + +protected Point computeSize (Composite composite, int wHint, int hHint, bool flushCache) { + Control [] children = composite.getChildren (); + int count = children.length; + int maxWidth = 0, maxHeight = 0; + for (int i=0; i 0) { + if (type is DWT.HORIZONTAL && wHint !is DWT.DEFAULT) { + w = Math.max (0, (wHint - (count - 1) * spacing) / count); + } + if (type is DWT.VERTICAL && hHint !is DWT.DEFAULT) { + h = Math.max (0, (hHint - (count - 1) * spacing) / count); + } + } + Point size = computeChildSize (child, w, h, flushCache); + maxWidth = Math.max (maxWidth, size.x); + maxHeight = Math.max (maxHeight, size.y); + } + int width = 0, height = 0; + if (type is DWT.HORIZONTAL) { + width = count * maxWidth; + if (count !is 0) width += (count - 1) * spacing; + height = maxHeight; + } else { + width = maxWidth; + height = count * maxHeight; + if (count !is 0) height += (count - 1) * spacing; + } + width += marginWidth * 2; + height += marginHeight * 2; + if (wHint !is DWT.DEFAULT) width = wHint; + if (hHint !is DWT.DEFAULT) height = hHint; + return new Point (width, height); +} + +Point computeChildSize (Control control, int wHint, int hHint, bool flushCache) { + FillData data = cast(FillData)control.getLayoutData (); + if (data is null) { + data = new FillData (); + control.setLayoutData (data); + } + Point size = null; + if (wHint is DWT.DEFAULT && hHint is DWT.DEFAULT) { + size = data.computeSize (control, wHint, hHint, flushCache); + } else { + // TEMPORARY CODE + int trimX, trimY; + if ( auto sa = cast(Scrollable)control ) { + Rectangle rect = sa.computeTrim (0, 0, 0, 0); + trimX = rect.width; + trimY = rect.height; + } else { + trimX = trimY = control.getBorderWidth () * 2; + } + int w = wHint is DWT.DEFAULT ? wHint : Math.max (0, wHint - trimX); + int h = hHint is DWT.DEFAULT ? hHint : Math.max (0, hHint - trimY); + size = data.computeSize (control, w, h, flushCache); + } + return size; +} + +protected bool flushCache (Control control) { + Object data = control.getLayoutData(); + if (data !is null) (cast(FillData)data).flushCache(); + return true; +} + +char[] getName () { + char[] string = this.classinfo.name; + int index = locatePrior( string, '.'); + if (index is string.length ) return string; + return string[ index + 1 .. string.length ]; +} + +protected void layout (Composite composite, bool flushCache) { + Rectangle rect = composite.getClientArea (); + Control [] children = composite.getChildren (); + int count = children.length; + if (count is 0) return; + int width = rect.width - marginWidth * 2; + int height = rect.height - marginHeight * 2; + if (type is DWT.HORIZONTAL) { + width -= (count - 1) * spacing; + int x = rect.x + marginWidth, extra = width % count; + int y = rect.y + marginHeight, cellWidth = width / count; + for (int i=0; i + *******************************************************************************/ +module dwt.layout.FormAttachment; + +import dwt.DWT; +import dwt.widgets.Control; +import dwt.layout.FormLayout; +import dwt.layout.FormData; + +import tango.text.convert.Format; + +/** + * Instances of this class are used to define the edges of a control + * within a FormLayout. + *

+ * FormAttachments are set into the top, bottom, left, + * and right fields of the FormData for a control. + * For example: + *

+ *      FormData data = new FormData();
+ *      data.top = new FormAttachment(0,5);
+ *      data.bottom = new FormAttachment(100,-5);
+ *      data.left = new FormAttachment(0,5);
+ *      data.right = new FormAttachment(100,-5);
+ *      button.setLayoutData(data);
+ * 
+ *

+ *

+ * A FormAttachment defines where to attach the side of + * a control by using the equation, y = ax + b. The "a" term represents + * a fraction of the parent composite's width (from the left) or height + * (from the top). It can be defined using a numerator and denominator, + * or just a percentage value. If a percentage is used, the denominator + * is set to 100. The "b" term in the equation represents an offset, in + * pixels, from the attachment position. For example: + *

+ *      FormAttachment attach = new FormAttachment (20, -5);
+ * 
+ * specifies that the side to which the FormAttachment + * object belongs will lie at 20% of the parent composite, minus 5 pixels. + *

+ *

+ * Control sides can also be attached to another control. + * For example: + *

+ *      FormAttachment attach = new FormAttachment (button, 10);
+ * 
+ * specifies that the side to which the FormAttachment + * object belongs will lie in the same position as the adjacent side of + * the button control, plus 10 pixels. The control side can + * also be attached to the opposite side of the specified control. + * For example: + *
+ *      FormData data = new FormData ();
+ *      data.left = new FormAttachment (button, 0, DWT.LEFT);
+ * 
+ * specifies that the left side of the control will lie in the same position + * as the left side of the button control. The control can also + * be attached in a position that will center the control on the specified + * control. For example: + *
+ *      data.left = new FormAttachment (button, 0, DWT.CENTER);
+ * 
+ * specifies that the left side of the control will be positioned so that it is + * centered between the left and right sides of the button control. + * If the alignment is not specified, the default is to attach to the adjacent side. + *

+ * + * @see FormLayout + * @see FormData + * + * @since 2.0 + */ +public final class FormAttachment { + /** + * numerator specifies the numerator of the "a" term in the + * equation, y = ax + b, which defines the attachment. + */ + public int numerator; + + /** + * denominator specifies the denominator of the "a" term in the + * equation, y = ax + b, which defines the attachment. + * + * The default value is 100. + */ + public int denominator = 100; + + /** + * offset specifies the offset, in pixels, of the control side + * from the attachment position. + * If the offset is positive, then the control side is offset + * to the right of or below the attachment position. If it is + * negative, then the control side is offset to the left of or + * above the attachment position. + * + * This is equivalent to the "b" term in the equation y = ax + b. + * The default value is 0. + */ + public int offset; + + /** + * control specifies the control to which the control side is + * attached. + */ + public Control control; + + /** + * alignment specifies the alignment of the control side that is + * attached to a control. + *

+ * For top and bottom attachments, TOP, BOTTOM and CENTER are used. For left + * and right attachments, LEFT, RIGHT and CENTER are used. If any other case + * occurs, the default will be used instead. + *

+ * + *
Possible values are:
    + *
  • TOP: Attach the side to the top side of the specified control.
  • + *
  • BOTTOM : Attach the side to the bottom side of the specified control.
  • + *
  • LEFT: Attach the side to the left side of the specified control.
  • + *
  • RIGHT: Attach the side to the right side of the specified control.
  • + *
  • CENTER: Attach the side at a position which will center the control on the specified control.
  • + *
  • DEFAULT: Attach the side to the adjacent side of the specified control.
  • + *
+ */ + public int alignment; + +/** + * Constructs a new instance of this class. + * Since no numerator, denominator or offset is specified, + * the attachment is treated as a percentage of the form. + * The numerator is zero, the denominator is 100 and the + * offset is zero. + * + * @since 3.2 + */ +public this () { +} + +/** + * Constructs a new instance of this class given a numerator + * Since no denominator or offset is specified, the default + * is to treat the numerator as a percentage of the form, with a + * denominator of 100. The offset is zero. + * + * @param numerator the percentage of the position + * + * @since 3.0 + */ +public this (int numerator) { + this (numerator, 100, 0); +} + +/** + * Constructs a new instance of this class given a numerator + * and an offset. Since no denominator is specified, the default + * is to treat the numerator as a percentage of the form, with a + * denominator of 100. + * + * @param numerator the percentage of the position + * @param offset the offset of the side from the position + */ +public this (int numerator, int offset) { + this (numerator, 100, offset); +} + +/** + * Constructs a new instance of this class given a numerator + * and denominator and an offset. The position of the side is + * given by the fraction of the form defined by the numerator + * and denominator. + * + * @param numerator the numerator of the position + * @param denominator the denominator of the position + * @param offset the offset of the side from the position + */ +public this (int numerator, int denominator, int offset) { + if (denominator == 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO); + this.numerator = numerator; + this.denominator = denominator; + this.offset = offset; +} + +/** + * Constructs a new instance of this class given a control. + * Since no alignment is specified, the default alignment is + * to attach the side to the adjacent side of the specified + * control. Since no offset is specified, an offset of 0 is + * used. + * + * @param control the control the side is attached to + */ +public this (Control control) { + this (control, 0, DWT.DEFAULT); +} + +/** + * Constructs a new instance of this class given a control + * and an offset. Since no alignment is specified, the default + * alignment is to attach the side to the adjacent side of the + * specified control. + * + * @param control the control the side is attached to + * @param offset the offset of the side from the control + */ +public this (Control control, int offset) { + this (control, offset, DWT.DEFAULT); +} + +/** + * Constructs a new instance of this class given a control, + * an offset and an alignment. + * + * @param control the control the side is attached to + * @param offset the offset of the side from the control + * @param alignment the alignment of the side to the control it is attached to + */ +public this (Control control, int offset, int alignment) { + this.control = control; + this.offset = offset; + this.alignment = alignment; +} + +FormAttachment divide (int value) { + return new FormAttachment (numerator, denominator * value, offset / value); +} + +int gcd (int m, int n) { + int temp; + m = Math.abs (m); + n = Math.abs (n); + if (m < n) { + temp = m; + m = n; + n = temp; + } + while (n != 0){ + temp = m; + m = n; + n = temp % n; + } + return m; +} + +FormAttachment minus (FormAttachment attachment) { + FormAttachment solution = new FormAttachment (); + solution.numerator = numerator * attachment.denominator - denominator * attachment.numerator; + solution.denominator = denominator * attachment.denominator; + int gcd = gcd (solution.denominator, solution.numerator); + solution.numerator = solution.numerator / gcd; + solution.denominator = solution.denominator / gcd; + solution.offset = offset - attachment.offset; + return solution; +} + +FormAttachment minus (int value) { + return new FormAttachment (numerator, denominator, offset - value); +} + +FormAttachment plus (FormAttachment attachment) { + FormAttachment solution = new FormAttachment (); + solution.numerator = numerator * attachment.denominator + denominator * attachment.numerator; + solution.denominator = denominator * attachment.denominator; + int gcd = gcd (solution.denominator, solution.numerator); + solution.numerator = solution.numerator / gcd; + solution.denominator = solution.denominator / gcd; + solution.offset = offset + attachment.offset; + return solution; +} + +FormAttachment plus (int value) { + return new FormAttachment (numerator, denominator, offset + value); +} + +int solveX (int value) { + if (denominator == 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO); + return ((numerator * value) / denominator) + offset; +} + +int solveY (int value) { + if (numerator == 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO); + return (value - offset) * denominator / numerator; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the FormAttachment + */ +public char[] toString () { + char[] string = control != null ? control.toString () : Format( "{}/{}", numerator, denominator ); + return Format("{{y = ({})x + {}}", string, ( offset >= 0 ? Format(")x + {}", offset ) : Format( ")x - {}", -offset))); +} + +} diff -r 000000000000 -r 5406a8f6526d dwt/layout/FormData.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/layout/FormData.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,350 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.layout.FormData; + + +import dwt.DWT; +import dwt.graphics.Point; +import dwt.widgets.Control; +import dwt.layout.FormAttachment; +import tango.text.Util; + +import tango.text.Util; +import tango.util.Convert; + +/** + * Instances of this class are used to define the attachments + * of a control in a FormLayout. + *

+ * To set a FormData object into a control, you use the + * setLayoutData () method. To define attachments for the + * FormData, set the fields directly, like this: + *

+ *      FormData data = new FormData();
+ *      data.left = new FormAttachment(0,5);
+ *      data.right = new FormAttachment(100,-5);
+ *      button.setLayoutData(formData);
+ * 
+ *

+ *

+ * FormData contains the FormAttachments for + * each edge of the control that the FormLayout uses to + * determine the size and position of the control. FormData + * objects also allow you to set the width and height of controls within + * a FormLayout. + *

+ * + * @see FormLayout + * @see FormAttachment + * + * @since 2.0 + */ +public final class FormData { + /** + * width specifies the preferred width in pixels. This value + * is the wHint passed into Control.computeSize(int, int, bool) + * to determine the preferred size of the control. + * + * The default value is DWT.DEFAULT. + * + * @see Control#computeSize(int, int, bool) + */ + public int width = DWT.DEFAULT; + /** + * height specifies the preferred height in pixels. This value + * is the hHint passed into Control.computeSize(int, int, bool) + * to determine the preferred size of the control. + * + * The default value is DWT.DEFAULT. + * + * @see Control#computeSize(int, int, bool) + */ + public int height = DWT.DEFAULT; + /** + * left specifies the attachment of the left side of + * the control. + */ + public FormAttachment left; + /** + * right specifies the attachment of the right side of + * the control. + */ + public FormAttachment right; + /** + * top specifies the attachment of the top of the control. + */ + public FormAttachment top; + /** + * bottom specifies the attachment of the bottom of the + * control. + */ + public FormAttachment bottom; + + int cacheWidth = -1, cacheHeight = -1; + int defaultWhint, defaultHhint, defaultWidth = -1, defaultHeight = -1; + int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1; + FormAttachment cacheLeft, cacheRight, cacheTop, cacheBottom; + bool isVisited, needed; + +/** + * Constructs a new instance of FormData using + * default values. + */ +public this () { +} + +/** + * Constructs a new instance of FormData according to the parameters. + * A value of DWT.DEFAULT indicates that no minimum width or + * no minimum height is specified. + * + * @param width a minimum width for the control + * @param height a minimum height for the control + */ +public this (int width, int height) { + this.width = width; + this.height = height; +} + +void computeSize (Control control, int wHint, int hHint, bool flushCache_) { + if (cacheWidth !is -1 && cacheHeight !is -1) return; + if (wHint is this.width && hHint is this.height) { + if (defaultWidth is -1 || defaultHeight is -1 || wHint !is defaultWhint || hHint !is defaultHhint) { + Point size = control.computeSize (wHint, hHint, flushCache_); + defaultWhint = wHint; + defaultHhint = hHint; + defaultWidth = size.x; + defaultHeight = size.y; + } + cacheWidth = defaultWidth; + cacheHeight = defaultHeight; + return; + } + if (currentWidth is -1 || currentHeight is -1 || wHint !is currentWhint || hHint !is currentHhint) { + Point size = control.computeSize (wHint, hHint, flushCache_); + currentWhint = wHint; + currentHhint = hHint; + currentWidth = size.x; + currentHeight = size.y; + } + cacheWidth = currentWidth; + cacheHeight = currentHeight; +} + +void flushCache () { + cacheWidth = cacheHeight = -1; + defaultHeight = defaultWidth = -1; + currentHeight = currentWidth = -1; +} + +int getWidth (Control control, bool flushCache) { + needed = true; + computeSize (control, width, height, flushCache); + return cacheWidth; +} + +int getHeight (Control control, bool flushCache) { + computeSize (control, width, height, flushCache); + return cacheHeight; +} + +FormAttachment getBottomAttachment (Control control, int spacing, bool flushCache) { + if (cacheBottom !is null) return cacheBottom; + if (isVisited) return cacheBottom = new FormAttachment (0, getHeight (control, flushCache)); + if (bottom is null) { + if (top is null) return cacheBottom = new FormAttachment (0, getHeight (control, flushCache)); + return cacheBottom = getTopAttachment (control, spacing, flushCache).plus (getHeight (control, flushCache)); + } + Control bottomControl = bottom.control; + if (bottomControl !is null) { + if (bottomControl.isDisposed ()) { + bottom.control = bottomControl = null; + } else { + if (bottomControl.getParent () !is control.getParent ()) { + bottomControl = null; + } + } + } + if (bottomControl is null) return cacheBottom = bottom; + isVisited = true; + FormData bottomData = cast(FormData) bottomControl.getLayoutData (); + FormAttachment bottomAttachment = bottomData.getBottomAttachment (bottomControl, spacing, flushCache); + switch (bottom.alignment) { + case DWT.BOTTOM: + cacheBottom = bottomAttachment.plus (bottom.offset); + break; + case DWT.CENTER: { + FormAttachment topAttachment = bottomData.getTopAttachment (bottomControl, spacing, flushCache); + FormAttachment bottomHeight = bottomAttachment.minus (topAttachment); + cacheBottom = bottomAttachment.minus (bottomHeight.minus (getHeight (control, flushCache)).divide (2)); + break; + } + default: { + FormAttachment topAttachment = bottomData.getTopAttachment (bottomControl, spacing, flushCache); + cacheBottom = topAttachment.plus (bottom.offset - spacing); + break; + } + } + isVisited = false; + return cacheBottom; +} + +FormAttachment getLeftAttachment (Control control, int spacing, bool flushCache) { + if (cacheLeft !is null) return cacheLeft; + if (isVisited) return cacheLeft = new FormAttachment (0, 0); + if (left is null) { + if (right is null) return cacheLeft = new FormAttachment (0, 0); + return cacheLeft = getRightAttachment (control, spacing, flushCache).minus (getWidth (control, flushCache)); + } + Control leftControl = left.control; + if (leftControl !is null) { + if (leftControl.isDisposed ()) { + left.control = leftControl = null; + } else { + if (leftControl.getParent () !is control.getParent ()) { + leftControl = null; + } + } + } + if (leftControl is null) return cacheLeft = left; + isVisited = true; + FormData leftData = cast(FormData) leftControl.getLayoutData (); + FormAttachment leftAttachment = leftData.getLeftAttachment (leftControl, spacing, flushCache); + switch (left.alignment) { + case DWT.LEFT: + cacheLeft = leftAttachment.plus (left.offset); + break; + case DWT.CENTER: { + FormAttachment rightAttachment = leftData.getRightAttachment (leftControl, spacing, flushCache); + FormAttachment leftWidth = rightAttachment.minus (leftAttachment); + cacheLeft = leftAttachment.plus (leftWidth.minus (getWidth (control, flushCache)).divide (2)); + break; + } + default: { + FormAttachment rightAttachment = leftData.getRightAttachment (leftControl, spacing, flushCache); + cacheLeft = rightAttachment.plus (left.offset + spacing); + } + } + isVisited = false; + return cacheLeft; +} + +char[] getName () { + char[] string = this.classinfo.name; + int index = locatePrior( string, '.'); + if (index is string.length ) return string; + return string[ index + 1 .. string.length ]; +} + +FormAttachment getRightAttachment (Control control, int spacing, bool flushCache) { + if (cacheRight !is null) return cacheRight; + if (isVisited) return cacheRight = new FormAttachment (0, getWidth (control, flushCache)); + if (right is null) { + if (left is null) return cacheRight = new FormAttachment (0, getWidth (control, flushCache)); + return cacheRight = getLeftAttachment (control, spacing, flushCache).plus (getWidth (control, flushCache)); + } + Control rightControl = right.control; + if (rightControl !is null) { + if (rightControl.isDisposed ()) { + right.control = rightControl = null; + } else { + if (rightControl.getParent () !is control.getParent ()) { + rightControl = null; + } + } + } + if (rightControl is null) return cacheRight = right; + isVisited = true; + FormData rightData = cast(FormData) rightControl.getLayoutData (); + FormAttachment rightAttachment = rightData.getRightAttachment (rightControl, spacing, flushCache); + switch (right.alignment) { + case DWT.RIGHT: + cacheRight = rightAttachment.plus (right.offset); + break; + case DWT.CENTER: { + FormAttachment leftAttachment = rightData.getLeftAttachment (rightControl, spacing, flushCache); + FormAttachment rightWidth = rightAttachment.minus (leftAttachment); + cacheRight = rightAttachment.minus (rightWidth.minus (getWidth (control, flushCache)).divide (2)); + break; + } + default: { + FormAttachment leftAttachment = rightData.getLeftAttachment (rightControl, spacing, flushCache); + cacheRight = leftAttachment.plus (right.offset - spacing); + break; + } + } + isVisited = false; + return cacheRight; +} + +FormAttachment getTopAttachment (Control control, int spacing, bool flushCache) { + if (cacheTop !is null) return cacheTop; + if (isVisited) return cacheTop = new FormAttachment (0, 0); + if (top is null) { + if (bottom is null) return cacheTop = new FormAttachment (0, 0); + return cacheTop = getBottomAttachment (control, spacing, flushCache).minus (getHeight (control, flushCache)); + } + Control topControl = top.control; + if (topControl !is null) { + if (topControl.isDisposed ()) { + top.control = topControl = null; + } else { + if (topControl.getParent () !is control.getParent ()) { + topControl = null; + } + } + } + if (topControl is null) return cacheTop = top; + isVisited = true; + FormData topData = cast(FormData) topControl.getLayoutData (); + FormAttachment topAttachment = topData.getTopAttachment (topControl, spacing, flushCache); + switch (top.alignment) { + case DWT.TOP: + cacheTop = topAttachment.plus (top.offset); + break; + case DWT.CENTER: { + FormAttachment bottomAttachment = topData.getBottomAttachment (topControl, spacing, flushCache); + FormAttachment topHeight = bottomAttachment.minus (topAttachment); + cacheTop = topAttachment.plus (topHeight.minus (getHeight (control, flushCache)).divide (2)); + break; + } + default: { + FormAttachment bottomAttachment = topData.getBottomAttachment (topControl, spacing, flushCache); + cacheTop = bottomAttachment.plus (top.offset + spacing); + break; + } + } + isVisited = false; + return cacheTop; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the FormData object + */ +public char[] toString () { + char[] string = getName()~" {"; + if (width !is DWT.DEFAULT) string ~= "width="~to!(char[])(width)~" "; + if (height !is DWT.DEFAULT) string ~= "height="~to!(char[])(height)~" "; + if (left !is null) string ~= "left="~to!(char[])(left)~" "; + if (right !is null) string ~= "right="~to!(char[])(right)~" "; + if (top !is null) string ~= "top="~to!(char[])(top)~" "; + if (bottom !is null) string ~= "bottom="~to!(char[])(bottom)~" "; + string = trim( string ); + string ~= "}"; + return string; +} + +} diff -r 000000000000 -r 5406a8f6526d dwt/layout/FormLayout.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/layout/FormLayout.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,395 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.layout.FormLayout; + +import dwt.layout.FormAttachment; +import dwt.layout.FormData; +import dwt.DWT; +import dwt.graphics.Point; +import dwt.graphics.Rectangle; +import dwt.widgets.Control; +import dwt.widgets.Layout; +import dwt.widgets.Composite; +import dwt.widgets.Scrollable; + +import tango.text.Util; +import tango.util.Convert; +import Math = tango.math.Math; + +/** + * Instances of this class control the position and size of the + * children of a composite control by using FormAttachments + * to optionally configure the left, top, right and bottom edges of + * each child. + *

+ * The following example code creates a FormLayout and then sets + * it into a Shell: + *

+ *      Display display = new Display ();
+ *      Shell shell = new Shell(display);
+ *      FormLayout layout = new FormLayout();
+ *      layout.marginWidth = 3;
+ *      layout.marginHeight = 3;
+ *      shell.setLayout(layout);
+ * 
+ *

+ *

+ * To use a FormLayout, create a FormData with + * FormAttachment for each child of Composite. + * The following example code attaches button1 to the top + * and left edge of the composite and button2 to the right + * edge of button1 and the top and right edges of the + * composite: + *

+ *      FormData data1 = new FormData();
+ *      data1.left = new FormAttachment(0, 0);
+ *      data1.top = new FormAttachment(0, 0);
+ *      button1.setLayoutData(data1);
+ *      FormData data2 = new FormData();
+ *      data2.left = new FormAttachment(button1);
+ *      data2.top = new FormAttachment(0, 0);
+ *      data2.right = new FormAttachment(100, 0);
+ *      button2.setLayoutData(data2);
+ * 
+ *

+ *

+ * Each side of a child control can be attached to a position in the parent + * composite, or to other controls within the Composite by + * creating instances of FormAttachment and setting them into + * the top, bottom, left, and right fields of the child's FormData. + *

+ *

+ * If a side is not given an attachment, it is defined as not being attached + * to anything, causing the child to remain at its preferred size. If a child + * is given no attachment on either the left or the right or top or bottom, it is + * automatically attached to the left and top of the composite respectively. + * The following code positions button1 and button2 + * but relies on default attachments: + *

+ *      FormData data2 = new FormData();
+ *      data2.left = new FormAttachment(button1);
+ *      data2.right = new FormAttachment(100, 0);
+ *      button2.setLayoutData(data2);
+ * 
+ *

+ *

+ * IMPORTANT: Do not define circular attachments. For example, do not attach + * the right edge of button1 to the left edge of button2 + * and then attach the left edge of button2 to the right edge of + * button1. This will over constrain the layout, causing undefined + * behavior. The algorithm will terminate, but the results are undefined. + *

+ * + * @see FormData + * @see FormAttachment + * + * @since 2.0 + * + */ +public final class FormLayout : Layout { + + /** + * marginWidth specifies the number of pixels of horizontal margin + * that will be placed along the left and right edges of the layout. + * + * The default value is 0. + */ + public int marginWidth = 0; + + /** + * marginHeight specifies the number of pixels of vertical margin + * that will be placed along the top and bottom edges of the layout. + * + * The default value is 0. + */ + public int marginHeight = 0; + + + /** + * marginLeft specifies the number of pixels of horizontal margin + * that will be placed along the left edge of the layout. + * + * The default value is 0. + * + * @since 3.1 + */ + public int marginLeft = 0; + + /** + * marginTop specifies the number of pixels of vertical margin + * that will be placed along the top edge of the layout. + * + * The default value is 0. + * + * @since 3.1 + */ + public int marginTop = 0; + + /** + * marginRight specifies the number of pixels of horizontal margin + * that will be placed along the right edge of the layout. + * + * The default value is 0. + * + * @since 3.1 + */ + public int marginRight = 0; + + /** + * marginBottom specifies the number of pixels of vertical margin + * that will be placed along the bottom edge of the layout. + * + * The default value is 0. + * + * @since 3.1 + */ + public int marginBottom = 0; + + /** + * spacing specifies the number of pixels between the edge of one control + * and the edge of its neighbouring control. + * + * The default value is 0. + * + * @since 3.0 + */ + public int spacing = 0; + +/** + * Constructs a new instance of this class. + */ +public this () { +} + +/* + * Computes the preferred height of the form with + * respect to the preferred height of the control. + * + * Given that the equations for top (T) and bottom (B) + * of the control in terms of the height of the form (X) + * are: + * T = AX + B + * B = CX + D + * + * The equation for the height of the control (H) + * is bottom (B) minus top (T) or (H = B - T) or: + * + * H = (CX + D) - (AX + B) + * + * Solving for (X), the height of the form, we get: + * + * X = (H + B - D) / (C - A) + * + * When (A = C), (C - A = 0) and the equation has no + * solution for X. This is a special case meaning that + * the control does not constrain the height of the + * form. In this case, we need to arbitrarily define + * the height of the form (X): + * + * Case 1: A = C, A = 0, C = 0 + * + * Let X = D, the distance from the top of the form + * to the bottom edge of the control. In this case, + * the control was attached to the top of the form + * and the form needs to be large enough to show the + * bottom edge of the control. + * + * Case 2: A = C, A = 1, C = 1 + * + * Let X = -B, the distance from the bottom of the + * form to the top edge of the control. In this case, + * the control was attached to the bottom of the form + * and the only way that the control would be visible + * is if the offset is negative. If the offset is + * positive, there is no possible height for the form + * that will show the control as it will always be + * below the bottom edge of the form. + * + * Case 3: A = C, A !is 0, C !is 0 and A !is 1, C !is 0 + * + * Let X = D / (1 - C), the distance from the top of the + * form to the bottom edge of the control. In this case, + * since C is not 0 or 1, it must be a fraction, U / V. + * The offset D is the distance from CX to the bottom edge + * of the control. This represents a fraction of the form + * (1 - C)X. Since the height of a fraction of the form is + * known, the height of the entire form can be found by setting + * (1 - C)X = D. We solve this equation for X in terms of U + * and V, giving us X = (U * D) / (U - V). Similarly, if the + * offset D is negative, the control is positioned above CX. + * The offset -B is the distance from the top edge of the control + * to CX. We can find the height of the entire form by setting + * CX = -B. Solving in terms of U and V gives us X = (-B * V) / U. + */ +int computeHeight (Control control, FormData data, bool flushCache) { + FormAttachment top = data.getTopAttachment (control, spacing, flushCache); + FormAttachment bottom = data.getBottomAttachment (control, spacing, flushCache); + FormAttachment height = bottom.minus (top); + if (height.numerator is 0) { + if (bottom.numerator is 0) return bottom.offset; + if (bottom.numerator is bottom.denominator) return -top.offset; + if (bottom.offset <= 0) { + return -top.offset * top.denominator / bottom.numerator; + } + int divider = bottom.denominator - bottom.numerator; + return bottom.denominator * bottom.offset / divider; + } + return height.solveY (data.getHeight (control, flushCache)); +} + +protected Point computeSize (Composite composite, int wHint, int hHint, bool flushCache) { + Point size = layout (composite, false, 0, 0, wHint, hHint, flushCache); + if (wHint !is DWT.DEFAULT) size.x = wHint; + if (hHint !is DWT.DEFAULT) size.y = hHint; + return size; +} + +protected bool flushCache (Control control) { + Object data = control.getLayoutData (); + if (data !is null) (cast(FormData) data).flushCache (); + return true; +} + +char[] getName () { + char[] string = this.classinfo.name; + int index = locatePrior( string, '.'); + if (index is string.length ) return string; + return string[ index + 1 .. string.length ]; +} + +/* + * Computes the preferred height of the form with + * respect to the preferred height of the control. + */ +int computeWidth (Control control, FormData data, bool flushCache) { + FormAttachment left = data.getLeftAttachment (control, spacing, flushCache); + FormAttachment right = data.getRightAttachment (control, spacing, flushCache); + FormAttachment width = right.minus (left); + if (width.numerator is 0) { + if (right.numerator is 0) return right.offset; + if (right.numerator is right.denominator) return -left.offset; + if (right.offset <= 0) { + return -left.offset * left.denominator / left.numerator; + } + int divider = right.denominator - right.numerator; + return right.denominator * right.offset / divider; + } + return width.solveY (data.getWidth (control, flushCache)); +} + +protected void layout (Composite composite, bool flushCache) { + Rectangle rect = composite.getClientArea (); + int x = rect.x + marginLeft + marginWidth; + int y = rect.y + marginTop + marginHeight; + int width = Math.max (0, rect.width - marginLeft - 2 * marginWidth - marginRight); + int height = Math.max (0, rect.height - marginTop - 2 * marginHeight - marginBottom); + layout (composite, true, x, y, width, height, flushCache); +} + +Point layout (Composite composite, bool move, int x, int y, int width, int height, bool flushCache) { + Control [] children = composite.getChildren (); + for (int i=0; i + *******************************************************************************/ +module dwt.layout.GridData; + +import dwt.DWT; +import dwt.graphics.Point; +import dwt.widgets.Control; + +import tango.text.Util; +import tango.util.Convert; + +/** + * GridData is the layout data object associated with + * GridLayout. To set a GridData object into a + * control, you use the Control.setLayoutData(Object) method. + *

+ * There are two ways to create a GridData object with certain + * fields set. The first is to set the fields directly, like this: + *

+ *      GridData gridData = new GridData();
+ *      gridData.horizontalAlignment = GridData.FILL;
+ *      gridData.grabExcessHorizontalSpace = true;
+ *      button1.setLayoutData(gridData);
+ * 
+ * The second is to take advantage of convenience style bits defined + * by GridData: + *
+ *      button1.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
+ * 
+ *

+ *

+ * NOTE: Do not reuse GridData objects. Every control in a + * Composite that is managed by a GridLayout + * must have a unique GridData object. If the layout data + * for a control in a GridLayout is null at layout time, + * a unique GridData object is created for it. + *

+ * + * @see GridLayout + * @see Control#setLayoutData + */ +public final class GridData { + /** + * verticalAlignment specifies how controls will be positioned + * vertically within a cell. + * + * The default value is CENTER. + * + * Possible values are:
    + *
  • DWT.BEGINNING (or DWT.TOP): Position the control at the top of the cell
  • + *
  • DWT.CENTER: Position the control in the vertical center of the cell
  • + *
  • DWT.END (or DWT.BOTTOM): Position the control at the bottom of the cell
  • + *
  • DWT.FILL: Resize the control to fill the cell vertically
  • + *
+ */ + public int verticalAlignment = CENTER; + + /** + * horizontalAlignment specifies how controls will be positioned + * horizontally within a cell. + * + * The default value is BEGINNING. + * + * Possible values are:
    + *
  • DWT.BEGINNING (or DWT.LEFT): Position the control at the left of the cell
  • + *
  • DWT.CENTER: Position the control in the horizontal center of the cell
  • + *
  • DWT.END (or DWT.RIGHT): Position the control at the right of the cell
  • + *
  • DWT.FILL: Resize the control to fill the cell horizontally
  • + *
+ */ + public int horizontalAlignment = BEGINNING; + + /** + * widthHint specifies the preferred width in pixels. This value + * is the wHint passed into Control.computeSize(int, int, bool) + * to determine the preferred size of the control. + * + * The default value is DWT.DEFAULT. + * + * @see Control#computeSize(int, int, bool) + */ + public int widthHint = DWT.DEFAULT; + + /** + * heightHint specifies the preferred height in pixels. This value + * is the hHint passed into Control.computeSize(int, int, bool) + * to determine the preferred size of the control. + * + * The default value is DWT.DEFAULT. + * + * @see Control#computeSize(int, int, bool) + */ + public int heightHint = DWT.DEFAULT; + + /** + * horizontalIndent specifies the number of pixels of indentation + * that will be placed along the left side of the cell. + * + * The default value is 0. + */ + public int horizontalIndent = 0; + + /** + * verticalIndent specifies the number of pixels of indentation + * that will be placed along the top side of the cell. + * + * The default value is 0. + * + * @since 3.1 + */ + public int verticalIndent = 0; + + /** + * horizontalSpan specifies the number of column cells that the control + * will take up. + * + * The default value is 1. + */ + public int horizontalSpan = 1; + + /** + * verticalSpan specifies the number of row cells that the control + * will take up. + * + * The default value is 1. + */ + public int verticalSpan = 1; + + /** + *

grabExcessHorizontalSpace specifies whether the width of the cell + * changes depending on the size of the parent Composite. If + * grabExcessHorizontalSpace is true, the following rules + * apply to the width of the cell:

+ *
    + *
  • If extra horizontal space is available in the parent, the cell will + * grow to be wider than its preferred width. The new width + * will be "preferred width + delta" where delta is the extra + * horizontal space divided by the number of grabbing columns.
  • + *
  • If there is not enough horizontal space available in the parent, the + * cell will shrink until it reaches its minimum width as specified by + * GridData.minimumWidth. The new width will be the maximum of + * "minimumWidth" and "preferred width - delta", where delta is + * the amount of space missing divided by the number of grabbing columns.
  • + *
  • If the parent is packed, the cell will be its preferred width + * as specified by GridData.widthHint.
  • + *
  • If the control spans multiple columns and there are no other grabbing + * controls in any of the spanned columns, the last column in the span will + * grab the extra space. If there is at least one other grabbing control + * in the span, the grabbing will be spread over the columns already + * marked as grabExcessHorizontalSpace.
  • + *
+ * + *

The default value is false.

+ * + * @see GridData#minimumWidth + * @see GridData#widthHint + */ + public bool grabExcessHorizontalSpace = false; + + /** + *

grabExcessVerticalSpace specifies whether the height of the cell + * changes depending on the size of the parent Composite. If + * grabExcessVerticalSpace is true, the following rules + * apply to the height of the cell:

+ *
    + *
  • If extra vertical space is available in the parent, the cell will + * grow to be taller than its preferred height. The new height + * will be "preferred height + delta" where delta is the extra + * vertical space divided by the number of grabbing rows.
  • + *
  • If there is not enough vertical space available in the parent, the + * cell will shrink until it reaches its minimum height as specified by + * GridData.minimumHeight. The new height will be the maximum of + * "minimumHeight" and "preferred height - delta", where delta is + * the amount of space missing divided by the number of grabbing rows.
  • + *
  • If the parent is packed, the cell will be its preferred height + * as specified by GridData.heightHint.
  • + *
  • If the control spans multiple rows and there are no other grabbing + * controls in any of the spanned rows, the last row in the span will + * grab the extra space. If there is at least one other grabbing control + * in the span, the grabbing will be spread over the rows already + * marked as grabExcessVerticalSpace.
  • + *
+ * + *

The default value is false.

+ * + * @see GridData#minimumHeight + * @see GridData#heightHint + */ + public bool grabExcessVerticalSpace = false; + + /** + * minimumWidth specifies the minimum width in pixels. This value + * applies only if grabExcessHorizontalSpace is true. A value of + * DWT.DEFAULT means that the minimum width will be the result + * of Control.computeSize(int, int, bool) where wHint is + * determined by GridData.widthHint. + * + * The default value is 0. + * + * @since 3.1 + * @see Control#computeSize(int, int, bool) + * @see GridData#widthHint + */ + public int minimumWidth = 0; + + /** + * minimumHeight specifies the minimum height in pixels. This value + * applies only if grabExcessVerticalSpace is true. A value of + * DWT.DEFAULT means that the minimum height will be the result + * of Control.computeSize(int, int, bool) where hHint is + * determined by GridData.heightHint. + * + * The default value is 0. + * + * @since 3.1 + * @see Control#computeSize(int, int, bool) + * @see GridData#heightHint + */ + public int minimumHeight = 0; + + /** + * exclude informs the layout to ignore this control when sizing + * and positioning controls. If this value is true, + * the size and position of the control will not be managed by the + * layout. If this value is false, the size and + * position of the control will be computed and assigned. + * + * The default value is false. + * + * @since 3.1 + */ + public bool exclude = false; + + /** + * Value for horizontalAlignment or verticalAlignment. + * Position the control at the top or left of the cell. + * Not recommended. Use DWT.BEGINNING, DWT.TOP or DWT.LEFT instead. + */ + public static const int BEGINNING = DWT.BEGINNING; + + /** + * Value for horizontalAlignment or verticalAlignment. + * Position the control in the vertical or horizontal center of the cell + * Not recommended. Use DWT.CENTER instead. + */ + public static const int CENTER = 2; + + /** + * Value for horizontalAlignment or verticalAlignment. + * Position the control at the bottom or right of the cell + * Not recommended. Use DWT.END, DWT.BOTTOM or DWT.RIGHT instead. + */ + public static const int END = 3; + + /** + * Value for horizontalAlignment or verticalAlignment. + * Resize the control to fill the cell horizontally or vertically. + * Not recommended. Use DWT.FILL instead. + */ + public static const int FILL = DWT.FILL; + + /** + * Style bit for new GridData(int). + * Position the control at the top of the cell. + * Not recommended. Use + * new GridData(int, DWT.BEGINNING, bool, bool) + * instead. + */ + public static const int VERTICAL_ALIGN_BEGINNING = 1 << 1; + + /** + * Style bit for new GridData(int) to position the + * control in the vertical center of the cell. + * Not recommended. Use + * new GridData(int, DWT.CENTER, bool, bool) + * instead. + */ + public static const int VERTICAL_ALIGN_CENTER = 1 << 2; + + /** + * Style bit for new GridData(int) to position the + * control at the bottom of the cell. + * Not recommended. Use + * new GridData(int, DWT.END, bool, bool) + * instead. + */ + public static const int VERTICAL_ALIGN_END = 1 << 3; + + /** + * Style bit for new GridData(int) to resize the + * control to fill the cell vertically. + * Not recommended. Use + * new GridData(int, DWT.FILL, bool, bool) + * instead + */ + public static const int VERTICAL_ALIGN_FILL = 1 << 4; + + /** + * Style bit for new GridData(int) to position the + * control at the left of the cell. + * Not recommended. Use + * new GridData(DWT.BEGINNING, int, bool, bool) + * instead. + */ + public static const int HORIZONTAL_ALIGN_BEGINNING = 1 << 5; + + /** + * Style bit for new GridData(int) to position the + * control in the horizontal center of the cell. + * Not recommended. Use + * new GridData(DWT.CENTER, int, bool, bool) + * instead. + */ + public static const int HORIZONTAL_ALIGN_CENTER = 1 << 6; + + /** + * Style bit for new GridData(int) to position the + * control at the right of the cell. + * Not recommended. Use + * new GridData(DWT.END, int, bool, bool) + * instead. + */ + public static const int HORIZONTAL_ALIGN_END = 1 << 7; + + /** + * Style bit for new GridData(int) to resize the + * control to fill the cell horizontally. + * Not recommended. Use + * new GridData(DWT.FILL, int, bool, bool) + * instead. + */ + public static const int HORIZONTAL_ALIGN_FILL = 1 << 8; + + /** + * Style bit for new GridData(int) to resize the + * control to fit the remaining horizontal space. + * Not recommended. Use + * new GridData(int, int, true, bool) + * instead. + */ + public static const int GRAB_HORIZONTAL = 1 << 9; + + /** + * Style bit for new GridData(int) to resize the + * control to fit the remaining vertical space. + * Not recommended. Use + * new GridData(int, int, bool, true) + * instead. + */ + public static const int GRAB_VERTICAL = 1 << 10; + + /** + * Style bit for new GridData(int) to resize the + * control to fill the cell vertically and to fit the remaining + * vertical space. + * FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL + * Not recommended. Use + * new GridData(int, DWT.FILL, bool, true) + * instead. + */ + public static const int FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL; + + /** + * Style bit for new GridData(int) to resize the + * control to fill the cell horizontally and to fit the remaining + * horizontal space. + * FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL + * Not recommended. Use + * new GridData(DWT.FILL, int, true, bool) + * instead. + */ + public static const int FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL; + + /** + * Style bit for new GridData(int) to resize the + * control to fill the cell horizontally and vertically and + * to fit the remaining horizontal and vertical space. + * FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL + * Not recommended. Use + * new GridData(DWT.FILL, DWT.FILL, true, true) + * instead. + */ + public static const int FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL; + + int cacheWidth = -1, cacheHeight = -1; + int defaultWhint, defaultHhint, defaultWidth = -1, defaultHeight = -1; + int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1; + +/** + * Constructs a new instance of GridData using + * default values. + */ +public this () { +} + +/** + * Constructs a new instance based on the GridData style. + * This constructor is not recommended. + * + * @param style the GridData style + */ +public this (int style) { + if ((style & VERTICAL_ALIGN_BEGINNING) !is 0) verticalAlignment = BEGINNING; + if ((style & VERTICAL_ALIGN_CENTER) !is 0) verticalAlignment = CENTER; + if ((style & VERTICAL_ALIGN_FILL) !is 0) verticalAlignment = FILL; + if ((style & VERTICAL_ALIGN_END) !is 0) verticalAlignment = END; + if ((style & HORIZONTAL_ALIGN_BEGINNING) !is 0) horizontalAlignment = BEGINNING; + if ((style & HORIZONTAL_ALIGN_CENTER) !is 0) horizontalAlignment = CENTER; + if ((style & HORIZONTAL_ALIGN_FILL) !is 0) horizontalAlignment = FILL; + if ((style & HORIZONTAL_ALIGN_END) !is 0) horizontalAlignment = END; + grabExcessHorizontalSpace = (style & GRAB_HORIZONTAL) !is 0; + grabExcessVerticalSpace = (style & GRAB_VERTICAL) !is 0; +} + +/** + * Constructs a new instance of GridData according to the parameters. + * + * @param horizontalAlignment how control will be positioned horizontally within a cell + * @param verticalAlignment how control will be positioned vertically within a cell + * @param grabExcessHorizontalSpace whether cell will be made wide enough to fit the remaining horizontal space + * @param grabExcessVerticalSpace whether cell will be made high enough to fit the remaining vertical space + * + * @since 3.0 + */ +public this (int horizontalAlignment, int verticalAlignment, bool grabExcessHorizontalSpace, bool grabExcessVerticalSpace) { + this (horizontalAlignment, verticalAlignment, grabExcessHorizontalSpace, grabExcessVerticalSpace, 1, 1); +} + +/** + * Constructs a new instance of GridData according to the parameters. + * + * @param horizontalAlignment how control will be positioned horizontally within a cell + * @param verticalAlignment how control will be positioned vertically within a cell + * @param grabExcessHorizontalSpace whether cell will be made wide enough to fit the remaining horizontal space + * @param grabExcessVerticalSpace whether cell will be made high enough to fit the remaining vertical space + * @param horizontalSpan the number of column cells that the control will take up + * @param verticalSpan the number of row cells that the control will take up + * + * @since 3.0 + */ +public this (int horizontalAlignment, int verticalAlignment, bool grabExcessHorizontalSpace, bool grabExcessVerticalSpace, int horizontalSpan, int verticalSpan) { + this.horizontalAlignment = horizontalAlignment; + this.verticalAlignment = verticalAlignment; + this.grabExcessHorizontalSpace = grabExcessHorizontalSpace; + this.grabExcessVerticalSpace = grabExcessVerticalSpace; + this.horizontalSpan = horizontalSpan; + this.verticalSpan = verticalSpan; +} + +/** + * Constructs a new instance of GridData according to the parameters. + * A value of DWT.DEFAULT indicates that no minimum width or + * no minimum height is specified. + * + * @param width a minimum width for the column + * @param height a minimum height for the row + * + * @since 3.0 + */ +public this (int width, int height) { + this.widthHint = width; + this.heightHint = height; +} + +void computeSize (Control control, int wHint, int hHint, bool flushCache) { + if (cacheWidth !is -1 && cacheHeight !is -1) return; + if (wHint is this.widthHint && hHint is this.heightHint) { + if (defaultWidth is -1 || defaultHeight is -1 || wHint !is defaultWhint || hHint !is defaultHhint) { + Point size = control.computeSize (wHint, hHint, flushCache); + defaultWhint = wHint; + defaultHhint = hHint; + defaultWidth = size.x; + defaultHeight = size.y; + } + cacheWidth = defaultWidth; + cacheHeight = defaultHeight; + return; + } + if (currentWidth is -1 || currentHeight is -1 || wHint !is currentWhint || hHint !is currentHhint) { + Point size = control.computeSize (wHint, hHint, flushCache); + currentWhint = wHint; + currentHhint = hHint; + currentWidth = size.x; + currentHeight = size.y; + } + cacheWidth = currentWidth; + cacheHeight = currentHeight; +} + +void flushCache () { + cacheWidth = cacheHeight = -1; + defaultWidth = defaultHeight = -1; + currentWidth = currentHeight = -1; +} + +char[] getName () { + char[] string = this.classinfo.name; + int index = locatePrior( string, '.'); + if (index is string.length ) return string; + return string[ index + 1 .. string.length ]; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the GridData object + */ +public char[] toString () { + char[] hAlign = ""; + switch (horizontalAlignment) { + case DWT.FILL: hAlign = "DWT.FILL"; break; + case DWT.BEGINNING: hAlign = "DWT.BEGINNING"; break; + case DWT.LEFT: hAlign = "DWT.LEFT"; break; + case DWT.END: hAlign = "DWT.END"; break; + case END: hAlign = "GridData.END"; break; + case DWT.RIGHT: hAlign = "DWT.RIGHT"; break; + case DWT.CENTER: hAlign = "DWT.CENTER"; break; + case CENTER: hAlign = "GridData.CENTER"; break; + default: hAlign = "Undefined "~to!(char[])(horizontalAlignment); break; + } + char[] vAlign = ""; + switch (verticalAlignment) { + case DWT.FILL: vAlign = "DWT.FILL"; break; + case DWT.BEGINNING: vAlign = "DWT.BEGINNING"; break; + case DWT.TOP: vAlign = "DWT.TOP"; break; + case DWT.END: vAlign = "DWT.END"; break; + case END: vAlign = "GridData.END"; break; + case DWT.BOTTOM: vAlign = "DWT.BOTTOM"; break; + case DWT.CENTER: vAlign = "DWT.CENTER"; break; + case CENTER: vAlign = "GridData.CENTER"; break; + default: vAlign = "Undefined "~to!(char[])(verticalAlignment); break; + } + char[] string = getName()~" {"; + string ~= "horizontalAlignment="~to!(char[])(hAlign)~" "; + if (horizontalIndent !is 0) string ~= "horizontalIndent="~to!(char[])(horizontalIndent)~" "; + if (horizontalSpan !is 1) string ~= "horizontalSpan="~to!(char[])(horizontalSpan)~" "; + if (grabExcessHorizontalSpace) string ~= "grabExcessHorizontalSpace="~to!(char[])(grabExcessHorizontalSpace)~" "; + if (widthHint !is DWT.DEFAULT) string ~= "widthHint="~to!(char[])(widthHint)~" "; + if (minimumWidth !is 0) string ~= "minimumWidth="~to!(char[])(minimumWidth)~" "; + string ~= "verticalAlignment="~vAlign~" "; + if (verticalIndent !is 0) string ~= "verticalIndent="~to!(char[])(verticalIndent)~" "; + if (verticalSpan !is 1) string ~= "verticalSpan="~to!(char[])(verticalSpan)~" "; + if (grabExcessVerticalSpace) string ~= "grabExcessVerticalSpace="~to!(char[])(grabExcessVerticalSpace)~" "; + if (heightHint !is DWT.DEFAULT) string ~= "heightHint="~to!(char[])(heightHint)~" "; + if (minimumHeight !is 0) string ~= "minimumHeight="~to!(char[])(minimumHeight)~" "; + if (exclude) string ~= "exclude="~to!(char[])(exclude)~" "; + string = string.trim(); + string ~= "}"; + return string; +} +} diff -r 000000000000 -r 5406a8f6526d dwt/layout/GridLayout.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/layout/GridLayout.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,759 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.layout.GridLayout; + +import dwt.layout.GridData; +import dwt.DWT; +import dwt.graphics.Point; +import dwt.graphics.Rectangle; +import dwt.widgets.Control; +import dwt.widgets.Composite; +import dwt.widgets.Layout; +import dwt.widgets.Scrollable; + +import dwt.dwthelper.System; +import dwt.dwthelper.Integer; + +import tango.text.Util; +import tango.util.Convert; +import Math = tango.math.Math; + + +/** + * Instances of this class lay out the control children of a + * Composite in a grid. + *

+ * GridLayout has a number of configuration fields, and the + * controls it lays out can have an associated layout data object, called + * GridData. The power of GridLayout lies in the + * ability to configure GridData for each control in the layout. + *

+ *

+ * The following code creates a shell managed by a GridLayout + * with 3 columns: + *

+ *      Display display = new Display();
+ *      Shell shell = new Shell(display);
+ *      GridLayout gridLayout = new GridLayout();
+ *      gridLayout.numColumns = 3;
+ *      shell.setLayout(gridLayout);
+ * 
+ * The numColumns field is the most important field in a + * GridLayout. Widgets are laid out in columns from left + * to right, and a new row is created when numColumns + 1 + * controls are added to the Composite. + *

+ * + * @see GridData + */ +public final class GridLayout : Layout { + + /** + * numColumns specifies the number of cell columns in the layout. + * If numColumns has a value less than 1, the layout will not + * set the size and position of any controls. + * + * The default value is 1. + */ + public int numColumns = 1; + + /** + * makeColumnsEqualWidth specifies whether all columns in the layout + * will be forced to have the same width. + * + * The default value is false. + */ + public bool makeColumnsEqualWidth = false; + + /** + * marginWidth specifies the number of pixels of horizontal margin + * that will be placed along the left and right edges of the layout. + * + * The default value is 5. + */ + public int marginWidth = 5; + + /** + * marginHeight specifies the number of pixels of vertical margin + * that will be placed along the top and bottom edges of the layout. + * + * The default value is 5. + */ + public int marginHeight = 5; + + /** + * marginLeft specifies the number of pixels of horizontal margin + * that will be placed along the left edge of the layout. + * + * The default value is 0. + * + * @since 3.1 + */ + public int marginLeft = 0; + + /** + * marginTop specifies the number of pixels of vertical margin + * that will be placed along the top edge of the layout. + * + * The default value is 0. + * + * @since 3.1 + */ + public int marginTop = 0; + + /** + * marginRight specifies the number of pixels of horizontal margin + * that will be placed along the right edge of the layout. + * + * The default value is 0. + * + * @since 3.1 + */ + public int marginRight = 0; + + /** + * marginBottom specifies the number of pixels of vertical margin + * that will be placed along the bottom edge of the layout. + * + * The default value is 0. + * + * @since 3.1 + */ + public int marginBottom = 0; + + /** + * horizontalSpacing specifies the number of pixels between the right + * edge of one cell and the left edge of its neighbouring cell to + * the right. + * + * The default value is 5. + */ + public int horizontalSpacing = 5; + + /** + * verticalSpacing specifies the number of pixels between the bottom + * edge of one cell and the top edge of its neighbouring cell underneath. + * + * The default value is 5. + */ + public int verticalSpacing = 5; + +/** + * Constructs a new instance of this class. + */ +public this () {} + +/** + * Constructs a new instance of this class given the + * number of columns, and whether or not the columns + * should be forced to have the same width. + * If numColumns has a value less than 1, the layout will not + * set the size and position of any controls. + * + * @param numColumns the number of columns in the grid + * @param makeColumnsEqualWidth whether or not the columns will have equal width + * + * @since 2.0 + */ +public this (int numColumns, bool makeColumnsEqualWidth) { + this.numColumns = numColumns; + this.makeColumnsEqualWidth = makeColumnsEqualWidth; +} + +protected Point computeSize (Composite composite, int wHint, int hHint, bool flushCache_) { + Point size = layout (composite, false, 0, 0, wHint, hHint, flushCache_); + if (wHint !is DWT.DEFAULT) size.x = wHint; + if (hHint !is DWT.DEFAULT) size.y = hHint; + return size; +} + +protected bool flushCache (Control control) { + Object data = control.getLayoutData (); + if (data !is null) (cast(GridData) data).flushCache (); + return true; +} + +GridData getData (Control [][] grid, int row, int column, int rowCount, int columnCount, bool first) { + Control control = grid [row] [column]; + if (control !is null) { + GridData data = cast(GridData) control.getLayoutData (); + int hSpan = Math.max (1, Math.min (data.horizontalSpan, columnCount)); + int vSpan = Math.max (1, data.verticalSpan); + int i = first ? row + vSpan - 1 : row - vSpan + 1; + int j = first ? column + hSpan - 1 : column - hSpan + 1; + if (0 <= i && i < rowCount) { + if (0 <= j && j < columnCount) { + if (control is grid [i][j]) return data; + } + } + } + return null; +} + +protected void layout (Composite composite, bool flushCache_) { + Rectangle rect = composite.getClientArea (); + layout (composite, true, rect.x, rect.y, rect.width, rect.height, flushCache_); +} + +Point layout (Composite composite, bool move, int x, int y, int width, int height, bool flushCache_) { + if (numColumns < 1) { + return new Point (marginLeft + marginWidth * 2 + marginRight, marginTop + marginHeight * 2 + marginBottom); + } + Control [] children = composite.getChildren (); + int count = 0; + for (int i=0; i 0) { + if (data.cacheWidth < data.minimumWidth) { + int trim = 0; + //TEMPORARY CODE + if ( auto sa = cast(Scrollable)child ) { + Rectangle rect = sa.computeTrim (0, 0, 0, 0); + trim = rect.width; + } else { + trim = child.getBorderWidth () * 2; + } + data.cacheWidth = data.cacheHeight = DWT.DEFAULT; + data.computeSize (child, Math.max (0, data.minimumWidth - trim), data.heightHint, false); + } + } + if (data.grabExcessVerticalSpace && data.minimumHeight > 0) { + data.cacheHeight = Math.max (data.cacheHeight, data.minimumHeight); + } + } + + /* Build the grid */ + int row = 0, column = 0, rowCount = 0, columnCount = numColumns; + Control [][] grid = new Control [][]( 4, columnCount ); + for (int i=0; i= grid.length) { + Control [][] newGrid = new Control[][]( lastRow + 4, columnCount ); + SimpleType!(Control[]).arraycopy (grid, 0, newGrid, 0, grid.length); + grid = newGrid; + } + if (grid [row] is null) { + grid [row] = new Control [columnCount]; + } + while (column < columnCount && grid [row] [column] !is null) { + column++; + } + int endCount = column + hSpan; + if (endCount <= columnCount) { + int index = column; + while (index < endCount && grid [row] [index] is null) { + index++; + } + if (index is endCount) break; + column = index; + } + if (column + hSpan >= columnCount) { + column = 0; + row++; + } + } + for (int j=0; j 1) { + int spanWidth = 0, spanMinWidth = 0, spanExpandCount = 0; + for (int k=0; k 0) { + if (makeColumnsEqualWidth) { + int equalWidth = (w + spanWidth) / hSpan; + int remainder = (w + spanWidth) % hSpan, last = -1; + for (int k = 0; k < hSpan; k++) { + widths [last=j-k] = Math.max (equalWidth, widths [j-k]); + } + if (last > -1) widths [last] += remainder; + } else { + if (spanExpandCount is 0) { + widths [j] += w; + } else { + int delta = w / spanExpandCount; + int remainder = w % spanExpandCount, last = -1; + for (int k = 0; k < hSpan; k++) { + if (expandColumn [j-k]) { + widths [last=j-k] += delta; + } + } + if (last > -1) widths [last] += remainder; + } + } + } + if (!data.grabExcessHorizontalSpace || data.minimumWidth !is 0) { + w = !data.grabExcessHorizontalSpace || data.minimumWidth is DWT.DEFAULT ? data.cacheWidth : data.minimumWidth; + w += data.horizontalIndent - spanMinWidth - (hSpan - 1) * horizontalSpacing; + if (w > 0) { + if (spanExpandCount is 0) { + minWidths [j] += w; + } else { + int delta = w / spanExpandCount; + int remainder = w % spanExpandCount, last = -1; + for (int k = 0; k < hSpan; k++) { + if (expandColumn [j-k]) { + minWidths [last=j-k] += delta; + } + } + if (last > -1) minWidths [last] += remainder; + } + } + } + } + } + } + } + if (makeColumnsEqualWidth) { + int minColumnWidth = 0; + int columnWidth = 0; + for (int i=0; i 0; + widths [i] = columnWidth; + } + } else { + if (width !is DWT.DEFAULT && expandCount > 0) { + int totalWidth = 0; + for (int i=0; i minWidths [j]) { + widths [last = j] = widths [j] + delta; + } else { + widths [j] = minWidths [j]; + expandColumn [j] = false; + c--; + } + } + } + if (last > -1) widths [last] += remainder; + + for (int j=0; j 1) { + if (!data.grabExcessHorizontalSpace || data.minimumWidth !is 0) { + int spanWidth = 0, spanExpandCount = 0; + for (int k=0; k 0) { + if (spanExpandCount is 0) { + widths [j] += w; + } else { + int delta2 = w / spanExpandCount; + int remainder2 = w % spanExpandCount, last2 = -1; + for (int k = 0; k < hSpan; k++) { + if (expandColumn [j-k]) { + widths [last2=j-k] += delta2; + } + } + if (last2 > -1) widths [last2] += remainder2; + } + } + } + } + } + } + } + if (c is 0) break; + totalWidth = 0; + for (int i=0; i currentWidth)) { + int trim = 0; + if ( auto sa = cast(Scrollable)child ) { + Rectangle rect = sa.computeTrim (0, 0, 0, 0); + trim = rect.width; + } else { + trim = child.getBorderWidth () * 2; + } + data.cacheWidth = data.cacheHeight = DWT.DEFAULT; + data.computeSize (child, Math.max (0, currentWidth - trim), data.heightHint, false); + if (data.grabExcessVerticalSpace && data.minimumHeight > 0) { + data.cacheHeight = Math.max (data.cacheHeight, data.minimumHeight); + } + if (flush is null) flush = new GridData [count]; + flush [flushLength++] = data; + } + } + } + } + } + } + + /* Row heights */ + int availableHeight = height - verticalSpacing * (rowCount - 1) - (marginTop + marginHeight * 2 + marginBottom); + expandCount = 0; + int [] heights = new int [rowCount]; + int [] minHeights = new int [rowCount]; + bool [] expandRow = new bool [rowCount]; + for (int i=0; i 1) { + int spanHeight = 0, spanMinHeight = 0, spanExpandCount = 0; + for (int k=0; k 0) { + if (spanExpandCount is 0) { + heights [i] += h; + } else { + int delta = h / spanExpandCount; + int remainder = h % spanExpandCount, last = -1; + for (int k = 0; k < vSpan; k++) { + if (expandRow [i-k]) { + heights [last=i-k] += delta; + } + } + if (last > -1) heights [last] += remainder; + } + } + if (!data.grabExcessVerticalSpace || data.minimumHeight !is 0) { + h = !data.grabExcessVerticalSpace || data.minimumHeight is DWT.DEFAULT ? data.cacheHeight : data.minimumHeight; + h += data.verticalIndent - spanMinHeight - (vSpan - 1) * verticalSpacing; + if (h > 0) { + if (spanExpandCount is 0) { + minHeights [i] += h; + } else { + int delta = h / spanExpandCount; + int remainder = h % spanExpandCount, last = -1; + for (int k = 0; k < vSpan; k++) { + if (expandRow [i-k]) { + minHeights [last=i-k] += delta; + } + } + if (last > -1) minHeights [last] += remainder; + } + } + } + } + } + } + } + if (height !is DWT.DEFAULT && expandCount > 0) { + int totalHeight = 0; + for (int i=0; i minHeights [i]) { + heights [last = i] = heights [i] + delta; + } else { + heights [i] = minHeights [i]; + expandRow [i] = false; + c--; + } + } + } + if (last > -1) heights [last] += remainder; + + for (int i=0; i 1) { + if (!data.grabExcessVerticalSpace || data.minimumHeight !is 0) { + int spanHeight = 0, spanExpandCount = 0; + for (int k=0; k 0) { + if (spanExpandCount is 0) { + heights [i] += h; + } else { + int delta2 = h / spanExpandCount; + int remainder2 = h % spanExpandCount, last2 = -1; + for (int k = 0; k < vSpan; k++) { + if (expandRow [i-k]) { + heights [last2=i-k] += delta2; + } + } + if (last2 > -1) heights [last2] += remainder2; + } + } + } + } + } + } + } + if (c is 0) break; + totalHeight = 0; + for (int i=0; i + *******************************************************************************/ +module dwt.layout.RowData; + +import dwt.DWT; +import dwt.graphics.Point; +import dwt.widgets.Control; + +import tango.text.Util; +import tango.util.Convert; + +/** + * Each control controlled by a RowLayout can have its initial + * width and height specified by setting a RowData object + * into the control. + *

+ * The following code uses a RowData object to change the initial + * size of a Button in a Shell: + *

+ *      Display display = new Display();
+ *      Shell shell = new Shell(display);
+ *      shell.setLayout(new RowLayout());
+ *      Button button1 = new Button(shell, DWT.PUSH);
+ *      button1.setText("Button 1");
+ *      button1.setLayoutData(new RowData(50, 40));
+ * 
+ *

+ * + * @see RowLayout + */ +public final class RowData { + /** + * width specifies the desired width in pixels. This value + * is the wHint passed into Control.computeSize(int, int, bool) + * to determine the preferred size of the control. + * + * The default value is DWT.DEFAULT. + * + * @see dwt.widgets.Control#computeSize(int, int, bool) + */ + public int width = DWT.DEFAULT; + /** + * height specifies the preferred height in pixels. This value + * is the hHint passed into Control.computeSize(int, int, bool) + * to determine the preferred size of the control. + * + * The default value is DWT.DEFAULT. + * + * @see dwt.widgets.Control#computeSize(int, int, bool) + */ + public int height = DWT.DEFAULT; + + /** + * exclude informs the layout to ignore this control when sizing + * and positioning controls. If this value is true, + * the size and position of the control will not be managed by the + * layout. If this value is false, the size and + * position of the control will be computed and assigned. + * + * The default value is false. + * + * @since 3.1 + */ + public bool exclude = false; + +/** + * Constructs a new instance of RowData using + * default values. + */ +public this () { +} + +/** + * Constructs a new instance of RowData according to the parameters. + * A value of DWT.DEFAULT indicates that no minimum width or + * no minimum height is specified. + * + * @param width a minimum width for the control + * @param height a minimum height for the control + */ +public this (int width, int height) { + this.width = width; + this.height = height; +} + +/** + * Constructs a new instance of RowData according to the parameter. + * A value of DWT.DEFAULT indicates that no minimum width or + * no minimum height is specified. + * + * @param point a point whose x coordinate specifies a minimum width for the control + * and y coordinate specifies a minimum height for the control + */ +public this (Point point) { + this (point.x, point.y); +} + +char[] getName () { + char[] string = this.classinfo.name; + int index = locatePrior( string, '.'); + if (index is string.length ) return string; + return string[ index + 1 .. string.length ]; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the RowData object + */ +public char[] toString () { + char[] string = getName ()~" {"; + if (width !is DWT.DEFAULT) string ~= "width="~to!(char[])(width)~" "; + if (height !is DWT.DEFAULT) string ~= "height="~to!(char[])(height)~" "; + if (exclude) string ~= "exclude="~to!(char[])(exclude)~" "; + string = trim( string ); + string ~= "}"; + return string; +} +} diff -r 000000000000 -r 5406a8f6526d dwt/layout/RowLayout.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/layout/RowLayout.d Sun Jan 20 21:50:55 2008 -0800 @@ -0,0 +1,477 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit + *******************************************************************************/ +module dwt.layout.RowLayout; + +import dwt.DWT; +import dwt.graphics.Point; +import dwt.graphics.Rectangle; +import dwt.widgets.Control; +import dwt.widgets.Layout; +import dwt.widgets.Composite; +import dwt.layout.RowData; +import tango.text.Util; +import tango.util.Convert; +import Math = tango.math.Math; + + +/** + * Instances of this class determine the size and position of the + * children of a Composite by placing them either in + * horizontal rows or vertical columns within the parent Composite. + *

+ * RowLayout aligns all controls in one row if the + * type is set to horizontal, and one column if it is + * set to vertical. It has the ability to wrap, and provides configurable + * margins and spacing. RowLayout has a number of configuration + * fields. In addition, the height and width of each control in a + * RowLayout can be specified by setting a RowData + * object into the control using setLayoutData (). + *

+ *

+ * The following example code creates a RowLayout, sets all + * of its fields to non-default values, and then sets it into a + * Shell. + *

+ *      RowLayout rowLayout = new RowLayout();
+ *      rowLayout.wrap = false;
+ *      rowLayout.pack = false;
+ *      rowLayout.justify = true;
+ *      rowLayout.type = DWT.VERTICAL;
+ *      rowLayout.marginLeft = 5;
+ *      rowLayout.marginTop = 5;
+ *      rowLayout.marginRight = 5;
+ *      rowLayout.marginBottom = 5;
+ *      rowLayout.spacing = 0;
+ *      shell.setLayout(rowLayout);
+ * 
+ * If you are using the default field values, you only need one line of code: + *
+ *      shell.setLayout(new RowLayout());
+ * 
+ *

+ * + * @see RowData + */ +public final class RowLayout : Layout { + + /** + * type specifies whether the layout places controls in rows or + * columns. + * + * The default value is HORIZONTAL. + * + * Possible values are:
    + *
  • HORIZONTAL: Position the controls horizontally from left to right
  • + *
  • VERTICAL: Position the controls vertically from top to bottom
  • + *
+ * + * @since 2.0 + */ + public int type = DWT.HORIZONTAL; + + /** + * marginWidth specifies the number of pixels of horizontal margin + * that will be placed along the left and right edges of the layout. + * + * The default value is 0. + * + * @since 3.0 + */ + public int marginWidth = 0; + + /** + * marginHeight specifies the number of pixels of vertical margin + * that will be placed along the top and bottom edges of the layout. + * + * The default value is 0. + * + * @since 3.0 + */ + public int marginHeight = 0; + + /** + * spacing specifies the number of pixels between the edge of one cell + * and the edge of its neighbouring cell. + * + * The default value is 3. + */ + public int spacing = 3; + + /** + * wrap specifies whether a control will be wrapped to the next + * row if there is insufficient space on the current row. + * + * The default value is true. + */ + public bool wrap = true; + + /** + * pack specifies whether all controls in the layout take + * their preferred size. If pack is false, all controls will + * have the same size which is the size required to accommodate the + * largest preferred height and the largest preferred width of all + * the controls in the layout. + * + * The default value is true. + */ + public bool pack = true; + + /** + * fill specifies whether the controls in a row should be + * all the same height for horizontal layouts, or the same + * width for vertical layouts. + * + * The default value is false. + * + * @since 3.0 + */ + public bool fill = false; + + /** + * justify specifies whether the controls in a row should be + * fully justified, with any extra space placed between the controls. + * + * The default value is false. + */ + public bool justify = false; + + /** + * marginLeft specifies the number of pixels of horizontal margin + * that will be placed along the left edge of the layout. + * + * The default value is 3. + */ + public int marginLeft = 3; + + /** + * marginTop specifies the number of pixels of vertical margin + * that will be placed along the top edge of the layout. + * + * The default value is 3. + */ + public int marginTop = 3; + + /** + * marginRight specifies the number of pixels of horizontal margin + * that will be placed along the right edge of the layout. + * + * The default value is 3. + */ + public int marginRight = 3; + + /** + * marginBottom specifies the number of pixels of vertical margin + * that will be placed along the bottom edge of the layout. + * + * The default value is 3. + */ + public int marginBottom = 3; + +/** + * Constructs a new instance of this class. + */ +public this () { +} + +/** + * Constructs a new instance of this class given the type. + * + * @param type the type of row layout + * + * @since 2.0 + */ +public this (int type) { + this.type = type; +} + +protected Point computeSize (Composite composite, int wHint, int hHint, bool flushCache_) { + Point extent; + if (type is DWT.HORIZONTAL) { + extent = layoutHorizontal (composite, false, (wHint !is DWT.DEFAULT) && wrap, wHint, flushCache_); + } else { + extent = layoutVertical (composite, false, (hHint !is DWT.DEFAULT) && wrap, hHint, flushCache_); + } + if (wHint !is DWT.DEFAULT) extent.x = wHint; + if (hHint !is DWT.DEFAULT) extent.y = hHint; + return extent; +} + +Point computeSize (Control control, bool flushCache_) { + int wHint = DWT.DEFAULT, hHint = DWT.DEFAULT; + RowData data = cast(RowData) control.getLayoutData (); + if (data !is null) { + wHint = data.width; + hHint = data.height; + } + return control.computeSize (wHint, hHint, flushCache_); +} + +protected bool flushCache (Control control) { + return true; +} + +char[] getName () { + char[] string = this.classinfo.name; + int index = locatePrior( string, '.'); + if (index is string.length ) return string; + return string[ index + 1 .. string.length ]; +} + +protected void layout (Composite composite, bool flushCache_) { + Rectangle clientArea = composite.getClientArea (); + if (type is DWT.HORIZONTAL) { + layoutHorizontal (composite, true, wrap, clientArea.width, flushCache_); + } else { + layoutVertical (composite, true, wrap, clientArea.height, flushCache_); + } +} + +Point layoutHorizontal (Composite composite, bool move, bool wrap, int width, bool flushCache_) { + Control [] children = composite.getChildren (); + int count = 0; + for (int i=0; i width)) { + wrapped = true; + if (move && (justify || fill)) wraps [i - 1] = maxHeight; + x = marginLeft + marginWidth; + y += spacing + maxHeight; + if (pack) maxHeight = 0; + } + if (pack || fill) { + maxHeight = Math.max (maxHeight, childHeight); + } + if (move) { + int childX = x + clientX, childY = y + clientY; + if (justify || fill) { + bounds [i] = new Rectangle (childX, childY, childWidth, childHeight); + } else { + child.setBounds (childX, childY, childWidth, childHeight); + } + } + x += spacing + childWidth; + maxX = Math.max (maxX, x); + } + maxX = Math.max (clientX + marginLeft + marginWidth, maxX - spacing); + if (!wrapped) maxX += marginRight + marginWidth; + if (move && (justify || fill)) { + int space = 0, margin = 0; + if (!wrapped) { + space = Math.max (0, (width - maxX) / (count + 1)); + margin = Math.max (0, ((width - maxX) % (count + 1)) / 2); + } else { + if (fill || justify) { + int last = 0; + if (count > 0) wraps [count - 1] = maxHeight; + for (int i=0; i height)) { + wrapped = true; + if (move && (justify || fill)) wraps [i - 1] = maxWidth; + x += spacing + maxWidth; + y = marginTop + marginHeight; + if (pack) maxWidth = 0; + } + if (pack || fill) { + maxWidth = Math.max (maxWidth, childWidth); + } + if (move) { + int childX = x + clientX, childY = y + clientY; + if (justify || fill) { + bounds [i] = new Rectangle (childX, childY, childWidth, childHeight); + } else { + child.setBounds (childX, childY, childWidth, childHeight); + } + } + y += spacing + childHeight; + maxY = Math.max (maxY, y); + } + maxY = Math.max (clientY + marginTop + marginHeight, maxY - spacing); + if (!wrapped) maxY += marginBottom + marginHeight; + if (move && (justify || fill)) { + int space = 0, margin = 0; + if (!wrapped) { + space = Math.max (0, (height - maxY) / (count + 1)); + margin = Math.max (0, ((height - maxY) % (count + 1)) / 2); + } else { + if (fill || justify) { + int last = 0; + if (count > 0) wraps [count - 1] = maxWidth; + for (int i=0; i